[PATCH v4 24/78] ncr5380: Implement NCR5380_dma_xfer_len and remove LIMIT_TRANSFERSIZE macro

2016-01-02 Thread Finn Thain
Follow the example of the atari_NCR5380.c core driver and adopt the
NCR5380_dma_xfer_len() hook. Implement NCR5380_dma_xfer_len() for dtc.c
and g_NCR5380.c to take care of the limitations of these cards. Keep the
default for drivers using PSEUDO_DMA.

Eliminate the unused macro LIMIT_TRANSFERSIZE. 

Signed-off-by: Finn Thain 
Reviewed-by: Hannes Reinecke 
Tested-by: Ondrej Zary 
Tested-by: Michael Schmitz 

---
 drivers/scsi/NCR5380.c   |   32 +---
 drivers/scsi/arm/cumana_1.c  |3 +++
 drivers/scsi/arm/oak.c   |2 ++
 drivers/scsi/atari_NCR5380.c |8 +---
 drivers/scsi/dtc.c   |   14 ++
 drivers/scsi/dtc.h   |3 +++
 drivers/scsi/g_NCR5380.c |   15 +++
 drivers/scsi/g_NCR5380.h |3 +++
 drivers/scsi/mac_scsi.c  |1 +
 drivers/scsi/pas16.h |2 ++
 drivers/scsi/t128.h  |2 ++
 11 files changed, 55 insertions(+), 30 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2016-01-03 16:03:30.0 +1100
+++ linux/drivers/scsi/NCR5380.c2016-01-03 16:03:31.0 +1100
@@ -201,11 +201,6 @@
  * DONT_USE_INTR - if defined, never use interrupts, even if we probe or
  *  override-configure an IRQ.
  *
- * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
- *  bytes at a time.  Since interrupts are disabled by default during
- *  these transfers, we might need this to give reasonable interrupt
- *  service time if the transfer size gets too large.
- *
  * LINKED - if defined, linked commands are supported.
  *
  * PSEUDO_DMA - if defined, PSEUDO DMA is used during the data transfer phases.
@@ -2000,29 +1995,12 @@ static void NCR5380_information_transfer
 */
 
 #if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
