diff options
author | Finn Thain <fthain@telegraphics.com.au> | 2016-10-10 00:46:53 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-11-08 17:29:48 -0500 |
commit | 4a98f896bf2c66a69517fc5e10dc67288cb8da93 (patch) | |
tree | c543e4ab8a0039eeedffaedf03cbc444a5efa775 | |
parent | 7c60663143c29ea64f51e692f950f8619e0e4c77 (diff) |
scsi: ncr5380: Use correct types for DMA routines
Apply prototypes to get consistent function signatures for the DMA
functions implemented in the board-specific drivers. To avoid using
macros to alter actual parameters, some of those functions are reworked
slightly.
This is a step toward the goal of passing the board-specific routines
to the core driver using an ops struct (as in a platform driver or
library module).
This also helps fix some inconsistent types: where the core driver uses
ints (cmd->SCp.this_residual and hostdata->dma_len) for keeping track of
transfers, certain board-specific routines used unsigned long.
While we are fixing these function signatures, pass the hostdata pointer
to DMA routines instead of a Scsi_Host pointer, for shorter and faster
code.
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/NCR5380.c | 74 | ||||
-rw-r--r-- | drivers/scsi/NCR5380.h | 25 | ||||
-rw-r--r-- | drivers/scsi/arm/cumana_1.c | 26 | ||||
-rw-r--r-- | drivers/scsi/arm/oak.c | 13 | ||||
-rw-r--r-- | drivers/scsi/atari_scsi.c | 45 | ||||
-rw-r--r-- | drivers/scsi/dmx3191d.c | 8 | ||||
-rw-r--r-- | drivers/scsi/g_NCR5380.c | 13 | ||||
-rw-r--r-- | drivers/scsi/g_NCR5380.h | 5 | ||||
-rw-r--r-- | drivers/scsi/mac_scsi.c | 36 | ||||
-rw-r--r-- | drivers/scsi/sun3_scsi.c | 45 |
10 files changed, 176 insertions, 114 deletions
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 85589922ef03..7d4e135a36cb 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c | |||
@@ -121,9 +121,10 @@ | |||
121 | * | 121 | * |
122 | * Either real DMA *or* pseudo DMA may be implemented | 122 | * Either real DMA *or* pseudo DMA may be implemented |
123 | * | 123 | * |
124 | * NCR5380_dma_write_setup(instance, src, count) - initialize | 124 | * NCR5380_dma_xfer_len - determine size of DMA/PDMA transfer |
125 | * NCR5380_dma_read_setup(instance, dst, count) - initialize | 125 | * NCR5380_dma_send_setup - execute DMA/PDMA from memory to 5380 |
126 | * NCR5380_dma_residual(instance); - residual count | 126 | * NCR5380_dma_recv_setup - execute DMA/PDMA from 5380 to memory |
127 | * NCR5380_dma_residual - residual byte count | ||
127 | * | 128 | * |
128 | * The generic driver is initialized by calling NCR5380_init(instance), | 129 | * The generic driver is initialized by calling NCR5380_init(instance), |
129 | * after setting the appropriate host specific fields and ID. If the | 130 | * after setting the appropriate host specific fields and ID. If the |
@@ -871,7 +872,7 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) | |||
871 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); | 872 | NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); |
872 | NCR5380_read(RESET_PARITY_INTERRUPT_REG); | 873 | NCR5380_read(RESET_PARITY_INTERRUPT_REG); |
873 | 874 | ||
874 | transferred = hostdata->dma_len - NCR5380_dma_residual(instance); | 875 | transferred = hostdata->dma_len - NCR5380_dma_residual(hostdata); |
875 | hostdata->dma_len = 0; | 876 | hostdata->dma_len = 0; |
876 | 877 | ||
877 | data = (unsigned char **)&hostdata->connected->SCp.ptr; | 878 | data = (unsigned char **)&hostdata->connected->SCp.ptr; |
@@ -1578,9 +1579,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, | |||
1578 | * starting the NCR. This is also the cleaner way for the TT. | 1579 | * starting the NCR. This is also the cleaner way for the TT. |
1579 | */ | 1580 | */ |
1580 | if (p & SR_IO) | 1581 | if (p & SR_IO) |
1581 | result = NCR5380_dma_recv_setup(instance, d, c); | 1582 | result = NCR5380_dma_recv_setup(hostdata, d, c); |
1582 | else | 1583 | else |
1583 | result = NCR5380_dma_send_setup(instance, d, c); | 1584 | result = NCR5380_dma_send_setup(hostdata, d, c); |
1584 | } | 1585 | } |
1585 | 1586 | ||
1586 | /* | 1587 | /* |
@@ -1612,9 +1613,9 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, | |||
1612 | * NCR access, else the DMA setup gets trashed! | 1613 | * NCR access, else the DMA setup gets trashed! |
1613 | */ | 1614 | */ |
1614 | if (p & SR_IO) | 1615 | if (p & SR_IO) |
1615 | result = NCR5380_dma_recv_setup(instance, d, c); | 1616 | result = NCR5380_dma_recv_setup(hostdata, d, c); |
1616 | else | 1617 | else |
1617 | result = NCR5380_dma_send_setup(instance, d, c); | 1618 | result = NCR5380_dma_send_setup(hostdata, d, c); |
1618 | } | 1619 | } |
1619 | 1620 | ||
1620 | /* On failure, NCR5380_dma_xxxx_setup() returns a negative int. */ | 1621 | /* On failure, NCR5380_dma_xxxx_setup() returns a negative int. */ |
@@ -1754,22 +1755,26 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) | |||
1754 | NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); | 1755 | NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); |
1755 | } | 1756 | } |
1756 | #ifdef CONFIG_SUN3 | 1757 | #ifdef CONFIG_SUN3 |
1757 | if (phase == PHASE_CMDOUT) { | 1758 | if (phase == PHASE_CMDOUT && |
1758 | void *d; | 1759 | sun3_dma_setup_done != cmd) { |
1759 | unsigned long count; | 1760 | int count; |
1760 | 1761 | ||
1761 | if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { | 1762 | if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { |
1762 | count = cmd->SCp.buffer->length; | 1763 | ++cmd->SCp.buffer; |
1763 | d = sg_virt(cmd->SCp.buffer); | 1764 | --cmd->SCp.buffers_residual; |
1764 | } else { | 1765 | cmd->SCp.this_residual = cmd->SCp.buffer->length; |
1765 | count = cmd->SCp.this_residual; | 1766 | cmd->SCp.ptr = sg_virt(cmd->SCp.buffer); |
1766 | d = cmd->SCp.ptr; | ||
1767 | } | 1767 | } |
1768 | 1768 | ||
1769 | if (sun3_dma_setup_done != cmd && | 1769 | count = sun3scsi_dma_xfer_len(hostdata, cmd); |
1770 | sun3scsi_dma_xfer_len(count, cmd) > 0) { | 1770 | |
1771 | sun3scsi_dma_setup(instance, d, count, | 1771 | if (count > 0) { |
1772 | rq_data_dir(cmd->request)); | 1772 | if (rq_data_dir(cmd->request)) |
1773 | sun3scsi_dma_send_setup(hostdata, | ||
1774 | cmd->SCp.ptr, count); | ||
1775 | else | ||
1776 | sun3scsi_dma_recv_setup(hostdata, | ||
1777 | cmd->SCp.ptr, count); | ||
1773 | sun3_dma_setup_done = cmd; | 1778 | sun3_dma_setup_done = cmd; |
1774 | } | 1779 | } |
1775 | #ifdef SUN3_SCSI_VME | 1780 | #ifdef SUN3_SCSI_VME |
@@ -1830,7 +1835,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) | |||
1830 | 1835 | ||
1831 | transfersize = 0; | 1836 | transfersize = 0; |
1832 | if (!cmd->device->borken) | 1837 | if (!cmd->device->borken) |
1833 | transfersize = NCR5380_dma_xfer_len(instance, cmd, phase); | 1838 | transfersize = NCR5380_dma_xfer_len(hostdata, cmd); |
1834 | 1839 | ||
1835 | if (transfersize > 0) { | 1840 | if (transfersize > 0) { |
1836 | len = transfersize; | 1841 | len = transfersize; |
@@ -2207,22 +2212,25 @@ static void NCR5380_reselect(struct Scsi_Host *instance) | |||
2207 | } | 2212 | } |
2208 | 2213 | ||
2209 | #ifdef CONFIG_SUN3 | 2214 | #ifdef CONFIG_SUN3 |
2210 | { | 2215 | if (sun3_dma_setup_done != tmp) { |
2211 | void *d; | 2216 | int count; |
2212 | unsigned long count; | ||
2213 | 2217 | ||
2214 | if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { | 2218 | if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { |
2215 | count = tmp->SCp.buffer->length; | 2219 | ++tmp->SCp.buffer; |
2216 | d = sg_virt(tmp->SCp.buffer); | 2220 | --tmp->SCp.buffers_residual; |
2217 | } else { | 2221 | tmp->SCp.this_residual = tmp->SCp.buffer->length; |
2218 | count = tmp->SCp.this_residual; | 2222 | tmp->SCp.ptr = sg_virt(tmp->SCp.buffer); |
2219 | d = tmp->SCp.ptr; | ||
2220 | } | 2223 | } |
2221 | 2224 | ||
2222 | if (sun3_dma_setup_done != tmp && | 2225 | count = sun3scsi_dma_xfer_len(hostdata, tmp); |
2223 | sun3scsi_dma_xfer_len(count, tmp) > 0) { | 2226 | |
2224 | sun3scsi_dma_setup(instance, d, count, | 2227 | if (count > 0) { |
2225 | rq_data_dir(tmp->request)); | 2228 | if (rq_data_dir(tmp->request)) |
2229 | sun3scsi_dma_send_setup(hostdata, | ||
2230 | tmp->SCp.ptr, count); | ||
2231 | else | ||
2232 | sun3scsi_dma_recv_setup(hostdata, | ||
2233 | tmp->SCp.ptr, count); | ||
2226 | sun3_dma_setup_done = tmp; | 2234 | sun3_dma_setup_done = tmp; |
2227 | } | 2235 | } |
2228 | } | 2236 | } |
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index b2c560cb0218..3c6ce5434449 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h | |||
@@ -317,5 +317,30 @@ static inline int NCR5380_poll_politely(struct NCR5380_hostdata *hostdata, | |||
317 | reg, bit, val, wait); | 317 | reg, bit, val, wait); |
318 | } | 318 | } |
319 | 319 | ||
320 | static int NCR5380_dma_xfer_len(struct NCR5380_hostdata *, | ||
321 | struct scsi_cmnd *); | ||
322 | static int NCR5380_dma_send_setup(struct NCR5380_hostdata *, | ||
323 | unsigned char *, int); | ||
324 | static int NCR5380_dma_recv_setup(struct NCR5380_hostdata *, | ||
325 | unsigned char *, int); | ||
326 | static int NCR5380_dma_residual(struct NCR5380_hostdata *); | ||
327 | |||
328 | static inline int NCR5380_dma_xfer_none(struct NCR5380_hostdata *hostdata, | ||
329 | struct scsi_cmnd *cmd) | ||
330 | { | ||
331 | return 0; | ||
332 | } | ||
333 | |||
334 | static inline int NCR5380_dma_setup_none(struct NCR5380_hostdata *hostdata, | ||
335 | unsigned char *data, int count) | ||
336 | { | ||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static inline int NCR5380_dma_residual_none(struct NCR5380_hostdata *hostdata) | ||
341 | { | ||
342 | return 0; | ||
343 | } | ||
344 | |||
320 | #endif /* __KERNEL__ */ | 345 | #endif /* __KERNEL__ */ |
321 | #endif /* NCR5380_H */ | 346 | #endif /* NCR5380_H */ |
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index fb7600dec5be..a87b99c7fb9a 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c | |||
@@ -17,10 +17,10 @@ | |||
17 | #define NCR5380_read(reg) cumanascsi_read(hostdata, reg) | 17 | #define NCR5380_read(reg) cumanascsi_read(hostdata, reg) |
18 | #define NCR5380_write(reg, value) cumanascsi_write(hostdata, reg, value) | 18 | #define NCR5380_write(reg, value) cumanascsi_write(hostdata, reg, value) |
19 | 19 | ||
20 | #define NCR5380_dma_xfer_len(instance, cmd, phase) (cmd->transfersize) | 20 | #define NCR5380_dma_xfer_len cumanascsi_dma_xfer_len |
21 | #define NCR5380_dma_recv_setup cumanascsi_pread | 21 | #define NCR5380_dma_recv_setup cumanascsi_pread |
22 | #define NCR5380_dma_send_setup cumanascsi_pwrite | 22 | #define NCR5380_dma_send_setup cumanascsi_pwrite |
23 | #define NCR5380_dma_residual(instance) (0) | 23 | #define NCR5380_dma_residual NCR5380_dma_residual_none |
24 | 24 | ||
25 | #define NCR5380_intr cumanascsi_intr | 25 | #define NCR5380_intr cumanascsi_intr |
26 | #define NCR5380_queue_command cumanascsi_queue_command | 26 | #define NCR5380_queue_command cumanascsi_queue_command |
@@ -40,12 +40,12 @@ static void cumanascsi_write(struct NCR5380_hostdata *, unsigned int, u8); | |||
40 | #define L(v) (((v)<<16)|((v) & 0x0000ffff)) | 40 | #define L(v) (((v)<<16)|((v) & 0x0000ffff)) |
41 | #define H(v) (((v)>>16)|((v) & 0xffff0000)) | 41 | #define H(v) (((v)>>16)|((v) & 0xffff0000)) |
42 | 42 | ||
43 | static inline int cumanascsi_pwrite(struct Scsi_Host *host, | 43 | static inline int cumanascsi_pwrite(struct NCR5380_hostdata *hostdata, |
44 | unsigned char *addr, int len) | 44 | unsigned char *addr, int len) |
45 | { | 45 | { |
46 | unsigned long *laddr; | 46 | unsigned long *laddr; |
47 | u8 __iomem *base = priv(host)->io; | 47 | u8 __iomem *base = hostdata->io; |
48 | u8 __iomem *dma = priv(host)->pdma_io + 0x2000; | 48 | u8 __iomem *dma = hostdata->pdma_io + 0x2000; |
49 | 49 | ||
50 | if(!len) return 0; | 50 | if(!len) return 0; |
51 | 51 | ||
@@ -100,19 +100,19 @@ static inline int cumanascsi_pwrite(struct Scsi_Host *host, | |||
100 | } | 100 | } |
101 | } | 101 | } |
102 | end: | 102 | end: |
103 | writeb(priv(host)->ctrl | 0x40, base + CTRL); | 103 | writeb(hostdata->ctrl | 0x40, base + CTRL); |
104 | 104 | ||
105 | if (len) | 105 | if (len) |
106 | return -1; | 106 | return -1; |
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static inline int cumanascsi_pread(struct Scsi_Host *host, | 110 | static inline int cumanascsi_pread(struct NCR5380_hostdata *hostdata, |
111 | unsigned char *addr, int len) | 111 | unsigned char *addr, int len) |
112 | { | 112 | { |
113 | unsigned long *laddr; | 113 | unsigned long *laddr; |
114 | u8 __iomem *base = priv(host)->io; | 114 | u8 __iomem *base = hostdata->io; |
115 | u8 __iomem *dma = priv(host)->pdma_io + 0x2000; | 115 | u8 __iomem *dma = hostdata->pdma_io + 0x2000; |
116 | 116 | ||
117 | if(!len) return 0; | 117 | if(!len) return 0; |
118 | 118 | ||
@@ -166,13 +166,19 @@ static inline int cumanascsi_pread(struct Scsi_Host *host, | |||
166 | } | 166 | } |
167 | } | 167 | } |
168 | end: | 168 | end: |
169 | writeb(priv(host)->ctrl | 0x40, base + CTRL); | 169 | writeb(hostdata->ctrl | 0x40, base + CTRL); |
170 | 170 | ||
171 | if (len) | 171 | if (len) |
172 | return -1; | 172 | return -1; |
173 | return 0; | 173 | return 0; |
174 | } | 174 | } |
175 | 175 | ||
176 | static int cumanascsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, | ||
177 | struct scsi_cmnd *cmd) | ||
178 | { | ||
179 | return cmd->transfersize; | ||
180 | } | ||
181 | |||
176 | static u8 cumanascsi_read(struct NCR5380_hostdata *hostdata, | 182 | static u8 cumanascsi_read(struct NCR5380_hostdata *hostdata, |
177 | unsigned int reg) | 183 | unsigned int reg) |
178 | { | 184 | { |
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index d320f88c32c4..6be6666534d4 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c | |||
@@ -19,10 +19,10 @@ | |||
19 | #define NCR5380_read(reg) readb(hostdata->io + ((reg) << 2)) | 19 | #define NCR5380_read(reg) readb(hostdata->io + ((reg) << 2)) |
20 | #define NCR5380_write(reg, value) writeb(value, hostdata->io + ((reg) << 2)) | 20 | #define NCR5380_write(reg, value) writeb(value, hostdata->io + ((reg) << 2)) |
21 | 21 | ||
22 | #define NCR5380_dma_xfer_len(instance, cmd, phase) (0) | 22 | #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none |
23 | #define NCR5380_dma_recv_setup oakscsi_pread | 23 | #define NCR5380_dma_recv_setup oakscsi_pread |
24 | #define NCR5380_dma_send_setup oakscsi_pwrite | 24 | #define NCR5380_dma_send_setup oakscsi_pwrite |
25 | #define NCR5380_dma_residual(instance) (0) | 25 | #define NCR5380_dma_residual NCR5380_dma_residual_none |
26 | 26 | ||
27 | #define NCR5380_queue_command oakscsi_queue_command | 27 | #define NCR5380_queue_command oakscsi_queue_command |
28 | #define NCR5380_info oakscsi_info | 28 | #define NCR5380_info oakscsi_info |
@@ -37,10 +37,10 @@ | |||
37 | #define STAT ((128 + 16) << 2) | 37 | #define STAT ((128 + 16) << 2) |
38 | #define DATA ((128 + 8) << 2) | 38 | #define DATA ((128 + 8) << 2) |
39 | 39 | ||
40 | static inline int oakscsi_pwrite(struct Scsi_Host *instance, | 40 | static inline int oakscsi_pwrite(struct NCR5380_hostdata *hostdata, |
41 | unsigned char *addr, int len) | 41 | unsigned char *addr, int len) |
42 | { | 42 | { |
43 | u8 __iomem *base = priv(instance)->io; | 43 | u8 __iomem *base = hostdata->io; |
44 | 44 | ||
45 | printk("writing %p len %d\n",addr, len); | 45 | printk("writing %p len %d\n",addr, len); |
46 | 46 | ||
@@ -52,10 +52,11 @@ printk("writing %p len %d\n",addr, len); | |||
52 | return 0; | 52 | return 0; |
53 | } | 53 | } |
54 | 54 | ||
55 | static inline int oakscsi_pread(struct Scsi_Host *instance, | 55 | static inline int oakscsi_pread(struct NCR5380_hostdata *hostdata, |
56 | unsigned char *addr, int len) | 56 | unsigned char *addr, int len) |
57 | { | 57 | { |
58 | u8 __iomem *base = priv(instance)->io; | 58 | u8 __iomem *base = hostdata->io; |
59 | |||
59 | printk("reading %p len %d\n", addr, len); | 60 | printk("reading %p len %d\n", addr, len); |
60 | while(len > 0) | 61 | while(len > 0) |
61 | { | 62 | { |
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index f77c311ba5d0..105b35393ce9 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c | |||
@@ -67,14 +67,10 @@ static void (*atari_scsi_reg_write)(unsigned int, u8); | |||
67 | #define NCR5380_abort atari_scsi_abort | 67 | #define NCR5380_abort atari_scsi_abort |
68 | #define NCR5380_info atari_scsi_info | 68 | #define NCR5380_info atari_scsi_info |
69 | 69 | ||
70 | #define NCR5380_dma_recv_setup(instance, data, count) \ | 70 | #define NCR5380_dma_xfer_len atari_scsi_dma_xfer_len |
71 | atari_scsi_dma_setup(instance, data, count, 0) | 71 | #define NCR5380_dma_recv_setup atari_scsi_dma_recv_setup |
72 | #define NCR5380_dma_send_setup(instance, data, count) \ | 72 | #define NCR5380_dma_send_setup atari_scsi_dma_send_setup |
73 | atari_scsi_dma_setup(instance, data, count, 1) | 73 | #define NCR5380_dma_residual atari_scsi_dma_residual |
74 | #define NCR5380_dma_residual(instance) \ | ||
75 | atari_scsi_dma_residual(instance) | ||
76 | #define NCR5380_dma_xfer_len(instance, cmd, phase) \ | ||
77 | atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) | ||
78 | 74 | ||
79 | #define NCR5380_acquire_dma_irq(instance) falcon_get_lock(instance) | 75 | #define NCR5380_acquire_dma_irq(instance) falcon_get_lock(instance) |
80 | #define NCR5380_release_dma_irq(instance) falcon_release_lock() | 76 | #define NCR5380_release_dma_irq(instance) falcon_release_lock() |
@@ -457,15 +453,14 @@ static int __init atari_scsi_setup(char *str) | |||
457 | __setup("atascsi=", atari_scsi_setup); | 453 | __setup("atascsi=", atari_scsi_setup); |
458 | #endif /* !MODULE */ | 454 | #endif /* !MODULE */ |
459 | 455 | ||
460 | 456 | static unsigned long atari_scsi_dma_setup(struct NCR5380_hostdata *hostdata, | |
461 | static unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, | ||
462 | void *data, unsigned long count, | 457 | void *data, unsigned long count, |
463 | int dir) | 458 | int dir) |
464 | { | 459 | { |
465 | unsigned long addr = virt_to_phys(data); | 460 | unsigned long addr = virt_to_phys(data); |
466 | 461 | ||
467 | dprintk(NDEBUG_DMA, "scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, " | 462 | dprintk(NDEBUG_DMA, "scsi%d: setting up dma, data = %p, phys = %lx, count = %ld, dir = %d\n", |
468 | "dir = %d\n", instance->host_no, data, addr, count, dir); | 463 | hostdata->host->host_no, data, addr, count, dir); |
469 | 464 | ||
470 | if (!IS_A_TT() && !STRAM_ADDR(addr)) { | 465 | if (!IS_A_TT() && !STRAM_ADDR(addr)) { |
471 | /* If we have a non-DMAable address on a Falcon, use the dribble | 466 | /* If we have a non-DMAable address on a Falcon, use the dribble |
@@ -522,8 +517,19 @@ static unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, | |||
522 | return count; | 517 | return count; |
523 | } | 518 | } |
524 | 519 | ||
520 | static inline int atari_scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata, | ||
521 | unsigned char *data, int count) | ||
522 | { | ||
523 | return atari_scsi_dma_setup(hostdata, data, count, 0); | ||
524 | } | ||
525 | |||
526 | static inline int atari_scsi_dma_send_setup(struct NCR5380_hostdata *hostdata, | ||
527 | unsigned char *data, int count) | ||
528 | { | ||
529 | return atari_scsi_dma_setup(hostdata, data, count, 1); | ||
530 | } | ||
525 | 531 | ||
526 | static long atari_scsi_dma_residual(struct Scsi_Host *instance) | 532 | static int atari_scsi_dma_residual(struct NCR5380_hostdata *hostdata) |
527 | { | 533 | { |
528 | return atari_dma_residual; | 534 | return atari_dma_residual; |
529 | } | 535 | } |
@@ -564,10 +570,11 @@ static int falcon_classify_cmd(struct scsi_cmnd *cmd) | |||
564 | * the overrun problem, so this question is academic :-) | 570 | * the overrun problem, so this question is academic :-) |
565 | */ | 571 | */ |
566 | 572 | ||
567 | static unsigned long atari_dma_xfer_len(unsigned long wanted_len, | 573 | static int atari_scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, |
568 | struct scsi_cmnd *cmd, int write_flag) | 574 | struct scsi_cmnd *cmd) |
569 | { | 575 | { |
570 | unsigned long possible_len, limit; | 576 | int wanted_len = cmd->SCp.this_residual; |
577 | int possible_len, limit; | ||
571 | 578 | ||
572 | if (wanted_len < DMA_MIN_SIZE) | 579 | if (wanted_len < DMA_MIN_SIZE) |
573 | return 0; | 580 | return 0; |
@@ -604,7 +611,7 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len, | |||
604 | * use the dribble buffer and thus can do only STRAM_BUFFER_SIZE bytes. | 611 | * use the dribble buffer and thus can do only STRAM_BUFFER_SIZE bytes. |
605 | */ | 612 | */ |
606 | 613 | ||
607 | if (write_flag) { | 614 | if (cmd->sc_data_direction == DMA_TO_DEVICE) { |
608 | /* Write operation can always use the DMA, but the transfer size must | 615 | /* Write operation can always use the DMA, but the transfer size must |
609 | * be rounded up to the next multiple of 512 (atari_dma_setup() does | 616 | * be rounded up to the next multiple of 512 (atari_dma_setup() does |
610 | * this). | 617 | * this). |
@@ -644,8 +651,8 @@ static unsigned long atari_dma_xfer_len(unsigned long wanted_len, | |||
644 | possible_len = limit; | 651 | possible_len = limit; |
645 | 652 | ||
646 | if (possible_len != wanted_len) | 653 | if (possible_len != wanted_len) |
647 | dprintk(NDEBUG_DMA, "Sorry, must cut DMA transfer size to %ld bytes " | 654 | dprintk(NDEBUG_DMA, "DMA transfer now %d bytes instead of %d\n", |
648 | "instead of %ld\n", possible_len, wanted_len); | 655 | possible_len, wanted_len); |
649 | 656 | ||
650 | return possible_len; | 657 | return possible_len; |
651 | } | 658 | } |
diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index ab7b097a465f..3aa4657478e8 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c | |||
@@ -37,10 +37,10 @@ | |||
37 | #define NCR5380_read(reg) inb(hostdata->base + (reg)) | 37 | #define NCR5380_read(reg) inb(hostdata->base + (reg)) |
38 | #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg)) | 38 | #define NCR5380_write(reg, value) outb(value, hostdata->base + (reg)) |
39 | 39 | ||
40 | #define NCR5380_dma_xfer_len(instance, cmd, phase) (0) | 40 | #define NCR5380_dma_xfer_len NCR5380_dma_xfer_none |
41 | #define NCR5380_dma_recv_setup(instance, dst, len) (0) | 41 | #define NCR5380_dma_recv_setup NCR5380_dma_setup_none |
42 | #define NCR5380_dma_send_setup(instance, src, len) (0) | 42 | #define NCR5380_dma_send_setup NCR5380_dma_setup_none |
43 | #define NCR5380_dma_residual(instance) (0) | 43 | #define NCR5380_dma_residual NCR5380_dma_residual_none |
44 | 44 | ||
45 | #define NCR5380_implementation_fields /* none */ | 45 | #define NCR5380_implementation_fields /* none */ |
46 | 46 | ||
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 98aef0eb8b59..7299ad9889c9 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c | |||
@@ -332,7 +332,7 @@ static void generic_NCR5380_release_resources(struct Scsi_Host *instance) | |||
332 | 332 | ||
333 | /** | 333 | /** |
334 | * generic_NCR5380_pread - pseudo DMA read | 334 | * generic_NCR5380_pread - pseudo DMA read |
335 | * @instance: adapter to read from | 335 | * @hostdata: scsi host private data |
336 | * @dst: buffer to read into | 336 | * @dst: buffer to read into |
337 | * @len: buffer length | 337 | * @len: buffer length |
338 | * | 338 | * |
@@ -340,10 +340,9 @@ static void generic_NCR5380_release_resources(struct Scsi_Host *instance) | |||
340 | * controller | 340 | * controller |
341 | */ | 341 | */ |
342 | 342 | ||
343 | static inline int generic_NCR5380_pread(struct Scsi_Host *instance, | 343 | static inline int generic_NCR5380_pread(struct NCR5380_hostdata *hostdata, |
344 | unsigned char *dst, int len) | 344 | unsigned char *dst, int len) |
345 | { | 345 | { |
346 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
347 | int blocks = len / 128; | 346 | int blocks = len / 128; |
348 | int start = 0; | 347 | int start = 0; |
349 | 348 | ||
@@ -406,7 +405,7 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance, | |||
406 | 405 | ||
407 | /** | 406 | /** |
408 | * generic_NCR5380_pwrite - pseudo DMA write | 407 | * generic_NCR5380_pwrite - pseudo DMA write |
409 | * @instance: adapter to read from | 408 | * @hostdata: scsi host private data |
410 | * @dst: buffer to read into | 409 | * @dst: buffer to read into |
411 | * @len: buffer length | 410 | * @len: buffer length |
412 | * | 411 | * |
@@ -414,10 +413,9 @@ static inline int generic_NCR5380_pread(struct Scsi_Host *instance, | |||
414 | * controller | 413 | * controller |
415 | */ | 414 | */ |
416 | 415 | ||
417 | static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance, | 416 | static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata, |
418 | unsigned char *src, int len) | 417 | unsigned char *src, int len) |
419 | { | 418 | { |
420 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
421 | int blocks = len / 128; | 419 | int blocks = len / 128; |
422 | int start = 0; | 420 | int start = 0; |
423 | 421 | ||
@@ -480,10 +478,9 @@ static inline int generic_NCR5380_pwrite(struct Scsi_Host *instance, | |||
480 | return 0; | 478 | return 0; |
481 | } | 479 | } |
482 | 480 | ||
483 | static int generic_NCR5380_dma_xfer_len(struct Scsi_Host *instance, | 481 | static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata, |
484 | struct scsi_cmnd *cmd) | 482 | struct scsi_cmnd *cmd) |
485 | { | 483 | { |
486 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
487 | int transfersize = cmd->transfersize; | 484 | int transfersize = cmd->transfersize; |
488 | 485 | ||
489 | if (hostdata->flags & FLAG_NO_PSEUDO_DMA) | 486 | if (hostdata->flags & FLAG_NO_PSEUDO_DMA) |
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h index 10191d1c488a..3ce5b65ccb00 100644 --- a/drivers/scsi/g_NCR5380.h +++ b/drivers/scsi/g_NCR5380.h | |||
@@ -32,11 +32,10 @@ | |||
32 | #define NCR53C400_host_buffer 0x3900 | 32 | #define NCR53C400_host_buffer 0x3900 |
33 | #define NCR53C400_region_size 0x3a00 | 33 | #define NCR53C400_region_size 0x3a00 |
34 | 34 | ||
35 | #define NCR5380_dma_xfer_len(instance, cmd, phase) \ | 35 | #define NCR5380_dma_xfer_len generic_NCR5380_dma_xfer_len |
36 | generic_NCR5380_dma_xfer_len(instance, cmd) | ||
37 | #define NCR5380_dma_recv_setup generic_NCR5380_pread | 36 | #define NCR5380_dma_recv_setup generic_NCR5380_pread |
38 | #define NCR5380_dma_send_setup generic_NCR5380_pwrite | 37 | #define NCR5380_dma_send_setup generic_NCR5380_pwrite |
39 | #define NCR5380_dma_residual(instance) (0) | 38 | #define NCR5380_dma_residual NCR5380_dma_residual_none |
40 | 39 | ||
41 | #define NCR5380_intr generic_NCR5380_intr | 40 | #define NCR5380_intr generic_NCR5380_intr |
42 | #define NCR5380_queue_command generic_NCR5380_queue_command | 41 | #define NCR5380_queue_command generic_NCR5380_queue_command |
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 07f956c18266..ccb68d12692c 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c | |||
@@ -33,11 +33,10 @@ | |||
33 | #define NCR5380_read(reg) in_8(hostdata->io + ((reg) << 4)) | 33 | #define NCR5380_read(reg) in_8(hostdata->io + ((reg) << 4)) |
34 | #define NCR5380_write(reg, value) out_8(hostdata->io + ((reg) << 4), value) | 34 | #define NCR5380_write(reg, value) out_8(hostdata->io + ((reg) << 4), value) |
35 | 35 | ||
36 | #define NCR5380_dma_xfer_len(instance, cmd, phase) \ | 36 | #define NCR5380_dma_xfer_len macscsi_dma_xfer_len |
37 | macscsi_dma_xfer_len(instance, cmd) | ||
38 | #define NCR5380_dma_recv_setup macscsi_pread | 37 | #define NCR5380_dma_recv_setup macscsi_pread |
39 | #define NCR5380_dma_send_setup macscsi_pwrite | 38 | #define NCR5380_dma_send_setup macscsi_pwrite |
40 | #define NCR5380_dma_residual(instance) (hostdata->pdma_residual) | 39 | #define NCR5380_dma_residual macscsi_dma_residual |
41 | 40 | ||
42 | #define NCR5380_intr macscsi_intr | 41 | #define NCR5380_intr macscsi_intr |
43 | #define NCR5380_queue_command macscsi_queue_command | 42 | #define NCR5380_queue_command macscsi_queue_command |
@@ -152,10 +151,9 @@ __asm__ __volatile__ \ | |||
152 | : "0"(s), "1"(d), "2"(n) \ | 151 | : "0"(s), "1"(d), "2"(n) \ |
153 | : "d0") | 152 | : "d0") |
154 | 153 | ||
155 | static int macscsi_pread(struct Scsi_Host *instance, | 154 | static inline int macscsi_pread(struct NCR5380_hostdata *hostdata, |
156 | unsigned char *dst, int len) | 155 | unsigned char *dst, int len) |
157 | { | 156 | { |
158 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
159 | unsigned char *s = hostdata->pdma_io + (INPUT_DATA_REG << 4); | 157 | unsigned char *s = hostdata->pdma_io + (INPUT_DATA_REG << 4); |
160 | unsigned char *d = dst; | 158 | unsigned char *d = dst; |
161 | int n = len; | 159 | int n = len; |
@@ -181,16 +179,16 @@ static int macscsi_pread(struct Scsi_Host *instance, | |||
181 | if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) | 179 | if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) |
182 | return 0; | 180 | return 0; |
183 | 181 | ||
184 | dsprintk(NDEBUG_PSEUDO_DMA, instance, | 182 | dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host, |
185 | "%s: bus error (%d/%d)\n", __func__, transferred, len); | 183 | "%s: bus error (%d/%d)\n", __func__, transferred, len); |
186 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); | 184 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); |
187 | d = dst + transferred; | 185 | d = dst + transferred; |
188 | n = len - transferred; | 186 | n = len - transferred; |
189 | } | 187 | } |
190 | 188 | ||
191 | scmd_printk(KERN_ERR, hostdata->connected, | 189 | scmd_printk(KERN_ERR, hostdata->connected, |
192 | "%s: phase mismatch or !DRQ\n", __func__); | 190 | "%s: phase mismatch or !DRQ\n", __func__); |
193 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); | 191 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); |
194 | return -1; | 192 | return -1; |
195 | } | 193 | } |
196 | 194 | ||
@@ -255,10 +253,9 @@ __asm__ __volatile__ \ | |||
255 | : "0"(s), "1"(d), "2"(n) \ | 253 | : "0"(s), "1"(d), "2"(n) \ |
256 | : "d0") | 254 | : "d0") |
257 | 255 | ||
258 | static int macscsi_pwrite(struct Scsi_Host *instance, | 256 | static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata, |
259 | unsigned char *src, int len) | 257 | unsigned char *src, int len) |
260 | { | 258 | { |
261 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
262 | unsigned char *s = src; | 259 | unsigned char *s = src; |
263 | unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4); | 260 | unsigned char *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4); |
264 | int n = len; | 261 | int n = len; |
@@ -290,25 +287,23 @@ static int macscsi_pwrite(struct Scsi_Host *instance, | |||
290 | return 0; | 287 | return 0; |
291 | } | 288 | } |
292 | 289 | ||
293 | dsprintk(NDEBUG_PSEUDO_DMA, instance, | 290 | dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host, |
294 | "%s: bus error (%d/%d)\n", __func__, transferred, len); | 291 | "%s: bus error (%d/%d)\n", __func__, transferred, len); |
295 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); | 292 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); |
296 | s = src + transferred; | 293 | s = src + transferred; |
297 | n = len - transferred; | 294 | n = len - transferred; |
298 | } | 295 | } |
299 | 296 | ||
300 | scmd_printk(KERN_ERR, hostdata->connected, | 297 | scmd_printk(KERN_ERR, hostdata->connected, |
301 | "%s: phase mismatch or !DRQ\n", __func__); | 298 | "%s: phase mismatch or !DRQ\n", __func__); |
302 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, instance); | 299 | NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host); |
303 | 300 | ||
304 | return -1; | 301 | return -1; |
305 | } | 302 | } |
306 | 303 | ||
307 | static int macscsi_dma_xfer_len(struct Scsi_Host *instance, | 304 | static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, |
308 | struct scsi_cmnd *cmd) | 305 | struct scsi_cmnd *cmd) |
309 | { | 306 | { |
310 | struct NCR5380_hostdata *hostdata = shost_priv(instance); | ||
311 | |||
312 | if (hostdata->flags & FLAG_NO_PSEUDO_DMA || | 307 | if (hostdata->flags & FLAG_NO_PSEUDO_DMA || |
313 | cmd->SCp.this_residual < 16) | 308 | cmd->SCp.this_residual < 16) |
314 | return 0; | 309 | return 0; |
@@ -316,6 +311,11 @@ static int macscsi_dma_xfer_len(struct Scsi_Host *instance, | |||
316 | return cmd->SCp.this_residual; | 311 | return cmd->SCp.this_residual; |
317 | } | 312 | } |
318 | 313 | ||
314 | static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata) | ||
315 | { | ||
316 | return hostdata->pdma_residual; | ||
317 | } | ||
318 | |||
319 | #include "NCR5380.c" | 319 | #include "NCR5380.c" |
320 | 320 | ||
321 | #define DRV_MODULE_NAME "mac_scsi" | 321 | #define DRV_MODULE_NAME "mac_scsi" |
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index b408474885dc..88db6992420e 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c | |||
@@ -51,12 +51,10 @@ | |||
51 | #define NCR5380_abort sun3scsi_abort | 51 | #define NCR5380_abort sun3scsi_abort |
52 | #define NCR5380_info sun3scsi_info | 52 | #define NCR5380_info sun3scsi_info |
53 | 53 | ||
54 | #define NCR5380_dma_recv_setup(instance, data, count) (count) | 54 | #define NCR5380_dma_xfer_len sun3scsi_dma_xfer_len |
55 | #define NCR5380_dma_send_setup(instance, data, count) (count) | 55 | #define NCR5380_dma_recv_setup sun3scsi_dma_count |
56 | #define NCR5380_dma_residual(instance) \ | 56 | #define NCR5380_dma_send_setup sun3scsi_dma_count |
57 | sun3scsi_dma_residual(instance) | 57 | #define NCR5380_dma_residual sun3scsi_dma_residual |
58 | #define NCR5380_dma_xfer_len(instance, cmd, phase) \ | ||
59 | sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd) | ||
60 | 58 | ||
61 | #define NCR5380_acquire_dma_irq(instance) (1) | 59 | #define NCR5380_acquire_dma_irq(instance) (1) |
62 | #define NCR5380_release_dma_irq(instance) | 60 | #define NCR5380_release_dma_irq(instance) |
@@ -143,8 +141,8 @@ static irqreturn_t scsi_sun3_intr(int irq, void *dev) | |||
143 | } | 141 | } |
144 | 142 | ||
145 | /* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */ | 143 | /* sun3scsi_dma_setup() -- initialize the dma controller for a read/write */ |
146 | static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance, | 144 | static int sun3scsi_dma_setup(struct NCR5380_hostdata *hostdata, |
147 | void *data, unsigned long count, int write_flag) | 145 | unsigned char *data, int count, int write_flag) |
148 | { | 146 | { |
149 | void *addr; | 147 | void *addr; |
150 | 148 | ||
@@ -196,9 +194,10 @@ static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance, | |||
196 | dregs->csr |= CSR_FIFO; | 194 | dregs->csr |= CSR_FIFO; |
197 | 195 | ||
198 | if(dregs->fifo_count != count) { | 196 | if(dregs->fifo_count != count) { |
199 | shost_printk(KERN_ERR, instance, "FIFO mismatch %04x not %04x\n", | 197 | shost_printk(KERN_ERR, hostdata->host, |
198 | "FIFO mismatch %04x not %04x\n", | ||
200 | dregs->fifo_count, (unsigned int) count); | 199 | dregs->fifo_count, (unsigned int) count); |
201 | NCR5380_dprint(NDEBUG_DMA, instance); | 200 | NCR5380_dprint(NDEBUG_DMA, hostdata->host); |
202 | } | 201 | } |
203 | 202 | ||
204 | /* setup udc */ | 203 | /* setup udc */ |
@@ -233,14 +232,34 @@ static unsigned long sun3scsi_dma_setup(struct Scsi_Host *instance, | |||
233 | 232 | ||
234 | } | 233 | } |
235 | 234 | ||
236 | static inline unsigned long sun3scsi_dma_residual(struct Scsi_Host *instance) | 235 | static int sun3scsi_dma_count(struct NCR5380_hostdata *hostdata, |
236 | unsigned char *data, int count) | ||
237 | { | ||
238 | return count; | ||
239 | } | ||
240 | |||
241 | static inline int sun3scsi_dma_recv_setup(struct NCR5380_hostdata *hostdata, | ||
242 | unsigned char *data, int count) | ||
243 | { | ||
244 | return sun3scsi_dma_setup(hostdata, data, count, 0); | ||
245 | } | ||
246 | |||
247 | static inline int sun3scsi_dma_send_setup(struct NCR5380_hostdata *hostdata, | ||
248 | unsigned char *data, int count) | ||
249 | { | ||
250 | return sun3scsi_dma_setup(hostdata, data, count, 1); | ||
251 | } | ||
252 | |||
253 | static int sun3scsi_dma_residual(struct NCR5380_hostdata *hostdata) | ||
237 | { | 254 | { |
238 | return last_residual; | 255 | return last_residual; |
239 | } | 256 | } |
240 | 257 | ||
241 | static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted_len, | 258 | static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata, |
242 | struct scsi_cmnd *cmd) | 259 | struct scsi_cmnd *cmd) |
243 | { | 260 | { |
261 | int wanted_len = cmd->SCp.this_residual; | ||
262 | |||
244 | if (wanted_len < DMA_MIN_SIZE || cmd->request->cmd_type != REQ_TYPE_FS) | 263 | if (wanted_len < DMA_MIN_SIZE || cmd->request->cmd_type != REQ_TYPE_FS) |
245 | return 0; | 264 | return 0; |
246 | 265 | ||