Home | History | Annotate | Download | only in dev
History log of /src/sys/arch/mac68k/dev/sbc.c
RevisionDateAuthorComments
 1.70  24-May-2025  nat Should the transfer stop somewhere in the firt four bytes transferred,
make sure the count is correct.

NFCI.
 1.69  10-Mar-2025  nat Remove CHECKMORE.

This was a performance penalty and was found to be unnecessary as the root
cause of errors doing pdma interrupt xfers was addressed in an earlier commit.
 1.68  10-Mar-2025  nat Serialize pdma xfers.

The same is done for pdma interrupt xfers.
 1.67  22-Nov-2024  nat Make writing of dummy byte conditional.

This is insurance against devices that do not leave ACK hanging at the end of
each transfer.

Final part of PR kern/58452.
 1.66  22-Nov-2024  nat This delay is no longer necessary.

The delays throught the code were there to ensure error free transfers. This
has been fixed in an eariler commit today by serializing the drq interrupt.

Part of PR kern/58452.
 1.65  22-Nov-2024  nat No need any additional delay waiting for DREQ.

This results in utilites like time(1) reporting results closer to reality
when timing the transfer of data. With the added benefit that transfers are
slightly faster.

Part of PR kern/58452.
 1.64  22-Nov-2024  nat Serialize drq interrupt.

This results in error free transfers between disks.

Part of PR kern/58452.
 1.63  26-Oct-2024  nat Spinkle a little delay.

This was needed to ensure a reliable transfer of data.
 1.62  26-Oct-2024  nat Write an extra byte to handle the last ACK from 5380.

This was found from the example code in the NCR5380 Interface Manual.

This is not needed (but does not hurt) on the 53C80 and later.

This fixed many problems from stuck busy to phase mismatches when aborting
transfers and avoiding hard lockups of the scsi subsystem originating from
what I first thought were errors from the target device.

XXX pullup-9, pullup 10.

I will look next at the pdma_out function to do the same there.
 1.61  26-Oct-2024  nat Rework of previous.

While here set the priority in sync witho pdma_in/out.
Use sbc_ready same as pdma_in/out.
 1.60  14-Sep-2024  nat Use smaller size when sending PDMA data, and check that the next block can
be sent before sending it.

This fixes PDMA support (which previously has been flakey at best).

These changes provide maximum performance and importantly reliablity.

The lack of support for the PDMA intr should now be revisited on the PowerBook
5xx series (Unfortunately I don't have the hw to test with).

These changes have been tested on emulated (PiSCSI/BlueSCSI) and real hw.
 1.59  18-Feb-2023  nat Introduce a flag to disable PDMA when writing.

The use of pdma when writing would always cause a panic on my Powerbook 160,
possibly others as well.

As posted to tech-kern.
 1.58  18-Feb-2023  nat Honor the XS_CTL_POLL flag and fallback to polled io instead of PDMA.

As posted to tech-kern.
 1.57  03-Sep-2018  riastradh Rename min/max -> uimin/uimax for better honesty.

These functions are defined on unsigned int. The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER! Some subsystems have

#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX. Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate. But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all. (Who knows, maybe in some cases integer
truncation is actually intended!)
 1.56  29-Jun-2014  martin branches: 1.56.26; 1.56.28;
Remove an unused variable
 1.55  07-Dec-2012  hauke branches: 1.55.10;
Remove the R1 syntactic sugar, since it collides with a #define in
<m68k/regs.h>, breaking the build.

The R1s serve to bring the buffer pointer to a 4 byte boundary, but
that should be clear from the context.
 1.54  23-Nov-2009  rmind branches: 1.54.12; 1.54.22;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.53  04-Apr-2008  tsutsui branches: 1.53.4;
Split devict_t/softc for ncr5380sbc SCSI, and misc cosmetic changes.
 1.52  04-Mar-2007  christos branches: 1.52.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.51  04-Aug-2006  mhitch branches: 1.51.10;
gcc4 "uninitialized" variable; previous workaround doesn't satisfy gcc4 -
explicitly initialize drq.
 1.50  10-May-2006  skrll Fix a bunch of cast lvalues.
 1.49  17-Jan-2006  chs branches: 1.49.2; 1.49.4; 1.49.6; 1.49.8; 1.49.10;