-   /* KLL
-* PSEUDO_DMA is defined here. If this is the 
g_NCR5380
-* driver then it will always be defined, so the
-* FLAG_NO_PSEUDO_DMA is used to inhibit PDMA 
in the base
-* NCR5380 case.  I think this is a fairly 
clean solution.
-* We supplement these 2 if's with the flag.
-*/
-#ifdef NCR5380_dma_xfer_len
-   if (!cmd->device->borken && !(hostdata->flags & 
FLAG_NO_PSEUDO_DMA) && (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 
0) {
-#else
-   transfersize = cmd->transfersize;
+   transfersize = 0;
+   if (!cmd->device->borken &&
+   !(hostdata->flags & FLAG_NO_PSEUDO_DMA))
+   transfersize = 
NCR5380_dma_xfer_len(instance, cmd, phase);
 
-#ifdef LIMIT_TRANSFERSIZE  /* If we have problems with interrupt service */
-   if (transfersize > 512)
-   transfersize = 512;
-#endif /* LIMIT_TRANSFERSIZE */
-
-   if (!cmd->device->borken && transfersize && 
!(hostdata->flags & FLAG_NO_PSEUDO_DMA) && cmd->SCp.this_residual && 
!(cmd->SCp.this_residual % transfersize)) {
-   /* Limit transfers to 32K, for xx400 & 
xx406
-* pseudoDMA that transfers in 128 
bytes blocks. */
-   if (transfersize > 32 * 1024)
-   transfersize = 32 * 1024;
-#endif
+   if (transfersize) {
len = transfersize;
if (NCR5380_transfer_dma(instance, 
, , (unsigned char **) >SCp.ptr)) {
/*
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:30.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2016-01-03 16:03:31.0 +1100
@@ -2170,11 +2170,13 @@ static void NCR5380_information_transfer
 */
 
 #if defined(REAL_DMA)
-   if (
 #if !defined(CONFIG_SUN3)
-   !cmd->device->borken &&
+   transfersize = 0;
+   if (!cmd->device->borken)
 #endif
-   (transfersize = 
NCR5380_dma_xfer_len(instance, cmd, phase)) >= DMA_MIN_SIZE) {
+   transfersize = 
NCR5380_dma_xfer_len(instance, cmd, phase);
+
+   if (transfersize >= DMA_MIN_SIZE) {

[PATCH v4 24/78] ncr5380: Implement NCR5380_dma_xfer_len and remove LIMIT_TRANSFERSIZE macro

2016-01-02 Thread Finn Thain
Follow the example of the atari_NCR5380.c core driver and adopt the
NCR5380_dma_xfer_len() hook. Implement NCR5380_dma_xfer_len() for dtc.c
and g_NCR5380.c to take care of the limitations of these cards. Keep the
default for drivers using PSEUDO_DMA.

Eliminate the unused macro LIMIT_TRANSFERSIZE. 

Signed-off-by: Finn Thain 
Reviewed-by: Hannes Reinecke 
Tested-by: Ondrej Zary 
Tested-by: Michael Schmitz 

---
 drivers/scsi/NCR5380.c   |   32 +---
 drivers/scsi/arm/cumana_1.c  |3 +++
 drivers/scsi/arm/oak.c   |2 ++
 drivers/scsi/atari_NCR5380.c |8 +---
 drivers/scsi/dtc.c   |   14 ++
 drivers/scsi/dtc.h   |3 +++
 drivers/scsi/g_NCR5380.c |   15 +++
 drivers/scsi/g_NCR5380.h |3 +++
 drivers/scsi/mac_scsi.c  |1 +
 drivers/scsi/pas16.h |2 ++
 drivers/scsi/t128.h  |2 ++
 11 files changed, 55 insertions(+), 30 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2016-01-03 16:03:30.0 +1100
+++ linux/drivers/scsi/NCR5380.c2016-01-03 16:03:31.0 +1100
@@ -201,11 +201,6 @@
  * DONT_USE_INTR - if defined, never use interrupts, even if we probe or
  *  override-configure an IRQ.
  *
- * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512
- *  bytes at a time.  Since interrupts are disabled by default during
- *  these transfers, we might need this to give reasonable interrupt
- *  service time if the transfer size gets too large.
- *
  * LINKED - if defined, linked commands are supported.
  *
  * PSEUDO_DMA - if defined, PSEUDO DMA is used during the data transfer phases.
@@ -2000,29 +1995,12 @@ static void NCR5380_information_transfer
 */
 
 #if defined(PSEUDO_DMA) || defined(REAL_DMA_POLL)
-   /* KLL
-* PSEUDO_DMA is defined here. If this is the 
g_NCR5380
-* driver then it will always be defined, so the
-* FLAG_NO_PSEUDO_DMA is used to inhibit PDMA 
in the base
-* NCR5380 case.  I think this is a fairly 
clean solution.
-* We supplement these 2 if's with the flag.
-*/
-#ifdef NCR5380_dma_xfer_len
-   if (!cmd->device->borken && !(hostdata->flags & 
FLAG_NO_PSEUDO_DMA) && (transfersize = NCR5380_dma_xfer_len(instance, cmd)) != 
0) {
-#else
-   transfersize = cmd->transfersize;
+   transfersize = 0;
+   if (!cmd->device->borken &&
+   !(hostdata->flags & FLAG_NO_PSEUDO_DMA))
+   transfersize = 
NCR5380_dma_xfer_len(instance, cmd, phase);
 
-#ifdef LIMIT_TRANSFERSIZE  /* If we have problems with interrupt service */
-   if (transfersize > 512)
-   transfersize = 512;
-#endif /* LIMIT_TRANSFERSIZE */
-
-   if (!cmd->device->borken && transfersize && 
!(hostdata->flags & FLAG_NO_PSEUDO_DMA) && cmd->SCp.this_residual && 
!(cmd->SCp.this_residual % transfersize)) {
-   /* Limit transfers to 32K, for xx400 & 
xx406
-* pseudoDMA that transfers in 128 
bytes blocks. */
-   if (transfersize > 32 * 1024)
-   transfersize = 32 * 1024;
-#endif
+   if (transfersize) {
len = transfersize;
if (NCR5380_transfer_dma(instance, 
, , (unsigned char **) >SCp.ptr)) {
/*
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2016-01-03 16:03:30.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2016-01-03 16:03:31.0 +1100
@@ -2170,11 +2170,13 @@ static void NCR5380_information_transfer
 */
 
 #if defined(REAL_DMA)
-   if (
 #if !defined(CONFIG_SUN3)
-   !cmd->device->borken &&
+   transfersize = 0;
+   if (!cmd->device->borken)
 #endif
-   (transfersize = 
NCR5380_dma_xfer_len(instance, cmd, phase)) >= DMA_MIN_SIZE) {
+   transfersize = 
NCR5380_dma_xfer_len(instance, cmd,