ncr5380: Eliminate macros, reduce code duplication, fix bugs etc
Subsystems (3)
v3 cover ncr5380: Eliminate macros, reduce code duplication, fix bugs etc
This patch series has more macro elimination and some tweaks to the DMA hooks so that all the wrapper drivers can share the same core DMA algorithm. This resolves the major discrepancies between the two core drivers, which relate to code conditional on the REAL_DMA and PSEUDO_DMA macros.
After all the wrapper drivers agree on the DMA hook api, the core driver fork gets resolved. NCR5380.c is adopted by atari_scsi and sun3_scsi and atari_NCR5380.c is then deleted.
Historically, the 5380 drivers suffered from over-use of conditional compilation, which caused the compile-time configuration space to explode, leading to core driver code that was practically untestable, unmaintainable and difficult to reason about. It also prevented driver modules from sharing object code.
Along with REAL_DMA, REAL_DMA_POLL and PSEUDO_DMA, most of the remaining macros are also eradicated, such as CONFIG_SCSI_GENERIC_NCR53C400, SUPPORT_TAGS, DONT_USE_INTR, AUTOPROBE_IRQ and BIOSPARAM.
Also in this patch series, some duplicated documentation is removed and the PDMA implementation in mac_scsi finally gets fixed.
This patch series was tested by exercising the dmx3191d and mac_scsi modules on suitable hardware. Michael has tested atari_scsi on an Atari Falcon. Help with driver testing on ISA cards is sought as I don't have such hardware. Likewise RiscPC ecards and Sun 3.
Changes since v1:
- Patch 4: don't remove MIN_DMA_SIZE macro from wrapper drivers.
- Patch 9: improve commit log entry and add 'Reviewed-by' tag.
- Patch 14: reduce shost->max_lun limit instead of adding MAX_LUN limit.
- Patches 20 and 22: set the default cmd_per_lun to 4.
- For the rest: add 'Reviewed-by' tag.
Changes since v2:
- Patches 20 and 22: revert the default cmd_per_lun to 2, like the v1 patch series.
- Add patch 23 to fix a theoretical bus reset/autosense issue.
--- Documentation/scsi/g_NCR5380.txt | 17 Documentation/scsi/scsi-parameters.txt | 11 drivers/scsi/Kconfig | 11 drivers/scsi/NCR5380.c | 659 ++++---- drivers/scsi/NCR5380.h | 143 - drivers/scsi/arm/cumana_1.c | 25 drivers/scsi/arm/oak.c | 22 drivers/scsi/atari_NCR5380.c | 2676 --------------------------------- drivers/scsi/atari_scsi.c | 144 - drivers/scsi/dmx3191d.c | 10 drivers/scsi/dtc.c | 27 drivers/scsi/dtc.h | 7 drivers/scsi/g_NCR5380.c | 143 - drivers/scsi/g_NCR5380.h | 26 drivers/scsi/mac_scsi.c | 239 +- drivers/scsi/pas16.c | 27 drivers/scsi/pas16.h | 5 drivers/scsi/sun3_scsi.c | 47 drivers/scsi/t128.c | 19 drivers/scsi/t128.h | 7 20 files changed, 634 insertions(+), 3631 deletions(-)
PATCH v3 1/23 g_ncr5380: Remove CONFIG_SCSI_GENERIC_NCR53C400
This change brings a number of improvements: fewer macros, better test coverage, simpler code and sane Kconfig options. The downside is a small chance of incompatibility (which seems unavoidable).
CONFIG_SCSI_GENERIC_NCR53C400 exists to enable or inhibit pseudo DMA transfers when the driver is used with 53C400-compatible cards. Thanks to Ondrej Zary's patches, PDMA now works which means it can be enabled unconditionally.
Due to bad design, CONFIG_SCSI_GENERIC_NCR53C400 ties together unrelated functionality as it sets both PSEUDO_DMA and BIOSPARAM macros. This patch effectively enables PSEUDO_DMA and disables BIOSPARAM.
The defconfigs and the Kconfig default leave CONFIG_SCSI_GENERIC_NCR53C400 undefined. Red Hat 9 and CentOS 2.1 were the same. This leaves both PSEUDO_DMA and BIOSPARAM disabled. The effect of this patch should be better performance from enabling PSEUDO_DMA.
On the other hand, Debian 4 and SLES 10 had CONFIG_SCSI_GENERIC_NCR53C400 enabled, so both PSEUDO_DMA and BIOSPARAM were enabled. This patch might affect configurations like this by disabling BIOSPARAM. My best guess is that this could be a problem only in the vanishingly rare case that
1) the CHS values stored in the boot device partition table are wrong and
2) a 5380 card is in use (because PDMA on 53C400 used to be broken).
---
Here are the distro kernel versions I looked at:
CentOS 2.1:
$ strings kernel-2.4.9-e.40.i686/lib/modules/2.4.9-e.40/kernel/drivers/scsi/g_NCR5380.o | grep extension NO NCR53C400 driver extensions
Red Hat 7:
$ strings kernel-2.4.18-3.i386/lib/modules/2.4.18-3/kernel/drivers/scsi/g_NCR5380.o | grep extension NO NCR53C400 driver extensions
Red Hat 9:
$ strings kernel-2.4.20-8.i586/lib/modules/2.4.20-8/kernel/drivers/scsi/g_NCR5380.o | grep extension NO NCR53C400 driver extensions
Debian 4:
$ strings linux-image-2.6.24-etchnhalf.1-486_2.6.24-6-etchnhalf.9etch3_i386/lib/modules/2.6.24-etchnhalf.1-486/kernel/drivers/scsi/g_NCR5380_mmio.ko | grep extension NCR53C400 extension version %d $ strings kernel-image-2.6.8-2-386_2.6.8-13_i386/lib/modules/2.6.8-2-386/kernel/drivers/scsi/g_NCR5380_mmio.ko | grep extension NCR53C400 extension version %d
SLES 10.2:
$ strings kernel-default-2.6.18.2-34.i586/lib/modules/2.6.18.2-34-default/kernel/drivers/scsi/g_NCR5380_mmio.ko | grep extension NCR53C400 extension version %d
--- drivers/scsi/Kconfig | 11 ------ drivers/scsi/g_NCR5380.c | 75 ++++++++++++++--------------------------------- drivers/scsi/g_NCR5380.h | 16 +--------- 3 files changed, 25 insertions(+), 77 deletions(-)
drivers/scsi/Kconfig +0 -11
@@ -812,17 +812,6 @@ config SCSI_GENERIC_NCR5380_MMIO To compile this driver as a module, choose M here: the module will be called g_NCR5380_mmio. -config SCSI_GENERIC_NCR53C400 - bool "Enable NCR53c400 extensions" - depends on SCSI_GENERIC_NCR5380 - help - This enables certain optimizations for the NCR53c400 SCSI cards. - You might as well try it out. Note that this driver will only probe - for the Trantor T130B in its default configuration; you might have - to pass a command line option to the kernel at boot time if it does - not detect your card. See the file - <file:Documentation/scsi/g_NCR5380.txt> for details. - config SCSI_IPS tristate "IBM ServeRAID support" depends on PCI && SCSI
drivers/scsi/g_NCR5380.c +23 -52
162 lines not on this page · raw message
drivers/scsi/g_NCR5380.h +2 -14
@@ -14,13 +14,6 @@#ifndef GENERIC_NCR5380_H #define GENERIC_NCR5380_H -#ifdef CONFIG_SCSI_GENERIC_NCR53C400 -#define BIOSPARAM -#define NCR5380_BIOSPARAM generic_NCR5380_biosparam -#else -#define NCR5380_BIOSPARAM NULL -#endif -#define __STRVAL (x) #x#define STRVAL (x) __STRVAL(x)
@@ -30,12 +23,6 @@#define NCR5380_map_type int#define NCR5380_map_name port -#ifdef CONFIG_SCSI_GENERIC_NCR53C400 -#define NCR5380_region_size 16 -#else -#define NCR5380_region_size 8 -#endif -#define NCR5380_read (reg) \ inb(instance->io_port + (reg))#define NCR5380_write (reg, value) \
@@ -55,7 +42,7 @@#define NCR5380_map_name base#define NCR53C400_mem_base 0x3880#define NCR53C400_host_buffer 0x3900 -#define NCR5380_region_size 0x3a00 +#define NCR53C400_region_size 0x3a00#define NCR5380_read (reg) \ readb(((struct NCR5380_hostdata *)shost_priv(instance))->iomem + \
@@ -66,6 +53,7 @@#define NCR5380_implementation_fields \ void __iomem *iomem; \ + resource_size_t iomem_size; \ int c400_ctl_status; \ int c400_blk_cnt; \ int c400_host_buf;
PATCH v3 2/23 ncr5380: Remove FLAG_NO_PSEUDO_DMA where possible
In reply to Finn ThainDrivers that define PSEUDO_DMA also define NCR5380_dma_xfer_len. The core driver must call NCR5380_dma_xfer_len which means FLAG_NO_PSEUDO_DMA can be eradicated from the core driver.
dmx3191d doesn't define PSEUDO_DMA and has no use for FLAG_NO_PSEUDO_DMA, so remove it there also.
--- drivers/scsi/NCR5380.c | 3 +-- drivers/scsi/dmx3191d.c | 2 +- drivers/scsi/g_NCR5380.c | 7 ++++++- drivers/scsi/g_NCR5380.h | 2 +- drivers/scsi/mac_scsi.c | 15 ++++++++++++++- 5 files changed, 23 insertions(+), 6 deletions(-)
drivers/scsi/dmx3191d.c +1 -1
@@ -93,7 +93,7 @@ static int dmx3191d_probe_one(struct pci*/ shost->irq =NO_IRQ ; - error =NCR5380_init (shost,FLAG_NO_PSEUDO_DMA ); + error =NCR5380_init (shost,0 );if (error) goto out_host_put;
drivers/scsi/mac_scsi.c +14 -1
@@ -37,7 +37,9 @@#define NCR5380_pread macscsi_pread#define NCR5380_pwrite macscsi_pwrite -#define NCR5380_dma_xfer_len (instance, cmd, phase) (cmd->transfersize) + +#define NCR5380_dma_xfer_len (instance, cmd, phase) \ + macscsi_dma_xfer_len(instance, cmd)#define NCR5380_intr macscsi_intr#define NCR5380_queue_command macscsi_queue_command
@@ -303,6 +305,17 @@ static int macscsi_pwrite(struct Scsi_Ho }#endif +static int macscsi_dma_xfer_len (struct Scsi_Host *instance, +struct scsi_cmnd *cmd) +{ +struct NCR5380_hostdata *hostdata =shost_priv (instance); + +if (hostdata->flags &FLAG_NO_PSEUDO_DMA ) +return 0 ; + +return cmd->transfersize; +} +#include "NCR5380.c" #define DRV_MODULE_NAME "mac_scsi"
drivers/scsi/g_NCR5380.c +6 -1
@@ -712,10 +712,15 @@ static inline int NCR5380_pwrite(structreturn 0 ; } -static int generic_NCR5380_dma_xfer_len (struct scsi_cmnd *cmd) +static int generic_NCR5380_dma_xfer_len (struct Scsi_Host *instance, +struct scsi_cmnd *cmd) { +struct NCR5380_hostdata *hostdata =shost_priv (instance);int transfersize = cmd->transfersize; +if (hostdata->flags &FLAG_NO_PSEUDO_DMA ) +return 0 ; +/* Limit transfers to 32K, for xx400 & xx406 * pseudoDMA that transfers in 128 bytes blocks. */
drivers/scsi/NCR5380.c +1 -2
@@ -1833,8 +1833,7 @@ static void NCR5380_information_transfer#if defined(PSEUDO_DMA ) || defined(REAL_DMA_POLL ) transfersize =0 ; -if (!cmd->device->borken && - !(hostdata->flags &FLAG_NO_PSEUDO_DMA )) +if (!cmd->device->borken) transfersize =NCR5380_dma_xfer_len (instance, cmd, phase);if (transfersize) {
drivers/scsi/g_NCR5380.h +1 -1
@@ -61,7 +61,7 @@#endif #define NCR5380_dma_xfer_len (instance, cmd, phase) \ - generic_NCR5380_dma_xfer_len(cmd) + generic_NCR5380_dma_xfer_len(instance, cmd)#define NCR5380_intr generic_NCR5380_intr#define NCR5380_queue_command generic_NCR5380_queue_command
PATCH v3 3/23 ncr5380: Remove REAL_DMA and REAL_DMA_POLL macros
In reply to Finn ThainFor the NCR5380.c core driver, these macros are never used. If REAL_DMA were to be defined, compilation would fail.
For the atari_NCR5380.c core driver, REAL_DMA is always defined.
Hence these macros are pointless.
--- drivers/scsi/NCR5380.c | 218 +------------------------------------------ drivers/scsi/NCR5380.h | 112 ---------------------- drivers/scsi/atari_NCR5380.c | 62 +----------- drivers/scsi/atari_scsi.c | 32 ------ drivers/scsi/sun3_scsi.c | 13 -- 5 files changed, 22 insertions(+), 415 deletions(-)
drivers/scsi/NCR5380.c +10 -208
@@ -35,18 +35,10 @@* code so that everything does the same thing that's done at the * end of a pseudo-DMA read operation. * -* 2. Fix REAL_DMA (interrupt driven, polled works fine) - -* basically, transfer size needs to be reduced by one -* and the last byte read as is done with PSEUDO_DMA. -* * 4. Test SCSI-II tagged queueing (I have no devices which support * tagged queueing) */ -#ifndef notyet -#undef REAL_DMA -#endif -#ifdef BOARD_REQUIRES_NO_DELAY #define io_recovery_delay (x)#else
@@ -131,12 +123,6 @@* * PSEUDO_DMA - if defined, PSEUDO DMA is used during the data transfer phases. * -* REAL_DMA - if defined, REAL DMA is used during the data transfer phases. -* -* REAL_DMA_POLL - if defined, REAL DMA is used but the driver doesn't -* rely on phase mismatch and EOP interrupts to determine end -* of phase. -* * These macros MUST be defined : * * NCR5380_read(register) - read from the specified register
@@ -147,15 +133,9 @@* specific implementation of the NCR5380 * * Either real DMA *or* pseudo DMA may be implemented -* REAL functions : -* NCR5380_REAL_DMA should be defined if real DMA is to be used. * Note that the DMA setup functions should return the number of bytes * that they were able to program the controller for. * -* Also note that generic i386/PC versions of these macros are -* available as NCR5380_i386_dma_write_setup, -* NCR5380_i386_dma_read_setup, and NCR5380_i386_dma_residual. -* * NCR5380_dma_write_setup(instance, src, count) - initialize * NCR5380_dma_read_setup(instance, dst, count) - initialize * NCR5380_dma_residual(instance); - residual count
@@ -486,12 +466,6 @@ static void prepare_info(struct Scsi_Hos#ifdef DIFFERENTIAL "DIFFERENTIAL "#endif -#ifdef REAL_DMA - "REAL_DMA " -#endif -#ifdef REAL_DMA_POLL - "REAL_DMA_POLL " -#endif #ifdef PARITY "PARITY "#endif
@@ -551,9 +525,8 @@ static int NCR5380_init(struct Scsi_Host hostdata->id_higher_mask |= i;for (i =0 ; i <8 ; ++i) hostdata->busy[i] =0 ; -#ifdef REAL_DMA - hostdata->dmalen =0 ; -#endif + hostdata->dma_len =0 ; +spin_lock_init (&hostdata->lock); hostdata->connected =NULL ; hostdata->sensing =NULL ;
@@ -850,11 +823,7 @@ static void NCR5380_main(struct work_strrequeue_cmd (instance, cmd); } } -if (hostdata->connected -#ifdef REAL_DMA - && !hostdata->dmalen -#endif - ) { +if (hostdata->connected && !hostdata->dma_len) {dsprintk (NDEBUG_MAIN , instance,"main: performing information transfer\n" );NCR5380_information_transfer (instance); done =0 ;
@@ -919,34 +888,6 @@ static irqreturn_t NCR5380_intr(int irq,dsprintk (NDEBUG_INTR , instance,"IRQ %d, BASR 0x%02x, SR 0x%02x, MR 0x%02x\n" , irq, basr, sr, mr); -#if defined(REAL_DMA ) -if ((mr &MR_DMA_MODE ) || (mr &MR_MONITOR_BSY )) { -/* Probably End of DMA, Phase Mismatch or Loss of BSY. -* We ack IRQ after clearing Mode Register. Workarounds -* for End of DMA errata need to happen in DMA Mode. -*/ - -dsprintk (NDEBUG_INTR , instance,"interrupt in DMA mode\n" ); - -int transferred; - -if (!hostdata->connected) -panic ("scsi%d : DMA interrupt with no connected cmd\n" , - instance->hostno); - - transferred = hostdata->dmalen -NCR5380_dma_residual (instance); - hostdata->connected->SCp.this_residual -= transferred; - hostdata->connected->SCp.ptr += transferred; - hostdata->dmalen =0 ; - -/* FIXME: we need to poll briefly then defer a workqueue task ! */ -NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG ,BASR_ACK ,0 ,2 *HZ ); - -NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); -NCR5380_write (MODE_REG ,MR_BASE ); -NCR5380_read (RESET_PARITY_INTERRUPT_REG ); - } else -#endif /* REAL_DMA */ if ((NCR5380_read (CURRENT_SCSI_DATA_REG ) & hostdata->id_mask) && (sr & (SR_SEL |SR_IO |SR_BSY |SR_RST )) == (SR_SEL |SR_IO )) {/* Probably reselected */
@@ -1495,7 +1436,7 @@ timeout:return -1 ; } -#if defined(REAL_DMA ) || defined(PSEUDO_DMA ) || defined (REAL_DMA_POLL ) +#if defined(PSEUDO_DMA )/* * Function : int NCR5380_transfer_dma (struct Scsi_Host *instance, * unsigned char *phase, int *count, unsigned char **data)
@@ -1525,34 +1466,14 @@ static int NCR5380_transfer_dma(struct S registerunsigned char *d = *data;unsigned char tmp;int foo; -#if defined(REAL_DMA_POLL ) -int cnt, toPIO; -unsigned char saved_data =0 , overrun =0 , residue; -#endif if ((tmp = (NCR5380_read (STATUS_REG ) &PHASE_MASK )) != p) { *phase = tmp;return -1 ; } -#if defined(REAL_DMA ) || defined(REAL_DMA_POLL ) -if (p &SR_IO ) { -if (!(hostdata->flags &FLAG_NO_DMA_FIXUPS )) - c -=2 ; - } - hostdata->dma_len = (p &SR_IO ) ?NCR5380_dma_read_setup (instance, d, c) :NCR5380_dma_write_setup (instance, d, c); - -dsprintk (NDEBUG_DMA , instance,"initializing DMA %s: length %d, address %p\n" , - (p &SR_IO ) ?"receive" :"send" , c, *data); -#endif NCR5380_write (TARGET_COMMAND_REG ,PHASE_SR_TO_TCR (p)); -#ifdef REAL_DMA -NCR5380_write (MODE_REG ,MR_BASE |MR_DMA_MODE |MR_MONITOR_BSY | -MR_ENABLE_EOP_INTR ); -#elif defined(REAL_DMA_POLL ) -NCR5380_write (MODE_REG ,MR_BASE |MR_DMA_MODE |MR_MONITOR_BSY ); -#else /* * Note : on my sample board, watch-dog timeouts occurred when interrupts * were not disabled for the duration of a single DMA transfer, from
@@ -1564,7 +1485,6 @@ static int NCR5380_transfer_dma(struct S MR_ENABLE_EOP_INTR); else NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY); -#endif /* def REAL_DMA */ dprintk (NDEBUG_DMA ,"scsi%d : mode reg = 0x%X\n" , instance->host_no,NCR5380_read (MODE_REG ));
@@ -1584,14 +1504,8 @@ static int NCR5380_transfer_dma(struct Sio_recovery_delay (1 ); } -#if defined(REAL_DMA_POLL ) -do { - tmp =NCR5380_read (BUS_AND_STATUS_REG ); - }while ((tmp &BASR_PHASE_MATCH ) && !(tmp & (BASR_BUSY_ERROR |BASR_END_DMA_TRANSFER ))); -/* -* At this point, either we've completed DMA, or we have a phase mismatch, -* or we've unexpectedly lost BUSY (which is a real error). +* A note regarding the DMA errata workarounds for early NMOS silicon. * * For DMA sends, we want to wait until the last byte has been * transferred out over the bus before we turn off DMA mode. Alas, there
@@ -1618,79 +1532,18 @@ static int NCR5380_transfer_dma(struct S* properly, or the target switches to MESSAGE IN phase to signal a * disconnection (either operation bringing the DMA to a clean halt). * However, in order to handle scatter-receive, we must work around the -* problem. The chosen fix is to DMA N-2 bytes, then check for the +* problem. The chosen fix is to DMA fewer bytes, then check for the * condition before taking the NCR5380 out of DMA mode. One or two extra * bytes are transferred via PIO as necessary to fill out the original * request. */ if (p &SR_IO ) { -if (!(hostdata->flags &FLAG_NO_DMA_FIXUPS )) { -udelay (10 ); -if ((NCR5380_read (BUS_AND_STATUS_REG ) & (BASR_PHASE_MATCH |BASR_ACK )) == - (BASR_PHASE_MATCH |BASR_ACK )) { - saved_data =NCR5380_read (INPUT_DATA_REGISTER ); - overrun =1 ; - } - } - }else { -int limit =100 ; -while (((tmp =NCR5380_read (BUS_AND_STATUS_REG )) &BASR_ACK ) || (NCR5380_read (STATUS_REG ) &SR_REQ )) { -if (!(tmp &BASR_PHASE_MATCH )) -break ; -if (--limit <0 ) -break ; - } - } - -dsprintk (NDEBUG_DMA ,"polled DMA transfer complete, basr 0x%02x, sr 0x%02x\n" , - tmp,NCR5380_read (STATUS_REG )); - -NCR5380_write (MODE_REG ,MR_BASE ); -NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); - - residue =NCR5380_dma_residual (instance); - c -= residue; - *count -= c; - *data += c; - *phase =NCR5380_read (STATUS_REG ) &PHASE_MASK ; - -if (!(hostdata->flags &FLAG_NO_DMA_FIXUPS ) && - *phase == p && (p &SR_IO ) && residue ==0 ) { -if (overrun) { -dprintk (NDEBUG_DMA ,"Got an input overrun, using saved byte\n" ); - **data = saved_data; - *data +=1 ; - *count -=1 ; - cnt = toPIO =1 ; - }else { -printk ("No overrun??\n" ); - cnt = toPIO =2 ; - } -dprintk (NDEBUG_DMA ,"Doing %d-byte PIO to 0x%X\n" , cnt, *data); -NCR5380_transfer_pio (instance, phase, &cnt, data); - *count -= toPIO - cnt; - } - -dprintk (NDEBUG_DMA ,"Return with data ptr = 0x%X, count %d, last 0x%X, next 0x%X\n" , *data, *count, *(*data + *count -1 ), *(*data + *count)); -return 0 ; - -#elif defined(REAL_DMA ) -return 0 ; -#else /* defined(REAL_DMA_POLL) */ -if (p &SR_IO ) { foo =NCR5380_pread (instance, d, hostdata->flags &FLAG_NO_DMA_FIXUP ? c : c -1 );if (!foo && !(hostdata->flags &FLAG_NO_DMA_FIXUP )) {/* -* We can't disable DMA mode after successfully transferring -* what we plan to be the last byte, since that would open up -* a race condition where if the target asserted REQ before -* we got the DMA mode reset, the NCR5380 would have latched -* an additional byte into the INPUT DATA register and we'd -* have dropped it. -* -* The workaround was to transfer one fewer bytes than we +* The workaround was to transfer fewer bytes than we * intended to with the pseudo-DMA read function, wait for * the chip to latch the last byte, read it, and then disable * pseudo-DMA mode.
@@ -1738,9 +1591,8 @@ static int NCR5380_transfer_dma(struct S *count =0 ; *phase =NCR5380_read (STATUS_REG ) &PHASE_MASK ; return foo; -#endif /* def REAL_DMA */ } -#endif /* defined(REAL_DMA) | defined(PSEUDO_DMA) */ +#endif /* PSEUDO_DMA */ /* * Function : NCR5380_information_transfer (struct Scsi_Host *instance)
@@ -1831,7 +1683,7 @@ static void NCR5380_information_transfer* in an unconditional loop. */ -#if defined(PSEUDO_DMA ) || defined(REAL_DMA_POLL ) +#if defined(PSEUDO_DMA ) transfersize =0 ;if (!cmd->device->borken) transfersize =NCR5380_dma_xfer_len (instance, cmd, phase);
@@ -1855,7 +1707,7 @@ static void NCR5380_information_transfer } else cmd->SCp.this_residual -= transfersize - len; } else -#endif /* defined(PSEUDO_DMA) || defined(REAL_DMA_POLL) */ +#endif /* PSEUDO_DMA */ {/* Break up transfer into 3 ms chunks, * presuming 6 accesses per handshake.
@@ -2202,52 +2054,6 @@ static void NCR5380_reselect(struct Scsi scmd_id(tmp), tmp->device->lun, tmp->tag); } -/* -* Function : void NCR5380_dma_complete (struct Scsi_Host *instance) -* -* Purpose : called by interrupt handler when DMA finishes or a phase -* mismatch occurs (which would finish the DMA transfer). -* -* Inputs : instance - this instance of the NCR5380. -* -* Returns : pointer to the scsi_cmnd structure for which the I_T_L -* nexus has been reestablished, on failure NULL is returned. -*/ - -#ifdef REAL_DMA -static void NCR5380_dma_complete (NCR5380_instance * instance) { -struct NCR5380_hostdata *hostdata =shost_priv (instance); -int transferred; - -/* -* XXX this might not be right. -* -* Wait for final byte to transfer, ie wait for ACK to go false. -* -* We should use the Last Byte Sent bit, unfortunately this is -* not available on the 5380/5381 (only the various CMOS chips) -* -* FIXME: timeout, and need to handle long timeout/irq case -*/ - -NCR5380_poll_politely (instance,BUS_AND_STATUS_REG ,BASR_ACK ,0 ,5 *HZ ); - -NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); - -/* -* The only places we should see a phase mismatch and have to send -* data from the same set of pointers will be the data transfer -* phases. So, residual, requested length are only important here. -*/ - -if (!(hostdata->connected->SCp.phase &SR_CD )) { - transferred = instance->dmalen -NCR5380_dma_residual (); - hostdata->connected->SCp.this_residual -= transferred; - hostdata->connected->SCp.ptr += transferred; - } -} -#endif /* def REAL_DMA */ -/** * list_find_cmd - test for presence of a command in a linked list * @haystack: list of commands
@@ -2359,9 +2165,7 @@ static int NCR5380_abort(struct scsi_cmnif (hostdata->connected == cmd) {dsprintk (NDEBUG_ABORT , instance,"abort: cmd %p is connected\n" , cmd); hostdata->connected =NULL ; -#ifdef REAL_DMA hostdata->dma_len =0 ; -#endif if (do_abort (instance)) {set_host_byte (cmd,DID_ERROR );complete_cmd (instance, cmd);
@@ -2464,9 +2268,7 @@ static int NCR5380_bus_reset(struct scsifor (i =0 ; i <8 ; ++i) hostdata->busy[i] =0 ; -#ifdef REAL_DMA hostdata->dma_len =0 ; -#endif queue_work (hostdata->work_q, &hostdata->main_task);spin_unlock_irqrestore (&hostdata->lock, flags);
drivers/scsi/NCR5380.h +0 -112
127 lines not on this page · raw message
drivers/scsi/atari_NCR5380.c +9 -53
183 lines not on this page · raw message
drivers/scsi/atari_scsi.c +1 -31
@@ -85,7 +85,6 @@/* Definitions for the core NCR5380 driver. */ -#define REAL_DMA #define SUPPORT_TAGS #define MAX_TAGS 32#define DMA_MIN_SIZE 32
@@ -159,14 +158,11 @@ static inline unsigned long SCSI_DMA_GETreturn adr; } -#ifdef REAL_DMA static void atari_scsi_fetch_restbytes (void ); -#endif static unsigned char (*atari_scsi_reg_read)(unsigned char reg);static void (*atari_scsi_reg_write)(unsigned char reg,unsigned char value); -#ifdef REAL_DMA static unsigned long atari_dma_residual, atari_dma_startaddr;static short atari_dma_active;/* pointer to the dribble buffer */
@@ -185,7 +181,6 @@ static char *atari_dma_orig_addr;/* mask for address bits that can't be used with the ST-DMA */ static unsigned long atari_dma_stram_mask;#define STRAM_ADDR (a) (((a) & atari_dma_stram_mask) == 0) -#endif static int setup_can_queue =-1 ;module_param (setup_can_queue, int,0 );
@@ -201,8 +196,6 @@ static int setup_toshiba_delay = -1;module_param (setup_toshiba_delay, int,0 ); -#if defined(REAL_DMA ) -static int scsi_dma_is_ignored_buserr (unsigned char dma_stat) {int i;
@@ -255,12 +248,9 @@ static void scsi_dma_buserr(int irq, voi }#endif -#endif -static irqreturn_t scsi_tt_intr (int irq,void *dev) { -#ifdef REAL_DMA struct Scsi_Host *instance = dev;struct NCR5380_hostdata *hostdata =shost_priv (instance);int dma_stat;
@@ -342,8 +332,6 @@ static irqreturn_t scsi_tt_intr(int irq, tt_scsi_dma.dma_ctrl =0 ; } -#endif /* REAL_DMA */ -NCR5380_intr (irq, dev);return IRQ_HANDLED ;
@@ -352,7 +340,6 @@ static irqreturn_t scsi_tt_intr(int irq,static irqreturn_t scsi_falcon_intr (int irq,void *dev) { -#ifdef REAL_DMA struct Scsi_Host *instance = dev;struct NCR5380_hostdata *hostdata =shost_priv (instance);int dma_stat;
@@ -405,15 +392,12 @@ static irqreturn_t scsi_falcon_intr(int atari_dma_orig_addr =NULL ; } -#endif /* REAL_DMA */ -NCR5380_intr (irq, dev);return IRQ_HANDLED ; } -#ifdef REAL_DMA static void atari_scsi_fetch_restbytes (void ) {int nr;
@@ -436,7 +420,6 @@ static void atari_scsi_fetch_restbytes(v *dst++ = *src++; } } -#endif /* REAL_DMA */ /* This function releases the lock on the DMA chip if there is no
@@ -508,8 +491,6 @@ __setup("atascsi=", atari_scsi_setup);#endif /* !MODULE */ -#if defined(REAL_DMA ) -static unsigned long atari_scsi_dma_setup (struct Scsi_Host *instance,void *data,unsigned long count,int dir)
@@ -703,9 +684,6 @@ static unsigned long atari_dma_xfer_len( } -#endif /* REAL_DMA */ - -/* NCR5380 register access functions * * There are separate functions for TT and Falcon, because the access
@@ -745,7 +723,6 @@ static int atari_scsi_bus_reset(struct slocal_irq_save (flags); -#ifdef REAL_DMA /* Abort a maybe active DMA transfer */ if (IS_A_TT ()) { tt_scsi_dma.dma_ctrl =0 ;
@@ -754,7 +731,6 @@ static int atari_scsi_bus_reset(struct s atari_dma_active =0 ; atari_dma_orig_addr =NULL ; } -#endif rv =NCR5380_bus_reset (cmd);
@@ -850,8 +826,6 @@ static int __init atari_scsi_probe(struc } } - -#ifdef REAL_DMA /* If running on a Falcon and if there's TT-Ram (i.e., more than one * memory block, since there's always ST-Ram in a Falcon), then * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
@@ -867,7 +841,6 @@ static int __init atari_scsi_probe(struc atari_dma_phys_buffer =atari_stram_to_phys (atari_dma_buffer); atari_dma_orig_addr =0 ; } -#endif instance =scsi_host_alloc (&atari_scsi_template,sizeof (struct NCR5380_hostdata ));
@@ -897,7 +870,7 @@ static int __init atari_scsi_probe(struc goto fail_irq; } tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ -#ifdef REAL_DMA + tt_scsi_dma.dma_ctrl =0 ; atari_dma_residual =0 ;
@@ -919,17 +892,14 @@ static int __init atari_scsi_probe(struc hostdata->read_overruns =4 ; } -#endif }else {/* Nothing to do for the interrupt: the ST-DMA is initialized * already. */ -#ifdef REAL_DMA atari_dma_residual =0 ; atari_dma_active =0 ; atari_dma_stram_mask = (ATARIHW_PRESENT (EXTD_DMA ) ?0x00000000 :0xff000000 ); -#endif }NCR5380_maybe_reset_bus (instance);
drivers/scsi/sun3_scsi.c +2 -11
@@ -38,7 +38,6 @@/* Definitions for the core NCR5380 driver. */ -#define REAL_DMA /* #define SUPPORT_TAGS */ /* minimum number of bytes to do dma on */ #define DMA_MIN_SIZE 129
@@ -527,15 +526,9 @@ static int __init sun3_scsi_probe(struct error =request_irq (instance->irq, scsi_sun3_intr,0 ,"NCR5380" , instance);if (error) { -#ifdef REAL_DMA pr_err (PFX "scsi%d: IRQ %d not free, bailing out\n" , instance->host_no, instance->irq); goto fail_irq; -#else -pr_warn (PFX "scsi%d: IRQ %d not free, interrupts disabled\n" , - instance->host_no, instance->irq); - instance->irq =NO_IRQ ; -#endif } dregs->csr =0 ;
@@ -565,8 +558,7 @@ static int __init sun3_scsi_probe(structreturn 0 ; fail_host: -if (instance->irq !=NO_IRQ ) -free_irq (instance->irq, instance); +free_irq (instance->irq, instance); fail_irq:NCR5380_exit (instance); fail_init:
@@ -583,8 +575,7 @@ static int __exit sun3_scsi_remove(strucstruct Scsi_Host *instance =platform_get_drvdata (pdev);scsi_remove_host (instance); -if (instance->irq !=NO_IRQ ) -free_irq (instance->irq, instance); +free_irq (instance->irq, instance);NCR5380_exit (instance);scsi_host_put (instance);if (udc_regs)
PATCH v3 4/23 atari_NCR5380: Remove DMA_MIN_SIZE macro
In reply to Finn ThainOnly the atari_scsi and sun3_scsi drivers define DMA_MIN_SIZE. Both drivers also define NCR5380_dma_xfer_len, which means DMA_MIN_SIZE can be removed from the core driver.
This removes another discrepancy between the two core drivers.
---
Changes since v1:
- Retain MIN_DMA_SIZE macro in wrapper drivers.
--- drivers/scsi/atari_NCR5380.c | 16 ++++++++-------- drivers/scsi/atari_scsi.c | 6 +++++- drivers/scsi/sun3_scsi.c | 19 +++++++++---------- 3 files changed, 22 insertions(+), 19 deletions(-)
drivers/scsi/atari_NCR5380.c +8 -8
@@ -1857,12 +1857,11 @@ static void NCR5380_information_transfer d = cmd->SCp.ptr; }/* this command setup for dma yet? */ -if ((count >=DMA_MIN_SIZE ) && (sun3_dma_setup_done != cmd)) { -if (cmd->request->cmd_type ==REQ_TYPE_FS ) { -sun3scsi_dma_setup (instance, d, count, -rq_data_dir (cmd->request)); - sun3_dma_setup_done = cmd; - } +if (sun3_dma_setup_done != cmd && +sun3scsi_dma_xfer_len (count, cmd) >0 ) { +sun3scsi_dma_setup (instance, d, count, +rq_data_dir (cmd->request)); + sun3_dma_setup_done = cmd; }#ifdef SUN3_SCSI_VME dregs->csr |=CSR_INTR ;
@@ -1927,7 +1926,7 @@ static void NCR5380_information_transfer#endif transfersize =NCR5380_dma_xfer_len (instance, cmd, phase); -if (transfersize >=DMA_MIN_SIZE ) { +if (transfersize >0 ) { len = transfersize; cmd->SCp.phase = phase; if (NCR5380_transfer_dma(instance, &phase,
@@ -2366,7 +2365,8 @@ static void NCR5380_reselect(struct Scsi d = tmp->SCp.ptr; }/* setup this command for dma if not already */ -if ((count >=DMA_MIN_SIZE ) && (sun3_dma_setup_done != tmp)) { +if (sun3_dma_setup_done != tmp && +sun3scsi_dma_xfer_len (count, tmp) >0 ) {sun3scsi_dma_setup (instance, d, count,rq_data_dir (tmp->request)); sun3_dma_setup_done = tmp;
drivers/scsi/atari_scsi.c +5 -1
@@ -83,11 +83,12 @@#include <scsi/scsi_host.h> +#define DMA_MIN_SIZE 32 +/* Definitions for the core NCR5380 driver. */ #define SUPPORT_TAGS #define MAX_TAGS 32 -#define DMA_MIN_SIZE 32#define NCR5380_implementation_fields/* none */
@@ -605,6 +606,9 @@ static unsigned long atari_dma_xfer_len( {unsigned long possible_len, limit; +if (wanted_len <DMA_MIN_SIZE ) +return 0 ; +if (IS_A_TT ())/* TT SCSI DMA can transfer arbitrary #bytes */ return wanted_len;
drivers/scsi/sun3_scsi.c +9 -10
@@ -36,12 +36,12 @@#include <scsi/scsi_host.h> #include "sun3_scsi.h" -/* Definitions for the core NCR5380 driver. */ - -/* #define SUPPORT_TAGS */ /* minimum number of bytes to do dma on */ #define DMA_MIN_SIZE 129 +/* Definitions for the core NCR5380 driver. */ + +/* #define SUPPORT_TAGS */ /* #define MAX_TAGS 32 */ #define NCR5380_implementation_fields/* none */
@@ -61,7 +61,7 @@#define NCR5380_dma_residual (instance) \ sun3scsi_dma_residual(instance)#define NCR5380_dma_xfer_len (instance, cmd, phase) \ - sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) + sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd)#define NCR5380_acquire_dma_irq (instance) (1)#define NCR5380_release_dma_irq (instance)
@@ -262,14 +262,13 @@ static inline unsigned long sun3scsi_dmareturn last_residual; } -static inline unsigned long sun3scsi_dma_xfer_len (unsigned long wanted, -struct scsi_cmnd *cmd, -int write_flag) +static inline unsigned long sun3scsi_dma_xfer_len (unsigned long wanted_len, +struct scsi_cmnd *cmd) { -if (cmd->request->cmd_type ==REQ_TYPE_FS ) -return wanted; -else +if (wanted_len <DMA_MIN_SIZE || cmd->request->cmd_type !=REQ_TYPE_FS )return 0 ; + +return wanted_len; }static inline int sun3scsi_dma_start (unsigned long count,unsigned char *data)
PATCH v3 5/23 ncr5380: Disable the DMA errata workaround flag by default
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-FLAG_DMA_FIXUP
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/69aaf7a7/attachment.ksh>
PATCH v3 6/23 ncr5380: Remove PSEUDO_DMA macro
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-PSEUDO_DMA-macro
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/b07e7d5f/attachment.ksh>
PATCH v3 7/23 ncr5380: Remove BOARD_REQUIRES_NO_DELAY macro
In reply to Finn ThainThe io_recovery_delay macro is intended to insert a microsecond delay between the chip register accesses that begin a DMA operation. This is reportedly needed for some ISA boards.
Reverse the sense of the macro test so that in the common case, where no delay is required, drivers need not define the macro.
--- drivers/scsi/NCR5380.c | 18 ++++++++---------- drivers/scsi/dtc.h | 2 ++ drivers/scsi/g_NCR5380.h | 2 ++ drivers/scsi/t128.h | 2 ++ 4 files changed, 14 insertions(+), 10 deletions(-)
drivers/scsi/NCR5380.c +8 -10
@@ -39,12 +39,6 @@* tagged queueing) */ -#ifdef BOARD_REQUIRES_NO_DELAY -#define io_recovery_delay (x) -#else -#define io_recovery_delay (x) udelay(x) -#endif -/* * Design *
@@ -150,6 +144,10 @@* possible) function may be used. */ +#ifndef NCR5380_io_delay +#define NCR5380_io_delay (x) +#endif +static int do_abort (struct Scsi_Host *);static void do_reset (struct Scsi_Host *);
@@ -1468,14 +1466,14 @@ static int NCR5380_transfer_dma(struct S*/ if (p &SR_IO ) { -io_recovery_delay (1 ); +NCR5380_io_delay (1 );NCR5380_write (START_DMA_INITIATOR_RECEIVE_REG ,0 ); }else { -io_recovery_delay (1 ); +NCR5380_io_delay (1 );NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE |ICR_ASSERT_DATA ); -io_recovery_delay (1 ); +NCR5380_io_delay (1 );NCR5380_write (START_DMA_SEND_REG ,0 ); -io_recovery_delay (1 ); +NCR5380_io_delay (1 ); }/*
drivers/scsi/dtc.h +2 -0
@@ -28,6 +28,8 @@#define NCR5380_bus_reset dtc_bus_reset#define NCR5380_info dtc_info +#define NCR5380_io_delay (x) udelay(x) +/* 15 12 11 10 1001 1100 0000 0000 */
drivers/scsi/g_NCR5380.h +2 -0
@@ -71,6 +71,8 @@#define NCR5380_pwrite generic_NCR5380_pwrite#define NCR5380_info generic_NCR5380_info +#define NCR5380_io_delay (x) udelay(x) +#define BOARD_NCR5380 0#define BOARD_NCR53C400 1#define BOARD_NCR53C400A 2
drivers/scsi/t128.h +2 -0
@@ -84,6 +84,8 @@#define NCR5380_bus_reset t128_bus_reset#define NCR5380_info t128_info +#define NCR5380_io_delay (x) udelay(x) +/* 15 14 12 10 7 5 3 1101 0100 1010 1000 */
PATCH v3 8/23 ncr5380: Use DMA hooks for PDMA
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-rename-pread-and-pwrite
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/c4ab8c2b/attachment.ksh>
PATCH v3 9/23 ncr5380: Adopt uniform DMA setup convention
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-dma-setup-api
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/53323aca/attachment.ksh>
PATCH v3 10/23 ncr5380: Merge DMA implementation from atari_NCR5380 core driver
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-merge-atari-dma-algorithm
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/84c12592/attachment.ksh>
PATCH v3 11/23 atari_scsi: Adopt NCR5380.c core driver
In reply to Finn ThainAdd support for the Atari ST DMA chip to the NCR5380.c core driver. This code is copied from atari_NCR5380.c.
--- drivers/scsi/NCR5380.c | 32 ++++++++++++++++++++++++++++++++ drivers/scsi/atari_scsi.c | 6 +++--- 2 files changed, 35 insertions(+), 3 deletions(-)
drivers/scsi/NCR5380.c +32 -0
@@ -29,6 +29,8 @@* Ronald van Cuijlenborg, Alan Cox and others. */ +/* Ported to Atari by Roman Hodek and others. */ +/* * Further development / testing that should be done : *
@@ -141,6 +143,14 @@#define NCR5380_io_delay (x)#endif +#ifndef NCR5380_acquire_dma_irq +#define NCR5380_acquire_dma_irq (x) (1) +#endif + +#ifndef NCR5380_release_dma_irq +#define NCR5380_release_dma_irq (x) +#endif +static int do_abort (struct Scsi_Host *);static void do_reset (struct Scsi_Host *);
@@ -658,6 +668,9 @@ static int NCR5380_queue_command(struct cmd->result =0 ; +if (!NCR5380_acquire_dma_irq (instance)) +return SCSI_MLQUEUE_HOST_BUSY ; +spin_lock_irqsave (&hostdata->lock, flags);/*
@@ -682,6 +695,19 @@ static int NCR5380_queue_command(structreturn 0 ; } +static inline void maybe_release_dma_irq (struct Scsi_Host *instance) +{ +struct NCR5380_hostdata *hostdata =shost_priv (instance); + +/* Caller does the locking needed to set & test these data atomically */ +if (list_empty (&hostdata->disconnected) && +list_empty (&hostdata->unissued) && +list_empty (&hostdata->autosense) && + !hostdata->connected && + !hostdata->selecting) +NCR5380_release_dma_irq (instance); +} +/** * dequeue_next_cmd - dequeue a command for processing * @instance: the scsi host instance
@@ -783,6 +809,7 @@ static void NCR5380_main(struct work_strif (!NCR5380_select (instance, cmd)) {dsprintk (NDEBUG_MAIN , instance,"main: select complete\n" ); +maybe_release_dma_irq (instance); }else {dsprintk (NDEBUG_MAIN |NDEBUG_QUEUES , instance,"main: select failed, returning %p to queue\n" , cmd);
@@ -1828,6 +1855,8 @@ static void NCR5380_information_transfer/* Enable reselect interrupts */ NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask); + +maybe_release_dma_irq (instance);return ;case MESSAGE_REJECT :/* Accept message by clearing ACK */
@@ -1963,6 +1992,7 @@ static void NCR5380_information_transfer hostdata->connected =NULL ; cmd->result =DID_ERROR <<16 ;complete_cmd (instance, cmd); +maybe_release_dma_irq (instance);NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);return ; }
@@ -2256,6 +2286,7 @@ out:dsprintk (NDEBUG_ABORT , instance,"abort: successfully aborted %p\n" , cmd);queue_work (hostdata->work_q, &hostdata->main_task); +maybe_release_dma_irq (instance);spin_unlock_irqrestore (&hostdata->lock, flags);return result;
@@ -2336,6 +2367,7 @@ static int NCR5380_bus_reset(struct scsi hostdata->dma_len =0 ;queue_work (hostdata->work_q, &hostdata->main_task); +maybe_release_dma_irq (instance);spin_unlock_irqrestore (&hostdata->lock, flags);return SUCCESS ;
drivers/scsi/atari_scsi.c +3 -3
@@ -99,9 +99,9 @@#define NCR5380_abort atari_scsi_abort#define NCR5380_info atari_scsi_info -#define NCR5380_dma_read_setup (instance, data, count) \ +#define NCR5380_dma_recv_setup (instance, data, count) \ atari_scsi_dma_setup(instance, data, count, 0) -#define NCR5380_dma_write_setup (instance, data, count) \ +#define NCR5380_dma_send_setup (instance, data, count) \ atari_scsi_dma_setup(instance, data, count, 1)#define NCR5380_dma_residual (instance) \ atari_scsi_dma_residual(instance)
@@ -715,7 +715,7 @@ static void atari_scsi_falcon_reg_write( } -#include "atari_NCR5380.c" +#include "NCR5380.c" static int atari_scsi_bus_reset (struct scsi_cmnd *cmd) {
PATCH v3 12/23 sun3_scsi: Adopt NCR5380.c core driver
In reply to Finn ThainAdd support for the custom Sun 3 DMA logic to the NCR5380.c core driver. This code is copied from atari_NCR5380.c.
---
The Sun 3 DMA code is still configured by macros. I have simplified things slightly but I have avoided more ambitious refactoring. It's not clear to me what that should look like and I can't test sun3_scsi anyway. At least this permits the removal of atari_NCR5380.c.
--- drivers/scsi/NCR5380.c | 131 +++++++++++++++++++++++++++++++++++++++++++---- drivers/scsi/sun3_scsi.c | 8 +- 2 files changed, 124 insertions(+), 15 deletions(-)
drivers/scsi/sun3_scsi.c +3 -5
@@ -54,10 +54,8 @@#define NCR5380_abort sun3scsi_abort#define NCR5380_info sun3scsi_info -#define NCR5380_dma_read_setup (instance, data, count) \ - sun3scsi_dma_setup(instance, data, count, 0) -#define NCR5380_dma_write_setup (instance, data, count) \ - sun3scsi_dma_setup(instance, data, count, 1) +#define NCR5380_dma_recv_setup (instance, data, count) (count) +#define NCR5380_dma_send_setup (instance, data, count) (count)#define NCR5380_dma_residual (instance) \ sun3scsi_dma_residual(instance)#define NCR5380_dma_xfer_len (instance, cmd, phase) \
@@ -406,7 +404,7 @@ static int sun3scsi_dma_finish(int write } -#include "atari_NCR5380.c" +#include "NCR5380.c" #ifdef SUN3_SCSI_VME #define SUN3_SCSI_NAME "Sun3 NCR5380 VME SCSI"
drivers/scsi/NCR5380.c +121 -10
222 lines not on this page · raw message
PATCH v3 13/23 ncr5380: Remove disused atari_NCR5380.c core driver
In reply to Finn ThainNow that atari_scsi and sun3_scsi have been converted to use the NCR5380.c core driver, remove atari_NCR5380.c. Also remove the last vestiges of its Tagged Command Queueing implementation from the wrapper drivers.
The TCQ support in atari_NCR5380.c is abandoned by this patch. It is not merged into the remaining core driver because,
1) atari_scsi defines SUPPORT_TAGS but leaves FLAG_TAGGED_QUEUING disabled by default, which indicates that it is mostly undesirable.
2) I'm told that it doesn't work correctly when enabled.
3) The algorithm does not make use of block layer tags which it will have to do because scmd->tag is deprecated.
4) sun3_scsi doesn't define SUPPORT_TAGS at all, yet the the SUPPORT_TAGS macro interacts with the CONFIG_SUN3 macro in 'interesting' ways.
5) Compile-time configuration with macros like SUPPORT_TAGS caused the configuration space to explode, leading to untestable and unmaintainable code that is too hard to reason about.
The merge_contiguous_buffers() code is also abandoned. This was unused by sun3_scsi. Only atari_scsi used it and then only on TT, because only TT supports scatter/gather. I suspect that the TT would work fine with ENABLE_CLUSTERING instead. If someone can benchmark the difference then perhaps the merge_contiguous_buffers() code can be be justified. Until then we are better off without the extra complexity.
--- drivers/scsi/NCR5380.c | 22 drivers/scsi/NCR5380.h | 19 drivers/scsi/atari_NCR5380.c | 2632 ------------------------------------------- drivers/scsi/atari_scsi.c | 11 drivers/scsi/mac_scsi.c | 8 drivers/scsi/sun3_scsi.c | 11 6 files changed, 4 insertions(+), 2699 deletions(-)
drivers/scsi/atari_scsi.c +1 -10
@@ -87,9 +87,6 @@/* Definitions for the core NCR5380 driver. */ -#define SUPPORT_TAGS -#define MAX_TAGS 32 -#define NCR5380_implementation_fields/* none */ #define NCR5380_read (reg) atari_scsi_reg_read(reg)
@@ -189,8 +186,6 @@ static int setup_cmd_per_lun = -1;module_param (setup_cmd_per_lun, int,0 );static int setup_sg_tablesize =-1 ;module_param (setup_sg_tablesize, int,0 ); -static int setup_use_tagged_queuing =-1 ; -module_param (setup_use_tagged_queuing, int,0 );static int setup_hostid =-1 ;module_param (setup_hostid, int,0 );static int setup_toshiba_delay =-1 ;
@@ -479,8 +474,7 @@ static int __init atari_scsi_setup(char setup_sg_tablesize = ints[3 ];if (ints[0 ] >=4 ) setup_hostid = ints[4 ]; -if (ints[0 ] >=5 ) - setup_use_tagged_queuing = ints[5 ]; +/* ints[5] (use_tagged_queuing) is ignored */ /* ints[6] (use_pdma) is ignored */ if (ints[0 ] >=7 ) setup_toshiba_delay = ints[7 ];
@@ -853,9 +847,6 @@ static int __init atari_scsi_probe(struc instance->irq = irq->start; host_flags |=IS_A_TT () ?0 :FLAG_LATE_DMA_SETUP ; -#ifdef SUPPORT_TAGS - host_flags |= setup_use_tagged_queuing >0 ?FLAG_TAGGED_QUEUING :0 ; -#endif host_flags |= setup_toshiba_delay >0 ?FLAG_TOSHIBA_DELAY :0 ; error =NCR5380_init (instance, host_flags);
drivers/scsi/sun3_scsi.c +0 -11
@@ -41,9 +41,6 @@/* Definitions for the core NCR5380 driver. */ -/* #define SUPPORT_TAGS */ -/* #define MAX_TAGS 32 */ -#define NCR5380_implementation_fields/* none */ #define NCR5380_read (reg) sun3scsi_read(reg)
@@ -75,10 +72,6 @@ static int setup_cmd_per_lun = -1;module_param (setup_cmd_per_lun, int,0 );static int setup_sg_tablesize =-1 ;module_param (setup_sg_tablesize, int,0 ); -#ifdef SUPPORT_TAGS -static int setup_use_tagged_queuing =-1 ; -module_param (setup_use_tagged_queuing, int,0 ); -#endif static int setup_hostid =-1 ;module_param (setup_hostid, int,0 );
@@ -512,10 +505,6 @@ static int __init sun3_scsi_probe(struct instance->io_port = (unsigned long )ioaddr; instance->irq = irq->start; -#ifdef SUPPORT_TAGS - host_flags |= setup_use_tagged_queuing >0 ?FLAG_TAGGED_QUEUING :0 ; -#endif - error =NCR5380_init (instance, host_flags);if (error) goto fail_init;
drivers/scsi/mac_scsi.c +1 -7
@@ -55,8 +55,6 @@ static int setup_sg_tablesize = -1;module_param (setup_sg_tablesize, int,0 );static int setup_use_pdma =-1 ;module_param (setup_use_pdma, int,0 ); -static int setup_use_tagged_queuing =-1 ; -module_param (setup_use_tagged_queuing, int,0 );static int setup_hostid =-1 ;module_param (setup_hostid, int,0 );static int setup_toshiba_delay =-1 ;
@@ -95,8 +93,7 @@ static int __init mac_scsi_setup(char *s setup_sg_tablesize = ints[3 ];if (ints[0 ] >=4 ) setup_hostid = ints[4 ]; -if (ints[0 ] >=5 ) - setup_use_tagged_queuing = ints[5 ]; +/* ints[5] (use_tagged_queuing) is ignored */ if (ints[0 ] >=6 ) setup_use_pdma = ints[6 ];if (ints[0 ] >=7 )
@@ -382,9 +379,6 @@ static int __init mac_scsi_probe(struct }else host_flags |=FLAG_NO_PSEUDO_DMA ; -#ifdef SUPPORT_TAGS - host_flags |= setup_use_tagged_queuing >0 ?FLAG_TAGGED_QUEUING :0 ; -#endif host_flags |= setup_toshiba_delay >0 ?FLAG_TOSHIBA_DELAY :0 ; error =NCR5380_init (instance, host_flags |FLAG_LATE_DMA_SETUP );
drivers/scsi/NCR5380.c +2 -20
@@ -34,13 +34,6 @@/* Adapted for the Sun 3 by Sam Creasey. */ /* -* Further development / testing that should be done : -* -* 4. Test SCSI-II tagged queueing (I have no devices which support -* tagged queueing) -*/ - -/* * Design * * This is a generic 5380 driver. To use it on a different platform,
@@ -1257,14 +1250,6 @@ static struct scsi_cmnd *NCR5380_select(* was true but before BSY was false during selection, the information * transfer phase should be a MESSAGE OUT phase so that we can send the * IDENTIFY message. -* -* If SCSI-II tagged queuing is enabled, we also send a SIMPLE_QUEUE_TAG -* message (2 bytes) with a tag ID that we increment with every command -* until it wraps back to 0. -* -* XXX - it turns out that there are some broken SCSI-II devices, -* which claim to support tagged queuing but fail when more than -* some number of commands are issued at once. */ /* Wait for start of REQ/ACK handshake */
@@ -1287,9 +1272,6 @@ static struct scsi_cmnd *NCR5380_select( tmp[0 ] =IDENTIFY (((instance->irq ==NO_IRQ ) ?0 :1 ), cmd->device->lun); len =1 ; - cmd->tag =0 ; - -/* Send message(s) */ data = tmp; phase =PHASE_MSGOUT ;NCR5380_transfer_pio (instance, &phase, &len, &data);
@@ -2256,8 +2238,8 @@ static void NCR5380_reselect(struct ScsiNCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); hostdata->connected = tmp; -dsprintk (NDEBUG_RESELECTION , instance,"nexus established, target %d, lun %llu, tag %d\n" , -scmd_id (tmp), tmp->device->lun, tmp->tag); +dsprintk (NDEBUG_RESELECTION , instance,"nexus established, target %d, lun %llu\n" , +scmd_id (tmp), tmp->device->lun); }/**
drivers/scsi/NCR5380.h +0 -19
@@ -199,13 +199,6 @@#define PHASE_SR_TO_TCR (phase) ((phase) >> 2) -/* -* "Special" value for the (unsigned char) command tag, to indicate -* I_T_L nexus instead of I_T_L_Q. -*/ - -#define TAG_NONE 0xff -/* * These are "special" values for the irq and dma_channel fields of the * Scsi_Host structure
@@ -223,17 +216,8 @@#define FLAG_DMA_FIXUP 1/* Use DMA errata workarounds */ #define FLAG_NO_PSEUDO_DMA 8/* Inhibit DMA */ #define FLAG_LATE_DMA_SETUP 32/* Setup NCR before DMA H/W */ -#define FLAG_TAGGED_QUEUING 64/* as X3T9.2 spelled it */ #define FLAG_TOSHIBA_DELAY 128/* Allow for borken CD-ROMs */ -#ifdef SUPPORT_TAGS -struct tag_alloc { - DECLARE_BITMAP(allocated, MAX_TAGS); -int nr_allocated; -int queue_size; -}; -#endif -struct NCR5380_hostdata {NCR5380_implementation_fields ;/* implementation specific */ struct Scsi_Host *host;/* Host backpointer */
@@ -254,9 +238,6 @@ struct NCR5380_hostdata {int read_overruns;/* number of bytes to cut from a * transfer to handle chip overruns */ struct work_struct main_task; -#ifdef SUPPORT_TAGS -struct tag_alloc TagAlloc[8 ][8 ];/* 8 targets and 8 LUNs */ -#endif struct workqueue_struct *work_q;unsigned long accesses_per_ms;/* chip register accesses per ms */ };
drivers/scsi/atari_NCR5380.c deleted +0 -2632
2,632 lines not on this page · raw message
PATCH v3 14/23 ncr5380: Reduce max_lun limit
In reply to Finn ThainThe driver has a limit of eight LUs because of the byte-sized bitfield that is used for busy flags. That means the maximum LUN is 7. The default is 8.
---
Changed since v1:
- Reduce shost->max_lun limit instead of adding 'MAX_LUN' limit.
--- drivers/scsi/NCR5380.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/NCR5380.c +2 -0
@@ -488,6 +488,8 @@ static int NCR5380_init(struct Scsi_Hostint i;unsigned long deadline; + instance->max_lun =7 ; + hostdata->host = instance; hostdata->id_mask =1 << instance->this_id; hostdata->id_higher_mask =0 ;
PATCH v3 15/23 dmx3191d: Drop max_sectors limit
In reply to Finn ThainThe dmx3191d driver is not capable of DMA or PDMA so all transfers use PIO. Now that large slow PIO transfers periodically stop and call cond_resched(), the max_sectors limit can go away.
--- drivers/scsi/dmx3191d.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/dmx3191d.c +0 -1
@@ -67,7 +67,6 @@ static struct scsi_host_template dmx3191 .cmd_per_lun = 2, .use_clustering = DISABLE_CLUSTERING, .cmd_size = NCR5380_CMD_SIZE, - .max_sectors = 128, }; static int dmx3191d_probe_one(struct pci_dev *pdev,
PATCH v3 16/23 ncr5380: Fix register decoding for debugging
In reply to Finn ThainDecode all bits in the chip registers. They are all useful at times. Fix printk severity so that this output can be suppressed along with the other debugging output.
--- drivers/scsi/NCR5380.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-)
drivers/scsi/NCR5380.c +25 -17
@@ -256,12 +256,20 @@ static struct { {0, NULL} }, basrs[] = { + {BASR_END_DMA_TRANSFER, "END OF DMA"}, + {BASR_DRQ, "DRQ"}, + {BASR_PARITY_ERROR, "PARITY ERROR"}, + {BASR_IRQ, "IRQ"}, + {BASR_PHASE_MATCH, "PHASE MATCH"}, + {BASR_BUSY_ERROR, "BUSY ERROR"}, {BASR_ATN, "ATN"}, {BASR_ACK, "ACK"}, {0, NULL} }, icrs[] = { {ICR_ASSERT_RST, "ASSERT RST"}, + {ICR_ARBITRATION_PROGRESS, "ARB. IN PROGRESS"}, + {ICR_ARBITRATION_LOST, "LOST ARB."}, {ICR_ASSERT_ACK, "ASSERT ACK"}, {ICR_ASSERT_BSY, "ASSERT BSY"}, {ICR_ASSERT_SEL, "ASSERT SEL"},
@@ -270,14 +278,14 @@ icrs[] = { {0, NULL} }, mrs[] = { - {MR_BLOCK_DMA_MODE, "MODE BLOCK DMA"}, - {MR_TARGET, "MODE TARGET"}, - {MR_ENABLE_PAR_CHECK, "MODE PARITY CHECK"}, - {MR_ENABLE_PAR_INTR, "MODE PARITY INTR"}, - {MR_ENABLE_EOP_INTR, "MODE EOP INTR"}, - {MR_MONITOR_BSY, "MODE MONITOR BSY"}, - {MR_DMA_MODE, "MODE DMA"}, - {MR_ARBITRATE, "MODE ARBITRATION"}, + {MR_BLOCK_DMA_MODE, "BLOCK DMA MODE"}, + {MR_TARGET, "TARGET"}, + {MR_ENABLE_PAR_CHECK, "PARITY CHECK"}, + {MR_ENABLE_PAR_INTR, "PARITY INTR"}, + {MR_ENABLE_EOP_INTR, "EOP INTR"}, + {MR_MONITOR_BSY, "MONITOR BSY"}, + {MR_DMA_MODE, "DMA MODE"}, + {MR_ARBITRATE, "ARBITRATE"}, {0, NULL} };
@@ -298,23 +306,23 @@ static void NCR5380_print(struct Scsi_Ho icr =NCR5380_read (INITIATOR_COMMAND_REG ); basr =NCR5380_read (BUS_AND_STATUS_REG ); -printk ("STATUS_REG: %02x " , status); +printk (KERN_DEBUG "SR = 0x%02x : " , status);for (i =0 ; signals[i].mask; ++i)if (status & signals[i].mask) -printk (",%s" , signals[i].name); -printk ("\nBASR: %02x " , basr); +printk (KERN_CONT "%s, " , signals[i].name); +printk (KERN_CONT "\nBASR = 0x%02x : " , basr);for (i =0 ; basrs[i].mask; ++i)if (basr & basrs[i].mask) -printk (",%s" , basrs[i].name); -printk ("\nICR: %02x " , icr); +printk (KERN_CONT "%s, " , basrs[i].name); +printk (KERN_CONT "\nICR = 0x%02x : " , icr);for (i =0 ; icrs[i].mask; ++i)if (icr & icrs[i].mask) -printk (",%s" , icrs[i].name); -printk ("\nMODE: %02x " , mr); +printk (KERN_CONT "%s, " , icrs[i].name); +printk (KERN_CONT "\nMR = 0x%02x : " , mr);for (i =0 ; mrs[i].mask; ++i)if (mr & mrs[i].mask) -printk (",%s" , mrs[i].name); -printk ("\n" ); +printk (KERN_CONT "%s, " , mrs[i].name); +printk (KERN_CONT "\n" ); } static struct {
PATCH v3 17/23 ncr5380: Remove remaining register storage qualifiers
In reply to Finn Thain--- drivers/scsi/NCR5380.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/NCR5380.c +3 -3
@@ -1555,9 +1555,9 @@ static int NCR5380_transfer_dma(struct S unsigned char **data) {struct NCR5380_hostdata *hostdata =shost_priv (instance); - registerint c = *count; - registerunsigned char p = *phase; - registerunsigned char *d = *data; +int c = *count; +unsigned char p = *phase; +unsigned char *d = *data;unsigned char tmp;int result =0 ;
PATCH v3 18/23 ncr5380: Remove DONT_USE_INTR and AUTOPROBE_IRQ macros
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-DONT_USE_INTR-and-AUTOPROBE_IRQ-macros
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160321/f9e21f09/attachment.ksh>
PATCH v3 19/23 ncr5380: Update usage documentation
In reply to Finn ThainUpdate kernel parameter documentation for atari_scsi, mac_scsi and g_NCR5380 drivers. Remove duplication.
--- Documentation/scsi/g_NCR5380.txt | 17 ++++++--------- Documentation/scsi/scsi-parameters.txt | 11 +++++++--- drivers/scsi/g_NCR5380.c | 36 --------------------------------- 3 files changed, 16 insertions(+), 48 deletions(-)
Documentation/scsi/scsi-parameters.txt +8 -3
@@ -27,13 +27,15 @@ parameters may be changed at runtime by aic79xx= [HW,SCSI] See Documentation/scsi/aic79xx.txt. - atascsi= [HW,SCSI] Atari SCSI + atascsi= [HW,SCSI] + See drivers/scsi/atari_scsi.c. BusLogic= [HW,SCSI] See drivers/scsi/BusLogic.c, comment before function BusLogic_ParseDriverOptions(). dtc3181e= [HW,SCSI] + See Documentation/scsi/g_NCR5380.txt. eata= [HW,SCSI]
@@ -51,8 +53,8 @@ parameters may be changed at runtime by ips= [HW,SCSI] Adaptec / IBM ServeRAID controller See header of drivers/scsi/ips.c. - mac5380= [HW,SCSI] Format: - <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> + mac5380= [HW,SCSI] + See drivers/scsi/mac_scsi.c. max_luns= [SCSI] Maximum number of LUNs to probe. Should be between 1 and 2^32-1.
@@ -65,10 +67,13 @@ parameters may be changed at runtime by See header of drivers/scsi/NCR_D700.c. ncr5380= [HW,SCSI] + See Documentation/scsi/g_NCR5380.txt. ncr53c400= [HW,SCSI] + See Documentation/scsi/g_NCR5380.txt. ncr53c400a= [HW,SCSI] + See Documentation/scsi/g_NCR5380.txt. ncr53c406a= [HW,SCSI]
Documentation/scsi/g_NCR5380.txt +7 -10
@@ -23,11 +23,10 @@ supported by the driver. If the default configuration does not work for you, you can use the kernel command lines (eg using the lilo append command): - ncr5380=port,irq,dma - ncr53c400=port,irq -or - ncr5380=base,irq,dma - ncr53c400=base,irq + ncr5380=addr,irq + ncr53c400=addr,irq + ncr53c400a=addr,irq + dtc3181e=addr,irq The driver does not probe for any addresses or ports other than those in the OVERRIDE or given to the kernel as above.
@@ -36,19 +35,17 @@ This driver provides some information on /proc/scsi/g_NCR5380/x where x is the scsi card number as detected at boot time. More info to come in the future. -When NCR53c400 support is compiled in, BIOS parameters will be returned by -the driver (the raw 5380 driver does not and I don't plan to fiddle with -it!). - This driver works as a module. When included as a module, parameters can be passed on the insmod/modprobe command line: ncr_irq=xx the interrupt ncr_addr=xx the port or base address (for port or memory mapped, resp.) - ncr_dma=xx the DMA ncr_5380=1 to set up for a NCR5380 board ncr_53c400=1 to set up for a NCR53C400 board + ncr_53c400a=1 to set up for a NCR53C400A board + dtc_3181e=1 to set up for a Domex Technology Corp 3181E board + hp_c2502=1 to set up for a Hewlett Packard C2502 board e.g. modprobe g_NCR5380 ncr_irq=5 ncr_addr=0x350 ncr_5380=1 for a port mapped NCR5380 board or
drivers/scsi/g_NCR5380.c +1 -35
@@ -18,42 +18,8 @@* * Added ISAPNP support for DTC436 adapters, * Thomas Sailer, [email protected] -*/ - -/* -* TODO : flesh out DMA support, find some one actually using this (I have -* a memory mapped Trantor board that works fine) -*/ - -/* -* The card is detected and initialized in one of several ways : -* 1. With command line overrides - NCR5380=port,irq may be -* used on the LILO command line to override the defaults. -* -* 2. With the GENERIC_NCR5380_OVERRIDE compile time define. This is -* specified as an array of address, irq, dma, board tuples. Ie, for -* one board at 0x350, IRQ5, no dma, I could say -* -DGENERIC_NCR5380_OVERRIDE={{0xcc000, 5, DMA_NONE, BOARD_NCR5380}} -* -* -1 should be specified for no or DMA interrupt, -2 to autoprobe for an -* IRQ line if overridden on the command line. * -* 3. When included as a module, with arguments passed on the command line: -* ncr_irq=xx the interrupt -* ncr_addr=xx the port or base address (for port or memory -* mapped, resp.) -* ncr_dma=xx the DMA -* ncr_5380=1 to set up for a NCR5380 board -* ncr_53c400=1 to set up for a NCR53C400 board -* e.g. -* modprobe g_NCR5380 ncr_irq=5 ncr_addr=0x350 ncr_5380=1 -* for a port mapped NCR5380 board or -* modprobe g_NCR5380 ncr_irq=255 ncr_addr=0xc8000 ncr_53c400=1 -* for a memory mapped NCR53C400 board with interrupts disabled. -* -* 255 should be specified for no or DMA interrupt, 254 to autoprobe for an -* IRQ line if overridden on the command line. -* +* See Documentation/scsi/g_NCR5380.txt for more info. */ #include <asm/io.h>
PATCH v3 20/23 atari_scsi: Set a reasonable default for cmd_per_lun
In reply to Finn ThainThis setting does not need to be conditional on Atari ST or TT.
---
Changed since v1:
- Set the default cmd_per_lun to 4 based on test results.
Changed since v2:
- Revert the default cmd_per_lun to 2, like in the v1 patch, because a uniform default across all ten 5380 wrapper drivers is worth more than a tiny improvement in one particular microbenchmark on one system. Michael tells me that 2 is also the best setting for his Atari Falcon.
--- drivers/scsi/atari_scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/atari_scsi.c +1 -2
@@ -752,6 +752,7 @@ static struct scsi_host_template atari_s .eh_abort_handler = atari_scsi_abort, .eh_bus_reset_handler = atari_scsi_bus_reset, .this_id = 7, + .cmd_per_lun = 2, .use_clustering = DISABLE_CLUSTERING, .cmd_size = NCR5380_CMD_SIZE, };
@@ -788,11 +789,9 @@ static int __init atari_scsi_probe(struc*/ if (ATARIHW_PRESENT (TT_SCSI )) { atari_scsi_template.can_queue =16 ; - atari_scsi_template.cmd_per_lun =8 ; atari_scsi_template.sg_tablesize =SG_ALL ; }else { atari_scsi_template.can_queue =8 ; - atari_scsi_template.cmd_per_lun =1 ; atari_scsi_template.sg_tablesize =SG_NONE ; }
PATCH v3 21/23 atari_scsi: Allow can_queue to be increased for Falcon
In reply to Finn ThainThe benefit of limiting can_queue to 1 is that atari_scsi shares the ST DMA chip more fairly with other drivers (e.g. falcon-ide).
Unfortunately, this can limit SCSI bus utilization. On systems without IDE, atari_scsi should issue SCSI commands whenever it can arbitrate for the bus. Make that possible by making can_queue configurable.
--- drivers/scsi/atari_scsi.c | 83 ++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 61 deletions(-)
drivers/scsi/atari_scsi.c +22 -61
@@ -14,55 +14,23 @@* */ - -/**************************************************************************/ -/* */ -/* Notes for Falcon SCSI: */ -/* ---------------------- */ -/* */ -/* Since the Falcon SCSI uses the ST-DMA chip, that is shared among */ -/* several device drivers, locking and unlocking the access to this */ -/* chip is required. But locking is not possible from an interrupt, */ -/* since it puts the process to sleep if the lock is not available. */ -/* This prevents "late" locking of the DMA chip, i.e. locking it just */ -/* before using it, since in case of disconnection-reconnection */ -/* commands, the DMA is started from the reselection interrupt. */ -/* */ -/* Two possible schemes for ST-DMA-locking would be: */ -/* 1) The lock is taken for each command separately and disconnecting */ -/* is forbidden (i.e. can_queue = 1). */ -/* 2) The DMA chip is locked when the first command comes in and */ -/* released when the last command is finished and all queues are */ -/* empty. */ -/* The first alternative would result in bad performance, since the */ -/* interleaving of commands would not be used. The second is unfair to */ -/* other drivers using the ST-DMA, because the queues will seldom be */ -/* totally empty if there is a lot of disk traffic. */ -/* */ -/* For this reasons I decided to employ a more elaborate scheme: */ -/* - First, we give up the lock every time we can (for fairness), this */ -/* means every time a command finishes and there are no other commands */ -/* on the disconnected queue. */ -/* - If there are others waiting to lock the DMA chip, we stop */ -/* issuing commands, i.e. moving them onto the issue queue. */ -/* Because of that, the disconnected queue will run empty in a */ -/* while. Instead we go to sleep on a 'fairness_queue'. */ -/* - If the lock is released, all processes waiting on the fairness */ -/* queue will be woken. The first of them tries to re-lock the DMA, */ -/* the others wait for the first to finish this task. After that, */ -/* they can all run on and do their commands... */ -/* This sounds complicated (and it is it :-(), but it seems to be a */ -/* good compromise between fairness and performance: As long as no one */ -/* else wants to work with the ST-DMA chip, SCSI can go along as */ -/* usual. If now someone else comes, this behaviour is changed to a */ -/* "fairness mode": just already initiated commands are finished and */ -/* then the lock is released. The other one waiting will probably win */ -/* the race for locking the DMA, since it was waiting for longer. And */ -/* after it has finished, SCSI can go ahead again. Finally: I hope I */ -/* have not produced any deadlock possibilities! */ -/* */ -/**************************************************************************/ - +/* +* Notes for Falcon SCSI DMA +* +* The 5380 device is one of several that all share the DMA chip. Hence +* "locking" and "unlocking" access to this chip is required. +* +* Two possible schemes for ST DMA acquisition by atari_scsi are: +* 1) The lock is taken for each command separately (i.e. can_queue == 1). +* 2) The lock is taken when the first command arrives and released +* when the last command is finished (i.e. can_queue > 1). +* +* The first alternative limits SCSI bus utilization, since interleaving +* commands is not possible. The second gives better performance but is +* unfair to other drivers needing to use the ST DMA chip. In order to +* allow the IDE and floppy drivers equal access to the ST DMA chip +* the default is can_queue == 1. +*/ #include <linux/module.h> #include <linux/types.h>
@@ -443,6 +411,10 @@ static int falcon_get_lock(struct Scsi_Hif (IS_A_TT ())return 1 ; +if (stdma_is_locked_by (scsi_falcon_intr) && + instance->hostt->can_queue >1 ) +return 1 ; +if (in_interrupt ())return stdma_try_lock (scsi_falcon_intr, instance);
@@ -776,22 +748,11 @@ static int __init atari_scsi_probe(struc atari_scsi_reg_write = atari_scsi_falcon_reg_write; } -/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. -* Higher values should work, too; try it! -* (But cmd_per_lun costs memory!) -* -* But there seems to be a bug somewhere that requires CAN_QUEUE to be -* 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since -* changed CMD_PER_LUN... -* -* Note: The Falcon currently uses 8/1 setting due to unsolved problems -* with cmd_per_lun != 1 -*/ if (ATARIHW_PRESENT (TT_SCSI )) { atari_scsi_template.can_queue =16 ; atari_scsi_template.sg_tablesize =SG_ALL ; }else { - atari_scsi_template.can_queue =8 ; + atari_scsi_template.can_queue =1 ; atari_scsi_template.sg_tablesize =SG_NONE ; }
PATCH v3 22/23 mac_scsi: Fix pseudo DMA implementation
In reply to Finn ThainFix various issues: Comments about bus errors are incorrect. The PDMA asm must return the size of the memory access that faulted so the transfer count can be adjusted accordingly. A phase change may cause a bus error but should not be treated as failure. A bus error does not always imply a phase change and generally the transfer may continue. Scatter/gather doesn't seem to work with PDMA due to overruns. This is a pity because peak throughput seems to double with SG_ALL. Tested on a Mac LC III.
---
Changed since v1:
- Set the default cmd_per_lun to 4 based on test results.
Changed since v2:
- Revert the default cmd_per_lun to 2, like in the v1 patch, because a uniform default across all ten 5380 wrapper drivers is worth more than a tiny improvement in one particular microbenchmark on one system.
- Add 'reviewed-by' tag.
--- drivers/scsi/NCR5380.h | 2 drivers/scsi/mac_scsi.c | 210 ++++++++++++++++++++++++++---------------------- 2 files changed, 118 insertions(+), 94 deletions(-)
drivers/scsi/mac_scsi.c +116 -94
@@ -28,7 +28,8 @@/* Definitions for the core NCR5380 driver. */ -#define NCR5380_implementation_fields unsigned char *pdma_base +#define NCR5380_implementation_fields unsigned char *pdma_base; \ + int pdma_residual#define NCR5380_read (reg) macscsi_read(instance, reg)#define NCR5380_write (reg, value) macscsi_write(instance, reg, value)
@@ -37,7 +38,7 @@ macscsi_dma_xfer_len(instance, cmd)#define NCR5380_dma_recv_setup macscsi_pread#define NCR5380_dma_send_setup macscsi_pwrite -#define NCR5380_dma_residual (instance) (0) +#define NCR5380_dma_residual (instance) (hostdata->pdma_residual)#define NCR5380_intr macscsi_intr#define NCR5380_queue_command macscsi_queue_command
@@ -104,18 +105,9 @@ static int __init mac_scsi_setup(char *s__setup ("mac5380=" , mac_scsi_setup);#endif /* !MODULE */ -/* -Pseudo-DMA: (Ove Edlund) -The code attempts to catch bus errors that occur if one for example -"trips over the cable". -XXX: Since bus errors in the PDMA routines never happen on my -computer, the bus error code is untested. -If the code works as intended, a bus error results in Pseudo-DMA -being disabled, meaning that the driver switches to slow handshake. -If bus errors are NOT extremely rare, this has to be changed. -*/ +/* Pseudo DMA asm originally by Ove Edlund */ -#define CP_IO_TO_MEM (s,d,len) \ +#define CP_IO_TO_MEM (s,d,n) \ __asm__ __volatile__ \ (" cmp.w #4,%2\n" \ " bls 8f\n" \
@@ -152,61 +144,73 @@ __asm__ __volatile__ \" 9: \n" \".section .fixup,\"ax\"\n" \" .even\n" \ -"90: moveq.l #1, %2\n" \ +"91: moveq.l #1, %2\n" \ +" jra 9b\n" \ +"94: moveq.l #4, %2\n" \" jra 9b\n" \".previous\n" \".section __ex_table,\"a\"\n" \" .align 4\n" \ -" .long 1b,90b\n" \ -" .long 3b,90b\n" \ -" .long 31b,90b\n" \ -" .long 32b,90b\n" \ -" .long 33b,90b\n" \ -" .long 34b,90b\n" \ -" .long 35b,90b\n" \ -" .long 36b,90b\n" \ -" .long 37b,90b\n" \ -" .long 5b,90b\n" \ -" .long 7b,90b\n" \ +" .long 1b,91b\n" \ +" .long 3b,94b\n" \ +" .long 31b,94b\n" \ +" .long 32b,94b\n" \ +" .long 33b,94b\n" \ +" .long 34b,94b\n" \ +" .long 35b,94b\n" \ +" .long 36b,94b\n" \ +" .long 37b,94b\n" \ +" .long 5b,94b\n" \ +" .long 7b,91b\n" \".previous" \ - : "=a"(s), "=a"(d), "=d"(len) \ - : "0"(s), "1"(d), "2"(len) \ + : "=a"(s), "=a"(d), "=d"(n) \ + : "0"(s), "1"(d), "2"(n) \ : "d0") static int macscsi_pread(struct Scsi_Host *instance, unsigned char *dst, int len) { struct NCR5380_hostdata *hostdata = shost_priv(instance); -unsigned char *d; -unsigned char *s; - - s = hostdata->pdma_base + (INPUT_DATA_REG <<4 ); - d = dst; - -/* These conditions are derived from MacOS */ - -while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && - !(NCR5380_read (STATUS_REG ) &SR_REQ )) - ; - -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && - (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) { -pr_err ("Error in macscsi_pread\n" ); -return -1 ; - } - -CP_IO_TO_MEM (s, d, len); - -if (len !=0 ) { -pr_notice ("Bus error in macscsi_pread\n" ); -return -1 ; +unsigned char *s = hostdata->pdma_base + (INPUT_DATA_REG <<4 ); +unsigned char *d = dst; +int n = len; +int transferred; + +while (!NCR5380_poll_politely (instance,BUS_AND_STATUS_REG , +BASR_DRQ |BASR_PHASE_MATCH , +BASR_DRQ |BASR_PHASE_MATCH ,HZ /64 )) { +CP_IO_TO_MEM (s, d, n); + + transferred = d - dst - n; + hostdata->pdma_residual = len - transferred; + +/* No bus error. */ +if (n ==0 ) +return 0 ; + +/* Target changed phase early? */ +if (NCR5380_poll_politely2 (instance,STATUS_REG ,SR_REQ ,SR_REQ , +BUS_AND_STATUS_REG ,BASR_ACK ,BASR_ACK ,HZ /64 ) <0 ) +scmd_printk (KERN_ERR , hostdata->connected, +"%s: !REQ and !ACK\n" , __func__); +if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) +return 0 ; + +dsprintk (NDEBUG_PSEUDO_DMA , instance, +"%s: bus error (%d/%d)\n" , __func__, transferred, len); +NCR5380_dprint (NDEBUG_PSEUDO_DMA , instance); + d = dst + transferred; + n = len - transferred; } -return 0 ; +scmd_printk (KERN_ERR , hostdata->connected, +"%s: phase mismatch or !DRQ\n" , __func__); +NCR5380_dprint (NDEBUG_PSEUDO_DMA , instance); +return -1 ; } -#define CP_MEM_TO_IO (s,d,len) \ +#define CP_MEM_TO_IO (s,d,n) \ __asm__ __volatile__ \ (" cmp.w #4,%2\n" \ " bls 8f\n" \
@@ -243,57 +247,76 @@ __asm__ __volatile__ \" 9: \n" \".section .fixup,\"ax\"\n" \" .even\n" \ -"90: moveq.l #1, %2\n" \ +"91: moveq.l #1, %2\n" \ +" jra 9b\n" \ +"94: moveq.l #4, %2\n" \" jra 9b\n" \".previous\n" \".section __ex_table,\"a\"\n" \" .align 4\n" \ -" .long 1b,90b\n" \ -" .long 3b,90b\n" \ -" .long 31b,90b\n" \ -" .long 32b,90b\n" \ -" .long 33b,90b\n" \ -" .long 34b,90b\n" \ -" .long 35b,90b\n" \ -" .long 36b,90b\n" \ -" .long 37b,90b\n" \ -" .long 5b,90b\n" \ -" .long 7b,90b\n" \ +" .long 1b,91b\n" \ +" .long 3b,94b\n" \ +" .long 31b,94b\n" \ +" .long 32b,94b\n" \ +" .long 33b,94b\n" \ +" .long 34b,94b\n" \ +" .long 35b,94b\n" \ +" .long 36b,94b\n" \ +" .long 37b,94b\n" \ +" .long 5b,94b\n" \ +" .long 7b,91b\n" \".previous" \ - : "=a"(s), "=a"(d), "=d"(len) \ - : "0"(s), "1"(d), "2"(len) \ + : "=a"(s), "=a"(d), "=d"(n) \ + : "0"(s), "1"(d), "2"(n) \ : "d0") static int macscsi_pwrite(struct Scsi_Host *instance, unsigned char *src, int len) { struct NCR5380_hostdata *hostdata = shost_priv(instance); -unsigned char *s; -unsigned char *d; - - s = src; - d = hostdata->pdma_base + (OUTPUT_DATA_REG <<4 ); - -/* These conditions are derived from MacOS */ - -while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && - (!(NCR5380_read (STATUS_REG ) &SR_REQ ) || - (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH ))) - ; - -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ )) { -pr_err ("Error in macscsi_pwrite\n" ); -return -1 ; +unsigned char *s = src; +unsigned char *d = hostdata->pdma_base + (OUTPUT_DATA_REG <<4 ); +int n = len; +int transferred; + +while (!NCR5380_poll_politely (instance,BUS_AND_STATUS_REG , +BASR_DRQ |BASR_PHASE_MATCH , +BASR_DRQ |BASR_PHASE_MATCH ,HZ /64 )) { +CP_MEM_TO_IO (s, d, n); + + transferred = s - src - n; + hostdata->pdma_residual = len - transferred; + +/* Target changed phase early? */ +if (NCR5380_poll_politely2 (instance,STATUS_REG ,SR_REQ ,SR_REQ , +BUS_AND_STATUS_REG ,BASR_ACK ,BASR_ACK ,HZ /64 ) <0 ) +scmd_printk (KERN_ERR , hostdata->connected, +"%s: !REQ and !ACK\n" , __func__); +if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) +return 0 ; + +/* No bus error. */ +if (n ==0 ) { +if (NCR5380_poll_politely (instance,TARGET_COMMAND_REG , +TCR_LAST_BYTE_SENT , +TCR_LAST_BYTE_SENT ,HZ /64 ) <0 ) +scmd_printk (KERN_ERR , hostdata->connected, +"%s: Last Byte Sent timeout\n" , __func__); +return 0 ; + } + +dsprintk (NDEBUG_PSEUDO_DMA , instance, +"%s: bus error (%d/%d)\n" , __func__, transferred, len); +NCR5380_dprint (NDEBUG_PSEUDO_DMA , instance); + s = src + transferred; + n = len - transferred; } -CP_MEM_TO_IO (s, d, len); - -if (len !=0 ) { -pr_notice ("Bus error in macscsi_pwrite\n" ); -return -1 ; - } +scmd_printk (KERN_ERR , hostdata->connected, +"%s: phase mismatch or !DRQ\n" , __func__); +NCR5380_dprint (NDEBUG_PSEUDO_DMA , instance); -return 0 ; +return -1 ; } static int macscsi_dma_xfer_len(struct Scsi_Host *instance,
@@ -301,10 +324,11 @@ static int macscsi_dma_xfer_len(struct S {struct NCR5380_hostdata *hostdata =shost_priv (instance); -if (hostdata->flags &FLAG_NO_PSEUDO_DMA ) +if (hostdata->flags &FLAG_NO_PSEUDO_DMA || + cmd->SCp.this_residual <16 )return 0 ; -return cmd->transfersize; +return cmd->SCp.this_residual; }#include "NCR5380.c"
@@ -322,7 +346,7 @@ static struct scsi_host_template mac_scs .eh_bus_reset_handler = macscsi_bus_reset, .can_queue = 16, .this_id = 7, - .sg_tablesize = SG_ALL, + .sg_tablesize = 1, .cmd_per_lun = 2, .use_clustering = DISABLE_CLUSTERING, .cmd_size = NCR5380_CMD_SIZE,
@@ -358,8 +382,6 @@ static int __init mac_scsi_probe(struct mac_scsi_template.sg_tablesize = setup_sg_tablesize;if (setup_hostid >=0 ) mac_scsi_template.this_id = setup_hostid &7 ; -if (setup_use_pdma <0 ) - setup_use_pdma =0 ; instance =scsi_host_alloc (&mac_scsi_template,sizeof (struct NCR5380_hostdata ));
drivers/scsi/NCR5380.h +2 -0
@@ -292,6 +292,8 @@ static void NCR5380_reselect(struct Scsistatic struct scsi_cmnd *NCR5380_select (struct Scsi_Host *,struct scsi_cmnd *);static int NCR5380_transfer_dma (struct Scsi_Host *instance,unsigned char *phase,int *count,unsigned char **data);static int NCR5380_transfer_pio (struct Scsi_Host *instance,unsigned char *phase,int *count,unsigned char **data); +static int NCR5380_poll_politely (struct Scsi_Host *,int ,int ,int ,int ); +static int NCR5380_poll_politely2 (struct Scsi_Host *,int ,int ,int ,int ,int ,int ,int );#endif /* __KERNEL__ */ #endif /* NCR5380_H */
PATCH v3 23/23 ncr5380: Call complete_cmd() for disconnected commands on bus reset
In reply to Finn ThainI'm told that some targets are liable to disconnect a REQUEST SENSE command. Theoretically this would cause a command undergoing autosense to be moved onto the disconnected list. The bus reset handler must call complete_cmd() for these commands, otherwise the hostdata->sensing pointer will not get cleared. That would cause autosense processing to stall and a timeout or an incorrect scsi_eh_restore_cmnd() would eventually follow.
--- drivers/scsi/NCR5380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/NCR5380.c +1 -1
@@ -2437,7 +2437,7 @@ static int NCR5380_bus_reset(struct scsistruct scsi_cmnd *cmd =NCR5380_to_scmd (ncmd);set_host_byte (cmd,DID_RESET ); - cmd->scsi_done (cmd); +complete_cmd (instance, cmd); }INIT_LIST_HEAD (&hostdata->disconnected);
Quoted 21 lines · On Monday 21 March 2016 03:31:49 Finn Thain wrote:
This patch series has more macro elimination and some tweaks to the DMA hooks so that all the wrapper drivers can share the same core DMA algorithm. This resolves the major discrepancies between the two core drivers, which relate to code conditional on the
REAL_DMAandPSEUDO_DMAmacros.After all the wrapper drivers agree on the DMA hook api, the core driver fork gets resolved.
NCR5380.cis adopted byatari_scsiandsun3_scsiandatari_NCR5380.cis then deleted.Historically, the 5380 drivers suffered from over-use of conditional compilation, which caused the compile-time configuration space to explode, leading to core driver code that was practically untestable, unmaintainable and difficult to reason about. It also prevented driver modules from sharing object code.
Along with
REAL_DMA,REAL_DMA_POLLandPSEUDO_DMA, most of the remaining macros are also eradicated, such asCONFIG_SCSI_GENERIC_NCR53C400,SUPPORT_TAGS,DONT_USE_INTR,AUTOPROBE_IRQand BIOSPARAM.
Quoted 7 lines
Also in this patch series, some duplicated documentation is removed and the PDMA implementation in
mac_scsifinally gets fixed.This patch series was tested by exercising the dmx3191d and
mac_scsimodules on suitable hardware. Michael has testedatari_scsion an Atari Falcon. Help with driver testing on ISA cards is sought as I don't have such hardware. Likewise RiscPC ecards and Sun 3.
Tested on HP C2502 (53C400A chip), Canon FG2-5202 (53C400 chip) and DTC-3181L (DTCT-436P chip) ISA cards - everything works fine!
Thanks.
HP C2502:
scsi host2: Generic NCR5380/NCR53C400 SCSI, io_port 0x280, n_io_port 16, base 0x0, irq 0, can_queue 16, cmd_per_lun 2, sg_tablesize 128, this_id 7, flags { }, options { }
Canon FG2-5202:
scsi host2: Generic NCR5380/NCR53C400 SCSI, io_port 0x0, n_io_port 0, base 0xd8000, irq 0, can_queue 16, cmd_per_lun 2, sg_tablesize 128, this_id 7, flags { }, options { }
DTC-3181L:
scsi host2: Generic NCR5380/NCR53C400 SCSI, io_port 0x240, n_io_port 16, base 0x0, irq 0, can_queue 16, cmd_per_lun 2, sg_tablesize 128, this_id 7, flags { }, options { }
Signature · 1 line
Ondrej Zary
Quoted 4 lines · Ondrej Zary
Tested on HP C2502 (53C400A chip), Canon FG2-5202 (53C400 chip) and DTC-3181L (DTCT-436P chip) ISA cards - everything works fine!
Thanks.
Thanks for testing, Ondrej.
Quoted 2 lines
Tested-by Ondrej Zary <[email protected]>
Hannes, would you please take a look at patches 04/23, 14/23, 20/23 and 23/23 when convenient? These four patches need a "reviewed-by" tag.
Re: [PATCH v3 04/23] atari_NCR5380: Remove DMA_MIN_SIZE macro
In reply to Finn ThainQuoted 6 lines · Finn Thain
Only the
atari_scsiandsun3_scsidrivers defineDMA_MIN_SIZE. Both drivers also defineNCR5380_dma_xfer_len, which meansDMA_MIN_SIZEcan be removed from the core driver.This removes another discrepancy between the two core drivers.
Quoted 8 lines
Signed-off-by Finn Thain <[email protected]>Tested-by Michael Schmitz <[email protected]>---
Changes since v1:
- RetainMIN_DMA_SIZEmacro in wrapper drivers.
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH v3 14/23] ncr5380: Reduce max_lun limit
In reply to Finn ThainQuoted 7 lines · Finn Thain
The driver has a limit of eight LUs because of the byte-sized bitfield that is used for busy flags. That means the maximum LUN is 7. The default is 8.
Signed-off-by Finn Thain <[email protected]>Tested-by Michael Schmitz <[email protected]>
Quoted 9 lines
---
Changed since v1:
- Reduceshost->max_lunlimit instead of adding 'MAX_LUN' limit.--- drivers/scsi/NCR5380.c | 2 ++ 1 file changed, 2 insertions(+)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH v3 20/23] atari_scsi: Set a reasonable default for cmd_per_lun
In reply to Finn ThainQuoted 16 lines · Finn Thain
This setting does not need to be conditional on Atari ST or TT.
Signed-off-by Finn Thain <[email protected]>Tested-by Michael Schmitz <[email protected]>---
Changed since v1:
- Set the defaultcmd_per_lunto 4 based on test results.Changed since v2:
- Revert the defaultcmd_per_lunto 2, like in the v1 patch, because a uniform default across all ten 5380 wrapper drivers is worth more than a tiny improvement in one particular microbenchmark on one system. Michael tells me that 2 is also the best setting for his Atari Falcon.
Quoted 4 lines
--- drivers/scsi/atari_scsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Cheers,
Hannes
Signature · 5 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH v3 23/23] ncr5380: Call complete_cmd() for disconnected commands on bus reset
In reply to Finn ThainQuoted 20 lines · Finn Thain
I'm told that some targets are liable to disconnect a REQUEST SENSE command. Theoretically this would cause a command undergoing autosense to be moved onto the disconnected list. The bus reset handler must call
complete_cmd()for these commands, otherwise thehostdata->sensingpointer will not get cleared. That would cause autosense processing to stall and a timeout or an incorrectscsi_eh_restore_cmnd()would eventually follow.Signed-off-by Finn Thain <[email protected]>--- drivers/scsi/NCR5380.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Index:
linux/drivers/scsi/NCR5380.c
===================================================================
drivers/scsi/NCR5380.c static int NCR5380_bus_reset(struct scsi · line 2443
Quoted 8 lines
drivers/scsi/NCR5380.c +1
-1@@ -2437,7 +2437,7 @@ static int NCR5380_bus_reset(struct scsistruct scsi_cmnd *cmd =NCR5380_to_scmd (ncmd);set_host_byte (cmd,DID_RESET ); - cmd->scsi_done (cmd); +complete_cmd (instance, cmd); }INIT_LIST_HEAD (&hostdata->disconnected);
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html