add fault-protection in sbc_pdma_in() like in all the other PDMA functions.
fixes PR 9679.
 1.48  24-Dec-2005  perry branches: 1.48.2;
__asm__ -> __asm
__const__ -> const
__inline__ -> inline
__volatile__ -> volatile
 1.47  11-Dec-2005  christos merge ktrace-lwp.
 1.46  16-Jun-2005  jmc branches: 1.46.2;
Fixes for volatile problems
 1.45  15-Jan-2005  chs branches: 1.45.8;
de-__P, remove register, ansify, b* -> mem*.
 1.44  15-Jul-2003  lukem __KERNEL_RCSID()
 1.43  03-May-2003  wiz branches: 1.43.2;
DMA, not dma nor Dma.
 1.42  27-Sep-2002  provos remove trailing \n in panic(). approved perry.
 1.41  18-Mar-2000  mycroft branches: 1.41.8; 1.41.12;
Add a ncr5380_attach() routine which does part of the initialization, attaches
the scsibus, and does the addref/delref dance.
 1.40  02-Nov-1999  scottr [Redo] Catch up with recent changes to scsipi flags. Closes PR 8675.
 1.39  17-Sep-1999  thorpej branches: 1.39.2; 1.39.4; 1.39.6;
Centralize the declaration and clearing of `cold'.
 1.38  19-Nov-1998  thorpej branches: 1.38.4;
Adapt to the new scsipi_adapter interface.
 1.37  10-Oct-1998  thorpej Garbage-collect the open_target_lu and close_target_lu entry points from
struct scsipi_adapter; they were not used.

Add a scsipi_ioctl entry point to struct scsipi_adapter. This will be
used to issue ioctl commands to the host adapters.

Inspired by PR #6090, from Matt Jacob.
 1.36  04-Jul-1998  jonathan defopt DDB.
 1.35  17-Jan-1998  scottr We haven't needed a driver-specific minphys() for quite some time now.
 1.34  12-Jan-1998  thorpej Update for changes to config.
 1.33  06-Dec-1997  scottr PR 4078: Enabling the SCSI IRQ interrupt to allow reselects to work
causes the MI interrupt handler to barf when we get a 5380 RST interrupt
while probing. Worse, the VIA latches the interrupt, so simply having
all interrupts disabled during autoconfig doesn't resolve the problem.
[I demonstrated the latter on a IIci, which erroneously reports a
reselection attempt(!) after autoconfig is complete. The latched
interrupt results from the SCSI bus reset we do when initializing the
bus.]

Since interrupts must be enabled during autoconfig anyway (sigh), test
to see if autoconfig has completed in sbc_irq_intr(). If not, we don't
pass the interrupt up to the MI interrupt handler. Also, make sure to
clear the VIA interrupt if we're servicing an unclaimed 5380 RST
interrupt.

Thanks to Bill Studenmund for providing the key insight needed to unlock
this problem.
 1.32  10-Oct-1997  scottr branches: 1.32.2;
Remove advertising clause.
 1.31  06-Sep-1997  scottr Catch bus error in sbc_pdma_out() and panic with a reasonable
error message.
 1.30  27-Aug-1997  bouyer Merge scsipi branch in the mainline. This add support for ATAPI devices
(currently only CD-ROM drives on i386). The sys/dev/scsipi system provides 2
busses to which devices can attach (scsibus and atapibus). This needed to
change some include files and structure names in the low level scsi drivers.
 1.29  11-Aug-1997  scottr Make #include directives consistent. All MD headers are of the form:

#include <mac68k/{dev,mac68k}/foo.h>
 1.28  30-Jun-1997  scottr branches: 1.28.2; 1.28.4;
Due to reliability problems on some models, back out the more radical of
the pc532/dev/ncr.c-inspired changes; in particular, wait for previous
transfer to complete before starting another, as we used to do. Retain
splbio() protection and simplified sbc_pdma_in().
 1.27  29-Jun-1997  scottr Update for mac68k_buserr_addr -> m68k_fault_addr change.
 1.26  13-May-1997  scottr Tweak sbc_drq_intr() (interrupt-driven PDMA interrupt handler); it
now works properly on at least some disks. Further testing is
necessary.
 1.25  28-Apr-1997  scottr Undo a hack added in the last overhaul (which caused an extraneous byte
to be written to the target). Also, use the sc_min_dma_len field
to determine whether to use PDMA or PIO.
 1.24  18-Apr-1997  scottr For small writes, use PIO rather than PDMA; this increases the reliability
of the driver (considerably, on some systems/targets).
 1.23  07-Apr-1997  scottr Rework PDMA read/write functions based on Matthias Pfaller's pc532 ncr
driver. Major highlights:

- Protect with splbio(), now that interrupts from the chip might be
enabled by default;
- Wait for current transfer to complete before returning, rather than
wait for previous transfer to complete before starting another;
- Instead of logging a "timeout" message when a target disconnects,
just return, letting the sbc_ready() and sbc_wait_not_req() print
timeout messages if such really did occur.

With interrupt changes to sbc_obio.c, disconnect/reselect now works if
configured into the kernel.
 1.22  01-Mar-1997  scottr Split bus-dependent autoconfig code from the driver. This allows for
the future addition of a Duo Dock front end.
 1.21  28-Feb-1997  scottr Convert to generalized VIA interrupt registration
 1.20  26-Feb-1997  gwr Minimal changes to adapt to removal of NCR5380_PERMIT_RESELECT.
This driver should be updated to allow per-target control over
disconnect/reselect, but I will leave that to the port masters.
 1.19  24-Feb-1997  scottr Update copyright and license.
 1.18  20-Jan-1997  scottr branches: 1.18.4;
#ifdef out write hack, and fix possible uninitialized variable.
 1.17  07-Jan-1997  scottr Fix typo in last: cf->cf_unit -> sc->dv.dv_unit
 1.16  05-Jan-1997  scottr Add basic support for a Duo dock SCSI controller, from Daishi Kato.

XXX - This could probably be improved if all docking hardware has a
NuBus declaration ROM that we can get to. This should be investigated
further.
 1.15  16-Dec-1996  scottr Convert all foo_match() functions to use a `struct cfdata *' for their
second argument. The NuBus autoconfig code had to be reorganized as a
result of this, and looks much more like a directly-attached bus now.
These changes eliminate __BROKEN_INDIRECT_CONFIG.
 1.14  13-Nov-1996  thorpej Use bitmask_snprintf().
 1.13  13-Oct-1996  christos backout previous kprintf change
 1.12  11-Oct-1996  christos printf -> kprintf, sprintf -> ksprintf
 1.11  28-Aug-1996  cgd (1) set scsi_link channel to either the appropriate channel (if a
multi-channel driver), or to SCSI_CHANNEL_ONLY_ONE if a
single-channel driver.
(2) use scsiprint() rather than a locally-defined autoconfig print
function, and kill any locally-defined print function.
 1.10  27-Aug-1996  cgd change cfprint_t type definition to take a const char *, rather than
a char *, because that's what was really intended, and because
if the print function modifies the string, various things could become
unhappy (so the string should _not_ be modified).
 1.9  19-Jun-1996  scottr Update some comments, and the copyright
 1.8  11-Jun-1996  scottr Deal with interrupt flags more carefully, and use the correct offset
for PB500-series SCSI I/O. While I'm here, update the copyright.
 1.7  29-May-1996  scottr - Simplify writes in sbc_drq_intr().
- When finished writing, if the SCSI bus has BSY asserted, write another
byte to the SBC to ensure we get an interrupt.
- Unflag SCSI interrupts on the VIA whenever we clear the interrupts
on the SBC itself.
 1.6  08-May-1996  scottr branches: 1.6.4;
Remove some gross hacks that were added due to interrupt grossness that
has been partially fixed. Also, add a new flag (which rearranges them
a bit, unfortunately) to use PDMA for polled transfers.
 1.5  05-May-1996  briggs Prototype for -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-uninitialized
