scsi: g_NCR5380: Fix PDMA transfer size
authorOndrej Zary <linux@rainbow-software.org>
Mon, 3 Jul 2017 07:59:05 +0000 (03:59 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 7 Aug 2017 18:04:00 +0000 (14:04 -0400)
generic_NCR5380_dma_xfer_len() incorrectly uses cmd->transfersize which
causes rescan-scsi-bus and CD-ROM access to hang the system.  Use
cmd->SCp.this_residual instead, like other NCR5380 drivers.

Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/g_NCR5380.c

index c34fc91ba48668c09970c5a83a6bd38fa90ccd12..fbb28ed0fce8b9116326b030917911b5a5a9a9de 100644 (file)
@@ -76,6 +76,7 @@
 #define IRQ_AUTO 254
 
 #define MAX_CARDS 8
+#define DMA_MAX_SIZE 32768
 
 /* old-style parameters for compatibility */
 static int ncr_irq = -1;
@@ -629,23 +630,16 @@ static inline int generic_NCR5380_pwrite(struct NCR5380_hostdata *hostdata,
 static int generic_NCR5380_dma_xfer_len(struct NCR5380_hostdata *hostdata,
                                         struct scsi_cmnd *cmd)
 {
-       int transfersize = cmd->transfersize;
+       int transfersize = cmd->SCp.this_residual;
 
        if (hostdata->flags & FLAG_NO_PSEUDO_DMA)
                return 0;
 
-       /* Limit transfers to 32K, for xx400 & xx406
-        * pseudoDMA that transfers in 128 bytes blocks.
-        */
-       if (transfersize > 32 * 1024 && cmd->SCp.this_residual &&
-           !(cmd->SCp.this_residual % transfersize))
-               transfersize = 32 * 1024;
-
        /* 53C400 datasheet: non-modulo-128-byte transfers should use PIO */
        if (transfersize % 128)
                transfersize = 0;
 
-       return transfersize;
+       return min(transfersize, DMA_MAX_SIZE);
 }
 
 /*