Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1356897 > unrolled thread

[PATCH 00/22] ncr5380: Eliminate macros, reduce code duplication, fix bugs etc

Started byFinn Thain <fthain@telegraphics.com.au>
First post2016-03-14 05:50 +0100
Last post2016-03-15 04:20 +0100
Articles 20 on this page of 42 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 00/22] ncr5380: Eliminate macros, reduce code duplication, fix bugs etc Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention Hannes Reinecke <hare@suse.de> - 2016-03-14 08:40 +0100
        Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 04:30 +0100
          Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention Hannes Reinecke <hare@suse.de> - 2016-03-15 08:00 +0100
    [PATCH 05/22] ncr5380: Disable the DMA errata workaround flag by default Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 12/22] sun3_scsi: Adopt NCR5380.c core driver Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 06/22] ncr5380: Remove PSEUDO_DMA macro Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 17/22] ncr5380: Remove remaining register storage qualifiers Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver Hannes Reinecke <hare@suse.de> - 2016-03-14 08:40 +0100
    [PATCH 15/22] dmx3191d: Drop max_sectors limit Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 14/22] ncr5380: Add MAX_LUN limit Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit Hannes Reinecke <hare@suse.de> - 2016-03-14 08:50 +0100
      Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit Christoph Hellwig <hch@infradead.org> - 2016-03-14 09:00 +0100
        Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 04:30 +0100
          Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit Christoph Hellwig <hch@infradead.org> - 2016-03-15 09:30 +0100
    [PATCH 07/22] ncr5380: Remove BOARD_REQUIRES_NO_DELAY macro Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 20/22] atari_scsi: Set a reasonable default for cmd_per_lun Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 20/22] atari_scsi: Set a reasonable default for  cmd_per_lun Hannes Reinecke <hare@suse.de> - 2016-03-14 08:50 +0100
        Re: [PATCH 20/22] atari_scsi: Set a reasonable default for  cmd_per_lun Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 04:30 +0100
          Re: [PATCH 20/22] atari_scsi: Set a reasonable default for  cmd_per_lun Hannes Reinecke <hare@suse.de> - 2016-03-15 08:00 +0100
            Re: [PATCH 20/22] atari_scsi: Set a reasonable default for  cmd_per_lun Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 09:30 +0100
          Re: [PATCH 20/22] atari_scsi: Set a reasonable default for  cmd_per_lun James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-03-15 15:40 +0100
    [PATCH 08/22] ncr5380: Use DMA hooks for PDMA Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 18/22] ncr5380: Remove DONT_USE_INTR and AUTOPROBE_IRQ macros Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 22/22] mac_scsi: Fix pseudo DMA implementation Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 02/22] ncr5380: Remove FLAG_NO_PSEUDO_DMA where possible Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 16/22] ncr5380: Fix register decoding for debugging Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 16/22] ncr5380: Fix register decoding for debugging Hannes Reinecke <hare@suse.de> - 2016-03-14 08:50 +0100
        Re: [PATCH 16/22] ncr5380: Fix register decoding for debugging Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 04:30 +0100
    [PATCH 19/22] ncr5380: Update usage documentation Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 21/22] atari_scsi: Allow can_queue to be increased for Falcon Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
      Re: [PATCH 21/22] atari_scsi: Allow can_queue to be increased for  Falcon Hannes Reinecke <hare@suse.de> - 2016-03-14 09:00 +0100
    [PATCH 10/22] ncr5380: Merge DMA implementation from atari_NCR5380 core driver Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 05:50 +0100
    [PATCH 01/22] g_ncr5380: Remove CONFIG_SCSI_GENERIC_NCR53C400 Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 06:00 +0100
      Re: [PATCH 01/22] g_ncr5380: Remove CONFIG_SCSI_GENERIC_NCR53C400 Hannes Reinecke <hare@suse.de> - 2016-03-14 08:30 +0100
    [PATCH 03/22] ncr5380: Remove REAL_DMA and REAL_DMA_POLL macros Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 06:00 +0100
      Re: [PATCH 03/22] ncr5380: Remove REAL_DMA and REAL_DMA_POLL macros Hannes Reinecke <hare@suse.de> - 2016-03-14 08:30 +0100
    [PATCH 04/22] atari_NCR5380: Remove DMA_MIN_SIZE macro Finn Thain <fthain@telegraphics.com.au> - 2016-03-14 06:00 +0100
      Re: [PATCH 04/22] atari_NCR5380: Remove DMA_MIN_SIZE macro Hannes Reinecke <hare@suse.de> - 2016-03-14 08:30 +0100
        Re: [PATCH 04/22] atari_NCR5380: Remove DMA_MIN_SIZE macro Finn Thain <fthain@telegraphics.com.au> - 2016-03-15 04:20 +0100

Page 1 of 3  [1] 2 3  Next page →


#1356897 — [PATCH 00/22] ncr5380: Eliminate macros, reduce code duplication, fix bugs etc

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 00/22] ncr5380: Eliminate macros, reduce code duplication, fix bugs etc
Message-ID<rcsC5-7iI-3@gated-at.bofh.it>
This patch series has more macro elimination and some tweaks to the
DMA hooks so that all the wrapper drivers can share the same core
DMA algorithm. This resolves the major discrepancies between the two
core drivers, which relate to code conditional on the REAL_DMA and
PSEUDO_DMA macros.

After all the wrapper drivers agree on the DMA hook api, the core driver
fork gets resolved. NCR5380.c is adopted by atari_scsi and sun3_scsi and
atari_NCR5380.c is then deleted.

Historically, the 5380 drivers suffered from over-use of conditional
compilation, which caused the compile-time configuration space to explode,
leading to core driver code that was practically untestable, unmaintainable
and difficult to reason about. It also prevented driver modules from
sharing object code.

Along with REAL_DMA, REAL_DMA_POLL and PSEUDO_DMA, most of the remaining
macros are also eradicated, such as CONFIG_SCSI_GENERIC_NCR53C400,
SUPPORT_TAGS, DONT_USE_INTR, AUTOPROBE_IRQ and BIOSPARAM.

Also in this patch series, some duplicated documentation is removed and
the PDMA implementation in mac_scsi finally gets fixed.

This patch series was tested by exercising the dmx3191d and mac_scsi modules
on suitable hardware. Help with driver testing on ISA and Atari hardware
is sought as I don't have any (likewise RiscPC ecards and Sun 3 hardware).

---
 Documentation/scsi/g_NCR5380.txt       |   17 
 Documentation/scsi/scsi-parameters.txt |   11 
 drivers/scsi/Kconfig                   |   11 
 drivers/scsi/NCR5380.c                 |  661 ++++----
 drivers/scsi/NCR5380.h                 |  145 -
 drivers/scsi/arm/cumana_1.c            |   25 
 drivers/scsi/arm/oak.c                 |   22 
 drivers/scsi/atari_NCR5380.c           | 2676 ---------------------------------
 drivers/scsi/atari_scsi.c              |  142 -
 drivers/scsi/dmx3191d.c                |   10 
 drivers/scsi/dtc.c                     |   27 
 drivers/scsi/dtc.h                     |    7 
 drivers/scsi/g_NCR5380.c               |  143 -
 drivers/scsi/g_NCR5380.h               |   26 
 drivers/scsi/mac_scsi.c                |  239 +-
 drivers/scsi/pas16.c                   |   27 
 drivers/scsi/pas16.h                   |    5 
 drivers/scsi/sun3_scsi.c               |   48 
 drivers/scsi/t128.c                    |   19 
 drivers/scsi/t128.h                    |    7 
 20 files changed, 636 insertions(+), 3632 deletions(-)

[toc] | [next] | [standalone]


#1356898 — [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 09/22] ncr5380: Adopt uniform DMA setup convention
Message-ID<rcsC5-7iI-5@gated-at.bofh.it>
In reply to#1356897
Standardize the DMA setup hooks so that the DMA implementation in
atari_NCR5380.c can be reconciled with pseudo DMA implementation in
NCR5380.c.

Calls to NCR5380_dma_recv_setup() and NCR5380_dma_send_setup() return
a negative value on failure, zero on PDMA transfer success and a positive
byte count for DMA setup success.

This convention is not entirely new, but is now applied consistently.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c      |   21 ++++++++++-----------
 drivers/scsi/arm/cumana_1.c |   10 ++++++++--
 drivers/scsi/arm/oak.c      |    4 ++--
 drivers/scsi/atari_scsi.c   |    3 ---
 4 files changed, 20 insertions(+), 18 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:34.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:37.000000000 +1100
@@ -1431,7 +1431,7 @@ static int NCR5380_transfer_dma(struct S
 	register unsigned char p = *phase;
 	register unsigned char *d = *data;
 	unsigned char tmp;
-	int foo;
+	int result;
 
 	if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
 		*phase = tmp;
@@ -1505,9 +1505,9 @@ static int NCR5380_transfer_dma(struct S
  */
 
 	if (p & SR_IO) {
-		foo = NCR5380_dma_recv_setup(instance, d,
+		result = NCR5380_dma_recv_setup(instance, d,
 			hostdata->flags & FLAG_DMA_FIXUP ? c - 1 : c);
-		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
+		if (!result && (hostdata->flags & FLAG_DMA_FIXUP)) {
 			/*
 			 * The workaround was to transfer fewer bytes than we
 			 * intended to with the pseudo-DMA read function, wait for
@@ -1525,19 +1525,19 @@ static int NCR5380_transfer_dma(struct S
 
 			if (NCR5380_poll_politely(instance, BUS_AND_STATUS_REG,
 			                          BASR_DRQ, BASR_DRQ, HZ) < 0) {
-				foo = -1;
+				result = -1;
 				shost_printk(KERN_ERR, instance, "PDMA read: DRQ timeout\n");
 			}
 			if (NCR5380_poll_politely(instance, STATUS_REG,
 			                          SR_REQ, 0, HZ) < 0) {
-				foo = -1;
+				result = -1;
 				shost_printk(KERN_ERR, instance, "PDMA read: !REQ timeout\n");
 			}
 			d[c - 1] = NCR5380_read(INPUT_DATA_REG);
 		}
 	} else {
-		foo = NCR5380_dma_send_setup(instance, d, c);
-		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
+		result = NCR5380_dma_send_setup(instance, d, c);
+		if (!result && (hostdata->flags & FLAG_DMA_FIXUP)) {
 			/*
 			 * Wait for the last byte to be sent.  If REQ is being asserted for
 			 * the byte we're interested, we'll ACK it and it will go false.
@@ -1545,7 +1545,7 @@ static int NCR5380_transfer_dma(struct S
 			if (NCR5380_poll_politely2(instance,
 			     BUS_AND_STATUS_REG, BASR_DRQ, BASR_DRQ,
 			     BUS_AND_STATUS_REG, BASR_PHASE_MATCH, 0, HZ) < 0) {
-				foo = -1;
+				result = -1;
 				shost_printk(KERN_ERR, instance, "PDMA write: DRQ and phase timeout\n");
 			}
 		}
@@ -1555,8 +1555,7 @@ static int NCR5380_transfer_dma(struct S
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 	*data = d + c;
 	*count = 0;
-	*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
-	return foo;
+	return result;
 }
 
 /*
@@ -1652,7 +1651,7 @@ static void NCR5380_information_transfer
 				if (!cmd->device->borken)
 					transfersize = NCR5380_dma_xfer_len(instance, cmd, phase);
 
-				if (transfersize) {
+				if (transfersize > 0) {
 					len = transfersize;
 					if (NCR5380_transfer_dma(instance, &phase,
 					    &len, (unsigned char **)&cmd->SCp.ptr)) {
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2016-03-14 15:26:34.000000000 +1100
+++ linux/drivers/scsi/arm/cumana_1.c	2016-03-14 15:26:37.000000000 +1100
@@ -101,7 +101,10 @@ static inline int cumanascsi_pwrite(stru
   }
 end:
   writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
-  return len;
+
+	if (len)
+		return -1;
+	return 0;
 }
 
 static inline int cumanascsi_pread(struct Scsi_Host *host,
@@ -163,7 +166,10 @@ static inline int cumanascsi_pread(struc
   }
 end:
   writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
-  return len;
+
+	if (len)
+		return -1;
+	return 0;
 }
 
 static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2016-03-14 15:26:34.000000000 +1100
+++ linux/drivers/scsi/arm/oak.c	2016-03-14 15:26:37.000000000 +1100
@@ -47,13 +47,13 @@ static inline int oakscsi_pwrite(struct
   void __iomem *base = priv(instance)->base;
 
 printk("writing %p len %d\n",addr, len);
-  if(!len) return -1;
 
   while(1)
   {
     int status;
     while (((status = readw(base + STAT)) & 0x100)==0);
   }
+  return 0;
 }
 
 static inline int oakscsi_pread(struct Scsi_Host *instance,
@@ -74,7 +74,7 @@ printk("reading %p len %d\n", addr, len)
       if(status & 0x200 || !timeout)
       {
         printk("status = %08X\n", status);
-        return 1;
+        return -1;
       }
     }
 
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2016-03-14 15:26:26.000000000 +1100
+++ linux/drivers/scsi/atari_scsi.c	2016-03-14 15:26:37.000000000 +1100
@@ -525,9 +525,6 @@ static unsigned long atari_scsi_dma_setu
 	 */
 	dma_cache_maintenance(addr, count, dir);
 
-	if (count == 0)
-		printk(KERN_NOTICE "SCSI warning: DMA programmed for 0 bytes !\n");
-
 	if (IS_A_TT()) {
 		tt_scsi_dma.dma_ctrl = dir;
 		SCSI_DMA_WRITE_P(dma_addr, addr);

[toc] | [prev] | [next] | [standalone]


#1357005 — Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention

FromHannes Reinecke <hare@suse.de>
Date2016-03-14 08:40 +0100
SubjectRe: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention
Message-ID<rcvgC-Hl-35@gated-at.bofh.it>
In reply to#1356898
On 03/14/2016 05:27 AM, Finn Thain wrote:
> Standardize the DMA setup hooks so that the DMA implementation in
> atari_NCR5380.c can be reconciled with pseudo DMA implementation in
> NCR5380.c.
> 
> Calls to NCR5380_dma_recv_setup() and NCR5380_dma_send_setup() return
> a negative value on failure, zero on PDMA transfer success and a positive
> byte count for DMA setup success.
> 
> This convention is not entirely new, but is now applied consistently.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
> ---
>  drivers/scsi/NCR5380.c      |   21 ++++++++++-----------
>  drivers/scsi/arm/cumana_1.c |   10 ++++++++--
>  drivers/scsi/arm/oak.c      |    4 ++--
>  drivers/scsi/atari_scsi.c   |    3 ---
>  4 files changed, 20 insertions(+), 18 deletions(-)
> 
> Index: linux/drivers/scsi/NCR5380.c
> ===================================================================
> --- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:34.000000000 +1100
> +++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:37.000000000 +1100
> @@ -1431,7 +1431,7 @@ static int NCR5380_transfer_dma(struct S
>  	register unsigned char p = *phase;
>  	register unsigned char *d = *data;
>  	unsigned char tmp;
> -	int foo;
> +	int result;
>  
>  	if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) {
>  		*phase = tmp;
> @@ -1505,9 +1505,9 @@ static int NCR5380_transfer_dma(struct S
>   */
>  
>  	if (p & SR_IO) {
> -		foo = NCR5380_dma_recv_setup(instance, d,
> +		result = NCR5380_dma_recv_setup(instance, d,
>  			hostdata->flags & FLAG_DMA_FIXUP ? c - 1 : c);
> -		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
> +		if (!result && (hostdata->flags & FLAG_DMA_FIXUP)) {
>  			/*
>  			 * The workaround was to transfer fewer bytes than we
>  			 * intended to with the pseudo-DMA read function, wait for
> @@ -1525,19 +1525,19 @@ static int NCR5380_transfer_dma(struct S
>  
>  			if (NCR5380_poll_politely(instance, BUS_AND_STATUS_REG,
>  			                          BASR_DRQ, BASR_DRQ, HZ) < 0) {
> -				foo = -1;
> +				result = -1;
>  				shost_printk(KERN_ERR, instance, "PDMA read: DRQ timeout\n");
>  			}
>  			if (NCR5380_poll_politely(instance, STATUS_REG,
>  			                          SR_REQ, 0, HZ) < 0) {
> -				foo = -1;
> +				result = -1;
>  				shost_printk(KERN_ERR, instance, "PDMA read: !REQ timeout\n");
>  			}
>  			d[c - 1] = NCR5380_read(INPUT_DATA_REG);
>  		}
>  	} else {
> -		foo = NCR5380_dma_send_setup(instance, d, c);
> -		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
> +		result = NCR5380_dma_send_setup(instance, d, c);
> +		if (!result && (hostdata->flags & FLAG_DMA_FIXUP)) {
>  			/*
>  			 * Wait for the last byte to be sent.  If REQ is being asserted for
>  			 * the byte we're interested, we'll ACK it and it will go false.
> @@ -1545,7 +1545,7 @@ static int NCR5380_transfer_dma(struct S
>  			if (NCR5380_poll_politely2(instance,
>  			     BUS_AND_STATUS_REG, BASR_DRQ, BASR_DRQ,
>  			     BUS_AND_STATUS_REG, BASR_PHASE_MATCH, 0, HZ) < 0) {
> -				foo = -1;
> +				result = -1;
>  				shost_printk(KERN_ERR, instance, "PDMA write: DRQ and phase timeout\n");
>  			}
>  		}
> @@ -1555,8 +1555,7 @@ static int NCR5380_transfer_dma(struct S
>  	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
>  	*data = d + c;
>  	*count = 0;
> -	*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
> -	return foo;
> +	return result;
>  }
>  
>  /*

Don't you miss a phase update here?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1357788 — Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-15 04:30 +0100
SubjectRe: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention
Message-ID<rcNQe-4LQ-5@gated-at.bofh.it>
In reply to#1357005
On Mon, 14 Mar 2016, Hannes Reinecke wrote:

> > @@ -1555,8 +1555,7 @@ static int NCR5380_transfer_dma(struct S
> >  	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
> >  	*data = d + c;
> >  	*count = 0;
> > -	*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
> > -	return foo;
> > +	return result;
> >  }
> >  
> >  /*
> 
> Don't you miss a phase update here?

I guess I missed explaining the change in the commit log.

The *phase assignment is redundant because after NCR5380_transfer_dma() 
returns control to NCR5380_information_transfer(), the latter routine then 
also returns, and so *phase is dead.

-- 

> 
> Cheers,
> 
> Hannes
> 

[toc] | [prev] | [next] | [standalone]


#1357834 — Re: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention

FromHannes Reinecke <hare@suse.de>
Date2016-03-15 08:00 +0100
SubjectRe: [PATCH 09/22] ncr5380: Adopt uniform DMA setup convention
Message-ID<rcR7s-6VA-17@gated-at.bofh.it>
In reply to#1357788
On 03/15/2016 04:19 AM, Finn Thain wrote:
> 
> On Mon, 14 Mar 2016, Hannes Reinecke wrote:
> 
>>> @@ -1555,8 +1555,7 @@ static int NCR5380_transfer_dma(struct S
>>>  	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
>>>  	*data = d + c;
>>>  	*count = 0;
>>> -	*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
>>> -	return foo;
>>> +	return result;
>>>  }
>>>  
>>>  /*
>>
>> Don't you miss a phase update here?
> 
> I guess I missed explaining the change in the commit log.
> 
> The *phase assignment is redundant because after NCR5380_transfer_dma() 
> returns control to NCR5380_information_transfer(), the latter routine then 
> also returns, and so *phase is dead.
> 
Right. Please add this to the commit message.

Otherwise:

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1356901 — [PATCH 05/22] ncr5380: Disable the DMA errata workaround flag by default

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 05/22] ncr5380: Disable the DMA errata workaround flag by default
Message-ID<rcsC6-7iI-11@gated-at.bofh.it>
In reply to#1356897
The only chip that needs the workarounds enabled is an early NMOS
device. That means that the common case is to disable them.

Unfortunately the sense of the flag is such that it has to be set
for the common case.

Rename the flag so that zero can be used to mean "no errata workarounds
needed". This simplifies the code.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c      |   14 +++++++-------
 drivers/scsi/NCR5380.h      |    2 +-
 drivers/scsi/arm/cumana_1.c |    2 +-
 drivers/scsi/arm/oak.c      |    2 +-
 drivers/scsi/dtc.c          |    2 +-
 drivers/scsi/g_NCR5380.c    |    8 +-------
 drivers/scsi/pas16.c        |    2 +-
 drivers/scsi/t128.c         |    2 +-
 8 files changed, 14 insertions(+), 20 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:23.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:27.000000000 +1100
@@ -457,7 +457,7 @@ static void prepare_info(struct Scsi_Hos
 	         instance->base, instance->irq,
 	         instance->can_queue, instance->cmd_per_lun,
 	         instance->sg_tablesize, instance->this_id,
-	         hostdata->flags & FLAG_NO_DMA_FIXUP  ? "NO_DMA_FIXUP "  : "",
+	         hostdata->flags & FLAG_DMA_FIXUP     ? "DMA_FIXUP "     : "",
 	         hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "",
 	         hostdata->flags & FLAG_TOSHIBA_DELAY ? "TOSHIBA_DELAY "  : "",
 #ifdef AUTOPROBE_IRQ
@@ -1480,11 +1480,11 @@ static int NCR5380_transfer_dma(struct S
 	 * before the setting of DMA mode to after transfer of the last byte.
 	 */
 
-	if (hostdata->flags & FLAG_NO_DMA_FIXUP)
+	if (hostdata->flags & FLAG_DMA_FIXUP)
+		NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY);
+	else
 		NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY |
 		                        MR_ENABLE_EOP_INTR);
-	else
-		NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY);
 
 	dprintk(NDEBUG_DMA, "scsi%d : mode reg = 0x%X\n", instance->host_no, NCR5380_read(MODE_REG));
 
@@ -1540,8 +1540,8 @@ static int NCR5380_transfer_dma(struct S
 
 	if (p & SR_IO) {
 		foo = NCR5380_pread(instance, d,
-			hostdata->flags & FLAG_NO_DMA_FIXUP ? c : c - 1);
-		if (!foo && !(hostdata->flags & FLAG_NO_DMA_FIXUP)) {
+			hostdata->flags & FLAG_DMA_FIXUP ? c - 1 : c);
+		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
 			/*
 			 * The workaround was to transfer fewer bytes than we
 			 * intended to with the pseudo-DMA read function, wait for
@@ -1571,7 +1571,7 @@ static int NCR5380_transfer_dma(struct S
 		}
 	} else {
 		foo = NCR5380_pwrite(instance, d, c);
-		if (!foo && !(hostdata->flags & FLAG_NO_DMA_FIXUP)) {
+		if (!foo && (hostdata->flags & FLAG_DMA_FIXUP)) {
 			/*
 			 * Wait for the last byte to be sent.  If REQ is being asserted for
 			 * the byte we're interested, we'll ACK it and it will go false.
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2016-03-14 15:26:23.000000000 +1100
+++ linux/drivers/scsi/NCR5380.h	2016-03-14 15:26:27.000000000 +1100
@@ -220,7 +220,7 @@
 #define NO_IRQ		0
 #endif
 
-#define FLAG_NO_DMA_FIXUP		1	/* No DMA errata workarounds */
+#define FLAG_DMA_FIXUP			1	/* Use DMA errata workarounds */
 #define FLAG_NO_PSEUDO_DMA		8	/* Inhibit DMA */
 #define FLAG_LATE_DMA_SETUP		32	/* Setup NCR before DMA H/W */
 #define FLAG_TAGGED_QUEUING		64	/* as X3T9.2 spelled it */
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/dtc.c	2016-03-14 15:26:27.000000000 +1100
@@ -229,7 +229,7 @@ found:
 		instance->base = addr;
 		((struct NCR5380_hostdata *)(instance)->hostdata)->base = base;
 
-		if (NCR5380_init(instance, FLAG_NO_DMA_FIXUP))
+		if (NCR5380_init(instance, 0))
 			goto out_unregister;
 
 		NCR5380_maybe_reset_bus(instance);
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2016-03-14 15:26:22.000000000 +1100
+++ linux/drivers/scsi/g_NCR5380.c	2016-03-14 15:26:27.000000000 +1100
@@ -348,23 +348,17 @@ static int __init generic_NCR5380_detect
 		flags = 0;
 		switch (overrides[current_override].board) {
 		case BOARD_NCR5380:
-			flags = FLAG_NO_PSEUDO_DMA;
-			break;
-		case BOARD_NCR53C400:
-			flags = FLAG_NO_DMA_FIXUP;
+			flags = FLAG_NO_PSEUDO_DMA | FLAG_DMA_FIXUP;
 			break;
 		case BOARD_NCR53C400A:
-			flags = FLAG_NO_DMA_FIXUP;
 			ports = ncr_53c400a_ports;
 			magic = ncr_53c400a_magic;
 			break;
 		case BOARD_HP_C2502:
-			flags = FLAG_NO_DMA_FIXUP;
 			ports = ncr_53c400a_ports;
 			magic = hp_c2502_magic;
 			break;
 		case BOARD_DTC3181E:
-			flags = FLAG_NO_DMA_FIXUP;
 			ports = dtc_3181e_ports;
 			magic = ncr_53c400a_magic;
 			break;
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/arm/cumana_1.c	2016-03-14 15:26:27.000000000 +1100
@@ -239,7 +239,7 @@ static int cumanascsi1_probe(struct expa
 
 	host->irq = ec->irq;
 
-	ret = NCR5380_init(host, 0);
+	ret = NCR5380_init(host, FLAG_DMA_FIXUP);
 	if (ret)
 		goto out_unmap;
 
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/arm/oak.c	2016-03-14 15:26:27.000000000 +1100
@@ -143,7 +143,7 @@ static int oakscsi_probe(struct expansio
 	host->irq = NO_IRQ;
 	host->n_io_port = 255;
 
-	ret = NCR5380_init(host, 0);
+	ret = NCR5380_init(host, FLAG_DMA_FIXUP);
 	if (ret)
 		goto out_unmap;
 
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/pas16.c	2016-03-14 15:26:27.000000000 +1100
@@ -377,7 +377,7 @@ static int __init pas16_detect(struct sc
 		
 	instance->io_port = io_port;
 
-	if (NCR5380_init(instance, 0))
+	if (NCR5380_init(instance, FLAG_DMA_FIXUP))
 		goto out_unregister;
 
 	NCR5380_maybe_reset_bus(instance);
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/t128.c	2016-03-14 15:26:27.000000000 +1100
@@ -210,7 +210,7 @@ found:
 	instance->base = base;
 	((struct NCR5380_hostdata *)instance->hostdata)->base = p;
 
-	if (NCR5380_init(instance, 0))
+	if (NCR5380_init(instance, FLAG_DMA_FIXUP))
 		goto out_unregister;
 
 	NCR5380_maybe_reset_bus(instance);

[toc] | [prev] | [next] | [standalone]


#1356902 — [PATCH 12/22] sun3_scsi: Adopt NCR5380.c core driver

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 12/22] sun3_scsi: Adopt NCR5380.c core driver
Message-ID<rcsC6-7iI-17@gated-at.bofh.it>
In reply to#1356897
Add support for the custom Sun 3 DMA logic to the NCR5380.c core driver.
This code is copied from atari_NCR5380.c.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---

The Sun 3 DMA code is still configured by macros. I have simplified things
slightly but I have avoided more ambitious refactoring. It's not clear to
me what that should look like and I can't test sun3_scsi anyway. At least
this permits the removal of atari_NCR5380.c.

---
 drivers/scsi/NCR5380.c   |  131 +++++++++++++++++++++++++++++++++++++++++++----
 drivers/scsi/sun3_scsi.c |    8 +-
 2 files changed, 124 insertions(+), 15 deletions(-)

Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2016-03-14 15:26:26.000000000 +1100
+++ linux/drivers/scsi/sun3_scsi.c	2016-03-14 15:26:44.000000000 +1100
@@ -51,10 +51,8 @@
 #define NCR5380_abort                   sun3scsi_abort
 #define NCR5380_info                    sun3scsi_info
 
-#define NCR5380_dma_read_setup(instance, data, count) \
-        sun3scsi_dma_setup(instance, data, count, 0)
-#define NCR5380_dma_write_setup(instance, data, count) \
-        sun3scsi_dma_setup(instance, data, count, 1)
+#define NCR5380_dma_recv_setup(instance, data, count) (count)
+#define NCR5380_dma_send_setup(instance, data, count) (count)
 #define NCR5380_dma_residual(instance) \
         sun3scsi_dma_residual(instance)
 #define NCR5380_dma_xfer_len(instance, cmd, phase) \
@@ -403,7 +401,7 @@ static int sun3scsi_dma_finish(int write
 
 }
 	
-#include "atari_NCR5380.c"
+#include "NCR5380.c"
 
 #ifdef SUN3_SCSI_VME
 #define SUN3_SCSI_NAME          "Sun3 NCR5380 VME SCSI"
Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:42.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:44.000000000 +1100
@@ -31,6 +31,8 @@
 
 /* Ported to Atari by Roman Hodek and others. */
 
+/* Adapted for the Sun 3 by Sam Creasey. */
+
 /*
  * Further development / testing that should be done :
  *
@@ -858,6 +860,23 @@ static void NCR5380_dma_complete(struct
 		}
 	}
 
+#ifdef CONFIG_SUN3
+	if ((sun3scsi_dma_finish(rq_data_dir(hostdata->connected->request)))) {
+		pr_err("scsi%d: overrun in UDC counter -- not prepared to deal with this!\n",
+		       instance->host_no);
+		BUG();
+	}
+
+	if ((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) ==
+	    (BASR_PHASE_MATCH | BASR_ACK)) {
+		pr_err("scsi%d: BASR %02x\n", instance->host_no,
+		       NCR5380_read(BUS_AND_STATUS_REG));
+		pr_err("scsi%d: bus stuck in data phase -- probably a single byte overrun!\n",
+		       instance->host_no);
+		BUG();
+	}
+#endif
+
 	NCR5380_write(MODE_REG, MR_BASE);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -981,10 +1000,16 @@ static irqreturn_t NCR5380_intr(int irq,
 			NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
 			dsprintk(NDEBUG_INTR, instance, "unknown interrupt\n");
+#ifdef SUN3_SCSI_VME
+			dregs->csr |= CSR_DMA_ENABLE;
+#endif
 		}
 		handled = 1;
 	} else {
 		shost_printk(KERN_NOTICE, instance, "interrupt without IRQ bit\n");
+#ifdef SUN3_SCSI_VME
+		dregs->csr |= CSR_DMA_ENABLE;
+#endif
 	}
 
 	spin_unlock_irqrestore(&hostdata->lock, flags);
@@ -1274,6 +1299,10 @@ static struct scsi_cmnd *NCR5380_select(
 	hostdata->connected = cmd;
 	hostdata->busy[cmd->device->id] |= 1 << cmd->device->lun;
 
+#ifdef SUN3_SCSI_VME
+	dregs->csr |= CSR_INTR;
+#endif
+
 	initialize_SCp(cmd);
 
 	cmd = NULL;
@@ -1557,6 +1586,11 @@ static int NCR5380_transfer_dma(struct S
 	dsprintk(NDEBUG_DMA, instance, "initializing DMA %s: length %d, address %p\n",
 	         (p & SR_IO) ? "receive" : "send", c, d);
 
+#ifdef CONFIG_SUN3
+	/* send start chain */
+	sun3scsi_dma_start(c, *data);
+#endif
+
 	NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(p));
 	NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_MONITOR_BSY |
 	                        MR_ENABLE_EOP_INTR);
@@ -1577,6 +1611,7 @@ static int NCR5380_transfer_dma(struct S
 	 */
 
 	if (p & SR_IO) {
+		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 		NCR5380_io_delay(1);
 		NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0);
 	} else {
@@ -1587,6 +1622,13 @@ static int NCR5380_transfer_dma(struct S
 		NCR5380_io_delay(1);
 	}
 
+#ifdef CONFIG_SUN3
+#ifdef SUN3_SCSI_VME
+	dregs->csr |= CSR_DMA_ENABLE;
+#endif
+	sun3_dma_active = 1;
+#endif
+
 	if (hostdata->flags & FLAG_LATE_DMA_SETUP) {
 		/* On the Falcon, the DMA setup must be done after the last
 		 * NCR access, else the DMA setup gets trashed!
@@ -1718,6 +1760,10 @@ static void NCR5380_information_transfer
 	unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
 	struct scsi_cmnd *cmd;
 
+#ifdef SUN3_SCSI_VME
+	dregs->csr |= CSR_INTR;
+#endif
+
 	while ((cmd = hostdata->connected)) {
 		struct NCR5380_cmd *ncmd = scsi_cmd_priv(cmd);
 
@@ -1729,6 +1775,31 @@ static void NCR5380_information_transfer
 				old_phase = phase;
 				NCR5380_dprint_phase(NDEBUG_INFORMATION, instance);
 			}
+#ifdef CONFIG_SUN3
+			if (phase == PHASE_CMDOUT) {
+				void *d;
+				unsigned long count;
+
+				if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
+					count = cmd->SCp.buffer->length;
+					d = sg_virt(cmd->SCp.buffer);
+				} else {
+					count = cmd->SCp.this_residual;
+					d = cmd->SCp.ptr;
+				}
+
+				if (sun3_dma_setup_done != cmd &&
+				    sun3scsi_dma_xfer_len(count, cmd) > 0) {
+					sun3scsi_dma_setup(instance, d, count,
+					                   rq_data_dir(cmd->request));
+					sun3_dma_setup_done = cmd;
+				}
+#ifdef SUN3_SCSI_VME
+				dregs->csr |= CSR_INTR;
+#endif
+			}
+#endif /* CONFIG_SUN3 */
+
 			if (sink && (phase != PHASE_MSGOUT)) {
 				NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp));
 
@@ -1811,6 +1882,10 @@ static void NCR5380_information_transfer
 					                     (unsigned char **)&cmd->SCp.ptr);
 					cmd->SCp.this_residual -= transfersize - len;
 				}
+#ifdef CONFIG_SUN3
+				if (sun3_dma_setup_done == cmd)
+					sun3_dma_setup_done = NULL;
+#endif
 				return;
 			case PHASE_MSGIN:
 				len = 1;
@@ -1889,6 +1964,9 @@ static void NCR5380_information_transfer
 
 					/* Enable reselect interrupts */
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+#ifdef SUN3_SCSI_VME
+					dregs->csr |= CSR_DMA_ENABLE;
+#endif
 					return;
 					/*
 					 * The SCSI data pointer is *IMPLICITLY* saved on a disconnect
@@ -2040,10 +2118,8 @@ static void NCR5380_reselect(struct Scsi
 {
 	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	unsigned char target_mask;
-	unsigned char lun, phase;
-	int len;
+	unsigned char lun;
 	unsigned char msg[3];
-	unsigned char *data;
 	struct NCR5380_cmd *ncmd;
 	struct scsi_cmnd *tmp;
 
@@ -2085,15 +2161,26 @@ static void NCR5380_reselect(struct Scsi
 		return;
 	}
 
-	len = 1;
-	data = msg;
-	phase = PHASE_MSGIN;
-	NCR5380_transfer_pio(instance, &phase, &len, &data);
+#ifdef CONFIG_SUN3
+	/* acknowledge toggle to MSGIN */
+	NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(PHASE_MSGIN));
+
+	/* peek at the byte without really hitting the bus */
+	msg[0] = NCR5380_read(CURRENT_SCSI_DATA_REG);
+#else
+	{
+		int len = 1;
+		unsigned char *data = msg;
+		unsigned char phase = PHASE_MSGIN;
 
-	if (len) {
-		do_abort(instance);
-		return;
+		NCR5380_transfer_pio(instance, &phase, &len, &data);
+
+		if (len) {
+			do_abort(instance);
+			return;
+		}
 	}
+#endif /* CONFIG_SUN3 */
 
 	if (!(msg[0] & 0x80)) {
 		shost_printk(KERN_ERR, instance, "expecting IDENTIFY message, got ");
@@ -2141,6 +2228,30 @@ static void NCR5380_reselect(struct Scsi
 		return;
 	}
 
+#ifdef CONFIG_SUN3
+	{
+		void *d;
+		unsigned long count;
+
+		if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) {
+			count = tmp->SCp.buffer->length;
+			d = sg_virt(tmp->SCp.buffer);
+		} else {
+			count = tmp->SCp.this_residual;
+			d = tmp->SCp.ptr;
+		}
+
+		if (sun3_dma_setup_done != tmp &&
+		    sun3scsi_dma_xfer_len(count, tmp) > 0) {
+			sun3scsi_dma_setup(instance, d, count,
+			                   rq_data_dir(tmp->request));
+			sun3_dma_setup_done = tmp;
+		}
+	}
+
+	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK);
+#endif /* CONFIG_SUN3 */
+
 	/* Accept message by clearing ACK */
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 

[toc] | [prev] | [next] | [standalone]


#1356903 — [PATCH 06/22] ncr5380: Remove PSEUDO_DMA macro

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 06/22] ncr5380: Remove PSEUDO_DMA macro
Message-ID<rcsC6-7iI-15@gated-at.bofh.it>
In reply to#1356897
For those wrapper drivers which only implement Programmed IO, have
NCR5380_dma_xfer_len() evaluate to zero. That allows PDMA to be easily
disabled at run-time and so the PSEUDO_DMA macro is no longer needed.

Also remove the spin counters used for debugging pseudo DMA drivers.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c      |   32 +-------------------------------
 drivers/scsi/NCR5380.h      |    4 ----
 drivers/scsi/arm/cumana_1.c |    2 --
 drivers/scsi/arm/oak.c      |    3 +--
 drivers/scsi/dmx3191d.c     |    4 ++++
 drivers/scsi/dtc.c          |    7 -------
 drivers/scsi/dtc.h          |    2 --
 drivers/scsi/g_NCR5380.c    |    1 -
 drivers/scsi/g_NCR5380.h    |    1 -
 drivers/scsi/mac_scsi.c     |   10 ----------
 drivers/scsi/pas16.c        |   10 ----------
 drivers/scsi/pas16.h        |    2 --
 drivers/scsi/t128.c         |    4 ----
 drivers/scsi/t128.h         |    2 --
 14 files changed, 6 insertions(+), 78 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:29.000000000 +1100
@@ -469,34 +469,9 @@ static void prepare_info(struct Scsi_Hos
 #ifdef PARITY
 	         "PARITY "
 #endif
-#ifdef PSEUDO_DMA
-	         "PSEUDO_DMA "
-#endif
 	         "");
 }
 
-#ifdef PSEUDO_DMA
-static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
-	char *buffer, int length)
-{
-	struct NCR5380_hostdata *hostdata = shost_priv(instance);
-
-	hostdata->spin_max_r = 0;
-	hostdata->spin_max_w = 0;
-	return 0;
-}
-
-static int __maybe_unused NCR5380_show_info(struct seq_file *m,
-                                            struct Scsi_Host *instance)
-{
-	struct NCR5380_hostdata *hostdata = shost_priv(instance);
-
-	seq_printf(m, "Highwater I/O busy spin counts: write %d, read %d\n",
-	        hostdata->spin_max_w, hostdata->spin_max_r);
-	return 0;
-}
-#endif
-
 /**
  * NCR5380_init - initialise an NCR5380
  * @instance: adapter to configure
@@ -1436,7 +1411,6 @@ timeout:
 	return -1;
 }
 
-#if defined(PSEUDO_DMA)
 /*
  * Function : int NCR5380_transfer_dma (struct Scsi_Host *instance,
  * unsigned char *phase, int *count, unsigned char **data)
@@ -1592,7 +1566,6 @@ static int NCR5380_transfer_dma(struct S
 	*phase = NCR5380_read(STATUS_REG) & PHASE_MASK;
 	return foo;
 }
-#endif /* PSEUDO_DMA */
 
 /*
  * Function : NCR5380_information_transfer (struct Scsi_Host *instance)
@@ -1683,7 +1656,6 @@ static void NCR5380_information_transfer
 				 * in an unconditional loop.
 				 */
 
-#if defined(PSEUDO_DMA)
 				transfersize = 0;
 				if (!cmd->device->borken)
 					transfersize = NCR5380_dma_xfer_len(instance, cmd, phase);
@@ -1706,9 +1678,7 @@ static void NCR5380_information_transfer
 						/* XXX - need to source or sink data here, as appropriate */
 					} else
 						cmd->SCp.this_residual -= transfersize - len;
-				} else
-#endif /* PSEUDO_DMA */
-				{
+				} else {
 					/* Break up transfer into 3 ms chunks,
 					 * presuming 6 accesses per handshake.
 					 */
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/NCR5380.h	2016-03-14 15:26:29.000000000 +1100
@@ -257,10 +257,6 @@ struct NCR5380_hostdata {
 #ifdef SUPPORT_TAGS
 	struct tag_alloc TagAlloc[8][8];	/* 8 targets and 8 LUNs */
 #endif
-#ifdef PSEUDO_DMA
-	unsigned spin_max_r;
-	unsigned spin_max_w;
-#endif
 	struct workqueue_struct *work_q;
 	unsigned long accesses_per_ms;	/* chip register accesses per ms */
 };
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/arm/cumana_1.c	2016-03-14 15:26:29.000000000 +1100
@@ -13,8 +13,6 @@
 
 #include <scsi/scsi_host.h>
 
-#define PSEUDO_DMA
-
 #define priv(host)			((struct NCR5380_hostdata *)(host)->hostdata)
 #define NCR5380_read(reg)		cumanascsi_read(instance, reg)
 #define NCR5380_write(reg, value)	cumanascsi_write(instance, reg, value)
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/arm/oak.c	2016-03-14 15:26:29.000000000 +1100
@@ -14,7 +14,6 @@
 
 #include <scsi/scsi_host.h>
 
-/*#define PSEUDO_DMA*/
 #define DONT_USE_INTR
 
 #define priv(host)			((struct NCR5380_hostdata *)(host)->hostdata)
@@ -24,7 +23,7 @@
 #define NCR5380_write(reg, value) \
 	writeb(value, priv(instance)->base + ((reg) << 2))
 
-#define NCR5380_dma_xfer_len(instance, cmd, phase)	(cmd->transfersize)
+#define NCR5380_dma_xfer_len(instance, cmd, phase)	(0)
 
 #define NCR5380_queue_command		oakscsi_queue_command
 #define NCR5380_info			oakscsi_info
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/dtc.c	2016-03-14 15:26:29.000000000 +1100
@@ -1,4 +1,3 @@
-#define PSEUDO_DMA
 #define DONT_USE_INTR
 
 /*
@@ -352,8 +351,6 @@ static inline int NCR5380_pread(struct S
 	while (!(NCR5380_read(DTC_CONTROL_REG) & D_CR_ACCESS))
 		++i;
 	rtrc(0);
-	if (i > hostdata->spin_max_r)
-		hostdata->spin_max_r = i;
 	return (0);
 }
 
@@ -400,8 +397,6 @@ static inline int NCR5380_pwrite(struct
 	rtrc(7);
 	/* Check for parity error here. fixme. */
 	rtrc(0);
-	if (i > hostdata->spin_max_w)
-		hostdata->spin_max_w = i;
 	return (0);
 }
 
@@ -440,8 +435,6 @@ static struct scsi_host_template driver_
 	.detect			= dtc_detect,
 	.release		= dtc_release,
 	.proc_name		= "dtc3x80",
-	.show_info		= dtc_show_info,
-	.write_info		= dtc_write_info,
 	.info			= dtc_info,
 	.queuecommand		= dtc_queue_command,
 	.eh_abort_handler	= dtc_abort,
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/g_NCR5380.c	2016-03-14 15:26:29.000000000 +1100
@@ -57,7 +57,6 @@
  */
 
 #define AUTOPROBE_IRQ
-#define PSEUDO_DMA
 
 #include <asm/io.h>
 #include <linux/blkdev.h>
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2016-03-14 15:26:22.000000000 +1100
+++ linux/drivers/scsi/mac_scsi.c	2016-03-14 15:26:29.000000000 +1100
@@ -28,8 +28,6 @@
 
 /* Definitions for the core NCR5380 driver. */
 
-#define PSEUDO_DMA
-
 #define NCR5380_implementation_fields   unsigned char *pdma_base
 
 #define NCR5380_read(reg)               macscsi_read(instance, reg)
@@ -46,8 +44,6 @@
 #define NCR5380_abort                   macscsi_abort
 #define NCR5380_bus_reset               macscsi_bus_reset
 #define NCR5380_info                    macscsi_info
-#define NCR5380_show_info               macscsi_show_info
-#define NCR5380_write_info              macscsi_write_info
 
 #include "NCR5380.h"
 
@@ -111,7 +107,6 @@ static int __init mac_scsi_setup(char *s
 __setup("mac5380=", mac_scsi_setup);
 #endif /* !MODULE */
 
-#ifdef PSEUDO_DMA
 /* 
    Pseudo-DMA: (Ove Edlund)
    The code attempts to catch bus errors that occur if one for example
@@ -303,7 +298,6 @@ static int macscsi_pwrite(struct Scsi_Ho
 
 	return 0;
 }
-#endif
 
 static int macscsi_dma_xfer_len(struct Scsi_Host *instance,
                                 struct scsi_cmnd *cmd)
@@ -324,8 +318,6 @@ static int macscsi_dma_xfer_len(struct S
 static struct scsi_host_template mac_scsi_template = {
 	.module			= THIS_MODULE,
 	.proc_name		= DRV_MODULE_NAME,
-	.show_info		= macscsi_show_info,
-	.write_info		= macscsi_write_info,
 	.name			= "Macintosh NCR5380 SCSI",
 	.info			= macscsi_info,
 	.queuecommand		= macscsi_queue_command,
@@ -351,9 +343,7 @@ static int __init mac_scsi_probe(struct
 	if (!pio_mem)
 		return -ENODEV;
 
-#ifdef PSEUDO_DMA
 	pdma_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-#endif
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/pas16.c	2016-03-14 15:26:29.000000000 +1100
@@ -1,5 +1,3 @@
-#define PSEUDO_DMA
-
 /*
  * This driver adapted from Drew Eckhardt's Trantor T128 driver
  *
@@ -479,7 +477,6 @@ static inline int NCR5380_pread (struct
 	P_DATA_REG_OFFSET);
     register int i = len;
     int ii = 0;
-    struct NCR5380_hostdata *hostdata = shost_priv(instance);
 
     while ( !(inb(instance->io_port + P_STATUS_REG_OFFSET) & P_ST_RDY) )
 	 ++ii;
@@ -492,8 +489,6 @@ static inline int NCR5380_pread (struct
 	    instance->host_no);
 	return -1;
     }
-    if (ii > hostdata->spin_max_r)
-        hostdata->spin_max_r = ii;
     return 0;
 }
 
@@ -516,7 +511,6 @@ static inline int NCR5380_pwrite (struct
     register unsigned short reg = (instance->io_port + P_DATA_REG_OFFSET);
     register int i = len;
     int ii = 0;
-    struct NCR5380_hostdata *hostdata = shost_priv(instance);
 
     while ( !((inb(instance->io_port + P_STATUS_REG_OFFSET)) & P_ST_RDY) )
 	 ++ii;
@@ -529,8 +523,6 @@ static inline int NCR5380_pwrite (struct
 	    instance->host_no);
 	return -1;
     }
-    if (ii > hostdata->spin_max_w)
-        hostdata->spin_max_w = ii;
     return 0;
 }
 
@@ -550,8 +542,6 @@ static struct scsi_host_template driver_
 	.detect			= pas16_detect,
 	.release		= pas16_release,
 	.proc_name		= "pas16",
-	.show_info		= pas16_show_info,
-	.write_info		= pas16_write_info,
 	.info			= pas16_info,
 	.queuecommand		= pas16_queue_command,
 	.eh_abort_handler	= pas16_abort,
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2016-03-14 15:26:27.000000000 +1100
+++ linux/drivers/scsi/t128.c	2016-03-14 15:26:29.000000000 +1100
@@ -1,5 +1,3 @@
-#define PSEUDO_DMA
-
 /*
  * Trantor T128/T128F/T228 driver
  *	Note : architecturally, the T100 and T130 are different and won't 
@@ -394,8 +392,6 @@ static struct scsi_host_template driver_
 	.detect			= t128_detect,
 	.release		= t128_release,
 	.proc_name		= "t128",
-	.show_info		= t128_show_info,
-	.write_info		= t128_write_info,
 	.info			= t128_info,
 	.queuecommand		= t128_queue_command,
 	.eh_abort_handler	= t128_abort,
Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2016-03-14 15:26:22.000000000 +1100
+++ linux/drivers/scsi/dmx3191d.c	2016-03-14 15:26:29.000000000 +1100
@@ -39,6 +39,10 @@
 #define NCR5380_read(reg)		inb(instance->io_port + reg)
 #define NCR5380_write(reg, value)	outb(value, instance->io_port + reg)
 
+#define NCR5380_dma_xfer_len(instance, cmd, phase)	(0)
+#define NCR5380_pread(instance, dst, len)		(0)
+#define NCR5380_pwrite(instance, src, len)		(0)
+
 #define NCR5380_implementation_fields	/* none */
 
 #include "NCR5380.h"
Index: linux/drivers/scsi/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/dtc.h	2016-03-14 15:26:29.000000000 +1100
@@ -27,8 +27,6 @@
 #define NCR5380_abort			dtc_abort
 #define NCR5380_bus_reset		dtc_bus_reset
 #define NCR5380_info			dtc_info
-#define NCR5380_show_info		dtc_show_info 
-#define NCR5380_write_info		dtc_write_info 
 
 /* 15 12 11 10
    1001 1100 0000 0000 */
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2016-03-14 15:26:22.000000000 +1100
+++ linux/drivers/scsi/g_NCR5380.h	2016-03-14 15:26:29.000000000 +1100
@@ -70,7 +70,6 @@
 #define NCR5380_pread generic_NCR5380_pread
 #define NCR5380_pwrite generic_NCR5380_pwrite
 #define NCR5380_info generic_NCR5380_info
-#define NCR5380_show_info generic_NCR5380_show_info
 
 #define BOARD_NCR5380	0
 #define BOARD_NCR53C400	1
Index: linux/drivers/scsi/pas16.h
===================================================================
--- linux.orig/drivers/scsi/pas16.h	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/pas16.h	2016-03-14 15:26:29.000000000 +1100
@@ -109,8 +109,6 @@
 #define NCR5380_abort pas16_abort
 #define NCR5380_bus_reset pas16_bus_reset
 #define NCR5380_info pas16_info
-#define NCR5380_show_info pas16_show_info
-#define NCR5380_write_info pas16_write_info
 
 /* 15 14 12 10 7 5 3 
    1101 0100 1010 1000 */
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2016-03-14 15:17:25.000000000 +1100
+++ linux/drivers/scsi/t128.h	2016-03-14 15:26:29.000000000 +1100
@@ -83,8 +83,6 @@
 #define NCR5380_abort t128_abort
 #define NCR5380_bus_reset t128_bus_reset
 #define NCR5380_info t128_info
-#define NCR5380_show_info t128_show_info
-#define NCR5380_write_info t128_write_info
 
 /* 15 14 12 10 7 5 3
    1101 0100 1010 1000 */

[toc] | [prev] | [next] | [standalone]


#1356904 — [PATCH 17/22] ncr5380: Remove remaining register storage qualifiers

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 17/22] ncr5380: Remove remaining register storage qualifiers
Message-ID<rcsC6-7iI-19@gated-at.bofh.it>
In reply to#1356897
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:50.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:51.000000000 +1100
@@ -1559,9 +1559,9 @@ static int NCR5380_transfer_dma(struct S
 				unsigned char **data)
 {
 	struct NCR5380_hostdata *hostdata = shost_priv(instance);
-	register int c = *count;
-	register unsigned char p = *phase;
-	register unsigned char *d = *data;
+	int c = *count;
+	unsigned char p = *phase;
+	unsigned char *d = *data;
 	unsigned char tmp;
 	int result = 0;
 

[toc] | [prev] | [next] | [standalone]


#1356906 — [PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver
Message-ID<rcsC6-7iI-23@gated-at.bofh.it>
In reply to#1356897
Add support for the Atari ST DMA chip to the NCR5380.c core driver.
This code is copied from atari_NCR5380.c.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c    |   32 ++++++++++++++++++++++++++++++++
 drivers/scsi/atari_scsi.c |    6 +++---
 2 files changed, 35 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:39.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:42.000000000 +1100
@@ -29,6 +29,8 @@
  * Ronald van Cuijlenborg, Alan Cox and others.
  */
 
+/* Ported to Atari by Roman Hodek and others. */
+
 /*
  * Further development / testing that should be done :
  *
@@ -141,6 +143,14 @@
 #define NCR5380_io_delay(x)
 #endif
 
+#ifndef NCR5380_acquire_dma_irq
+#define NCR5380_acquire_dma_irq(x)	(1)
+#endif
+
+#ifndef NCR5380_release_dma_irq
+#define NCR5380_release_dma_irq(x)
+#endif
+
 static int do_abort(struct Scsi_Host *);
 static void do_reset(struct Scsi_Host *);
 
@@ -658,6 +668,9 @@ static int NCR5380_queue_command(struct
 
 	cmd->result = 0;
 
+	if (!NCR5380_acquire_dma_irq(instance))
+		return SCSI_MLQUEUE_HOST_BUSY;
+
 	spin_lock_irqsave(&hostdata->lock, flags);
 
 	/*
@@ -682,6 +695,19 @@ static int NCR5380_queue_command(struct
 	return 0;
 }
 
+static inline void maybe_release_dma_irq(struct Scsi_Host *instance)
+{
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	/* Caller does the locking needed to set & test these data atomically */
+	if (list_empty(&hostdata->disconnected) &&
+	    list_empty(&hostdata->unissued) &&
+	    list_empty(&hostdata->autosense) &&
+	    !hostdata->connected &&
+	    !hostdata->selecting)
+		NCR5380_release_dma_irq(instance);
+}
+
 /**
  * dequeue_next_cmd - dequeue a command for processing
  * @instance: the scsi host instance
@@ -783,6 +809,7 @@ static void NCR5380_main(struct work_str
 
 			if (!NCR5380_select(instance, cmd)) {
 				dsprintk(NDEBUG_MAIN, instance, "main: select complete\n");
+				maybe_release_dma_irq(instance);
 			} else {
 				dsprintk(NDEBUG_MAIN | NDEBUG_QUEUES, instance,
 				         "main: select failed, returning %p to queue\n", cmd);
@@ -1828,6 +1855,8 @@ static void NCR5380_information_transfer
 
 					/* Enable reselect interrupts */
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
+
+					maybe_release_dma_irq(instance);
 					return;
 				case MESSAGE_REJECT:
 					/* Accept message by clearing ACK */
@@ -1963,6 +1992,7 @@ static void NCR5380_information_transfer
 					hostdata->connected = NULL;
 					cmd->result = DID_ERROR << 16;
 					complete_cmd(instance, cmd);
+					maybe_release_dma_irq(instance);
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 					return;
 				}
@@ -2256,6 +2286,7 @@ out:
 		dsprintk(NDEBUG_ABORT, instance, "abort: successfully aborted %p\n", cmd);
 
 	queue_work(hostdata->work_q, &hostdata->main_task);
+	maybe_release_dma_irq(instance);
 	spin_unlock_irqrestore(&hostdata->lock, flags);
 
 	return result;
@@ -2336,6 +2367,7 @@ static int NCR5380_bus_reset(struct scsi
 	hostdata->dma_len = 0;
 
 	queue_work(hostdata->work_q, &hostdata->main_task);
+	maybe_release_dma_irq(instance);
 	spin_unlock_irqrestore(&hostdata->lock, flags);
 
 	return SUCCESS;
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2016-03-14 15:26:37.000000000 +1100
+++ linux/drivers/scsi/atari_scsi.c	2016-03-14 15:26:42.000000000 +1100
@@ -97,9 +97,9 @@
 #define NCR5380_abort                   atari_scsi_abort
 #define NCR5380_info                    atari_scsi_info
 
-#define NCR5380_dma_read_setup(instance, data, count) \
+#define NCR5380_dma_recv_setup(instance, data, count) \
         atari_scsi_dma_setup(instance, data, count, 0)
-#define NCR5380_dma_write_setup(instance, data, count) \
+#define NCR5380_dma_send_setup(instance, data, count) \
         atari_scsi_dma_setup(instance, data, count, 1)
 #define NCR5380_dma_residual(instance) \
         atari_scsi_dma_residual(instance)
@@ -713,7 +713,7 @@ static void atari_scsi_falcon_reg_write(
 }
 
 
-#include "atari_NCR5380.c"
+#include "NCR5380.c"
 
 static int atari_scsi_bus_reset(struct scsi_cmnd *cmd)
 {

[toc] | [prev] | [next] | [standalone]


#1356999 — Re: [PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver

FromHannes Reinecke <hare@suse.de>
Date2016-03-14 08:40 +0100
SubjectRe: [PATCH 11/22] atari_scsi: Adopt NCR5380.c core driver
Message-ID<rcvgB-Hl-11@gated-at.bofh.it>
In reply to#1356906
On 03/14/2016 05:27 AM, Finn Thain wrote:
> Add support for the Atari ST DMA chip to the NCR5380.c core driver.
> This code is copied from atari_NCR5380.c.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
> ---
>  drivers/scsi/NCR5380.c    |   32 ++++++++++++++++++++++++++++++++
>  drivers/scsi/atari_scsi.c |    6 +++---
>  2 files changed, 35 insertions(+), 3 deletions(-)
> 
Reviewd-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1356909 — [PATCH 15/22] dmx3191d: Drop max_sectors limit

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 15/22] dmx3191d: Drop max_sectors limit
Message-ID<rcsC6-7iI-31@gated-at.bofh.it>
In reply to#1356897
The dmx3191d driver is not capable of DMA or PDMA so all transfers
use PIO. Now that large slow PIO transfers periodically stop and call
cond_resched(), the max_sectors limit can go away.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/dmx3191d.c |    1 -
 1 file changed, 1 deletion(-)

Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2016-03-14 15:26:39.000000000 +1100
+++ linux/drivers/scsi/dmx3191d.c	2016-03-14 15:26:49.000000000 +1100
@@ -67,7 +67,6 @@ static struct scsi_host_template dmx3191
 	.cmd_per_lun		= 2,
 	.use_clustering		= DISABLE_CLUSTERING,
 	.cmd_size		= NCR5380_CMD_SIZE,
-	.max_sectors		= 128,
 };
 
 static int dmx3191d_probe_one(struct pci_dev *pdev,

[toc] | [prev] | [next] | [standalone]


#1356911 — [PATCH 14/22] ncr5380: Add MAX_LUN limit

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 14/22] ncr5380: Add MAX_LUN limit
Message-ID<rcsC7-7iI-37@gated-at.bofh.it>
In reply to#1356897
The driver has a limit of eight LUs because of the byte-sized bitfield
that is used for busy flags. Reject commands with LUN > 7.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c |    6 ++++++
 drivers/scsi/NCR5380.h |    2 ++
 2 files changed, 8 insertions(+)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:45.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:48.000000000 +1100
@@ -661,6 +661,12 @@ static int NCR5380_queue_command(struct
 	}
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
 
+	if (cmd->device->lun > MAX_LUN) {
+		cmd->result = DID_NO_CONNECT << 16;
+		cmd->scsi_done(cmd);
+		return 0;
+	}
+
 	cmd->result = 0;
 
 	if (!NCR5380_acquire_dma_irq(instance))
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2016-03-14 15:26:45.000000000 +1100
+++ linux/drivers/scsi/NCR5380.h	2016-03-14 15:26:48.000000000 +1100
@@ -244,6 +244,8 @@ struct NCR5380_hostdata {
 
 #ifdef __KERNEL__
 
+#define MAX_LUN	7
+
 struct NCR5380_cmd {
 	struct list_head list;
 };

[toc] | [prev] | [next] | [standalone]


#1357012 — Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit

FromHannes Reinecke <hare@suse.de>
Date2016-03-14 08:50 +0100
SubjectRe: [PATCH 14/22] ncr5380: Add MAX_LUN limit
Message-ID<rcvqh-KB-7@gated-at.bofh.it>
In reply to#1356911
On 03/14/2016 05:27 AM, Finn Thain wrote:
> The driver has a limit of eight LUs because of the byte-sized bitfield
> that is used for busy flags. Reject commands with LUN > 7.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
> ---
>  drivers/scsi/NCR5380.c |    6 ++++++
>  drivers/scsi/NCR5380.h |    2 ++
>  2 files changed, 8 insertions(+)
> 
> Index: linux/drivers/scsi/NCR5380.c
> ===================================================================
> --- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:45.000000000 +1100
> +++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:48.000000000 +1100
> @@ -661,6 +661,12 @@ static int NCR5380_queue_command(struct
>  	}
>  #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
>  
> +	if (cmd->device->lun > MAX_LUN) {
> +		cmd->result = DID_NO_CONNECT << 16;
> +		cmd->scsi_done(cmd);
> +		return 0;
> +	}
> +
>  	cmd->result = 0;
>  
>  	if (!NCR5380_acquire_dma_irq(instance))
> Index: linux/drivers/scsi/NCR5380.h
> ===================================================================
> --- linux.orig/drivers/scsi/NCR5380.h	2016-03-14 15:26:45.000000000 +1100
> +++ linux/drivers/scsi/NCR5380.h	2016-03-14 15:26:48.000000000 +1100
> @@ -244,6 +244,8 @@ struct NCR5380_hostdata {
>  
>  #ifdef __KERNEL__
>  
> +#define MAX_LUN	7
> +
>  struct NCR5380_cmd {
>  	struct list_head list;
>  };
> 
> 
Why not simply use shost->max_lun ?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1357023 — Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit

FromChristoph Hellwig <hch@infradead.org>
Date2016-03-14 09:00 +0100
SubjectRe: [PATCH 14/22] ncr5380: Add MAX_LUN limit
Message-ID<rcvzY-O1-11@gated-at.bofh.it>
In reply to#1356911
On Mon, Mar 14, 2016 at 03:27:14PM +1100, Finn Thain wrote:
> The driver has a limit of eight LUs because of the byte-sized bitfield
> that is used for busy flags. Reject commands with LUN > 7.

Please just set the max_lun parameter in the host template, which will
take care of this.

[toc] | [prev] | [next] | [standalone]


#1357787 — Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-15 04:30 +0100
SubjectRe: [PATCH 14/22] ncr5380: Add MAX_LUN limit
Message-ID<rcNQd-4LQ-1@gated-at.bofh.it>
In reply to#1357023
On Mon, 14 Mar 2016, Christoph Hellwig wrote:

> On Mon, Mar 14, 2016 at 03:27:14PM +1100, Finn Thain wrote:
> > The driver has a limit of eight LUs because of the byte-sized bitfield
> > that is used for busy flags. Reject commands with LUN > 7.
> 
> Please just set the max_lun parameter in the host template, which will 
> take care of this.

The reason I didn't do that initially was that I could not convince myself 
that all command submission paths would enforce the shost->max_lun limit. 
But I'll take your word for it.

I don't think the host template is the right place for this (there are 
about ten of these that would need to be changed anyway) because 
scsi_host_alloc() assigns shost->max_lun = 8. So I'll add the 
instance->max_lun = 7 assignment to NCR5380_init().

-- 

[toc] | [prev] | [next] | [standalone]


#1357896 — Re: [PATCH 14/22] ncr5380: Add MAX_LUN limit

FromChristoph Hellwig <hch@infradead.org>
Date2016-03-15 09:30 +0100
SubjectRe: [PATCH 14/22] ncr5380: Add MAX_LUN limit
Message-ID<rcSwy-7WK-19@gated-at.bofh.it>
In reply to#1357787
On Tue, Mar 15, 2016 at 02:20:55PM +1100, Finn Thain wrote:
> I don't think the host template is the right place for this (there are 
> about ten of these that would need to be changed anyway) because 
> scsi_host_alloc() assigns shost->max_lun = 8. So I'll add the 
> instance->max_lun = 7 assignment to NCR5380_init().

Ok.

[toc] | [prev] | [next] | [standalone]


#1356912 — [PATCH 07/22] ncr5380: Remove BOARD_REQUIRES_NO_DELAY macro

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 07/22] ncr5380: Remove BOARD_REQUIRES_NO_DELAY macro
Message-ID<rcsC7-7iI-39@gated-at.bofh.it>
In reply to#1356897
The io_recovery_delay macro is intended to insert a microsecond delay
between the chip register accesses that begin a DMA operation. This
is reportedly needed for some ISA boards.

Reverse the sense of the macro test so that in the common case,
where no delay is required, drivers need not define the macro.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/NCR5380.c   |   18 ++++++++----------
 drivers/scsi/dtc.h       |    2 ++
 drivers/scsi/g_NCR5380.h |    2 ++
 drivers/scsi/t128.h      |    2 ++
 4 files changed, 14 insertions(+), 10 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2016-03-14 15:26:29.000000000 +1100
+++ linux/drivers/scsi/NCR5380.c	2016-03-14 15:26:32.000000000 +1100
@@ -39,12 +39,6 @@
  * tagged queueing)
  */
 
-#ifdef BOARD_REQUIRES_NO_DELAY
-#define io_recovery_delay(x)
-#else
-#define io_recovery_delay(x)	udelay(x)
-#endif
-
 /*
  * Design
  *
@@ -150,6 +144,10 @@
  * possible) function may be used.
  */
 
+#ifndef NCR5380_io_delay
+#define NCR5380_io_delay(x)
+#endif
+
 static int do_abort(struct Scsi_Host *);
 static void do_reset(struct Scsi_Host *);
 
@@ -1468,14 +1466,14 @@ static int NCR5380_transfer_dma(struct S
 	 */
 
 	if (p & SR_IO) {
-		io_recovery_delay(1);
+		NCR5380_io_delay(1);
 		NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0);
 	} else {
-		io_recovery_delay(1);
+		NCR5380_io_delay(1);
 		NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA);
-		io_recovery_delay(1);
+		NCR5380_io_delay(1);
 		NCR5380_write(START_DMA_SEND_REG, 0);
-		io_recovery_delay(1);
+		NCR5380_io_delay(1);
 	}
 
 /*
Index: linux/drivers/scsi/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2016-03-14 15:26:29.000000000 +1100
+++ linux/drivers/scsi/dtc.h	2016-03-14 15:26:32.000000000 +1100
@@ -28,6 +28,8 @@
 #define NCR5380_bus_reset		dtc_bus_reset
 #define NCR5380_info			dtc_info
 
+#define NCR5380_io_delay(x)		udelay(x)
+
 /* 15 12 11 10
    1001 1100 0000 0000 */
 
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2016-03-14 15:26:29.000000000 +1100
+++ linux/drivers/scsi/g_NCR5380.h	2016-03-14 15:26:32.000000000 +1100
@@ -71,6 +71,8 @@
 #define NCR5380_pwrite generic_NCR5380_pwrite
 #define NCR5380_info generic_NCR5380_info
 
+#define NCR5380_io_delay(x)		udelay(x)
+
 #define BOARD_NCR5380	0
 #define BOARD_NCR53C400	1
 #define BOARD_NCR53C400A 2
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2016-03-14 15:26:29.000000000 +1100
+++ linux/drivers/scsi/t128.h	2016-03-14 15:26:32.000000000 +1100
@@ -84,6 +84,8 @@
 #define NCR5380_bus_reset t128_bus_reset
 #define NCR5380_info t128_info
 
+#define NCR5380_io_delay(x)		udelay(x)
+
 /* 15 14 12 10 7 5 3
    1101 0100 1010 1000 */
 

[toc] | [prev] | [next] | [standalone]


#1356913 — [PATCH 20/22] atari_scsi: Set a reasonable default for cmd_per_lun

FromFinn Thain <fthain@telegraphics.com.au>
Date2016-03-14 05:50 +0100
Subject[PATCH 20/22] atari_scsi: Set a reasonable default for cmd_per_lun
Message-ID<rcsC7-7iI-43@gated-at.bofh.it>
In reply to#1356897
This setting does not need to be conditional on Atari ST or TT.

Without TCQ support, cmd_per_lun == 2 is probably reasonable...

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>

---
 drivers/scsi/atari_scsi.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2016-03-14 15:26:45.000000000 +1100