Also change the device probing scheme to use something a bit more rational.
A current side-effect is that nubus cards are double-mapped. I expect
to fix that shortly.
Also change splclock() to block everything but serial hardware interrupts.
 1.4  30-Apr-1996  scottr Kill unused variables and fix prototypes.
 1.3  30-Apr-1996  scottr - Drop SCSI IRQ interrupts if we are already handling one. This works around
a condition that occurs with some slow SCSI devices when they disconnect
(e.g. the AppleCD 600), generating spurious selection interrupts.
- Reorganize the debugging code slightly.
 1.2  25-Apr-1996  scottr Ooops. ncr_sbcreg.h -> sbcreg.h
 1.1  25-Apr-1996  scottr Renamed these files.
 1.6.4.2  20-Jun-1996  jtc Pulled up from revision 1.9 by request of Scott Reynolds.
Updates copyright/licence and comments. No code changes.
 1.6.4.1  11-Jun-1996  scottr Pull up from trunk:
>Deal with interrupt flags more carefully, and use the correct offset
>for PB500-series SCSI I/O. While I'm here, update the copyright.
 1.18.4.1  12-Mar-1997  is Merge in changes from The Trunk, partially just reimplementing newarp.
 1.28.4.4  14-Oct-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.3  06-Sep-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.2  27-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.4.1  23-Aug-1997  thorpej Update marc-pcmcia branch from trunk.
 1.28.2.2  14-Aug-1997  bouyer Sync with trunk.
 1.28.2.1  01-Jul-1997  bouyer Updates for new scsipi subsystem. Actally known to work on i386 and sparc.
 1.32.2.4  29-Jan-1998  mellon Pull up 1.34 (scottr)
 1.32.2.3  09-Dec-1997  thorpej Sync w/ trunk: fix potential hang during autoconfig. (scottr)
 1.32.2.2  19-Nov-1997  mellon DEBUG -> SBC_DEBUG (scottr)
 1.32.2.1  18-Nov-1997  mellon Undo parts of 1.23 to fix autoconfig hangs on some Macs. Not on trunk - trunk version is more correct. (scottr)
 1.38.4.3  16-Nov-1999  scottr Pull up the version from the trunk; some changes crept in that ought not
to have been committed.
 1.38.4.2  02-Nov-1999  scottr [Redo] Sync with main branch.
 1.38.4.1  16-May-1999  scottr Sync with main branch.
 1.39.6.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.39.4.1  15-Nov-1999  fvdl Sync with -current
 1.39.2.1  20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.41.12.1  18-Oct-2002  nathanw Catch up to -current.
 1.41.8.1  10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.43.2.5  10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.43.2.4  17-Jan-2005  skrll Sync with HEAD.
 1.43.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.43.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.43.2.1  03-Aug-2004  skrll Sync with HEAD
 1.45.8.1  30-Jan-2006  tron Pull up following revision(s) (requested by chs in ticket #1146):
sys/arch/mac68k/dev/sbc.c: revision 1.49
add fault-protection in sbc_pdma_in() like in all the other PDMA functions.
fixes PR 9679.
 1.46.2.3  03-Sep-2007  yamt sync with head.
 1.46.2.2  30-Dec-2006  yamt sync with head.
 1.46.2.1  21-Jun-2006  yamt sync with head.
 1.48.2.1  01-Feb-2006  yamt sync with head.
 1.49.10.1  24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.49.8.1  11-May-2006  elad sync with head
 1.49.6.2  11-Aug-2006  yamt sync with head
 1.49.6.1  24-May-2006  yamt sync with head.
 1.49.4.1  01-Jun-2006  kardel Sync with head.
 1.49.2.1  09-Sep-2006  rpaulo sync with head
 1.51.10.1  12-Mar-2007  rmind Sync with HEAD.
 1.52.40.1  02-Jun-2008  mjf Sync with HEAD.
 1.53.4.1  11-Mar-2010  yamt sync with head
 1.54.22.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.54.22.1  25-Feb-2013  tls resync with head
 1.54.12.1  16-Jan-2013  yamt sync with (a bit old) head
 1.55.10.1  10-Aug-2014  tls Rebase.
 1.56.28.1  10-Jun-2019  christos Sync with HEAD
 1.56.26.1  06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)

RSS XML Feed