aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/atari_NCR5380.c
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2014-11-12 00:12:14 -0500
committerChristoph Hellwig <hch@lst.de>2014-11-20 03:11:16 -0500
commitef1081cbf05b22d3d0e05b267a5559a8cd8e8d4a (patch)
tree327b642eab6b4d83d5cc268e78a1fb62bfa097ff /drivers/scsi/atari_NCR5380.c
parentf527590278f1b823ba979a234241d09ed2c436b4 (diff)
atari_NCR5380: Refactor Falcon special cases
Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others by moving some of the Falcon-specific code out of the core driver: !IS_A_TT, atari_read_overruns and falcon_dont_release. Replace these with hostdata variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c so don't set it. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/atari_NCR5380.c')
-rw-r--r--drivers/scsi/atari_NCR5380.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 75d34031c280..371ca14f08ea 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -839,7 +839,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags)
839 hostdata->connected = NULL; 839 hostdata->connected = NULL;
840 hostdata->issue_queue = NULL; 840 hostdata->issue_queue = NULL;
841 hostdata->disconnected_queue = NULL; 841 hostdata->disconnected_queue = NULL;
842 hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT; 842 hostdata->flags = flags;
843 843
844 if (!the_template) { 844 if (!the_template) {
845 the_template = instance->hostt; 845 the_template = instance->hostt;
@@ -1054,7 +1054,7 @@ static void NCR5380_main(struct work_struct *work)
1054 hostdata->issue_queue = NEXT(tmp); 1054 hostdata->issue_queue = NEXT(tmp);
1055 } 1055 }
1056 SET_NEXT(tmp, NULL); 1056 SET_NEXT(tmp, NULL);
1057 falcon_dont_release++; 1057 hostdata->retain_dma_intr++;
1058 1058
1059 /* reenable interrupts after finding one */ 1059 /* reenable interrupts after finding one */
1060 local_irq_restore(flags); 1060 local_irq_restore(flags);
@@ -1082,7 +1082,7 @@ static void NCR5380_main(struct work_struct *work)
1082 cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE); 1082 cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE);
1083#endif 1083#endif
1084 if (!NCR5380_select(instance, tmp)) { 1084 if (!NCR5380_select(instance, tmp)) {
1085 falcon_dont_release--; 1085 hostdata->retain_dma_intr--;
1086 /* release if target did not response! */ 1086 /* release if target did not response! */
1087 falcon_release_lock_if_possible(hostdata); 1087 falcon_release_lock_if_possible(hostdata);
1088 break; 1088 break;
@@ -1094,7 +1094,7 @@ static void NCR5380_main(struct work_struct *work)
1094#ifdef SUPPORT_TAGS 1094#ifdef SUPPORT_TAGS
1095 cmd_free_tag(tmp); 1095 cmd_free_tag(tmp);
1096#endif 1096#endif
1097 falcon_dont_release--; 1097 hostdata->retain_dma_intr--;
1098 local_irq_restore(flags); 1098 local_irq_restore(flags);
1099 dprintk(NDEBUG_MAIN, "scsi%d: main(): select() failed, " 1099 dprintk(NDEBUG_MAIN, "scsi%d: main(): select() failed, "
1100 "returned to issue_queue\n", HOSTNO); 1100 "returned to issue_queue\n", HOSTNO);
@@ -1151,7 +1151,7 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance)
1151 return; 1151 return;
1152 } 1152 }
1153 1153
1154 if (atari_read_overruns) { 1154 if (hostdata->read_overruns) {
1155 p = hostdata->connected->SCp.phase; 1155 p = hostdata->connected->SCp.phase;
1156 if (p & SR_IO) { 1156 if (p & SR_IO) {
1157 udelay(10); 1157 udelay(10);
@@ -1181,9 +1181,9 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance)
1181 *data += transfered; 1181 *data += transfered;
1182 *count -= transfered; 1182 *count -= transfered;
1183 1183
1184 if (atari_read_overruns) { 1184 if (hostdata->read_overruns) {
1185 if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) { 1185 if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) {
1186 cnt = toPIO = atari_read_overruns; 1186 cnt = toPIO = hostdata->read_overruns;
1187 if (overrun) { 1187 if (overrun) {
1188 dprintk(NDEBUG_DMA, "Got an input overrun, using saved byte\n"); 1188 dprintk(NDEBUG_DMA, "Got an input overrun, using saved byte\n");
1189 *(*data)++ = saved_data; 1189 *(*data)++ = saved_data;
@@ -1838,8 +1838,8 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,
1838 return -1; 1838 return -1;
1839 } 1839 }
1840 1840
1841 if (atari_read_overruns && (p & SR_IO)) 1841 if (hostdata->read_overruns && (p & SR_IO))
1842 c -= atari_read_overruns; 1842 c -= hostdata->read_overruns;
1843 1843
1844 dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n", 1844 dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n",
1845 HOSTNO, (p & SR_IO) ? "reading" : "writing", 1845 HOSTNO, (p & SR_IO) ? "reading" : "writing",
@@ -1851,7 +1851,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,
1851 NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY); 1851 NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
1852#endif /* def REAL_DMA */ 1852#endif /* def REAL_DMA */
1853 1853
1854 if (IS_A_TT()) { 1854 if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) {
1855 /* On the Medusa, it is a must to initialize the DMA before 1855 /* On the Medusa, it is a must to initialize the DMA before
1856 * starting the NCR. This is also the cleaner way for the TT. 1856 * starting the NCR. This is also the cleaner way for the TT.
1857 */ 1857 */
@@ -1869,7 +1869,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance,
1869 NCR5380_write(START_DMA_SEND_REG, 0); 1869 NCR5380_write(START_DMA_SEND_REG, 0);
1870 } 1870 }
1871 1871
1872 if (!IS_A_TT()) { 1872 if (hostdata->flags & FLAG_LATE_DMA_SETUP) {
1873 /* On the Falcon, the DMA setup must be done after the last */ 1873 /* On the Falcon, the DMA setup must be done after the last */
1874 /* NCR access, else the DMA setup gets trashed! 1874 /* NCR access, else the DMA setup gets trashed!
1875 */ 1875 */
@@ -2084,7 +2084,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
2084 /* Accept message by clearing ACK */ 2084 /* Accept message by clearing ACK */
2085 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); 2085 NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
2086 /* ++guenther: possible race with Falcon locking */ 2086 /* ++guenther: possible race with Falcon locking */
2087 falcon_dont_release++; 2087 hostdata->retain_dma_intr++;
2088 hostdata->connected = NULL; 2088 hostdata->connected = NULL;
2089 dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %llu " 2089 dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %llu "
2090 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); 2090 "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
@@ -2167,7 +2167,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
2167 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) 2167 while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
2168 barrier(); 2168 barrier();
2169 2169
2170 falcon_dont_release--; 2170 hostdata->retain_dma_intr--;
2171 /* ++roman: For Falcon SCSI, release the lock on the 2171 /* ++roman: For Falcon SCSI, release the lock on the
2172 * ST-DMA here if no other commands are waiting on the 2172 * ST-DMA here if no other commands are waiting on the
2173 * disconnected queue. 2173 * disconnected queue.
@@ -2474,7 +2474,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
2474#endif 2474#endif
2475 ) { 2475 ) {
2476 /* ++guenther: prevent race with falcon_release_lock */ 2476 /* ++guenther: prevent race with falcon_release_lock */
2477 falcon_dont_release++; 2477 hostdata->retain_dma_intr++;
2478 if (prev) { 2478 if (prev) {
2479 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp)); 2479 REMOVE(prev, NEXT(prev), tmp, NEXT(tmp));
2480 SET_NEXT(prev, NEXT(tmp)); 2480 SET_NEXT(prev, NEXT(tmp));
@@ -2512,7 +2512,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
2512 hostdata->connected = tmp; 2512 hostdata->connected = tmp;
2513 dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n", 2513 dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n",
2514 HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag); 2514 HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
2515 falcon_dont_release--; 2515 hostdata->retain_dma_intr--;
2516} 2516}
2517 2517
2518 2518