+++ linux/drivers/scsi/atari_scsi.c	2016-03-14 15:26:55.000000000 +1100
@@ -750,6 +750,7 @@ static struct scsi_host_template atari_s
 	.eh_abort_handler	= atari_scsi_abort,
 	.eh_bus_reset_handler	= atari_scsi_bus_reset,
 	.this_id		= 7,
+	.cmd_per_lun		= 2,
 	.use_clustering		= DISABLE_CLUSTERING,
 	.cmd_size		= NCR5380_CMD_SIZE,
 };
@@ -786,11 +787,9 @@ static int __init atari_scsi_probe(struc
 	 */
 	if (ATARIHW_PRESENT(TT_SCSI)) {
 		atari_scsi_template.can_queue    = 16;
-		atari_scsi_template.cmd_per_lun  = 8;
 		atari_scsi_template.sg_tablesize = SG_ALL;
 	} else {
 		atari_scsi_template.can_queue    = 8;
-		atari_scsi_template.cmd_per_lun  = 1;
 		atari_scsi_template.sg_tablesize = SG_NONE;
 	}
 

[toc] | [prev] | [next] | [standalone]


#1357011 — Re: [PATCH 20/22] atari_scsi: Set a reasonable default for cmd_per_lun

FromHannes Reinecke <hare@suse.de>
Date2016-03-14 08:50 +0100
SubjectRe: [PATCH 20/22] atari_scsi: Set a reasonable default for cmd_per_lun
Message-ID<rcvqh-KB-3@gated-at.bofh.it>
In reply to#1356913
On 03/14/2016 05:27 AM, Finn Thain wrote:
> This setting does not need to be conditional on Atari ST or TT.
> 
> Without TCQ support, cmd_per_lun == 2 is probably reasonable...
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
> ---
>  drivers/scsi/atari_scsi.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> Index: linux/drivers/scsi/atari_scsi.c
> ===================================================================
> --- linux.orig/drivers/scsi/atari_scsi.c	2016-03-14 15:26:45.000000000 +1100
> +++ linux/drivers/scsi/atari_scsi.c	2016-03-14 15:26:55.000000000 +1100
> @@ -750,6 +750,7 @@ static struct scsi_host_template atari_s
>  	.eh_abort_handler	= atari_scsi_abort,
>  	.eh_bus_reset_handler	= atari_scsi_bus_reset,
>  	.this_id		= 7,
> +	.cmd_per_lun		= 2,
>  	.use_clustering		= DISABLE_CLUSTERING,
>  	.cmd_size		= NCR5380_CMD_SIZE,
>  };
_2_ ? Are you being overly cheeky here?
I sincerely doubt the driver is capable of submitting two
simultaneous commands ...
Care to explain?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


Page 1 of 3  [1] 2 3  Next page →

Back to top | Article view | linux.kernel


csiph-web