Commit 55181be8 authored by Finn Thain's avatar Finn Thain Committed by Martin K. Petersen

ncr5380: Replace redundant flags with FLAG_NO_DMA_FIXUP

The flags DMA_WORKS_RIGHT, FLAG_NCR53C400 and FLAG_HAS_LAST_BYTE_SENT
all mean the same thing, i.e. the chip is not a 538[01]. (More recent
devices such as the 53C80 have a 'Last Byte Sent' bit in the Target
Command Register as well as other fixes for End-of-DMA errata.)

These flags have no additional meanings since previous cleanup patches
eliminated the NCR53C400 macro, moved g_NCR5380-specific code out of the
core driver and standardized interrupt handling.

Use the FLAG_NO_DMA_FIXUP flag to suppress End-of-DMA errata workarounds,
for those cards and drivers that make use of the TCR_LAST_BYTE_SENT bit.
Remove the old flags.
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Reviewed-by: default avatarHannes Reinecke <hare@suse.com>
Tested-by: default avatarOndrej Zary <linux@rainbow-software.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent b32ade12
...@@ -541,7 +541,7 @@ static void prepare_info(struct Scsi_Host *instance) ...@@ -541,7 +541,7 @@ static void prepare_info(struct Scsi_Host *instance)
instance->base, instance->irq, instance->base, instance->irq,
instance->can_queue, instance->cmd_per_lun, instance->can_queue, instance->cmd_per_lun,
instance->sg_tablesize, instance->this_id, instance->sg_tablesize, instance->this_id,
hostdata->flags & FLAG_NCR53C400 ? "NCR53C400 " : "", hostdata->flags & FLAG_NO_DMA_FIXUP ? "NO_DMA_FIXUP " : "",
hostdata->flags & FLAG_DTC3181E ? "DTC3181E " : "", hostdata->flags & FLAG_DTC3181E ? "DTC3181E " : "",
hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "",
hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : "", hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY " : "",
...@@ -702,6 +702,7 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) ...@@ -702,6 +702,7 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
hostdata->connected = NULL; hostdata->connected = NULL;
hostdata->issue_queue = NULL; hostdata->issue_queue = NULL;
hostdata->disconnected_queue = NULL; hostdata->disconnected_queue = NULL;
hostdata->flags = flags;
INIT_WORK(&hostdata->main_task, NCR5380_main); INIT_WORK(&hostdata->main_task, NCR5380_main);
hostdata->work_q = alloc_workqueue("ncr5380_%d", hostdata->work_q = alloc_workqueue("ncr5380_%d",
...@@ -710,12 +711,6 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) ...@@ -710,12 +711,6 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
if (!hostdata->work_q) if (!hostdata->work_q)
return -ENOMEM; return -ENOMEM;
/* The CHECK code seems to break the 53C400. Will check it later maybe */
if (flags & FLAG_NCR53C400)
hostdata->flags = FLAG_HAS_LAST_BYTE_SENT | flags;
else
hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT | flags;
hostdata->host = instance; hostdata->host = instance;
prepare_info(instance); prepare_info(instance);
...@@ -1614,7 +1609,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase ...@@ -1614,7 +1609,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase
* before the setting of DMA mode to after transfer of the last byte. * before the setting of DMA mode to after transfer of the last byte.
*/ */
if (hostdata->flags & FLAG_NCR53C400) if (hostdata->flags & FLAG_NO_DMA_FIXUP)
NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY | NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY |
MR_ENABLE_EOP_INTR); MR_ENABLE_EOP_INTR);
else else
...@@ -1734,14 +1729,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase ...@@ -1734,14 +1729,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase
return 0; return 0;
#else /* defined(REAL_DMA_POLL) */ #else /* defined(REAL_DMA_POLL) */
if (p & SR_IO) { if (p & SR_IO) {
#ifdef DMA_WORKS_RIGHT foo = NCR5380_pread(instance, d,
foo = NCR5380_pread(instance, d, c); hostdata->flags & FLAG_NO_DMA_FIXUP ? c : c - 1);
#else if (!foo && !(hostdata->flags & FLAG_NO_DMA_FIXUP)) {
int diff = 1;
if (hostdata->flags & FLAG_NCR53C400) {
diff = 0;
}
if (!(foo = NCR5380_pread(instance, d, c - diff))) {
/* /*
* We can't disable DMA mode after successfully transferring * We can't disable DMA mode after successfully transferring
* what we plan to be the last byte, since that would open up * what we plan to be the last byte, since that would open up
...@@ -1764,46 +1754,32 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase ...@@ -1764,46 +1754,32 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase
* byte. * byte.
*/ */
if (!(hostdata->flags & FLAG_NCR53C400)) { if (NCR5380_poll_politely(instance, BUS_AND_STATUS_REG,
while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)); BASR_DRQ, BASR_DRQ, HZ) < 0) {
/* Wait for clean handshake */ foo = -1;
while (NCR5380_read(STATUS_REG) & SR_REQ); shost_printk(KERN_ERR, instance, "PDMA read: DRQ timeout\n");
d[c - 1] = NCR5380_read(INPUT_DATA_REG); }
if (NCR5380_poll_politely(instance, STATUS_REG,
SR_REQ, 0, HZ) < 0) {
foo = -1;
shost_printk(KERN_ERR, instance, "PDMA read: !REQ timeout\n");
} }
d[c - 1] = NCR5380_read(INPUT_DATA_REG);
} }
#endif
} else { } else {
#ifdef DMA_WORKS_RIGHT
foo = NCR5380_pwrite(instance, d, c); foo = NCR5380_pwrite(instance, d, c);
#else if (!foo && !(hostdata->flags & FLAG_NO_DMA_FIXUP)) {
int timeout;
dprintk(NDEBUG_C400_PWRITE, "About to pwrite %d bytes\n", c);
if (!(foo = NCR5380_pwrite(instance, d, c))) {
/* /*
* Wait for the last byte to be sent. If REQ is being asserted for * Wait for the last byte to be sent. If REQ is being asserted for
* the byte we're interested, we'll ACK it and it will go false. * the byte we're interested, we'll ACK it and it will go false.
*/ */
if (!(hostdata->flags & FLAG_HAS_LAST_BYTE_SENT)) { if (NCR5380_poll_politely2(instance,
timeout = 20000; BUS_AND_STATUS_REG, BASR_DRQ, BASR_DRQ,
while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)); BUS_AND_STATUS_REG, BASR_PHASE_MATCH, 0, HZ) < 0) {
foo = -1;
if (!timeout) shost_printk(KERN_ERR, instance, "PDMA write: DRQ and phase timeout\n");
dprintk(NDEBUG_LAST_BYTE_SENT, "scsi%d : timed out on last byte\n", instance->host_no);
if (hostdata->flags & FLAG_CHECK_LAST_BYTE_SENT) {
hostdata->flags &= ~FLAG_CHECK_LAST_BYTE_SENT;
if (NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT) {
hostdata->flags |= FLAG_HAS_LAST_BYTE_SENT;
dprintk(NDEBUG_LAST_BYTE_SENT, "scsi%d : last byte sent works\n", instance->host_no);
}
}
} else {
dprintk(NDEBUG_C400_PWRITE, "Waiting for LASTBYTE\n");
while (!(NCR5380_read(TARGET_COMMAND_REG) & TCR_LAST_BYTE_SENT));
dprintk(NDEBUG_C400_PWRITE, "Got LASTBYTE\n");
} }
} }
#endif
} }
NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(MODE_REG, MR_BASE);
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
......
...@@ -226,9 +226,7 @@ ...@@ -226,9 +226,7 @@
#define NO_IRQ 0 #define NO_IRQ 0
#endif #endif
#define FLAG_HAS_LAST_BYTE_SENT 1 /* NCR53c81 or better */ #define FLAG_NO_DMA_FIXUP 1 /* No DMA errata workarounds */
#define FLAG_CHECK_LAST_BYTE_SENT 2 /* Only test once */
#define FLAG_NCR53C400 4 /* NCR53c400 */
#define FLAG_NO_PSEUDO_DMA 8 /* Inhibit DMA */ #define FLAG_NO_PSEUDO_DMA 8 /* Inhibit DMA */
#define FLAG_DTC3181E 16 /* DTC3181E */ #define FLAG_DTC3181E 16 /* DTC3181E */
#define FLAG_LATE_DMA_SETUP 32 /* Setup NCR before DMA H/W */ #define FLAG_LATE_DMA_SETUP 32 /* Setup NCR before DMA H/W */
......
#define PSEUDO_DMA #define PSEUDO_DMA
#define DONT_USE_INTR #define DONT_USE_INTR
#define DMA_WORKS_RIGHT
/* /*
* DTC 3180/3280 driver, by * DTC 3180/3280 driver, by
...@@ -233,7 +231,7 @@ static int __init dtc_detect(struct scsi_host_template * tpnt) ...@@ -233,7 +231,7 @@ static int __init dtc_detect(struct scsi_host_template * tpnt)
instance->base = addr; instance->base = addr;
((struct NCR5380_hostdata *)(instance)->hostdata)->base = base; ((struct NCR5380_hostdata *)(instance)->hostdata)->base = base;
if (NCR5380_init(instance, 0)) if (NCR5380_init(instance, FLAG_NO_DMA_FIXUP))
goto out_unregister; goto out_unregister;
NCR5380_maybe_reset_bus(instance); NCR5380_maybe_reset_bus(instance);
......
...@@ -321,7 +321,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) ...@@ -321,7 +321,7 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
break; break;
case BOARD_NCR53C400: case BOARD_NCR53C400:
#ifdef PSEUDO_DMA #ifdef PSEUDO_DMA
flags = FLAG_NCR53C400; flags = FLAG_NO_DMA_FIXUP;
#endif #endif
break; break;
case BOARD_NCR53C400A: case BOARD_NCR53C400A:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment