@@ -525,8 +525,8 @@ static inline int generic_NCR5380_precv(struct NCR5380_hostdata *hostdata,
NCR5380_write(hostdata->c400_blk_cnt, len / 128);
do {
- if (hostdata->board == BOARD_DTC3181E && start == len - 128) {
- /* Ignore early CSR_GATED_53C80_IRQ */
+ if (start == len - 128) {
+ /* Ignore End of DMA interrupt for the last buffer */
if (NCR5380_poll_politely(hostdata, hostdata->c400_ctl_status,
CSR_HOST_BUF_NOT_RDY, 0, HZ / 64) < 0)
break;
@@ -603,17 +603,27 @@ static inline int generic_NCR5380_psend(struct NCR5380_hostdata *hostdata,
if (NCR5380_read(hostdata->c400_ctl_status) &
CSR_HOST_BUF_NOT_RDY) {
- /* The chip has done a 128 B buffer swap but the first
- * buffer still has not reached the SCSI bus.
- */
- if (start > 0)
+ /* Both 128 B buffers are in use */
+ if (start >= 128)
+ start -= 128;
+ if (start >= 128)
start -= 128;
break;
}
+ if (start >= len && NCR5380_read(hostdata->c400_blk_cnt) == 0)
+ break;
+
if (NCR5380_read(hostdata->c400_ctl_status) &
- CSR_GATED_53C80_IRQ)
+ CSR_GATED_53C80_IRQ) {
+ /* Host buffer is empty, other one is in use */
+ if (start >= 128)
+ start -= 128;
break;
+ }
+
+ if (start >= len)
+ continue;
if (hostdata->io_port && hostdata->io_width == 2)
outsw(hostdata->io_port + hostdata->c400_host_buf,
@@ -625,7 +635,7 @@ static inline int generic_NCR5380_psend(struct NCR5380_hostdata *hostdata,
memcpy_toio(hostdata->io + NCR53C400_host_buffer,
src + start, 128);
start += 128;
- } while (start < len);
+ } while (1);
residual = len - start;