All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers
@ 2014-10-02  6:56 Finn Thain
  2014-10-02  6:56 ` [PATCH 01/29] ncr5380: Use printk() not pr_debug() Finn Thain
                   ` (28 more replies)
  0 siblings, 29 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k


This patch series has fixes for bugs and compiler warnings as well as code
cleanup and modernization. It covers all ten NCR5380 drivers and the three
core NCR5380 drivers so it's fairly large.

At the end of this series about a thousand lines (net) have been removed
including two header files. A lot of C pre-processor abuse is eliminated.
There are patches for scsi_add_host() conversion for atari_scsi, mac_scsi
and sun3_scsi.

Some steps are taken toward re-unification of the NCR5380 core driver forks
by reducing divergence between them. Also, the atari_NCR5380.c core driver
is generalized such that it can be used by sun3_scsi.c. The next step is
to remove sun_NCR5380.c by adopting atari_NCR5380.c.

I have compile-tested all of the NCR5380 drivers (x86, ARM and m68k) and
executed mac_scsi and dmx3191d on suitable hardware. I found no regressions
but the core NCR5380 drivers have bugs unrelated to these patches.

Testing mac_scsi and dmx3191d provides only limited code coverage for these
patches. Some testing on Sun 3, Atari ST and/or Atari TT would be nice
(I don't have the hardware).

There are old bugs relating to exception handling and autosense in the
core NCR5380 drivers that can make testing difficult. I'm working on a series
of patches to address these bugs. Those patches are not yet ready for
submission but they were helpful in testing this patch series and may be
helpful to other testers. Let me know if so.

---
 arch/m68k/atari/config.c            |    5 
 arch/m68k/atari/stdma.c             |   62 ++-
 arch/m68k/include/asm/atari_stdma.h |    4 
 arch/m68k/include/asm/macintosh.h   |    3 
 arch/m68k/mac/config.c              |  101 ++++-
 arch/m68k/sun3/config.c             |   11 
 drivers/scsi/Kconfig                |    2 
 drivers/scsi/NCR5380.c              |  296 +++++----------
 drivers/scsi/NCR5380.h              |   59 +--
 drivers/scsi/arm/cumana_1.c         |   18 
 drivers/scsi/arm/oak.c              |   21 -
 drivers/scsi/atari_NCR5380.c        |  383 ++++++++------------
 drivers/scsi/atari_scsi.c           |  677 +++++++++++++++---------------------
 drivers/scsi/atari_scsi.h           |   60 ---
 drivers/scsi/dmx3191d.c             |   31 -
 drivers/scsi/dtc.c                  |   85 +---
 drivers/scsi/dtc.h                  |   26 -
 drivers/scsi/g_NCR5380.c            |  224 -----------
 drivers/scsi/g_NCR5380.h            |   26 -
 drivers/scsi/mac_scsi.c             |  545 ++++++++++++----------------
 drivers/scsi/mac_scsi.h             |   74 ---
 drivers/scsi/pas16.c                |  106 +----
 drivers/scsi/pas16.h                |   21 -
 drivers/scsi/sun3_NCR5380.c         |  187 ++-------
 drivers/scsi/sun3_scsi.c            |  518 ++++++++++++---------------
 drivers/scsi/sun3_scsi.h            |   75 ---
 drivers/scsi/t128.c                 |   83 +---
 drivers/scsi/t128.h                 |   23 -
 28 files changed, 1366 insertions(+), 2360 deletions(-)





^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 01/29] ncr5380: Use printk() not pr_debug()
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-06  9:11   ` Hannes Reinecke
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                   ` (27 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-use-printk-not-pr_debug --]
[-- Type: text/plain, Size: 941 bytes --]

Having defined NDEBUG, and having set the console log level, I'd like to see
some output. Don't use pr_debug(), it's annoying to have to define DEBUG as
well.

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

---

Use of pr_debug() here was a bad idea of mine. Joe was right when
he questioned it.

---
 drivers/scsi/NCR5380.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:55:49.000000000 +1000
@@ -296,7 +296,8 @@ struct NCR5380_hostdata {
 #endif
 
 #define dprintk(flg, fmt, ...) \
-	do { if ((NDEBUG) & (flg)) pr_debug(fmt, ## __VA_ARGS__); } while (0)
+	do { if ((NDEBUG) & (flg)) \
+		printk(KERN_DEBUG fmt, ## __VA_ARGS__); } while (0)
 
 #if NDEBUG
 #define NCR5380_dprint(flg, arg) \



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 02/29] ncr5380: Remove unused hostdata fields
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
  2014-10-02  6:56 ` [PATCH 01/29] ncr5380: Use printk() not pr_debug() Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-06  9:12   ` Hannes Reinecke
  2014-10-02  6:56 ` [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options Finn Thain
                   ` (26 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-unused-hostdata --]
[-- Type: text/plain, Size: 4293 bytes --]

Remove unused fields from hostdata structs declared with the
NCR5380_implementation_fields macro.

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

---
 drivers/scsi/dmx3191d.c  |    4 ++--
 drivers/scsi/mac_scsi.c  |   33 ---------------------------------
 drivers/scsi/mac_scsi.h  |    3 +--
 drivers/scsi/sun3_scsi.c |    2 --
 drivers/scsi/sun3_scsi.h |    3 +--
 5 files changed, 4 insertions(+), 41 deletions(-)

Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:55:50.000000000 +1000
@@ -38,8 +38,8 @@
 #define NCR5380_read(reg)		inb(port + reg)
 #define NCR5380_write(reg, value)	outb(value, port + reg)
 
-#define NCR5380_implementation_fields	unsigned int port
-#define NCR5380_local_declare()		NCR5380_implementation_fields
+#define NCR5380_implementation_fields	/* none */
+#define NCR5380_local_declare()		unsigned int port
 #define NCR5380_setup(instance)		port = instance->io_port
 
 /*
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:55:50.000000000 +1000
@@ -93,35 +93,6 @@ static volatile unsigned char *mac_scsi_
  * NCR 5380 register access functions
  */
 
-#if 0
-/* Debug versions */
-#define CTRL(p,v) (*ctrl = (v))
-
-static char macscsi_read(struct Scsi_Host *instance, int reg)
-{
-  int iobase = instance->io_port;
-  int i;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  i = in_8(iobase + (reg<<4));
-  CTRL(iobase, 0x40);
-
-  return i;
-}
-
-static void macscsi_write(struct Scsi_Host *instance, int reg, int value)
-{
-  int iobase = instance->io_port;
-  int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
-
-  CTRL(iobase, 0);
-  out_8(iobase + (reg<<4), value);
-  CTRL(iobase, 0x40);
-}
-#else
-
-/* Fast versions */
 static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
 {
   return in_8(instance->io_port + (reg<<4));
@@ -131,8 +102,6 @@ static __inline__ void macscsi_write(str
 {
   out_8(instance->io_port + (reg<<4), value);
 }
-#endif
-
 
 /*
  * Function : mac_scsi_setup(char *str)
@@ -279,8 +248,6 @@ int __init macscsi_detect(struct scsi_ho
 
     instance->n_io_port = 255;
 
-    ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
-
     if (instance->irq != SCSI_IRQ_NONE)
 	if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) {
 	    printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.h	2014-10-02 16:55:50.000000000 +1000
@@ -47,8 +47,7 @@
 
 #include <scsi/scsicam.h>
 
-#define NCR5380_implementation_fields \
-    int port, ctrl
+#define NCR5380_implementation_fields /* none */
 
 #define NCR5380_local_declare() \
         struct Scsi_Host *_instance
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:50.000000000 +1000
@@ -313,8 +313,6 @@ static int __init sun3scsi_detect(struct
 
 	instance->n_io_port = 32;
 
-        ((struct NCR5380_hostdata *)instance->hostdata)->ctrl = 0;
-
 	if (request_irq(instance->irq, scsi_sun3_intr,
 			     0, "Sun3SCSI-5380", instance)) {
 #ifndef REAL_DMA
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:50.000000000 +1000
@@ -78,8 +78,7 @@ static int sun3scsi_release (struct Scsi
 #define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI"
 #endif
 
-#define NCR5380_implementation_fields \
-    int port, ctrl
+#define NCR5380_implementation_fields /* none */
 
 #define NCR5380_local_declare() \
         struct Scsi_Host *_instance



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
  2014-10-02  6:56 ` [PATCH 01/29] ncr5380: Use printk() not pr_debug() Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-06  9:19   ` Hannes Reinecke
  2014-10-02  6:56   ` Finn Thain
                   ` (25 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-fix-compiler-warnings-and-setup --]
[-- Type: text/plain, Size: 3570 bytes --]

Some __setup() options mentioned in Documentation/scsi don't work because
a few lines of code went missing sometime since Linux 2.4. Fix the options
and thus fix some compiler warnings for both the non-modular case,

    CC      drivers/scsi/dtc.o
drivers/scsi/dtc.c:176:20: warning: 'dtc_setup' defined but not used [-Wunused-function]

and the modular case,

    CC [M]  drivers/scsi/pas16.o
drivers/scsi/pas16.c:335:20: warning: 'pas16_setup' defined but not used [-Wunused-function]
    CC [M]  drivers/scsi/t128.o
drivers/scsi/t128.c:147:20: warning: 't128_setup' defined but not used [-Wunused-function]

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

---
 drivers/scsi/dtc.c   |    8 +++++++-
 drivers/scsi/pas16.c |   10 +++++++++-
 drivers/scsi/t128.c  |   11 ++++++++++-
 3 files changed, 26 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:55:51.000000000 +1000
@@ -173,10 +173,13 @@ static const struct signature {
  *
  */
 
-static void __init dtc_setup(char *str, int *ints)
+static int __init dtc_setup(char *str)
 {
 	static int commandline_current = 0;
 	int i;
+	int ints[10];
+
+	get_options(str, ARRAY_SIZE(ints), ints);
 	if (ints[0] != 2)
 		printk("dtc_setup: usage dtc=address,irq\n");
 	else if (commandline_current < NO_OVERRIDES) {
@@ -189,7 +192,10 @@ static void __init dtc_setup(char *str,
 			}
 		++commandline_current;
 	}
+	return 1;
 }
+
+__setup("dtc=", dtc_setup);
 #endif
 
 /* 
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:55:51.000000000 +1000
@@ -337,6 +337,7 @@ static int __init
 }
 
 
+#ifndef MODULE
 /*
  * Function : pas16_setup(char *str, int *ints)
  *
@@ -347,10 +348,13 @@ static int __init
  *
  */
 
-void __init pas16_setup(char *str, int *ints)
+static int __init pas16_setup(char *str)
 {
     static int commandline_current = 0;
     int i;
+    int ints[10];
+
+    get_options(str, ARRAY_SIZE(ints), ints);
     if (ints[0] != 2) 
 	printk("pas16_setup : usage pas16=io_port,irq\n");
     else 
@@ -364,8 +368,12 @@ void __init pas16_setup(char *str, int *
 		}
 	    ++commandline_current;
 	}
+    return 1;
 }
 
+__setup("pas16=", pas16_setup);
+#endif
+
 /* 
  * Function : int pas16_detect(struct scsi_host_template * tpnt)
  *
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:29.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:55:51.000000000 +1000
@@ -148,6 +148,7 @@ static struct signature {
 
 #define NO_SIGNATURES ARRAY_SIZE(signatures)
 
+#ifndef MODULE
 /*
  * Function : t128_setup(char *str, int *ints)
  *
@@ -158,9 +159,13 @@ static struct signature {
  *
  */
 
-void __init t128_setup(char *str, int *ints){
+static int __init t128_setup(char *str)
+{
     static int commandline_current = 0;
     int i;
+    int ints[10];
+
+    get_options(str, ARRAY_SIZE(ints), ints);
     if (ints[0] != 2) 
 	printk("t128_setup : usage t128=address,irq\n");
     else 
@@ -174,8 +179,12 @@ void __init t128_setup(char *str, int *i
 		}
 	    ++commandline_current;
 	}
+    return 1;
 }
 
+__setup("t128=", t128_setup);
+#endif
+
 /* 
  * Function : int t128_detect(struct scsi_host_template * tpnt)
  *



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 04/29] ncr5380: Remove unused macros
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-remove-unused-macros --]
[-- Type: text/plain, Size: 8327 bytes --]

Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and USE_WRAPPER; and 
in some drivers, NCR5380_intr and NCR5380_proc_info). DRIVER_SETUP serves no
purpose anymore. Remove these macro definitions.

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

---
 drivers/scsi/NCR5380.c    |    2 +-
 drivers/scsi/arm/oak.c    |    1 -
 drivers/scsi/atari_scsi.h |    1 -
 drivers/scsi/g_NCR5380.c  |    5 -----
 drivers/scsi/g_NCR5380.h  |    1 -
 drivers/scsi/mac_scsi.c   |    3 ---
 drivers/scsi/pas16.c      |    5 -----
 drivers/scsi/sun3_scsi.c  |   15 ---------------
 drivers/scsi/sun3_scsi.h  |    1 -
 drivers/scsi/t128.c       |    5 -----
 10 files changed, 1 insertion(+), 38 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:55:50.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:55:52.000000000 +1000
@@ -55,7 +55,6 @@
 #include "NCR5380.h"
 
 #define RESET_BOOT
-#define DRIVER_SETUP
 
 extern void via_scsi_clear(void);
 
@@ -113,7 +112,6 @@ static __inline__ void macscsi_write(str
  */
 
 static int __init mac_scsi_setup(char *str) {
-#ifdef DRIVER_SETUP	
 	int ints[7];
 	
 	(void)get_options( str, ARRAY_SIZE(ints), ints);
@@ -166,7 +164,6 @@ static int __init mac_scsi_setup(char *s
 	}
 #endif /* SUPPORT_TAGS */
 	
-#endif /* DRIVER_SETUP */
 	return 1;
 }
 
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:50.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:52.000000000 +1000
@@ -43,10 +43,6 @@
  * Options :
  *
  * PARITY - enable parity checking.  Not supported.
- *
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
  */
 
 #define AUTOSENSE
@@ -79,18 +75,7 @@
 
 extern int sun3_map_test(unsigned long, char *);
 
-#define USE_WRAPPER
 /*#define RESET_BOOT */
-#define DRIVER_SETUP
-
-/*
- * BUG can be used to trigger a strange code-size related hang on 2.1 kernels
- */
-#ifdef BUG
-#undef RESET_BOOT
-#undef DRIVER_SETUP
-#endif
-
 /* #define SUPPORT_TAGS */
 
 #ifdef SUN3_SCSI_VME
Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:55:52.000000000 +1000
@@ -649,7 +649,7 @@ NCR5380_print_options(struct Scsi_Host *
 	       " UNSAFE "
 #endif
 	    );
-	printk(" USLEEP, USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
+	printk(" USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
 	printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
 	if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) {
 		printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:51.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:55:52.000000000 +1000
@@ -1,6 +1,5 @@
 #define AUTOSENSE
 #define PSEUDO_DMA
-#define FOO
 #define UNSAFE  /* Not unsafe for PAS16 -- use it */
 #define PDEBUG 0
 
@@ -52,8 +51,6 @@
  * increase compared to polled I/O.
  *
  * PARITY - enable parity checking.  Not supported.
- * 
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
  *
  * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  This
  *	    parameter comes from the NCR5380 code.  It is NOT unsafe with
@@ -63,8 +60,6 @@
  *	    want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or
  *	    twiddle with the transfer size in the high level code.
  *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - There are many different models of
  *     the Pro Audio Spectrum/Studio 16, and I only have one of
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:52.000000000 +1000
@@ -44,10 +44,6 @@
  *
  * PARITY - enable parity checking.  Not supported.
  *
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  With command line overrides - NCR5380=port,irq may be 
  *     used on the LILO command line to override the defaults.
@@ -79,7 +75,6 @@
  */
 
 /* settings for DTC3181E card with only Mustek scanner attached */
-#define USLEEP
 #define USLEEP_POLL	1
 #define USLEEP_SLEEP	20
 #define USLEEP_WAITLONG	500
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:55:52.000000000 +1000
@@ -29,7 +29,6 @@
 
 #define NCR5380_read(reg)		readb(_base + ((reg) << 2))
 #define NCR5380_write(reg, value)	writeb(value, _base + ((reg) << 2))
-#define NCR5380_intr			oakscsi_intr
 #define NCR5380_queue_command		oakscsi_queue_command
 #define NCR5380_show_info		oakscsi_show_info
 #define NCR5380_write_info		oakscsi_write_info
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.h	2014-10-02 16:55:52.000000000 +1000
@@ -118,7 +118,6 @@ static const char* generic_NCR5380_info(
 #define NCR5380_bus_reset generic_NCR5380_bus_reset
 #define NCR5380_pread generic_NCR5380_pread
 #define NCR5380_pwrite generic_NCR5380_pwrite
-#define NCR5380_proc_info notyet_generic_proc_info
 
 #define BOARD_NCR5380	0
 #define BOARD_NCR53C400	1
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:51.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:55:52.000000000 +1000
@@ -47,17 +47,12 @@
  * increase compared to polled I/O.
  *
  * PARITY - enable parity checking.  Not supported.
- * 
- * SCSI2 - enable support for SCSI-II tagged queueing.  Untested.
- *
  *
  * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  You
  *          only really want to use this if you're having a problem with
  *          dropped characters during high speed communications, and even
  *          then, you're going to be better off twiddling with transfersize.
  *
- * USLEEP - enable support for devices that don't disconnect.  Untested.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - since the board is memory mapped, 
  *     a BIOS signature is scanned for to locate the registers.
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:50.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:52.000000000 +1000
@@ -89,7 +89,6 @@ static int sun3scsi_release (struct Scsi
 #define NCR5380_read(reg) sun3scsi_read(reg)
 #define NCR5380_write(reg, value) sun3scsi_write(reg, value)
 
-#define NCR5380_intr sun3scsi_intr
 #define NCR5380_queue_command sun3scsi_queue_command
 #define NCR5380_bus_reset sun3scsi_bus_reset
 #define NCR5380_abort sun3scsi_abort
Index: linux/drivers/scsi/atari_scsi.h
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.h	2014-10-02 16:55:52.000000000 +1000
@@ -44,7 +44,6 @@
 #define NCR5380_read(reg)		  atari_scsi_reg_read( reg )
 #define NCR5380_write(reg, value) atari_scsi_reg_write( reg, value )
 
-#define NCR5380_intr atari_scsi_intr
 #define NCR5380_queue_command atari_scsi_queue_command
 #define NCR5380_abort atari_scsi_abort
 #define NCR5380_show_info atari_scsi_show_info

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 04/29] ncr5380: Remove unused macros
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-unused-macros
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/52ba4ecb/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 05/29] ncr5380: Remove useless prototypes
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (3 preceding siblings ...)
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 06/29] ncr5380: Remove more " Finn Thain
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-useless-prototypes --]
[-- Type: text/plain, Size: 9294 bytes --]

Add missing static qualifiers and remove the now pointless prototypes. The
NCR5380_* prototypes are all declared in NCR5380.h and renamed using macros.
Further declarations are redundant (some are completely unused). Remove them.

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

---
 drivers/scsi/atari_scsi.c |    5 -----
 drivers/scsi/dtc.h        |    7 -------
 drivers/scsi/g_NCR5380.c  |    6 +++---
 drivers/scsi/g_NCR5380.h  |    6 ------
 drivers/scsi/mac_scsi.c   |    2 --
 drivers/scsi/pas16.c      |    6 +++---
 drivers/scsi/pas16.h      |    6 ------
 drivers/scsi/sun3_scsi.c  |    4 +---
 drivers/scsi/sun3_scsi.h  |    7 -------
 drivers/scsi/t128.c       |    7 ++++---
 drivers/scsi/t128.h       |    6 ------
 11 files changed, 11 insertions(+), 51 deletions(-)

Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:53.000000000 +1000
@@ -272,7 +272,7 @@ static int __init do_DTC3181E_setup(char
  *	Locks: none
  */
 
-int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
+static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt)
 {
 	static int current_override = 0;
 	int count;
@@ -484,7 +484,7 @@ int __init generic_NCR5380_detect(struct
  *	Report driver information for the NCR5380
  */
  	
-const char *generic_NCR5380_info(struct Scsi_Host *host)
+static const char *generic_NCR5380_info(struct Scsi_Host *host)
 {
 	static const char string[] = "Generic NCR5380/53C400 Driver";
 	return string;
@@ -499,7 +499,7 @@ const char *generic_NCR5380_info(struct
  *	Locks: none
  */
  
-int generic_NCR5380_release_resources(struct Scsi_Host *instance)
+static int generic_NCR5380_release_resources(struct Scsi_Host *instance)
 {
 	NCR5380_local_declare();
 	NCR5380_setup(instance);
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:55:53.000000000 +1000
@@ -382,7 +382,7 @@ __setup("pas16=", pas16_setup);
  *
  */
 
-int __init pas16_detect(struct scsi_host_template * tpnt)
+static int __init pas16_detect(struct scsi_host_template *tpnt)
 {
     static int current_override = 0;
     static unsigned short current_base = 0;
@@ -512,8 +512,8 @@ int __init pas16_detect(struct scsi_host
  * and matching the H_C_S coordinates to what DOS uses.
  */
 
-int pas16_biosparam(struct scsi_device *sdev, struct block_device *dev,
-		sector_t capacity, int * ip)
+static int pas16_biosparam(struct scsi_device *sdev, struct block_device *dev,
+                           sector_t capacity, int *ip)
 {
   int size = capacity;
   ip[0] = 64;
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:53.000000000 +1000
@@ -86,8 +86,6 @@ extern int sun3_map_test(unsigned long,
 
 
 static irqreturn_t scsi_sun3_intr(int irq, void *dummy);
-static inline unsigned char sun3scsi_read(int reg);
-static inline void sun3scsi_write(int reg, int value);
 
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
@@ -348,7 +346,7 @@ static int __init sun3scsi_detect(struct
 	return 1;
 }
 
-int sun3scsi_release (struct Scsi_Host *shpnt)
+static int sun3scsi_release(struct Scsi_Host *shpnt)
 {
 	if (shpnt->irq != SCSI_IRQ_NONE)
 		free_irq(shpnt->irq, shpnt);
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:55:53.000000000 +1000
@@ -193,7 +193,8 @@ __setup("t128=", t128_setup);
  *
  */
 
-int __init t128_detect(struct scsi_host_template * tpnt){
+static int __init t128_detect(struct scsi_host_template *tpnt)
+{
     static int current_override = 0, current_base = 0;
     struct Scsi_Host *instance;
     unsigned long base;
@@ -325,8 +326,8 @@ static int t128_release(struct Scsi_Host
  * and matching the H_C_S coordinates to what DOS uses.
  */
 
-int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
-		sector_t capacity, int * ip)
+static int t128_biosparam(struct scsi_device *sdev, struct block_device *bdev,
+                          sector_t capacity, int *ip)
 {
   ip[0] = 64;
   ip[1] = 32;
Index: linux/drivers/scsi/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/dtc.h	2014-10-02 16:55:53.000000000 +1000
@@ -32,13 +32,6 @@
 #define DTCDEBUG_INIT	0x1
 #define DTCDEBUG_TRANSFER 0x2
 
-static int dtc_abort(Scsi_Cmnd *);
-static int dtc_biosparam(struct scsi_device *, struct block_device *,
-		         sector_t, int*);
-static int dtc_detect(struct scsi_host_template *);
-static int dtc_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int dtc_bus_reset(Scsi_Cmnd *);
-
 #ifndef CMD_PER_LUN
 #define CMD_PER_LUN 2
 #endif
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.h	2014-10-02 16:55:53.000000000 +1000
@@ -39,12 +39,6 @@
 #endif
 
 #ifndef ASM
-static int generic_NCR5380_abort(Scsi_Cmnd *);
-static int generic_NCR5380_detect(struct scsi_host_template *);
-static int generic_NCR5380_release_resources(struct Scsi_Host *);
-static int generic_NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int generic_NCR5380_bus_reset(Scsi_Cmnd *);
-static const char* generic_NCR5380_info(struct Scsi_Host *);
 
 #ifndef CMD_PER_LUN
 #define CMD_PER_LUN 2
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:55:53.000000000 +1000
@@ -56,8 +56,6 @@
 
 #define RESET_BOOT
 
-extern void via_scsi_clear(void);
-
 #ifdef RESET_BOOT
 static void mac_scsi_reset_boot(struct Scsi_Host *instance);
 #endif
Index: linux/drivers/scsi/pas16.h
===================================================================
--- linux.orig/drivers/scsi/pas16.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/pas16.h	2014-10-02 16:55:53.000000000 +1000
@@ -114,12 +114,6 @@
 
 
 #ifndef ASM
-static int pas16_abort(Scsi_Cmnd *);
-static int pas16_biosparam(struct scsi_device *, struct block_device *,
-			   sector_t, int*);
-static int pas16_detect(struct scsi_host_template *);
-static int pas16_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int pas16_bus_reset(Scsi_Cmnd *);
 
 #ifndef CMD_PER_LUN
 #define CMD_PER_LUN 2
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:53.000000000 +1000
@@ -43,13 +43,6 @@
 
 #define IOBASE_SUN3_VMESCSI 0xff200000
 
-static int sun3scsi_abort(struct scsi_cmnd *);
-static int sun3scsi_detect (struct scsi_host_template *);
-static const char *sun3scsi_info (struct Scsi_Host *);
-static int sun3scsi_bus_reset(struct scsi_cmnd *);
-static int sun3scsi_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int sun3scsi_release (struct Scsi_Host *);
-
 #ifndef CMD_PER_LUN
 #define CMD_PER_LUN 2
 #endif
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/t128.h	2014-10-02 16:55:53.000000000 +1000
@@ -88,12 +88,6 @@
 #define T_DATA_REG_OFFSET	0x1e00	/* rw 512 bytes long */
 
 #ifndef ASM
-static int t128_abort(struct scsi_cmnd *);
-static int t128_biosparam(struct scsi_device *, struct block_device *,
-			  sector_t, int*);
-static int t128_detect(struct scsi_host_template *);
-static int t128_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int t128_bus_reset(struct scsi_cmnd *);
 
 #ifndef CMD_PER_LUN
 #define CMD_PER_LUN 2
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:55:53.000000000 +1000
@@ -181,12 +181,7 @@ static inline void DISABLE_IRQ(void)
 /***************************** Prototypes *****************************/
 
 #ifdef REAL_DMA
-static int scsi_dma_is_ignored_buserr(unsigned char dma_stat);
 static void atari_scsi_fetch_restbytes(void);
-static long atari_scsi_dma_residual(struct Scsi_Host *instance);
-static int falcon_classify_cmd(Scsi_Cmnd *cmd);
-static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
-					Scsi_Cmnd *cmd, int write_flag);
 #endif
 static irqreturn_t scsi_tt_intr(int irq, void *dummy);
 static irqreturn_t scsi_falcon_intr(int irq, void *dummy);

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 06/29] ncr5380: Remove more useless prototypes
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (4 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 05/29] ncr5380: Remove useless prototypes Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros Finn Thain
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-more-useless-prototypes --]
[-- Type: text/plain, Size: 8672 bytes --]

Make use of the host template static initializer instead of assigning
handlers at run-time. Move __maybe_unused qualifiers from declarations
to definitions. Move the atari_scsi_bus_reset() wrapper after the
definition of NCR5380_bus_reset(). All of the host template handler
prototypes are now redundant so remove them.

The write_info() handler is only relevant to drivers using PSEUDO_DMA so
this patch fixes the compiler warning in atari_NCR5380.c and sun3_NCR5380.c:

  CC      drivers/scsi/atari_scsi.o
  drivers/scsi/NCR5380.h:329: warning: 'NCR5380_write_info' declared 'static' but never defined

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

---
 drivers/scsi/NCR5380.h       |    8 ----
 drivers/scsi/atari_NCR5380.c |    3 +
 drivers/scsi/atari_scsi.c    |   76 ++++++++++++++++++++-----------------------
 drivers/scsi/dtc.c           |    7 +--
 drivers/scsi/pas16.c         |    7 +--
 drivers/scsi/sun3_NCR5380.c  |    3 +
 drivers/scsi/t128.c          |    7 +--
 7 files changed, 50 insertions(+), 61 deletions(-)

Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:55:49.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:55:55.000000000 +1000
@@ -322,14 +322,6 @@ static irqreturn_t NCR5380_intr(int irq,
 #endif
 static void NCR5380_main(struct work_struct *work);
 static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance);
-static int NCR5380_abort(Scsi_Cmnd * cmd);
-static int NCR5380_bus_reset(Scsi_Cmnd * cmd);
-static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *);
-static int __maybe_unused NCR5380_show_info(struct seq_file *,
-	struct Scsi_Host *);
-static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
-	char *buffer, int length);
-
 static void NCR5380_reselect(struct Scsi_Host *instance);
 static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag);
 #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:55:51.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:55:55.000000000 +1000
@@ -219,10 +219,6 @@ static int __init dtc_detect(struct scsi
 	void __iomem *base;
 	int sig, count;
 
-	tpnt->proc_name = "dtc3x80";
-	tpnt->show_info = dtc_show_info;
-	tpnt->write_info = dtc_write_info;
-
 	for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
 		addr = 0;
 		base = NULL;
@@ -477,6 +473,9 @@ static struct scsi_host_template driver_
 	.name				= "DTC 3180/3280 ",
 	.detect				= dtc_detect,
 	.release			= dtc_release,
+	.proc_name			= "dtc3x80",
+	.show_info			= dtc_show_info,
+	.write_info			= dtc_write_info,
 	.queuecommand			= dtc_queue_command,
 	.eh_abort_handler		= dtc_abort,
 	.eh_bus_reset_handler		= dtc_bus_reset,
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:55:55.000000000 +1000
@@ -390,10 +390,6 @@ static int __init pas16_detect(struct sc
     unsigned short io_port;
     int  count;
 
-    tpnt->proc_name = "pas16";
-    tpnt->show_info = pas16_show_info;
-    tpnt->write_info = pas16_write_info;
-
     if (pas16_addr != 0) {
 	overrides[0].io_port = pas16_addr;
 	/*
@@ -622,6 +618,9 @@ static struct scsi_host_template driver_
 	.name           = "Pro Audio Spectrum-16 SCSI",
 	.detect         = pas16_detect,
 	.release        = pas16_release,
+	.proc_name      = "pas16",
+	.show_info      = pas16_show_info,
+	.write_info     = pas16_write_info,
 	.queuecommand   = pas16_queue_command,
 	.eh_abort_handler = pas16_abort,
 	.eh_bus_reset_handler = pas16_bus_reset,
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:55:55.000000000 +1000
@@ -201,10 +201,6 @@ static int __init t128_detect(struct scs
     void __iomem *p;
     int sig, count;
 
-    tpnt->proc_name = "t128";
-    tpnt->show_info = t128_show_info;
-    tpnt->write_info = t128_write_info;
-
     for (count = 0; current_override < NO_OVERRIDES; ++current_override) {
 	base = 0;
 	p = NULL;
@@ -435,6 +431,9 @@ static struct scsi_host_template driver_
 	.name           = "Trantor T128/T128F/T228",
 	.detect         = t128_detect,
 	.release        = t128_release,
+	.proc_name      = "t128",
+	.show_info      = t128_show_info,
+	.write_info     = t128_write_info,
 	.queuecommand   = t128_queue_command,
 	.eh_abort_handler = t128_abort,
 	.eh_bus_reset_handler    = t128_bus_reset,
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:55.000000000 +1000
@@ -769,7 +769,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cm
 	seq_printf(m, "\n");
 }
 
-static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance)
+static int __maybe_unused NCR5380_show_info(struct seq_file *m,
+                                            struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
 	Scsi_Cmnd *ptr;
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:55.000000000 +1000
@@ -715,7 +715,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cm
 	seq_printf(m, "\n");
 }
 
-static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance)
+static int __maybe_unused NCR5380_show_info(struct seq_file *m,
+                                            struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
 	Scsi_Cmnd *ptr;
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:55:55.000000000 +1000
@@ -783,45 +783,6 @@ static int __init atari_scsi_setup(char
 __setup("atascsi=", atari_scsi_setup);
 #endif /* !MODULE */
 
-static int atari_scsi_bus_reset(Scsi_Cmnd *cmd)
-{
-	int rv;
-	struct NCR5380_hostdata *hostdata =
-		(struct NCR5380_hostdata *)cmd->device->host->hostdata;
-
-	/* For doing the reset, SCSI interrupts must be disabled first,
-	 * since the 5380 raises its IRQ line while _RST is active and we
-	 * can't disable interrupts completely, since we need the timer.
-	 */
-	/* And abort a maybe active DMA transfer */
-	if (IS_A_TT()) {
-		atari_turnoff_irq(IRQ_TT_MFP_SCSI);
-#ifdef REAL_DMA
-		tt_scsi_dma.dma_ctrl = 0;
-#endif /* REAL_DMA */
-	} else {
-		atari_turnoff_irq(IRQ_MFP_FSCSI);
-#ifdef REAL_DMA
-		st_dma.dma_mode_status = 0x90;
-		atari_dma_active = 0;
-		atari_dma_orig_addr = NULL;
-#endif /* REAL_DMA */
-	}
-
-	rv = NCR5380_bus_reset(cmd);
-
-	/* Re-enable ints */
-	if (IS_A_TT()) {
-		atari_turnon_irq(IRQ_TT_MFP_SCSI);
-	} else {
-		atari_turnon_irq(IRQ_MFP_FSCSI);
-	}
-	if (rv == SUCCESS)
-		falcon_release_lock_if_possible(hostdata);
-
-	return rv;
-}
-
 
 #ifdef CONFIG_ATARI_SCSI_RESET_BOOT
 static void __init atari_scsi_reset_boot(void)
@@ -1094,6 +1055,43 @@ static void atari_scsi_falcon_reg_write(
 
 #include "atari_NCR5380.c"
 
+static int atari_scsi_bus_reset(struct scsi_cmnd *cmd)
+{
+	int rv;
+	struct NCR5380_hostdata *hostdata = shost_priv(cmd->device->host);
+
+	/* For doing the reset, SCSI interrupts must be disabled first,
+	 * since the 5380 raises its IRQ line while _RST is active and we
+	 * can't disable interrupts completely, since we need the timer.
+	 */
+	/* And abort a maybe active DMA transfer */
+	if (IS_A_TT()) {
+		atari_turnoff_irq(IRQ_TT_MFP_SCSI);
+#ifdef REAL_DMA
+		tt_scsi_dma.dma_ctrl = 0;
+#endif
+	} else {
+		atari_turnoff_irq(IRQ_MFP_FSCSI);
+#ifdef REAL_DMA
+		st_dma.dma_mode_status = 0x90;
+		atari_dma_active = 0;
+		atari_dma_orig_addr = NULL;
+#endif
+	}
+
+	rv = NCR5380_bus_reset(cmd);
+
+	if (IS_A_TT())
+		atari_turnon_irq(IRQ_TT_MFP_SCSI);
+	else
+		atari_turnon_irq(IRQ_MFP_FSCSI);
+
+	if (rv == SUCCESS)
+		falcon_release_lock_if_possible(hostdata);
+
+	return rv;
+}
+
 static struct scsi_host_template driver_template = {
 	.show_info		= atari_scsi_show_info,
 	.name			= "Atari native SCSI",



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (5 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 06/29] ncr5380: Remove more " Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  8:09   ` Geert Uytterhoeven
  2014-10-06  9:19   ` Hannes Reinecke
  2014-10-02  6:56   ` Finn Thain
                   ` (21 subsequent siblings)
  28 siblings, 2 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-cleanup-TAG_NONE-and-TAG_NEXT --]
[-- Type: text/plain, Size: 10562 bytes --]

Both atari_NCR5380.c and sun3_NCR5380.c core drivers #undef TAG_NONE and then
redefine it. But the original definition is unused because NCR5380.c lacks
support for tagged queueing. So just define it once.

The TAG_NEXT macro only appears in the arguments to NCR5380_select() calls.
But that routine doesn't use its tag argument as the tag was already assigned
in NCR5380_main(). So remove the unused argument and the macro.

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

---
 drivers/scsi/NCR5380.c       |   29 +++++++++++++----------------
 drivers/scsi/NCR5380.h       |   11 ++++-------
 drivers/scsi/atari_NCR5380.c |   19 +++++--------------
 drivers/scsi/sun3_NCR5380.c  |   19 +++++--------------
 4 files changed, 27 insertions(+), 51 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:57.000000000 +1000
@@ -316,10 +316,6 @@ static struct scsi_host_template *the_te
  * important: the tag bit must be cleared before 'nr_allocated' is decreased.
  */
 
-/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */
-#undef TAG_NONE
-#define TAG_NONE 0xff
-
 typedef struct {
 	DECLARE_BITMAP(allocated, MAX_TAGS);
 	int nr_allocated;
@@ -1114,9 +1110,7 @@ static void NCR5380_main(struct work_str
 #ifdef SUPPORT_TAGS
 					cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE);
 #endif
-					if (!NCR5380_select(instance, tmp,
-					    (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE :
-					    TAG_NEXT)) {
+					if (!NCR5380_select(instance, tmp)) {
 						falcon_dont_release--;
 						/* release if target did not response! */
 						falcon_release_lock_if_possible(hostdata);
@@ -1347,17 +1341,14 @@ static void collect_stats(struct NCR5380
 #endif
 
 /*
- * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd,
- *	int tag);
+ * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  *	including ARBITRATION, SELECTION, and initial message out for
  *	IDENTIFY and queue messages.
  *
  * Inputs : instance - instantiation of the 5380 driver on which this
- *	target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for
- *	new tag, TAG_NONE for untagged queueing, otherwise set to the tag for
- *	the command that is presently connected.
+ *	target lives, cmd - SCSI command to execute.
  *
  * Returns : -1 if selection could not execute for some reason,
  *	0 if selection succeeded or failed because the target
@@ -1377,7 +1368,7 @@ static void collect_stats(struct NCR5380
  *		cmd->result host byte set to DID_BAD_TARGET.
  */
 
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd, int tag)
+static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd)
 {
 	SETUP_HOSTDATA(instance);
 	unsigned char tmp[3], phase;
@@ -2754,7 +2745,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			local_irq_restore(flags);
 			dprintk(NDEBUG_ABORT, "scsi%d: aborting disconnected command.\n", HOSTNO);
 
-			if (NCR5380_select(instance, cmd, (int)cmd->tag))
+			if (NCR5380_select(instance, cmd))
 				return FAILED;
 
 			dprintk(NDEBUG_ABORT, "scsi%d: nexus reestablished.\n", HOSTNO);
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:57.000000000 +1000
@@ -305,10 +305,6 @@ static struct scsi_host_template *the_te
  * important: the tag bit must be cleared before 'nr_allocated' is decreased.
  */
 
-/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */
-#undef TAG_NONE
-#define TAG_NONE 0xff
-
 /* For the m68k, the number of bits in 'allocated' must be a multiple of 32! */
 #if (MAX_TAGS % 32) != 0
 #error "MAX_TAGS must be a multiple of 32!"
@@ -1054,9 +1050,7 @@ static void NCR5380_main (struct work_st
 #ifdef SUPPORT_TAGS
 		    cmd_get_tag( tmp, tmp->cmnd[0] != REQUEST_SENSE );
 #endif
-		    if (!NCR5380_select(instance, tmp, 
-			    (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : 
-			    TAG_NEXT)) {
+		    if (!NCR5380_select(instance, tmp)) {
 			break;
 		    } else {
 			local_irq_disable();
@@ -1289,16 +1283,14 @@ static void collect_stats(struct NCR5380
 
 /* 
  * Function : int NCR5380_select(struct Scsi_Host *instance,
- * 				 struct scsi_cmnd *cmd,	int tag);
+ *				 struct scsi_cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  *	including ARBITRATION, SELECTION, and initial message out for 
  *	IDENTIFY and queue messages. 
  *
  * Inputs : instance - instantiation of the 5380 driver on which this 
- * 	target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for 
- *	new tag, TAG_NONE for untagged queueing, otherwise set to the tag for 
- *	the command that is presently connected.
+ *	target lives, cmd - SCSI command to execute.
  * 
  * Returns : -1 if selection could not execute for some reason,
  *	0 if selection succeeded or failed because the target 
@@ -1318,8 +1310,7 @@ static void collect_stats(struct NCR5380
  *		cmd->result host byte set to DID_BAD_TARGET.
  */
 
-static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd,
-			  int tag)
+static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
 {
     SETUP_HOSTDATA(instance);
     unsigned char tmp[3], phase;
@@ -2733,7 +2724,7 @@ static int NCR5380_abort(struct scsi_cmn
             local_irq_restore(flags);
 	    dprintk(NDEBUG_ABORT, "scsi%d: aborting disconnected command.\n", HOSTNO);
   
-            if (NCR5380_select (instance, cmd, (int) cmd->tag)) 
+	    if (NCR5380_select(instance, cmd))
 		return FAILED;
 
 	    dprintk(NDEBUG_ABORT, "scsi%d: nexus reestablished.\n", HOSTNO);
Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:55:57.000000000 +1000
@@ -1072,14 +1072,14 @@ static void NCR5380_main(struct work_str
 					hostdata->selecting = NULL;
 					/* RvC: have to preset this to indicate a new command is being performed */
 
-					if (!NCR5380_select(instance, tmp,
-							    /* 
-							     * REQUEST SENSE commands are issued without tagged
-							     * queueing, even on SCSI-II devices because the 
-							     * contingent allegiance condition exists for the 
-							     * entire unit.
-							     */
-							    (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) {
+					/*
+					 * REQUEST SENSE commands are issued without tagged
+					 * queueing, even on SCSI-II devices because the
+					 * contingent allegiance condition exists for the
+					 * entire unit.
+					 */
+
+					if (!NCR5380_select(instance, tmp)) {
 						break;
 					} else {
 						LIST(tmp, hostdata->issue_queue);
@@ -1096,7 +1096,7 @@ static void NCR5380_main(struct work_str
 		if (hostdata->selecting) {
 			tmp = (Scsi_Cmnd *) hostdata->selecting;
 			/* Selection will drop and retake the lock */
-			if (!NCR5380_select(instance, tmp, (tmp->cmnd[0] == REQUEST_SENSE) ? TAG_NONE : TAG_NEXT)) {
+			if (!NCR5380_select(instance, tmp)) {
 				/* Ok ?? */
 			} else {
 				/* RvC: device failed, so we wait a long time
@@ -1245,17 +1245,14 @@ static void collect_stats(struct NCR5380
 
 
 /* 
- * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, 
- *      int tag);
+ * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  *      including ARBITRATION, SELECTION, and initial message out for 
  *      IDENTIFY and queue messages. 
  *
  * Inputs : instance - instantiation of the 5380 driver on which this 
- *      target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for 
- *      new tag, TAG_NONE for untagged queueing, otherwise set to the tag for 
- *      the command that is presently connected.
+ *      target lives, cmd - SCSI command to execute.
  * 
  * Returns : -1 if selection could not execute for some reason,
  *      0 if selection succeeded or failed because the target 
@@ -1277,7 +1274,7 @@ static void collect_stats(struct NCR5380
  *	Locks: caller holds hostdata lock in IRQ mode
  */
  
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag) 
+static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd)
 {
 	NCR5380_local_declare();
 	struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
@@ -2773,7 +2770,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
 		if (cmd == tmp) {
 			dprintk(NDEBUG_ABORT, "scsi%d : aborting disconnected command.\n", instance->host_no);
 
-			if (NCR5380_select(instance, cmd, (int) cmd->tag))
+			if (NCR5380_select(instance, cmd))
 				return FAILED;
 			dprintk(NDEBUG_ABORT, "scsi%d : nexus reestablished.\n", instance->host_no);
 
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:55:57.000000000 +1000
@@ -224,14 +224,11 @@
 #define DISCONNECT_LONG		2
 
 /* 
- * These are "special" values for the tag parameter passed to NCR5380_select.
+ * "Special" value for the (unsigned char) command tag, to indicate
+ * I_T_L nexus instead of I_T_L_Q.
  */
 
-#define TAG_NEXT	-1	/* Use next free tag */
-#define TAG_NONE	-2	/* 
-				 * Establish I_T_L nexus instead of I_T_L_Q
-				 * even on SCSI-II devices.
-				 */
+#define TAG_NONE	0xff
 
 /*
  * These are "special" values for the irq and dma_channel fields of the 
@@ -323,7 +320,7 @@ static irqreturn_t NCR5380_intr(int irq,
 static void NCR5380_main(struct work_struct *work);
 static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance);
 static void NCR5380_reselect(struct Scsi_Host *instance);
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag);
+static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd);
 #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
 #endif



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 08/29] ncr5380: Remove redundant AUTOSENSE macro
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-remove-AUTOSENSE-macro --]
[-- Type: text/plain, Size: 11872 bytes --]

Every NCR5380 driver sets AUTOSENSE so it need not be optional (and the
mid-layer expects it). Remove this redundant macro to improve readability.

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

---
 drivers/scsi/NCR5380.c       |   14 +-------------
 drivers/scsi/NCR5380.h       |    5 -----
 drivers/scsi/arm/cumana_1.c  |    1 -
 drivers/scsi/arm/oak.c       |    1 -
 drivers/scsi/atari_NCR5380.c |   15 +--------------
 drivers/scsi/atari_scsi.c    |    1 -
 drivers/scsi/dmx3191d.c      |    1 -
 drivers/scsi/dtc.c           |    4 ----
 drivers/scsi/g_NCR5380.c     |    2 --
 drivers/scsi/mac_scsi.c      |    2 --
 drivers/scsi/pas16.c         |    4 ----
 drivers/scsi/sun3_NCR5380.c  |   16 +---------------
 drivers/scsi/sun3_scsi.c     |    2 --
 drivers/scsi/t128.c          |    4 ----
 14 files changed, 3 insertions(+), 69 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:55:57.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:55:58.000000000 +1000
@@ -627,9 +627,6 @@ NCR5380_print_options(struct Scsi_Host *
 #ifdef AUTOPROBE_IRQ
 	       " AUTOPROBE_IRQ"
 #endif
-#ifdef AUTOSENSE
-	       " AUTOSENSE"
-#endif
 #ifdef DIFFERENTIAL
 	       " DIFFERENTIAL"
 #endif
@@ -857,12 +854,6 @@ static int NCR5380_init(struct Scsi_Host
 	hostdata->host = instance;
 	hostdata->time_expires = 0;
 
-#ifndef AUTOSENSE
-	if ((instance->cmd_per_lun > 1) || instance->can_queue > 1)
-		    printk(KERN_WARNING "scsi%d : WARNING : support for multiple outstanding commands enabled\n" "         without AUTOSENSE option, contingent allegiance conditions may\n"
-		    	   "         be incorrectly cleared.\n", instance->host_no);
-#endif				/* def AUTOSENSE */
-
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 	NCR5380_write(MODE_REG, MR_BASE);
 	NCR5380_write(TARGET_COMMAND_REG, 0);
@@ -2259,7 +2250,6 @@ static void NCR5380_information_transfer
 					else if (status_byte(cmd->SCp.Status) != GOOD)
 						cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
-#ifdef AUTOSENSE
 					if ((cmd->cmnd[0] == REQUEST_SENSE) &&
 						hostdata->ses.cmd_len) {
 						scsi_eh_restore_cmnd(cmd, &hostdata->ses);
@@ -2276,9 +2266,7 @@ static void NCR5380_information_transfer
 						    hostdata->issue_queue;
 						hostdata->issue_queue = (Scsi_Cmnd *) cmd;
 						dprintk(NDEBUG_QUEUES, "scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no);
-					} else
-#endif				/* def AUTOSENSE */
-					{
+					} else {
 						collect_stats(hostdata, cmd);
 						cmd->scsi_done(cmd);
 					}
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:55:57.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:55:58.000000000 +1000
@@ -25,10 +25,7 @@
 #define NCR5380_H
 
 #include <linux/interrupt.h>
-
-#ifdef AUTOSENSE
 #include <scsi/scsi_eh.h>
-#endif
 
 #define NCR5380_PUBLIC_RELEASE 7
 #define NCR53C400_PUBLIC_RELEASE 2
@@ -281,9 +278,7 @@ struct NCR5380_hostdata {
 	unsigned pendingr;
 	unsigned pendingw;
 #endif
-#ifdef AUTOSENSE
 	struct scsi_eh_save ses;
-#endif
 };
 
 #ifdef __KERNEL__
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/arm/cumana_1.c	2014-10-02 16:55:58.000000000 +1000
@@ -18,7 +18,6 @@
 
 #include <scsi/scsicam.h>
 
-#define AUTOSENSE
 #define PSEUDO_DMA
 
 #define CUMANASCSI_PUBLIC_RELEASE 1
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:55:58.000000000 +1000
@@ -17,7 +17,6 @@
 #include "../scsi.h"
 #include <scsi/scsi_host.h>
 
-#define AUTOSENSE
 /*#define PSEUDO_DMA*/
 
 #define OAKSCSI_PUBLIC_RELEASE 1
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:57.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
@@ -680,9 +680,6 @@ static inline void NCR5380_all_init(void
 static void __init NCR5380_print_options(struct Scsi_Host *instance)
 {
 	printk(" generic options"
-#ifdef AUTOSENSE
-	       " AUTOSENSE"
-#endif
 #ifdef REAL_DMA
 	       " REAL DMA"
 #endif
@@ -839,13 +836,6 @@ static int __init NCR5380_init(struct Sc
 		first_instance = instance;
 	}
 
-#ifndef AUTOSENSE
-	if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1))
-		printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n"
-		       "        without AUTOSENSE option, contingent allegiance conditions may\n"
-		       "        be incorrectly cleared.\n", HOSTNO);
-#endif /* def AUTOSENSE */
-
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 	NCR5380_write(MODE_REG, MR_BASE);
 	NCR5380_write(TARGET_COMMAND_REG, 0);
@@ -2195,7 +2185,6 @@ static void NCR5380_information_transfer
 					else if (status_byte(cmd->SCp.Status) != GOOD)
 						cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
-#ifdef AUTOSENSE
 					if ((cmd->cmnd[0] == REQUEST_SENSE) &&
 						hostdata->ses.cmd_len) {
 						scsi_eh_restore_cmnd(cmd, &hostdata->ses);
@@ -2215,9 +2204,7 @@ static void NCR5380_information_transfer
 						local_irq_restore(flags);
 						dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 							  "issue queue\n", H_NO(cmd));
-					} else
-#endif /* def AUTOSENSE */
-					{
+					} else {
 #ifdef NCR5380_STATS
 						collect_stats(hostdata, cmd);
 #endif
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:55:58.000000000 +1000
@@ -67,7 +67,6 @@
 
 #include <linux/module.h>
 
-#define AUTOSENSE
 /* For the Atari version, use only polled IO or REAL_DMA */
 #define	REAL_DMA
 /* Support tagged queuing? (on devices that are able to... :-) */
Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:55:50.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:55:58.000000000 +1000
@@ -33,7 +33,6 @@
 /*
  * Definitions for the generic 5380 driver.
  */
-#define AUTOSENSE
 
 #define NCR5380_read(reg)		inb(port + reg)
 #define NCR5380_write(reg, value)	outb(value, port + reg)
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:55:58.000000000 +1000
@@ -1,5 +1,4 @@
 
-#define AUTOSENSE
 #define PSEUDO_DMA
 #define DONT_USE_INTR
 #define UNSAFE			/* Leave interrupts enabled during pseudo-dma I/O */
@@ -30,9 +29,6 @@
 
 /*
  * Options : 
- * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
- *      for commands that return with a CHECK CONDITION status. 
- *
  * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
  * increase compared to polled I/O.
  *
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
@@ -80,8 +80,6 @@
 #define USLEEP_WAITLONG	500
 
 #define AUTOPROBE_IRQ
-#define AUTOSENSE
-
 
 #ifdef CONFIG_SCSI_GENERIC_NCR53C400
 #define NCR53C400_PSEUDO_DMA 1
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:55:58.000000000 +1000
@@ -48,8 +48,6 @@
 #include <scsi/scsi_host.h>
 #include "mac_scsi.h"
 
-/* These control the behaviour of the generic 5380 core */
-#define AUTOSENSE
 #define PSEUDO_DMA
 
 #include "NCR5380.h"
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:55:58.000000000 +1000
@@ -1,4 +1,3 @@
-#define AUTOSENSE
 #define PSEUDO_DMA
 #define UNSAFE  /* Not unsafe for PAS16 -- use it */
 #define PDEBUG 0
@@ -39,9 +38,6 @@
 
 /*
  * Options : 
- * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
- *      for commands that return with a CHECK CONDITION status. 
- *
  * 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
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:57.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
@@ -626,9 +626,6 @@ static inline void NCR5380_all_init (voi
 static void __init NCR5380_print_options (struct Scsi_Host *instance)
 {
     printk(" generic options"
-#ifdef AUTOSENSE 
-    " AUTOSENSE"
-#endif
 #ifdef REAL_DMA
     " REAL DMA"
 #endif
@@ -785,14 +782,6 @@ static int __init NCR5380_init(struct Sc
 	first_instance = instance;
     }
 	
-
-#ifndef AUTOSENSE
-    if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1))
-	 printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n"
-	        "        without AUTOSENSE option, contingent allegiance conditions may\n"
-	        "        be incorrectly cleared.\n", HOSTNO);
-#endif /* def AUTOSENSE */
-
     NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
     NCR5380_write(MODE_REG, MR_BASE);
     NCR5380_write(TARGET_COMMAND_REG, 0);
@@ -2158,7 +2147,6 @@ static void NCR5380_information_transfer
 		    else if (status_byte(cmd->SCp.Status) != GOOD)
 			cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 		    
-#ifdef AUTOSENSE
 		    if ((cmd->cmnd[0] == REQUEST_SENSE) &&
 			                        hostdata->ses.cmd_len) {
 			scsi_eh_restore_cmnd(cmd, &hostdata->ses);
@@ -2182,9 +2170,7 @@ static void NCR5380_information_transfer
 		        local_irq_restore(flags);
 			dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 				  "issue queue\n", H_NO(cmd));
-		   } else
-#endif /* def AUTOSENSE */
-		   {
+		   } else {
 #ifdef NCR5380_STATS
 		       collect_stats(hostdata, cmd);
 #endif
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:58.000000000 +1000
@@ -45,8 +45,6 @@
  * PARITY - enable parity checking.  Not supported.
  */
 
-#define AUTOSENSE
-
 #include <linux/types.h>
 #include <linux/stddef.h>
 #include <linux/ctype.h>
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:55.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:55:58.000000000 +1000
@@ -1,4 +1,3 @@
-#define AUTOSENSE
 #define PSEUDO_DMA
 
 /*
@@ -40,9 +39,6 @@
 
 /*
  * Options : 
- * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
- *      for commands that return with a CHECK CONDITION status. 
- *
  * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
  * increase compared to polled I/O.
  *

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 08/29] ncr5380: Remove redundant AUTOSENSE macro
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-AUTOSENSE-macro
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/6cff966e/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 09/29] ncr5380: Remove duplicate comments
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (7 preceding siblings ...)
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs Finn Thain
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-duplicate-comments --]
[-- Type: text/plain, Size: 10547 bytes --]

The LIMIT_TRANSFERSIZE, PSEUDO_DMA, PARITY and UNSAFE options are all
documented in the core drivers where they are used. The same goes for the
chip databook reference. Remove the duplicate comments.

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

---
 drivers/scsi/dtc.c       |   17 +----------------
 drivers/scsi/dtc.h       |   16 ----------------
 drivers/scsi/g_NCR5380.c |   16 ----------------
 drivers/scsi/g_NCR5380.h |   12 ------------
 drivers/scsi/mac_scsi.c  |   12 ------------
 drivers/scsi/mac_scsi.h  |   12 ------------
 drivers/scsi/pas16.c     |   31 -------------------------------
 drivers/scsi/pas16.h     |   12 ------------
 drivers/scsi/sun3_scsi.c |   21 ---------------------
 drivers/scsi/sun3_scsi.h |   12 ------------
 drivers/scsi/t128.c      |   23 -----------------------
 drivers/scsi/t128.h      |   12 ------------
 12 files changed, 1 insertion(+), 195 deletions(-)

Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:00.000000000 +1000
@@ -19,24 +19,9 @@
  *      +1 (303) 440-4894
  *
  * DISTRIBUTION RELEASE 1.
- *
- * For more information, please consult 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
-*/
+ */
 
 /*
- * Options : 
- * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
- * increase compared to polled I/O.
- *
- * PARITY - enable parity checking.  Not supported.
- *
- * UNSAFE - leave interrupts enabled during pseudo-DMA transfers. 
- *		You probably want this.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - since the board is memory mapped, 
  *     a BIOS signature is scanned for to locate the registers.
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:00.000000000 +1000
@@ -20,18 +20,6 @@
  * Thomas Sailer, sailer@ife.ee.ethz.ch
  *
  * ALPHA RELEASE 1. 
- *
- * For more information, please consult 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 /* 
@@ -40,10 +28,6 @@
  */
 
 /*
- * Options :
- *
- * PARITY - enable parity checking.  Not supported.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  With command line overrides - NCR5380=port,irq may be 
  *     used on the LILO command line to override the defaults.
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:56:00.000000000 +1000
@@ -22,40 +22,9 @@
  * Media Vision
  * (510) 770-8600
  * (800) 348-7116
- * 
- * and 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 /*
- * Options : 
- * 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.
- *
- * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
- * increase compared to polled I/O.
- *
- * PARITY - enable parity checking.  Not supported.
- *
- * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  This
- *	    parameter comes from the NCR5380 code.  It is NOT unsafe with
- *	    the PAS16 and you should use it.  If you don't you will have
- *	    a problem with dropped characters during high speed
- *	    communications during SCSI transfers.  If you really don't
- *	    want to use UNSAFE you can try defining LIMIT_TRANSFERSIZE or
- *	    twiddle with the transfer size in the high level code.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - There are many different models of
  *     the Pro Audio Spectrum/Studio 16, and I only have one of
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:00.000000000 +1000
@@ -22,27 +22,6 @@
  * Copyright 1995, Russell King
  *
  * ALPHA RELEASE 1.
- *
- * For more information, please consult
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
- */
-
-
-/*
- * This is from mac_scsi.h, but hey, maybe this is useful for Sun3 too! :)
- *
- * Options :
- *
- * PARITY - enable parity checking.  Not supported.
  */
 
 #include <linux/types.h>
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:56:00.000000000 +1000
@@ -23,32 +23,9 @@
  * 5415 Randall Place
  * Fremont, CA 94538
  * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
- * 
- * and 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 /*
- * Options : 
- * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance
- * increase compared to polled I/O.
- *
- * PARITY - enable parity checking.  Not supported.
- *
- * UNSAFE - leave interrupts enabled during pseudo-DMA transfers.  You
- *          only really want to use this if you're having a problem with
- *          dropped characters during high speed communications, and even
- *          then, you're going to be better off twiddling with transfersize.
- *
  * The card is detected and initialized in one of several ways : 
  * 1.  Autoprobe (default) - since the board is memory mapped, 
  *     a BIOS signature is scanned for to locate the registers.
Index: linux/drivers/scsi/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/dtc.h	2014-10-02 16:56:00.000000000 +1000
@@ -7,22 +7,6 @@
  *      +1 (303) 440-4894
  *
  * DISTRIBUTION RELEASE 2. 
- *
- * For more information, please consult 
- *
- * 
- * 
- * and 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #ifndef DTC3280_H
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.h	2014-10-02 16:56:00.000000000 +1000
@@ -11,18 +11,6 @@
  *    K.Lentin@cs.monash.edu.au
  *
  * ALPHA RELEASE 1. 
- *
- * For more information, please consult 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #ifndef GENERIC_NCR5380_H
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:00.000000000 +1000
@@ -11,18 +11,6 @@
  * Copyright 1995, Russell King
  *
  * ALPHA RELEASE 1.
- *
- * For more information, please consult
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #include <linux/types.h>
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:55:50.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.h	2014-10-02 16:56:00.000000000 +1000
@@ -8,18 +8,6 @@
  *      +1 (303) 440-4894
  *
  * ALPHA RELEASE 1.
- *
- * For more information, please consult
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #ifndef MAC_NCR5380_H
Index: linux/drivers/scsi/pas16.h
===================================================================
--- linux.orig/drivers/scsi/pas16.h	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/pas16.h	2014-10-02 16:56:00.000000000 +1000
@@ -18,18 +18,6 @@
  * Media Vision
  * (510) 770-8600
  * (800) 348-7116
- * 
- * and 
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:00.000000000 +1000
@@ -15,18 +15,6 @@
  *      +1 (303) 440-4894
  *
  * ALPHA RELEASE 1.
- *
- * For more information, please consult
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #ifndef SUN3_SCSI_H
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2014-10-02 16:55:53.000000000 +1000
+++ linux/drivers/scsi/t128.h	2014-10-02 16:56:00.000000000 +1000
@@ -20,18 +20,6 @@
  * 5415 Randall Place
  * Fremont, CA 94538
  * 1+ (415) 770-1400, FAX 1+ (415) 770-9910
- *
- * and
- *
- * NCR 5380 Family
- * SCSI Protocol Controller
- * Databook
- *
- * NCR Microelectronics
- * 1635 Aeroplaza Drive
- * Colorado Springs, CO 80916
- * 1+ (719) 578-3400
- * 1+ (800) 334-5454
  */
 
 #ifndef T128_H



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (8 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 09/29] ncr5380: Remove duplicate comments Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  8:22   ` Geert Uytterhoeven
  2014-10-02  6:56 ` [PATCH 11/29] ncr5380: Remove NCR5380_STATS Finn Thain
                   ` (18 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-SCSI_IRQ_NONE-fixes --]
[-- Type: text/plain, Size: 16541 bytes --]

Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than
SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE
if it is to issue IDENTIFY commands that prevent target disconnection.

Other drivers, when they can't get an IRQ or can't use one, will set
host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will
attempt to free IRQ 255 which was never requested.

Fix these bugs by using IRQ_NONE in place of SCSI_IRQ_NONE. This means
IRQ 0 is no longer probed by ISA drivers but I don't think this matters.

Setting IRQ = 255 for these ISA drivers is understood to mean no IRQ.
This remains supported so as to avoid breaking existing ISA setups (which
can be difficult to get working) and because existing documentation
(SANE, TLDP etc) describes this usage for the ISA NCR5380 driver options.

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

---

The are whitespace issues with this code; it will be cleaned up in a
later patch.

---
 drivers/scsi/NCR5380.c   |   12 ++++++------
 drivers/scsi/NCR5380.h   |    1 -
 drivers/scsi/dmx3191d.c  |    7 ++++---
 drivers/scsi/dtc.c       |   22 +++++++++++++---------
 drivers/scsi/g_NCR5380.c |   18 +++++++++++-------
 drivers/scsi/mac_scsi.c  |    8 ++++----
 drivers/scsi/pas16.c     |   20 +++++++++++---------
 drivers/scsi/sun3_scsi.c |    6 +++---
 drivers/scsi/t128.c      |   14 +++++++++-----
 9 files changed, 61 insertions(+), 47 deletions(-)

Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:02.000000000 +1000
@@ -254,31 +254,35 @@ found:
 		else
 			instance->irq = NCR5380_probe_irq(instance, DTC_IRQS);
 
+		/* Compatibility with documented NCR5380 kernel parameters */
+		if (instance->irq == 255)
+			instance->irq = IRQ_NONE;
+
 #ifndef DONT_USE_INTR
 		/* With interrupts enabled, it will sometimes hang when doing heavy
 		 * reads. So better not enable them until I finger it out. */
-		if (instance->irq != SCSI_IRQ_NONE)
+		if (instance->irq != IRQ_NONE)
 			if (request_irq(instance->irq, dtc_intr, 0,
 					"dtc", instance)) {
 				printk(KERN_ERR "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
-				instance->irq = SCSI_IRQ_NONE;
+				instance->irq = IRQ_NONE;
 			}
 
-		if (instance->irq == SCSI_IRQ_NONE) {
+		if (instance->irq == IRQ_NONE) {
 			printk(KERN_WARNING "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 			printk(KERN_WARNING "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 		}
 #else
-		if (instance->irq != SCSI_IRQ_NONE)
+		if (instance->irq != IRQ_NONE)
 			printk(KERN_WARNING "scsi%d : interrupts not used. Might as well not jumper it.\n", instance->host_no);
-		instance->irq = SCSI_IRQ_NONE;
+		instance->irq = IRQ_NONE;
 #endif
 #if defined(DTCDEBUG) && (DTCDEBUG & DTCDEBUG_INIT)
 		printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
 		printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) instance->base);
-		if (instance->irq == SCSI_IRQ_NONE)
+		if (instance->irq == IRQ_NONE)
 			printk(" interrupts disabled");
 		else
 			printk(" irq %d", instance->irq);
@@ -350,7 +354,7 @@ static inline int NCR5380_pread(struct S
 	i = 0;
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 	NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 		NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ);
 	else
 		NCR5380_write(DTC_CONTROL_REG, CSR_DIR_READ | CSR_INT_BASE);
@@ -401,7 +405,7 @@ static inline int NCR5380_pwrite(struct
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 	NCR5380_write(MODE_REG, MR_ENABLE_EOP_INTR | MR_DMA_MODE);
 	/* set direction (write) */
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 		NCR5380_write(DTC_CONTROL_REG, 0);
 	else
 		NCR5380_write(DTC_CONTROL_REG, CSR_5380_INTR);
@@ -440,7 +444,7 @@ static int dtc_release(struct Scsi_Host
 {
 	NCR5380_local_declare();
 	NCR5380_setup(shost);
-	if (shost->irq)
+	if (shost->irq != IRQ_NONE)
 		free_irq(shost->irq, shost);
 	NCR5380_exit(shost);
 	if (shost->io_port && shost->n_io_port)
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:56:02.000000000 +1000
@@ -62,13 +62,11 @@
  *   If you have problems with your card not being recognized, use
  *   the LILO command line override.  Try to get it recognized without
  *   interrupts.  Ie, for a board at the default 0x388 base port,
- *   boot: linux pas16=0x388,255
+ *   boot: linux pas16=0x388,0
  *
- *   SCSI_IRQ_NONE (255) should be specified for no interrupt,
+ *   IRQ_NONE (0) should be specified for no interrupt,
  *   IRQ_AUTO (254) to autoprobe for an IRQ line if overridden
  *   on the command line.
- *
- *   (IRQ_AUTO == 254, SCSI_IRQ_NONE == 255 in NCR5380.h)
  */
  
 #include <linux/module.h>
@@ -416,15 +414,19 @@ static int __init pas16_detect(struct sc
 	else 
 	    instance->irq = NCR5380_probe_irq(instance, PAS16_IRQS);
 
-	if (instance->irq != SCSI_IRQ_NONE) 
+	/* Compatibility with documented NCR5380 kernel parameters */
+	if (instance->irq == 255)
+		instance->irq = IRQ_NONE;
+
+	if (instance->irq != IRQ_NONE)
 	    if (request_irq(instance->irq, pas16_intr, 0,
 			    "pas16", instance)) {
 		printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
 		    instance->host_no, instance->irq);
-		instance->irq = SCSI_IRQ_NONE;
+		instance->irq = IRQ_NONE;
 	    } 
 
-	if (instance->irq == SCSI_IRQ_NONE) {
+	if (instance->irq == IRQ_NONE) {
 	    printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 	    printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 	    /* Disable 5380 interrupts, leave drive params the same */
@@ -438,7 +440,7 @@ static int __init pas16_detect(struct sc
 
 	printk("scsi%d : at 0x%04x", instance->host_no, (int) 
 	    instance->io_port);
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 	    printk (" interrupts disabled");
 	else 
 	    printk (" irq %d", instance->irq);
@@ -568,7 +570,7 @@ static inline int NCR5380_pwrite (struct
 
 static int pas16_release(struct Scsi_Host *shost)
 {
-	if (shost->irq)
+	if (shost->irq != IRQ_NONE)
 		free_irq(shost->irq, shost);
 	NCR5380_exit(shost);
 	if (shost->dma_channel != 0xff)
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:56:02.000000000 +1000
@@ -228,15 +228,19 @@ found:
 	else 
 	    instance->irq = NCR5380_probe_irq(instance, T128_IRQS);
 
-	if (instance->irq != SCSI_IRQ_NONE) 
+	/* Compatibility with documented NCR5380 kernel parameters */
+	if (instance->irq == 255)
+		instance->irq = IRQ_NONE;
+
+	if (instance->irq != IRQ_NONE)
 	    if (request_irq(instance->irq, t128_intr, 0, "t128",
 			    instance)) {
 		printk("scsi%d : IRQ%d not free, interrupts disabled\n", 
 		    instance->host_no, instance->irq);
-		instance->irq = SCSI_IRQ_NONE;
+		instance->irq = IRQ_NONE;
 	    } 
 
-	if (instance->irq == SCSI_IRQ_NONE) {
+	if (instance->irq == IRQ_NONE) {
 	    printk("scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 	    printk("scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 	}
@@ -246,7 +250,7 @@ found:
 #endif
 
 	printk("scsi%d : at 0x%08lx", instance->host_no, instance->base);
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 	    printk (" interrupts disabled");
 	else 
 	    printk (" irq %d", instance->irq);
@@ -265,7 +269,7 @@ static int t128_release(struct Scsi_Host
 {
 	NCR5380_local_declare();
 	NCR5380_setup(shost);
-	if (shost->irq)
+	if (shost->irq != IRQ_NONE)
 		free_irq(shost->irq, shost);
 	NCR5380_exit(shost);
 	if (shost->io_port && shost->n_io_port)
Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:02.000000000 +1000
@@ -574,12 +574,12 @@ static int __init __maybe_unused NCR5380
 	int trying_irqs, i, mask;
 	NCR5380_setup(instance);
 
-	for (trying_irqs = i = 0, mask = 1; i < 16; ++i, mask <<= 1)
+	for (trying_irqs = 0, i = 1, mask = 2; i < 16; ++i, mask <<= 1)
 		if ((mask & possible) && (request_irq(i, &probe_intr, 0, "NCR-probe", NULL) == 0))
 			trying_irqs |= mask;
 
 	timeout = jiffies + (250 * HZ / 1000);
-	probe_irq = SCSI_IRQ_NONE;
+	probe_irq = IRQ_NONE;
 
 	/*
 	 * A interrupt is triggered whenever BSY = false, SEL = true
@@ -596,13 +596,13 @@ static int __init __maybe_unused NCR5380
 	NCR5380_write(OUTPUT_DATA_REG, hostdata->id_mask);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_DATA | ICR_ASSERT_SEL);
 
-	while (probe_irq == SCSI_IRQ_NONE && time_before(jiffies, timeout))
+	while (probe_irq == IRQ_NONE && time_before(jiffies, timeout))
 		schedule_timeout_uninterruptible(1);
 	
 	NCR5380_write(SELECT_ENABLE_REG, 0);
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 
-	for (i = 0, mask = 1; i < 16; ++i, mask <<= 1)
+	for (i = 1, mask = 2; i < 16; ++i, mask <<= 1)
 		if (trying_irqs & mask)
 			free_irq(i, NULL);
 
@@ -730,7 +730,7 @@ static int __maybe_unused NCR5380_show_i
 
 	SPRINTF("\nBase Addr: 0x%05lX    ", (long) instance->base);
 	SPRINTF("io_port: %04x      ", (int) instance->io_port);
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 		SPRINTF("IRQ: None.\n");
 	else
 		SPRINTF("IRQ: %d.\n", instance->irq);
@@ -1500,7 +1500,7 @@ part2:
 	}
 
 	dprintk(NDEBUG_SELECTION, "scsi%d : target %d selected, going into MESSAGE OUT phase.\n", instance->host_no, cmd->device->id);
-	tmp[0] = IDENTIFY(((instance->irq == SCSI_IRQ_NONE) ? 0 : 1), cmd->device->lun);
+	tmp[0] = IDENTIFY(((instance->irq == IRQ_NONE) ? 0 : 1), cmd->device->lun);
 
 	len = 1;
 	cmd->tag = 0;
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:02.000000000 +1000
@@ -232,7 +232,6 @@
  * Scsi_Host structure
  */
 
-#define SCSI_IRQ_NONE	255
 #define DMA_NONE	255
 #define IRQ_AUTO	254
 #define DMA_AUTO	254
Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:56:02.000000000 +1000
@@ -100,7 +100,7 @@ static int dmx3191d_probe_one(struct pci
 		 */
 		printk(KERN_WARNING "dmx3191: IRQ %d not available - "
 				    "switching to polled mode.\n", pdev->irq);
-		shost->irq = SCSI_IRQ_NONE;
+		shost->irq = IRQ_NONE;
 	}
 
 	pci_set_drvdata(pdev, shost);
@@ -113,7 +113,8 @@ static int dmx3191d_probe_one(struct pci
 	return 0;
 
  out_free_irq:
-	free_irq(shost->irq, shost);
+	if (shost->irq != IRQ_NONE)
+		free_irq(shost->irq, shost);
  out_release_region:
 	release_region(io, DMX3191D_REGION_LEN);
  out_disable_device:
@@ -130,7 +131,7 @@ static void dmx3191d_remove_one(struct p
 
 	NCR5380_exit(shost);
 
-	if (shost->irq != SCSI_IRQ_NONE)
+	if (shost->irq != IRQ_NONE)
 		free_irq(shost->irq, shost);
 	release_region(shost->io_port, DMX3191D_REGION_LEN);
 	pci_disable_device(pdev);
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:02.000000000 +1000
@@ -312,7 +312,7 @@ static int __init generic_NCR5380_detect
 			if (pnp_irq_valid(dev, 0))
 				overrides[count].irq = pnp_irq(dev, 0);
 			else
-				overrides[count].irq = SCSI_IRQ_NONE;
+				overrides[count].irq = IRQ_NONE;
 			if (pnp_dma_valid(dev, 0))
 				overrides[count].dma = pnp_dma(dev, 0);
 			else
@@ -432,20 +432,24 @@ static int __init generic_NCR5380_detect
 		else
 			instance->irq = NCR5380_probe_irq(instance, 0xffff);
 
-		if (instance->irq != SCSI_IRQ_NONE)
+		/* Compatibility with documented NCR5380 kernel parameters */
+		if (instance->irq == 255)
+			instance->irq = IRQ_NONE;
+
+		if (instance->irq != IRQ_NONE)
 			if (request_irq(instance->irq, generic_NCR5380_intr,
 					0, "NCR5380", instance)) {
 				printk(KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n", instance->host_no, instance->irq);
-				instance->irq = SCSI_IRQ_NONE;
+				instance->irq = IRQ_NONE;
 			}
 
-		if (instance->irq == SCSI_IRQ_NONE) {
+		if (instance->irq == IRQ_NONE) {
 			printk(KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n", instance->host_no);
 			printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 		}
 
 		printk(KERN_INFO "scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int) instance->NCR5380_instance_name);
-		if (instance->irq == SCSI_IRQ_NONE)
+		if (instance->irq == IRQ_NONE)
 			printk(" interrupts disabled");
 		else
 			printk(" irq %d", instance->irq);
@@ -486,7 +490,7 @@ static int generic_NCR5380_release_resou
 	NCR5380_local_declare();
 	NCR5380_setup(instance);
 	
-	if (instance->irq != SCSI_IRQ_NONE)
+	if (instance->irq != IRQ_NONE)
 		free_irq(instance->irq, instance);
 	NCR5380_exit(instance);
 
@@ -796,7 +800,7 @@ static int generic_NCR5380_show_info(str
 	PRINTP("NO NCR53C400 driver extensions\n");
 #endif
 	PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name);
-	if (scsi_ptr->irq == SCSI_IRQ_NONE)
+	if (scsi_ptr->irq == IRQ_NONE)
 		PRINTP("no interrupt\n");
 	else
 		PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq);
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:02.000000000 +1000
@@ -229,15 +229,15 @@ int __init macscsi_detect(struct scsi_ho
 
     instance->n_io_port = 255;
 
-    if (instance->irq != SCSI_IRQ_NONE)
+    if (instance->irq != IRQ_NONE)
 	if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) {
 	    printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
 		   instance->host_no, instance->irq);
-	    instance->irq = SCSI_IRQ_NONE;
+	    instance->irq = IRQ_NONE;
 	}
 
     printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port);
-    if (instance->irq == SCSI_IRQ_NONE)
+    if (instance->irq == IRQ_NONE)
 	printk (KERN_INFO "s disabled");
     else
 	printk (KERN_INFO " %d", instance->irq);
@@ -252,7 +252,7 @@ int __init macscsi_detect(struct scsi_ho
 
 int macscsi_release (struct Scsi_Host *shpnt)
 {
-	if (shpnt->irq != SCSI_IRQ_NONE)
+	if (shpnt->irq != IRQ_NONE)
 		free_irq(shpnt->irq, shpnt);
 	NCR5380_exit(shpnt);
 
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:02.000000000 +1000
@@ -278,7 +278,7 @@ static int __init sun3scsi_detect(struct
 #ifndef REAL_DMA
 		printk("scsi%d: IRQ%d not free, interrupts disabled\n",
 		       instance->host_no, instance->irq);
-		instance->irq = SCSI_IRQ_NONE;
+		instance->irq = IRQ_NONE;
 #else
 		printk("scsi%d: IRQ%d not free, bailing out\n",
 		       instance->host_no, instance->irq);
@@ -288,7 +288,7 @@ static int __init sun3scsi_detect(struct
 	
 	pr_info("scsi%d: %s at port %lX irq", instance->host_no,
 		tpnt->proc_name, instance->io_port);
-	if (instance->irq == SCSI_IRQ_NONE)
+	if (instance->irq == IRQ_NONE)
 		printk ("s disabled");
 	else
 		printk (" %d", instance->irq);
@@ -325,7 +325,7 @@ static int __init sun3scsi_detect(struct
 
 static int sun3scsi_release(struct Scsi_Host *shpnt)
 {
-	if (shpnt->irq != SCSI_IRQ_NONE)
+	if (shpnt->irq != IRQ_NONE)
 		free_irq(shpnt->irq, shpnt);
 
 	iounmap((void *)sun3_scsi_regp);



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 11/29] ncr5380: Remove NCR5380_STATS
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (9 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56   ` Finn Thain
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-NCR5380_STATS --]
[-- Type: text/plain, Size: 14678 bytes --]

The NCR5380_STATS option is only enabled by g_NCR5380 yet it adds
clutter to all three core drivers. The atari_NCR5380.c and sun3_NCR5380.c
core drivers have a slightly different implementation of the
NCR5380_STATS option.

Out of all ten NCR5380 drivers, only one of them (g_NCR5380) actually
has the code to report on the collected stats. Aside from being unreadable,
that code seems to be broken because there's no initialization of timebase.
sun3_NCR5380.c and atari_NCR5380.c have the timebase initialization but
lack the code to report the stats.

Remove all of this code to improve readability and reduce divergence
between the three core drivers.

This patch and the next one completely eliminate the PRINTP and ANDP
pre-processor abuse.

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

---
 drivers/scsi/NCR5380.c       |   64 ---------------------------------------
 drivers/scsi/NCR5380.h       |    9 -----
 drivers/scsi/atari_NCR5380.c |   65 ----------------------------------------
 drivers/scsi/g_NCR5380.c     |   45 ----------------------------
 drivers/scsi/sun3_NCR5380.c  |   69 -------------------------------------------
 5 files changed, 252 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:04.000000000 +1000
@@ -833,18 +833,6 @@ static int NCR5380_init(struct Scsi_Host
 	
 	INIT_DELAYED_WORK(&hostdata->coroutine, NCR5380_main);
 	
-#ifdef NCR5380_STATS
-	for (i = 0; i < 8; ++i) {
-		hostdata->time_read[i] = 0;
-		hostdata->time_write[i] = 0;
-		hostdata->bytes_read[i] = 0;
-		hostdata->bytes_write[i] = 0;
-	}
-	hostdata->timebase = 0;
-	hostdata->pendingw = 0;
-	hostdata->pendingr = 0;
-#endif
-
 	/* The CHECK code seems to break the 53C400. Will check it later maybe */
 	if (flags & FLAG_NCR53C400)
 		hostdata->flags = FLAG_HAS_LAST_BYTE_SENT | flags;
@@ -943,25 +931,6 @@ static int NCR5380_queue_command_lck(Scs
 	}
 #endif				/* (NDEBUG & NDEBUG_NO_WRITE) */
 
-#ifdef NCR5380_STATS
-	switch (cmd->cmnd[0]) {
-		case WRITE:
-		case WRITE_6:
-		case WRITE_10:
-			hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
-			hostdata->pendingw++;
-			break;
-		case READ:
-		case READ_6:
-		case READ_10:
-			hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
-			hostdata->pendingr++;
-			break;
-	}
-#endif
-
 	/* 
 	 * We use the host_scribble field as a pointer to the next command  
 	 * in a queue 
@@ -1206,35 +1175,6 @@ static irqreturn_t NCR5380_intr(int dumm
 
 #endif 
 
-/**
- *	collect_stats		-	collect stats on a scsi command
- *	@hostdata: adapter 
- *	@cmd: command being issued
- *
- *	Update the statistical data by parsing the command in question
- */
- 
-static void collect_stats(struct NCR5380_hostdata *hostdata, Scsi_Cmnd * cmd) 
-{
-#ifdef NCR5380_STATS
-	switch (cmd->cmnd[0]) {
-	case WRITE:
-	case WRITE_6:
-	case WRITE_10:
-		hostdata->time_write[scmd_id(cmd)] += (jiffies - hostdata->timebase);
-		hostdata->pendingw--;
-		break;
-	case READ:
-	case READ_6:
-	case READ_10:
-		hostdata->time_read[scmd_id(cmd)] += (jiffies - hostdata->timebase);
-		hostdata->pendingr--;
-		break;
-	}
-#endif
-}
-
-
 /* 
  * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
@@ -1463,7 +1403,6 @@ part2:
 			return -1;
 		}
 		cmd->result = DID_BAD_TARGET << 16;
-		collect_stats(hostdata, cmd);
 		cmd->scsi_done(cmd);
 		NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 		dprintk(NDEBUG_SELECTION, "scsi%d : target did not respond within 250ms\n", instance->host_no);
@@ -2215,7 +2154,6 @@ static void NCR5380_information_transfer
 					cmd->next_link->tag = cmd->tag;
 					cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
 					dprintk(NDEBUG_LINKED, "scsi%d : target %d lun %d linked request done, calling scsi_done().\n", instance->host_no, cmd->device->id, cmd->device->lun);
-					collect_stats(hostdata, cmd);
 					cmd->scsi_done(cmd);
 					cmd = hostdata->connected;
 					break;
@@ -2267,7 +2205,6 @@ static void NCR5380_information_transfer
 						hostdata->issue_queue = (Scsi_Cmnd *) cmd;
 						dprintk(NDEBUG_QUEUES, "scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no);
 					} else {
-						collect_stats(hostdata, cmd);
 						cmd->scsi_done(cmd);
 					}
 
@@ -2414,7 +2351,6 @@ static void NCR5380_information_transfer
 					hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
 					hostdata->connected = NULL;
 					cmd->result = DID_ERROR << 16;
-					collect_stats(hostdata, cmd);
 					cmd->scsi_done(cmd);
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 					return;
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:04.000000000 +1000
@@ -268,15 +268,6 @@ struct NCR5380_hostdata {
 	int select_time;			/* timer in select for target response */
 	volatile Scsi_Cmnd *selecting;
 	struct delayed_work coroutine;		/* our co-routine */
-#ifdef NCR5380_STATS
-	unsigned timebase;			/* Base for time calcs */
-	long time_read[8];			/* time to do reads */
-	long time_write[8];			/* time to do writes */
-	unsigned long bytes_read[8];		/* bytes read */
-	unsigned long bytes_write[8];		/* bytes written */
-	unsigned pendingr;
-	unsigned pendingw;
-#endif
 	struct scsi_eh_save ses;
 };
 
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
@@ -885,34 +885,6 @@ static int NCR5380_queue_command_lck(Scs
 	}
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
 
-#ifdef NCR5380_STATS
-# if 0
-	if (!hostdata->connected && !hostdata->issue_queue &&
-	    !hostdata->disconnected_queue) {
-		hostdata->timebase = jiffies;
-	}
-# endif
-# ifdef NCR5380_STAT_LIMIT
-	if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
-# endif
-		switch (cmd->cmnd[0]) {
-		case WRITE:
-		case WRITE_6:
-		case WRITE_10:
-			hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
-			hostdata->pendingw++;
-			break;
-		case READ:
-		case READ_6:
-		case READ_10:
-			hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
-			hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
-			hostdata->pendingr++;
-			break;
-		}
-#endif
-
 	/*
 	 * We use the host_scribble field as a pointer to the next command
 	 * in a queue
@@ -1305,31 +1277,6 @@ static irqreturn_t NCR5380_intr(int irq,
 	return IRQ_RETVAL(handled);
 }
 
-#ifdef NCR5380_STATS
-static void collect_stats(struct NCR5380_hostdata* hostdata, Scsi_Cmnd *cmd)
-{
-# ifdef NCR5380_STAT_LIMIT
-	if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
-# endif
-		switch (cmd->cmnd[0]) {
-		case WRITE:
-		case WRITE_6:
-		case WRITE_10:
-			hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
-			/*hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);*/
-			hostdata->pendingw--;
-			break;
-		case READ:
-		case READ_6:
-		case READ_10:
-			hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
-			/*hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);*/
-			hostdata->pendingr--;
-			break;
-		}
-}
-#endif
-
 /*
  * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
  *
@@ -1594,9 +1541,6 @@ static int NCR5380_select(struct Scsi_Ho
 			return -1;
 		}
 		cmd->result = DID_BAD_TARGET << 16;
-#ifdef NCR5380_STATS
-		collect_stats(hostdata, cmd);
-#endif
 #ifdef SUPPORT_TAGS
 		cmd_free_tag(cmd);
 #endif
@@ -2123,9 +2067,6 @@ static void NCR5380_information_transfer
 					dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked request "
 						   "done, calling scsi_done().\n",
 						   HOSTNO, cmd->device->id, cmd->device->lun);
-#ifdef NCR5380_STATS
-					collect_stats(hostdata, cmd);
-#endif
 					cmd->scsi_done(cmd);
 					cmd = hostdata->connected;
 					break;
@@ -2205,9 +2146,6 @@ static void NCR5380_information_transfer
 						dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 							  "issue queue\n", H_NO(cmd));
 					} else {
-#ifdef NCR5380_STATS
-						collect_stats(hostdata, cmd);
-#endif
 						cmd->scsi_done(cmd);
 					}
 
@@ -2392,9 +2330,6 @@ static void NCR5380_information_transfer
 #endif
 					hostdata->connected = NULL;
 					cmd->result = DID_ERROR << 16;
-#ifdef NCR5380_STATS
-					collect_stats(hostdata, cmd);
-#endif
 					cmd->scsi_done(cmd);
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 					falcon_release_lock_if_possible(hostdata);
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
@@ -69,8 +69,6 @@
 #define NCR53C400_PSEUDO_DMA 1
 #define PSEUDO_DMA
 #define NCR53C400
-#define NCR5380_STATS
-#undef NCR5380_STAT_LIMIT
 #endif
 
 #include <asm/io.h>
@@ -779,9 +777,6 @@ static int generic_NCR5380_show_info(str
 	int i;
 	Scsi_Cmnd *ptr;
 	struct NCR5380_hostdata *hostdata;
-#ifdef NCR5380_STATS
-	struct scsi_device *dev;
-#endif
 
 	NCR5380_setup(scsi_ptr);
 	hostdata = (struct NCR5380_hostdata *) scsi_ptr->hostdata;
@@ -805,46 +800,6 @@ static int generic_NCR5380_show_info(str
 	else
 		PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq);
 
-#ifdef NCR5380_STATS
-	if (hostdata->connected || hostdata->issue_queue || hostdata->disconnected_queue)
-		PRINTP("There are commands pending, transfer rates may be crud\n");
-	if (hostdata->pendingr)
-		PRINTP("  %d pending reads" ANDP hostdata->pendingr);
-	if (hostdata->pendingw)
-		PRINTP("  %d pending writes" ANDP hostdata->pendingw);
-	if (hostdata->pendingr || hostdata->pendingw)
-		PRINTP("\n");
-	shost_for_each_device(dev, scsi_ptr) {
-		unsigned long br = hostdata->bytes_read[dev->id];
-		unsigned long bw = hostdata->bytes_write[dev->id];
-		long tr = hostdata->time_read[dev->id] / HZ;
-		long tw = hostdata->time_write[dev->id] / HZ;
-
-		PRINTP("  T:%d %s " ANDP dev->id ANDP scsi_device_type(dev->type));
-		for (i = 0; i < 8; i++)
-			if (dev->vendor[i] >= 0x20)
-				seq_putc(m, dev->vendor[i]);
-		seq_putc(m, ' ');
-		for (i = 0; i < 16; i++)
-			if (dev->model[i] >= 0x20)
-				seq_putc(m, dev->model[i]);
-		seq_putc(m, ' ');
-		for (i = 0; i < 4; i++)
-			if (dev->rev[i] >= 0x20)
-				seq_putc(m, dev->rev[i]);
-		seq_putc(m, ' ');
-
-		PRINTP("\n%10ld kb read    in %5ld secs" ANDP br / 1024 ANDP tr);
-		if (tr)
-			PRINTP(" @ %5ld bps" ANDP br / tr);
-
-		PRINTP("\n%10ld kb written in %5ld secs" ANDP bw / 1024 ANDP tw);
-		if (tw)
-			PRINTP(" @ %5ld bps" ANDP bw / tw);
-		PRINTP("\n");
-	}
-#endif
-
 	status = NCR5380_read(STATUS_REG);
 	if (!(status & SR_REQ))
 		PRINTP("REQ not asserted, phase unknown.\n");
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
@@ -833,36 +833,6 @@ static int NCR5380_queue_command_lck(str
     }
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
 
-
-#ifdef NCR5380_STATS
-# if 0
-    if (!hostdata->connected && !hostdata->issue_queue &&
-	!hostdata->disconnected_queue) {
-	hostdata->timebase = jiffies;
-    }
-# endif
-# ifdef NCR5380_STAT_LIMIT
-    if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
-# endif
-	switch (cmd->cmnd[0])
-	{
-	    case WRITE:
-	    case WRITE_6:
-	    case WRITE_10:
-		hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase);
-		hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);
-		hostdata->pendingw++;
-		break;
-	    case READ:
-	    case READ_6:
-	    case READ_10:
-		hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase);
-		hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);
-		hostdata->pendingr++;
-		break;
-	}
-#endif
-
     /* 
      * We use the host_scribble field as a pointer to the next command  
      * in a queue 
@@ -1243,33 +1213,6 @@ static irqreturn_t NCR5380_intr (int irq
     return IRQ_RETVAL(handled);
 }
 
-#ifdef NCR5380_STATS
-static void collect_stats(struct NCR5380_hostdata *hostdata,
-			  struct scsi_cmnd *cmd)
-{
-# ifdef NCR5380_STAT_LIMIT
-    if (scsi_bufflen(cmd) > NCR5380_STAT_LIMIT)
-# endif
-	switch (cmd->cmnd[0])
-	{
-	    case WRITE:
-	    case WRITE_6:
-	    case WRITE_10:
-		hostdata->time_write[cmd->device->id] += (jiffies - hostdata->timebase);
-		/*hostdata->bytes_write[cmd->device->id] += scsi_bufflen(cmd);*/
-		hostdata->pendingw--;
-		break;
-	    case READ:
-	    case READ_6:
-	    case READ_10:
-		hostdata->time_read[cmd->device->id] += (jiffies - hostdata->timebase);
-		/*hostdata->bytes_read[cmd->device->id] += scsi_bufflen(cmd);*/
-		hostdata->pendingr--;
-		break;
-	}
-}
-#endif
-
 /* 
  * Function : int NCR5380_select(struct Scsi_Host *instance,
  *				 struct scsi_cmnd *cmd)
@@ -1535,9 +1478,6 @@ static int NCR5380_select(struct Scsi_Ho
 	    return -1;
 	}
 	cmd->result = DID_BAD_TARGET << 16;
-#ifdef NCR5380_STATS
-	collect_stats(hostdata, cmd);
-#endif
 #ifdef SUPPORT_TAGS
 	cmd_free_tag( cmd );
 #endif
@@ -2087,9 +2027,6 @@ static void NCR5380_information_transfer
 		    dprintk(NDEBUG_LINKED, "scsi%d: target %d lun %d linked request "
 			       "done, calling scsi_done().\n",
 			       HOSTNO, cmd->device->id, cmd->device->lun);
-#ifdef NCR5380_STATS
-		    collect_stats(hostdata, cmd);
-#endif
 		    cmd->scsi_done(cmd);
 		    cmd = hostdata->connected;
 		    break;
@@ -2171,9 +2108,6 @@ static void NCR5380_information_transfer
 			dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 				  "issue queue\n", H_NO(cmd));
 		   } else {
-#ifdef NCR5380_STATS
-		       collect_stats(hostdata, cmd);
-#endif
 		       cmd->scsi_done(cmd);
 		    }
 
@@ -2356,9 +2290,6 @@ static void NCR5380_information_transfer
 #endif
 		    hostdata->connected = NULL;
 		    cmd->result = DID_ERROR << 16;
-#ifdef NCR5380_STATS
-		    collect_stats(hostdata, cmd);
-#endif
 		    cmd->scsi_done(cmd);
 		    NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 		    return;

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 12/29] ncr5380: Cleanup host info() methods
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-info-methods --]
[-- Type: text/plain, Size: 32258 bytes --]

If the host->info() method is not set, then host->name is used by default.
For atari_scsi, that is exactly the same text. So remove the redundant
info() method. Keep sun3_scsi.c in line with atari_scsi.

Some NCR5380 drivers return an empty string from the info() method
(arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default
(dmx3191d dtc.c g_NCR5380.c pas16.c t128.c).

Implement a common info() method to replace a lot of duplicated code which
the various drivers use to announce the same information.

This replaces most of the (deprecated) show_info() output and all of the
NCR5380_print_info() output. This also eliminates a bunch of code in
g_NCR5380 which just duplicates functionality in the core driver.

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

---
 drivers/scsi/NCR5380.c       |   75 ++++++++++++++---------
 drivers/scsi/NCR5380.h       |    3 
 drivers/scsi/arm/cumana_1.c  |   14 ----
 drivers/scsi/arm/oak.c       |   14 ----
 drivers/scsi/atari_NCR5380.c |   58 +++++++++++-------
 drivers/scsi/atari_scsi.c    |   24 -------
 drivers/scsi/atari_scsi.h    |    1 
 drivers/scsi/dmx3191d.c      |    1 
 drivers/scsi/dtc.c           |   10 ---
 drivers/scsi/dtc.h           |    1 
 drivers/scsi/g_NCR5380.c     |  135 -------------------------------------------
 drivers/scsi/g_NCR5380.h     |    2 
 drivers/scsi/mac_scsi.c      |   14 ----
 drivers/scsi/mac_scsi.h      |    1 
 drivers/scsi/pas16.c         |   12 ---
 drivers/scsi/pas16.h         |    1 
 drivers/scsi/sun3_NCR5380.c  |   60 +++++++++++--------
 drivers/scsi/sun3_scsi.c     |   18 -----
 drivers/scsi/sun3_scsi.h     |    1 
 drivers/scsi/t128.c          |   11 ---
 drivers/scsi/t128.h          |    1 
 21 files changed, 137 insertions(+), 320 deletions(-)

Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/arm/cumana_1.c	2014-10-02 16:56:05.000000000 +1000
@@ -29,6 +29,7 @@
 #define NCR5380_write(reg, value)	cumanascsi_write(_instance, reg, value)
 #define NCR5380_intr			cumanascsi_intr
 #define NCR5380_queue_command		cumanascsi_queue_command
+#define NCR5380_info			cumanascsi_info
 
 #define NCR5380_implementation_fields	\
 	unsigned ctrl;			\
@@ -41,11 +42,6 @@ void cumanascsi_setup(char *str, int *in
 {
 }
 
-const char *cumanascsi_info(struct Scsi_Host *spnt)
-{
-	return "";
-}
-
 #define CTRL	0x16fc
 #define STAT	0x2004
 #define L(v)	(((v)<<16)|((v) & 0x0000ffff))
@@ -266,14 +262,6 @@ static int cumanascsi1_probe(struct expa
 		goto out_unmap;
 	}
 
-	printk("scsi%d: at port 0x%08lx irq %d",
-		host->host_no, host->io_port, host->irq);
-	printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
-		host->can_queue, host->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE);
-	printk("\nscsi%d:", host->host_no);
-	NCR5380_print_options(host);
-	printk("\n");
-
 	ret = scsi_add_host(host, &ec->dev);
 	if (ret)
 		goto out_free_irq;
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:56:05.000000000 +1000
@@ -29,6 +29,7 @@
 #define NCR5380_read(reg)		readb(_base + ((reg) << 2))
 #define NCR5380_write(reg, value)	writeb(value, _base + ((reg) << 2))
 #define NCR5380_queue_command		oakscsi_queue_command
+#define NCR5380_info			oakscsi_info
 #define NCR5380_show_info		oakscsi_show_info
 #define NCR5380_write_info		oakscsi_write_info
 
@@ -40,11 +41,6 @@
 #undef START_DMA_INITIATOR_RECEIVE_REG
 #define START_DMA_INITIATOR_RECEIVE_REG	(128 + 7)
 
-const char * oakscsi_info (struct Scsi_Host *spnt)
-{
-	return "";
-}
-
 #define STAT	((128 + 16) << 2)
 #define DATA	((128 + 8) << 2)
 
@@ -153,14 +149,6 @@ static int oakscsi_probe(struct expansio
 
 	NCR5380_init(host, 0);
 
-	printk("scsi%d: at port 0x%08lx irqs disabled",
-		host->host_no, host->io_port);
-	printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
-		host->can_queue, host->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE);
-	printk("\nscsi%d:", host->host_no);
-	NCR5380_print_options(host);
-	printk("\n");
-
 	ret = scsi_add_host(host, &ec->dev);
 	if (ret)
 		goto out_unmap;
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:55:58.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:05.000000000 +1000
@@ -699,21 +699,6 @@ static int __init atari_scsi_detect(stru
 #endif
 	}
 
-	printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d "
-#ifdef SUPPORT_TAGS
-			"TAGGED-QUEUING=%s "
-#endif
-			"HOSTID=%d",
-			instance->host_no, instance->hostt->can_queue,
-			instance->hostt->cmd_per_lun,
-			instance->hostt->sg_tablesize,
-#ifdef SUPPORT_TAGS
-			setup_use_tagged_queuing ? "yes" : "no",
-#endif
-			instance->hostt->this_id );
-	NCR5380_print_options(instance);
-	printk("\n");
-
 	called = 1;
 	return 1;
 }
@@ -815,15 +800,6 @@ static void __init atari_scsi_reset_boot
 }
 #endif
 
-
-static const char *atari_scsi_info(struct Scsi_Host *host)
-{
-	/* atari_scsi_detect() is verbose enough... */
-	static const char string[] = "Atari native SCSI";
-	return string;
-}
-
-
 #if defined(REAL_DMA)
 
 static unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance,
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:05.000000000 +1000
@@ -236,16 +236,6 @@ int __init macscsi_detect(struct scsi_ho
 	    instance->irq = IRQ_NONE;
 	}
 
-    printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port);
-    if (instance->irq == IRQ_NONE)
-	printk (KERN_INFO "s disabled");
-    else
-	printk (KERN_INFO " %d", instance->irq);
-    printk(KERN_INFO " options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
-	   instance->can_queue, instance->cmd_per_lun, MACSCSI_PUBLIC_RELEASE);
-    printk(KERN_INFO "\nscsi%d:", instance->host_no);
-    NCR5380_print_options(instance);
-    printk("\n");
     called = 1;
     return 1;
 }
@@ -297,10 +287,6 @@ static void mac_scsi_reset_boot(struct S
 }
 #endif
 
-const char * macscsi_info (struct Scsi_Host *spnt) {
-	return "";
-}
-
 /* 
    Pseudo-DMA: (Ove Edlund)
    The code attempts to catch bus errors that occur if one for example
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:05.000000000 +1000
@@ -286,19 +286,6 @@ static int __init sun3scsi_detect(struct
 #endif
 	}
 	
-	pr_info("scsi%d: %s at port %lX irq", instance->host_no,
-		tpnt->proc_name, instance->io_port);
-	if (instance->irq == IRQ_NONE)
-		printk ("s disabled");
-	else
-		printk (" %d", instance->irq);
-	printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d",
-	       instance->can_queue, instance->cmd_per_lun,
-	       SUN3SCSI_PUBLIC_RELEASE);
-	printk("\nscsi%d:", instance->host_no);
-	NCR5380_print_options(instance);
-	printk("\n");
-
 	dregs->csr = 0;
 	udelay(SUN3_DMA_DELAY);
 	dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR;
@@ -380,11 +367,6 @@ static void sun3_scsi_reset_boot(struct
 }
 #endif
 
-static const char *sun3scsi_info(struct Scsi_Host *spnt)
-{
-    return "";
-}
-
 // safe bits for the CSR
 #define CSR_GOOD 0x060f
 
Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:56:04.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:05.000000000 +1000
@@ -610,47 +610,71 @@ static int __init __maybe_unused NCR5380
 }
 
 /**
- *	NCR58380_print_options	-	show options
- *	@instance: unused for now
+ *	NCR58380_info - report driver and host information
+ *	@instance: relevant scsi host instance
  *
- *	Called by probe code indicating the NCR5380 driver options that 
- *	were selected. At some point this will switch to runtime options
- *	read from the adapter in question
+ *	For use as the host template info() handler.
  *
  *	Locks: none
  */
 
-static void __init __maybe_unused
-NCR5380_print_options(struct Scsi_Host *instance)
+static const char *NCR5380_info(struct Scsi_Host *instance)
 {
-	printk(" generic options"
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	return hostdata->info;
+}
+
+static void prepare_info(struct Scsi_Host *instance)
+{
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	snprintf(hostdata->info, sizeof(hostdata->info),
+	         "%s, io_port 0x%lx, n_io_port %d, "
+	         "base 0x%lx, irq %d, "
+	         "can_queue %d, cmd_per_lun %d, "
+	         "sg_tablesize %d, this_id %d, "
+	         "flags { %s%s%s}, "
+#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG)
+	         "USLEEP_POLL %d, USLEEP_WAITLONG %d, "
+#endif
+	         "options { %s} ",
+	         instance->hostt->name, instance->io_port, instance->n_io_port,
+	         instance->base, instance->irq,
+	         instance->can_queue, instance->cmd_per_lun,
+	         instance->sg_tablesize, instance->this_id,
+	         hostdata->flags & FLAG_NCR53C400     ? "NCR53C400 "     : "",
+	         hostdata->flags & FLAG_DTC3181E      ? "DTC3181E "      : "",
+	         hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "",
+#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG)
+	         USLEEP_POLL, USLEEP_WAITLONG,
+#endif
 #ifdef AUTOPROBE_IRQ
-	       " AUTOPROBE_IRQ"
+	         "AUTOPROBE_IRQ "
 #endif
 #ifdef DIFFERENTIAL
-	       " DIFFERENTIAL"
+	         "DIFFERENTIAL "
 #endif
 #ifdef REAL_DMA
-	       " REAL DMA"
+	         "REAL_DMA "
 #endif
 #ifdef REAL_DMA_POLL
-	       " REAL DMA POLL"
+	         "REAL_DMA_POLL "
 #endif
 #ifdef PARITY
-	       " PARITY"
+	         "PARITY "
 #endif
 #ifdef PSEUDO_DMA
-	       " PSEUDO DMA"
+	         "PSEUDO_DMA "
 #endif
 #ifdef UNSAFE
-	       " UNSAFE "
+	         "UNSAFE "
 #endif
-	    );
-	printk(" USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP);
-	printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
-	if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) {
-		printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE);
-	}
+#ifdef NCR53C400
+	         "NCR53C400 "
+#endif
+	         "");
+	hostdata->info[sizeof(hostdata->info) - 1] = '\0';
 }
 
 /**
@@ -728,13 +752,6 @@ static int __maybe_unused NCR5380_show_i
 	SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
 #endif
 
-	SPRINTF("\nBase Addr: 0x%05lX    ", (long) instance->base);
-	SPRINTF("io_port: %04x      ", (int) instance->io_port);
-	if (instance->irq == IRQ_NONE)
-		SPRINTF("IRQ: None.\n");
-	else
-		SPRINTF("IRQ: %d.\n", instance->irq);
-
 #ifdef DTC_PUBLIC_RELEASE
 	SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", dtc_wmaxi, dtc_maxi);
 #endif
@@ -842,6 +859,8 @@ static int NCR5380_init(struct Scsi_Host
 	hostdata->host = instance;
 	hostdata->time_expires = 0;
 
+	prepare_info(instance);
+
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 	NCR5380_write(MODE_REG, MR_BASE);
 	NCR5380_write(TARGET_COMMAND_REG, 0);
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:04.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:05.000000000 +1000
@@ -269,6 +269,7 @@ struct NCR5380_hostdata {
 	volatile Scsi_Cmnd *selecting;
 	struct delayed_work coroutine;		/* our co-routine */
 	struct scsi_eh_save ses;
+	char info[256];
 };
 
 #ifdef __KERNEL__
@@ -303,7 +304,7 @@ static void NCR5380_information_transfer
 static irqreturn_t NCR5380_intr(int irq, void *dev_id);
 #endif
 static void NCR5380_main(struct work_struct *work);
-static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance);
+static const char *NCR5380_info(struct Scsi_Host *instance);
 static void NCR5380_reselect(struct Scsi_Host *instance);
 static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd);
 #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:05.000000000 +1000
@@ -281,15 +281,6 @@ found:
 		printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
-		printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) instance->base);
-		if (instance->irq == IRQ_NONE)
-			printk(" interrupts disabled");
-		else
-			printk(" irq %d", instance->irq);
-		printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, DTC_PUBLIC_RELEASE);
-		NCR5380_print_options(instance);
-		printk("\n");
-
 		++current_override;
 		++count;
 	}
@@ -461,6 +452,7 @@ static struct scsi_host_template driver_
 	.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,
 	.eh_bus_reset_handler		= dtc_bus_reset,
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
@@ -446,15 +446,6 @@ static int __init generic_NCR5380_detect
 			printk(KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n", instance->host_no);
 		}
 
-		printk(KERN_INFO "scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int) instance->NCR5380_instance_name);
-		if (instance->irq == IRQ_NONE)
-			printk(" interrupts disabled");
-		else
-			printk(" irq %d", instance->irq);
-		printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, GENERIC_NCR5380_PUBLIC_RELEASE);
-		NCR5380_print_options(instance);
-		printk("\n");
-
 		++current_override;
 		++count;
 	}
@@ -462,19 +453,6 @@ static int __init generic_NCR5380_detect
 }
 
 /**
- *	generic_NCR5380_info	-	reporting string
- *	@host: NCR5380 to report on
- *
- *	Report driver information for the NCR5380
- */
- 	
-static const char *generic_NCR5380_info(struct Scsi_Host *host)
-{
-	static const char string[] = "Generic NCR5380/53C400 Driver";
-	return string;
-}
-
-/**
  *	generic_NCR5380_release_resources	-	free resources
  *	@instance: host adapter to clean up 
  *
@@ -720,120 +698,9 @@ static inline int NCR5380_pwrite(struct
  
 #include "NCR5380.c"
 
-#define PRINTP(x) seq_printf(m, x)
-#define ANDP ,
-
-static void sprint_opcode(struct seq_file *m, int opcode)
-{
-	PRINTP("0x%02x " ANDP opcode);
-}
-
-static void sprint_command(struct seq_file *m, unsigned char *command)
-{
-	int i, s;
-	sprint_opcode(m, command[0]);
-	for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
-		PRINTP("%02x " ANDP command[i]);
-	PRINTP("\n");
-}
-
-/**
- *	sprintf_Scsi_Cmnd	-	print a scsi command
- *	@m: seq_fil to print into
- *	@cmd: SCSI command block
- *	
- *	Print out the target and command data in hex
- */
-
-static void sprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd * cmd)
-{
-	PRINTP("host number %d destination target %d, lun %d\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun);
-	PRINTP("        command = ");
-	sprint_command(m, cmd->cmnd);
-}
-
-/**
- *	generic_NCR5380_proc_info	-	/proc for NCR5380 driver
- *	@buffer: buffer to print into
- *	@start: start position
- *	@offset: offset into buffer
- *	@len: length
- *	@hostno: instance to affect
- *	@inout: read/write
- *
- *	Provide the procfs information for the 5380 controller. We fill
- *	this with useful debugging information including the commands
- *	being executed, disconnected command queue and the statistical
- *	data
- *
- *	Locks: global cli/lock for queue walk
- */
- 
-static int generic_NCR5380_show_info(struct seq_file *m, struct Scsi_Host *scsi_ptr)
-{
-	NCR5380_local_declare();
-	unsigned long flags;
-	unsigned char status;
-	int i;
-	Scsi_Cmnd *ptr;
-	struct NCR5380_hostdata *hostdata;
-
-	NCR5380_setup(scsi_ptr);
-	hostdata = (struct NCR5380_hostdata *) scsi_ptr->hostdata;
-
-	spin_lock_irqsave(scsi_ptr->host_lock, flags);
-	PRINTP("SCSI host number %d : %s\n" ANDP scsi_ptr->host_no ANDP scsi_ptr->hostt->name);
-	PRINTP("Generic NCR5380 driver version %d\n" ANDP GENERIC_NCR5380_PUBLIC_RELEASE);
-	PRINTP("NCR5380 core version %d\n" ANDP NCR5380_PUBLIC_RELEASE);
-#ifdef NCR53C400
-	PRINTP("NCR53C400 extension version %d\n" ANDP NCR53C400_PUBLIC_RELEASE);
-	PRINTP("NCR53C400 card%s detected\n" ANDP(((struct NCR5380_hostdata *) scsi_ptr->hostdata)->flags & FLAG_NCR53C400) ? "" : " not");
-# if NCR53C400_PSEUDO_DMA
-	PRINTP("NCR53C400 pseudo DMA used\n");
-# endif
-#else
-	PRINTP("NO NCR53C400 driver extensions\n");
-#endif
-	PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name);
-	if (scsi_ptr->irq == IRQ_NONE)
-		PRINTP("no interrupt\n");
-	else
-		PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq);
-
-	status = NCR5380_read(STATUS_REG);
-	if (!(status & SR_REQ))
-		PRINTP("REQ not asserted, phase unknown.\n");
-	else {
-		for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i);
-		PRINTP("Phase %s\n" ANDP phases[i].name);
-	}
-
-	if (!hostdata->connected) {
-		PRINTP("No currently connected command\n");
-	} else {
-		sprint_Scsi_Cmnd(m, (Scsi_Cmnd *) hostdata->connected);
-	}
-
-	PRINTP("issue_queue\n");
-
-	for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
-		sprint_Scsi_Cmnd(m, ptr);
-
-	PRINTP("disconnected_queue\n");
-
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
-		sprint_Scsi_Cmnd(m, ptr);
-
-	spin_unlock_irqrestore(scsi_ptr->host_lock, flags);
-	return 0;
-}
-
-#undef PRINTP
-#undef ANDP
-
 static struct scsi_host_template driver_template = {
 	.show_info      	= generic_NCR5380_show_info,
-	.name           	= "Generic NCR5380/NCR53C400 Scsi Driver",
+	.name           	= "Generic NCR5380/NCR53C400 SCSI",
 	.detect         	= generic_NCR5380_detect,
 	.release        	= generic_NCR5380_release_resources,
 	.info           	= generic_NCR5380_info,
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:56:05.000000000 +1000
@@ -438,17 +438,6 @@ static int __init pas16_detect(struct sc
 	printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
-	printk("scsi%d : at 0x%04x", instance->host_no, (int) 
-	    instance->io_port);
-	if (instance->irq == IRQ_NONE)
-	    printk (" interrupts disabled");
-	else 
-	    printk (" irq %d", instance->irq);
-	printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
-	    CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE);
-	NCR5380_print_options(instance);
-	printk("\n");
-
 	++current_override;
 	++count;
     }
@@ -588,6 +577,7 @@ static struct scsi_host_template driver_
 	.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,
 	.eh_bus_reset_handler = pas16_bus_reset,
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:56:05.000000000 +1000
@@ -249,16 +249,6 @@ found:
 	printk("scsi%d : irq = %d\n", instance->host_no, instance->irq);
 #endif
 
-	printk("scsi%d : at 0x%08lx", instance->host_no, instance->base);
-	if (instance->irq == IRQ_NONE)
-	    printk (" interrupts disabled");
-	else 
-	    printk (" irq %d", instance->irq);
-	printk(" options CAN_QUEUE=%d  CMD_PER_LUN=%d release=%d",
-	    CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE);
-	NCR5380_print_options(instance);
-	printk("\n");
-
 	++current_override;
 	++count;
     }
@@ -411,6 +401,7 @@ static struct scsi_host_template driver_
 	.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,
 	.eh_bus_reset_handler    = t128_bus_reset,
Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:56:02.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:56:05.000000000 +1000
@@ -57,6 +57,7 @@
 static struct scsi_host_template dmx3191d_driver_template = {
 	.proc_name		= DMX3191D_DRIVER_NAME,
 	.name			= "Domex DMX3191D",
+	.info			= NCR5380_info,
 	.queuecommand		= NCR5380_queue_command,
 	.eh_abort_handler	= NCR5380_abort,
 	.eh_bus_reset_handler	= NCR5380_bus_reset,
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.h	2014-10-02 16:56:05.000000000 +1000
@@ -100,6 +100,8 @@
 #define NCR5380_bus_reset generic_NCR5380_bus_reset
 #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/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/dtc.h	2014-10-02 16:56:05.000000000 +1000
@@ -65,6 +65,7 @@
 #define NCR5380_queue_command		dtc_queue_command
 #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 
 
Index: linux/drivers/scsi/pas16.h
===================================================================
--- linux.orig/drivers/scsi/pas16.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/pas16.h	2014-10-02 16:56:05.000000000 +1000
@@ -143,6 +143,7 @@
 #define NCR5380_queue_command pas16_queue_command
 #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
 
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/t128.h	2014-10-02 16:56:05.000000000 +1000
@@ -116,6 +116,7 @@
 #define NCR5380_queue_command t128_queue_command
 #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
 
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.h	2014-10-02 16:56:05.000000000 +1000
@@ -53,6 +53,7 @@
 #define NCR5380_queue_command macscsi_queue_command
 #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
 
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
@@ -144,12 +144,6 @@
  * be able to coexist with appropriate changes to the high level
  * SCSI code.
  *
- * A NCR5380_PUBLIC_REVISION macro is provided, with the release
- * number (updated for each public release) printed by the
- * NCR5380_print_options command, which should be called from the
- * wrapper detect function, so that I know what release of the driver
- * users are using.
- *
  * Issues specific to the NCR5380 :
  *
  * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead
@@ -247,7 +241,6 @@
  * NCR5380_queue_command
  * NCR5380_reset
  * NCR5380_abort
- * NCR5380_proc_info
  *
  * to be the global entry points into the specific driver, ie
  * #define NCR5380_queue_command t128_queue_command.
@@ -259,8 +252,7 @@
  * The generic driver is initialized by calling NCR5380_init(instance),
  * after setting the appropriate host specific fields and ID.  If the
  * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
- * possible) function may be used.  Before the specific driver initialization
- * code finishes, NCR5380_print_options should be called.
+ * possible) function may be used.
  */
 
 static struct Scsi_Host *first_instance = NULL;
@@ -667,30 +659,50 @@ static inline void NCR5380_all_init(void
 	}
 }
 
-
-/*
- * Function : void NCR58380_print_options (struct Scsi_Host *instance)
+/**
+ * NCR58380_info - report driver and host information
+ * @instance: relevant scsi host instance
  *
- * Purpose : called by probe code indicating the NCR5380 driver
- *	     options that were selected.
+ * For use as the host template info() handler.
  *
- * Inputs : instance, pointer to this instance.  Unused.
+ * Locks: none
  */
 
-static void __init NCR5380_print_options(struct Scsi_Host *instance)
+static const char *NCR5380_info(struct Scsi_Host *instance)
+{
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	return hostdata->info;
+}
+
+static void prepare_info(struct Scsi_Host *instance)
 {
-	printk(" generic options"
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	snprintf(hostdata->info, sizeof(hostdata->info),
+	         "%s, io_port 0x%lx, n_io_port %d, "
+	         "base 0x%lx, irq %d, "
+	         "can_queue %d, cmd_per_lun %d, "
+	         "sg_tablesize %d, this_id %d, "
+	         "options { %s} ",
+	         instance->hostt->name, instance->io_port, instance->n_io_port,
+	         instance->base, instance->irq,
+	         instance->can_queue, instance->cmd_per_lun,
+	         instance->sg_tablesize, instance->this_id,
+#ifdef DIFFERENTIAL
+	         "DIFFERENTIAL "
+#endif
 #ifdef REAL_DMA
-	       " REAL DMA"
+	         "REAL_DMA "
 #endif
 #ifdef PARITY
-	       " PARITY"
+	         "PARITY "
 #endif
 #ifdef SUPPORT_TAGS
-	       " SCSI-2 TAGGED QUEUING"
+	         "SUPPORT_TAGS "
 #endif
-	       );
-	printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
+	         "");
+	hostdata->info[sizeof(hostdata->info) - 1] = '\0';
 }
 
 /*
@@ -836,6 +848,8 @@ static int __init NCR5380_init(struct Sc
 		first_instance = instance;
 	}
 
+	prepare_info(instance);
+
 	NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 	NCR5380_write(MODE_REG, MR_BASE);
 	NCR5380_write(TARGET_COMMAND_REG, 0);
Index: linux/drivers/scsi/atari_scsi.h
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:55:52.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.h	2014-10-02 16:56:05.000000000 +1000
@@ -47,6 +47,7 @@
 #define NCR5380_queue_command atari_scsi_queue_command
 #define NCR5380_abort atari_scsi_abort
 #define NCR5380_show_info atari_scsi_show_info
+#define NCR5380_info atari_scsi_info
 #define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0)
 #define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1)
 #define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst )
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:04.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
@@ -131,12 +131,6 @@
  * be able to coexist with appropriate changes to the high level
  * SCSI code.  
  *
- * A NCR5380_PUBLIC_REVISION macro is provided, with the release
- * number (updated for each public release) printed by the 
- * NCR5380_print_options command, which should be called from the 
- * wrapper detect function, so that I know what release of the driver
- * users are using.
- *
  * Issues specific to the NCR5380 : 
  *
  * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead 
@@ -234,7 +228,6 @@
  * NCR5380_queue_command
  * NCR5380_reset
  * NCR5380_abort
- * NCR5380_proc_info
  *
  * to be the global entry points into the specific driver, ie 
  * #define NCR5380_queue_command t128_queue_command.
@@ -246,8 +239,7 @@
  * The generic driver is initialized by calling NCR5380_init(instance),
  * after setting the appropriate host specific fields and ID.  If the 
  * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance,
- * possible) function may be used.  Before the specific driver initialization
- * code finishes, NCR5380_print_options should be called.
+ * possible) function may be used.
  */
 
 static struct Scsi_Host *first_instance = NULL;
@@ -613,30 +605,50 @@ static inline void NCR5380_all_init (voi
     }
 }
 
- 
-/*
- * Function : void NCR58380_print_options (struct Scsi_Host *instance)
+/**
+ * NCR58380_info - report driver and host information
+ * @instance: relevant scsi host instance
  *
- * Purpose : called by probe code indicating the NCR5380 driver
- *	     options that were selected.
+ * For use as the host template info() handler.
  *
- * Inputs : instance, pointer to this instance.  Unused.
+ * Locks: none
  */
 
-static void __init NCR5380_print_options (struct Scsi_Host *instance)
+static const char *NCR5380_info(struct Scsi_Host *instance)
+{
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	return hostdata->info;
+}
+
+static void prepare_info(struct Scsi_Host *instance)
 {
-    printk(" generic options"
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	snprintf(hostdata->info, sizeof(hostdata->info),
+	         "%s, io_port 0x%lx, n_io_port %d, "
+	         "base 0x%lx, irq %d, "
+	         "can_queue %d, cmd_per_lun %d, "
+	         "sg_tablesize %d, this_id %d, "
+	         "options { %s} ",
+	         instance->hostt->name, instance->io_port, instance->n_io_port,
+	         instance->base, instance->irq,
+	         instance->can_queue, instance->cmd_per_lun,
+	         instance->sg_tablesize, instance->this_id,
+#ifdef DIFFERENTIAL
+	         "DIFFERENTIAL "
+#endif
 #ifdef REAL_DMA
-    " REAL DMA"
+	         "REAL_DMA "
 #endif
 #ifdef PARITY
-    " PARITY"
+	         "PARITY "
 #endif
 #ifdef SUPPORT_TAGS
-    " SCSI-2 TAGGED QUEUING"
+	         "SUPPORT_TAGS "
 #endif
-    );
-    printk(" generic release=%d", NCR5380_PUBLIC_RELEASE);
+	         "");
+	hostdata->info[sizeof(hostdata->info) - 1] = '\0';
 }
 
 /*
@@ -781,7 +793,9 @@ static int __init NCR5380_init(struct Sc
 	the_template = instance->hostt;
 	first_instance = instance;
     }
-	
+
+    prepare_info(instance);
+
     NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
     NCR5380_write(MODE_REG, MR_BASE);
     NCR5380_write(TARGET_COMMAND_REG, 0);
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:00.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:05.000000000 +1000
@@ -74,6 +74,7 @@
 #define NCR5380_bus_reset sun3scsi_bus_reset
 #define NCR5380_abort sun3scsi_abort
 #define NCR5380_show_info sun3scsi_show_info
+#define NCR5380_info sun3scsi_info
 #define NCR5380_dma_xfer_len(i, cmd, phase) \
         sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
 



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 12/29] ncr5380: Cleanup host info() methods
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-info-methods
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/51209ff3/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 13/29] ncr5380: Move static PDMA spin counters to host data
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-move-pdma-spin-counters --]
[-- Type: text/plain, Size: 6904 bytes --]

Static variables from dtc.c and pas16.c should not appear in the core
NCR5380.c driver. Aside from being a layering issue this worsens the
divergence between the three core driver variants (atari_NCR5380.c and
sun3_NCR5380.c don't support PSEUDO_DMA) and it can mean multiple hosts
share the same counters.

Fix this by making the pseudo DMA spin counters in the core more generic.
This also avoids the abuse of the {DTC,PAS16}_PUBLIC_RELEASE macros, so
they can be removed.

oak.c doesn't use PDMA and hence it doesn't use the counters and hence it
needs no write_info() method. Remove it.

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

---
 drivers/scsi/NCR5380.c |   22 ++++++++++------------
 drivers/scsi/NCR5380.h |    4 ++++
 drivers/scsi/arm/oak.c |    2 --
 drivers/scsi/dtc.c     |   13 ++++++-------
 drivers/scsi/pas16.c   |   12 ++++++------
 5 files changed, 26 insertions(+), 27 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:09.000000000 +1000
@@ -693,6 +693,7 @@ static void NCR5380_print_status(struct
 	NCR5380_dprint_phase(NDEBUG_ANY, instance);
 }
 
+#ifdef PSEUDO_DMA
 /******************************************/
 /*
  * /proc/scsi/[dtc pas16 t128 generic]/[0-ASC_NUM_BOARD_SUPPORTED]
@@ -710,14 +711,13 @@ static void NCR5380_print_status(struct
 static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance,
 	char *buffer, int length)
 {
-#ifdef DTC_PUBLIC_RELEASE
-	dtc_wmaxi = dtc_maxi = 0;
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-	pas_wmaxi = pas_maxi = 0;
-#endif
-	return (-ENOSYS);	/* Currently this is a no-op */
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+	hostdata->spin_max_r = 0;
+	hostdata->spin_max_w = 0;
+	return 0;
 }
+#endif
 
 #undef SPRINTF
 #define SPRINTF(args...) seq_printf(m, ## args)
@@ -752,11 +752,9 @@ static int __maybe_unused NCR5380_show_i
 	SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
 #endif
 
-#ifdef DTC_PUBLIC_RELEASE
-	SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", dtc_wmaxi, dtc_maxi);
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-	SPRINTF("Highwater I/O busy_spin_counts -- write: %d  read: %d\n", pas_wmaxi, pas_maxi);
+#ifdef PSEUDO_DMA
+	SPRINTF("Highwater I/O busy spin counts: write %d, read %d\n",
+	        hostdata->spin_max_w, hostdata->spin_max_r);
 #endif
 	spin_lock_irq(instance->host_lock);
 	if (!hostdata->connected)
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:09.000000000 +1000
@@ -270,6 +270,10 @@ struct NCR5380_hostdata {
 	struct delayed_work coroutine;		/* our co-routine */
 	struct scsi_eh_save ses;
 	char info[256];
+#ifdef PSEUDO_DMA
+	unsigned spin_max_r;
+	unsigned spin_max_w;
+#endif
 };
 
 #ifdef __KERNEL__
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:09.000000000 +1000
@@ -332,13 +332,11 @@ static int dtc_biosparam(struct scsi_dev
  * 	timeout.
 */
 
-static int dtc_maxi = 0;
-static int dtc_wmaxi = 0;
-
 static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst, int len)
 {
 	unsigned char *d = dst;
 	int i;			/* For counting time spent in the poll-loop */
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	NCR5380_local_declare();
 	NCR5380_setup(instance);
 
@@ -369,8 +367,8 @@ static inline int NCR5380_pread(struct S
 	NCR5380_write(MODE_REG, 0);	/* Clear the operating mode */
 	rtrc(0);
 	NCR5380_read(RESET_PARITY_INTERRUPT_REG);
-	if (i > dtc_maxi)
-		dtc_maxi = i;
+	if (i > hostdata->spin_max_r)
+		hostdata->spin_max_r = i;
 	return (0);
 }
 
@@ -390,6 +388,7 @@ static inline int NCR5380_pread(struct S
 static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, int len)
 {
 	int i;
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	NCR5380_local_declare();
 	NCR5380_setup(instance);
 
@@ -422,8 +421,8 @@ static inline int NCR5380_pwrite(struct
 	/* Check for parity error here. fixme. */
 	NCR5380_write(MODE_REG, 0);	/* Clear the operating mode */
 	rtrc(0);
-	if (i > dtc_wmaxi)
-		dtc_wmaxi = i;
+	if (i > hostdata->spin_max_w)
+		hostdata->spin_max_w = i;
 	return (0);
 }
 
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:56:09.000000000 +1000
@@ -88,8 +88,6 @@
 #include "NCR5380.h"
 
 
-static int pas_maxi = 0;
-static int pas_wmaxi = 0;
 static unsigned short pas16_addr = 0;
 static int pas16_irq = 0;
  
@@ -502,6 +500,7 @@ 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;
@@ -514,8 +513,8 @@ static inline int NCR5380_pread (struct
 	    instance->host_no);
 	return -1;
     }
-   if (ii > pas_maxi)
-      pas_maxi = ii;
+    if (ii > hostdata->spin_max_r)
+        hostdata->spin_max_r = ii;
     return 0;
 }
 
@@ -538,6 +537,7 @@ 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;
@@ -550,8 +550,8 @@ static inline int NCR5380_pwrite (struct
 	    instance->host_no);
 	return -1;
     }
-    if (ii > pas_maxi)
-	 pas_wmaxi = ii;
+    if (ii > hostdata->spin_max_w)
+        hostdata->spin_max_w = ii;
     return 0;
 }
 
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:56:09.000000000 +1000
@@ -31,7 +31,6 @@
 #define NCR5380_queue_command		oakscsi_queue_command
 #define NCR5380_info			oakscsi_info
 #define NCR5380_show_info		oakscsi_show_info
-#define NCR5380_write_info		oakscsi_write_info
 
 #define NCR5380_implementation_fields	\
 	void __iomem *base
@@ -108,7 +107,6 @@ printk("reading %p len %d\n", addr, len)
 static struct scsi_host_template oakscsi_template = {
 	.module			= THIS_MODULE,
 	.show_info		= oakscsi_show_info,
-	.write_info		= oakscsi_write_info,
 	.name			= "Oak 16-bit SCSI",
 	.info			= oakscsi_info,
 	.queuecommand		= oakscsi_queue_command,

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 13/29] ncr5380: Move static PDMA spin counters to host data
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-move-pdma-spin-counters
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/b6a4c33e/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 14/29] ncr5380: Remove pointless compiler command line override macros
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (12 preceding siblings ...)
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56   ` Finn Thain
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-compiler-invocation-macros --]
[-- Type: text/plain, Size: 6071 bytes --]

Compile-time override of scsi host defaults is pointless for drivers that
provide module parameters and __setup options for that. Too many macros make
the code hard to read so remove them.

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

---
 drivers/scsi/atari_scsi.c |    2 +-
 drivers/scsi/atari_scsi.h |    3 ---
 drivers/scsi/mac_scsi.c   |   19 +++++++++----------
 drivers/scsi/mac_scsi.h   |   16 ----------------
 drivers/scsi/sun3_scsi.c  |   20 ++++++++++----------
 drivers/scsi/sun3_scsi.h  |   18 ------------------
 6 files changed, 20 insertions(+), 58 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:10.000000000 +1000
@@ -177,13 +177,12 @@ int __init macscsi_detect(struct scsi_ho
     if (macintosh_config->scsi_type != MAC_SCSI_OLD)
 	return( 0 );
 
-    /* setup variables */
-    tpnt->can_queue =
-	(setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE;
-    tpnt->cmd_per_lun =
-	(setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN;
-    tpnt->sg_tablesize = 
-	(setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE;
+	if (setup_can_queue > 0)
+		tpnt->can_queue = setup_can_queue;
+	if (setup_cmd_per_lun > 0)
+		tpnt->cmd_per_lun = setup_cmd_per_lun;
+	if (setup_sg_tablesize >= 0)
+		tpnt->sg_tablesize = setup_sg_tablesize;
 
     if (setup_hostid >= 0)
 	tpnt->this_id = setup_hostid;
@@ -194,7 +193,7 @@ int __init macscsi_detect(struct scsi_ho
 
 #ifdef SUPPORT_TAGS
     if (setup_use_tagged_queuing < 0)
-	setup_use_tagged_queuing = USE_TAGGED_QUEUING;
+	setup_use_tagged_queuing = 0;
 #endif
 
     /* Once we support multiple 5380s (e.g. DuoDock) we'll do
@@ -496,10 +495,10 @@ static struct scsi_host_template driver_
 	.queuecommand			= macscsi_queue_command,
 	.eh_abort_handler		= macscsi_abort,
 	.eh_bus_reset_handler		= macscsi_bus_reset,
-	.can_queue			= CAN_QUEUE,
+	.can_queue			= 16,
 	.this_id			= 7,
 	.sg_tablesize			= SG_ALL,
-	.cmd_per_lun			= CMD_PER_LUN,
+	.cmd_per_lun			= 2,
 	.use_clustering			= DISABLE_CLUSTERING
 };
 
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.h	2014-10-02 16:56:10.000000000 +1000
@@ -17,22 +17,6 @@
 
 #ifndef ASM
 
-#ifndef CMD_PER_LUN
-#define CMD_PER_LUN 2
-#endif
-
-#ifndef CAN_QUEUE
-#define CAN_QUEUE 16
-#endif
-
-#ifndef SG_TABLESIZE
-#define SG_TABLESIZE SG_NONE
-#endif
-
-#ifndef USE_TAGGED_QUEUING
-#define	USE_TAGGED_QUEUING 0
-#endif
-
 #include <scsi/scsicam.h>
 
 #define NCR5380_implementation_fields /* none */
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:10.000000000 +1000
@@ -198,12 +198,12 @@ static int __init sun3scsi_detect(struct
 #endif
 
 	/* setup variables */
-	tpnt->can_queue =
-		(setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE;
-	tpnt->cmd_per_lun =
-		(setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN;
-	tpnt->sg_tablesize = 
-		(setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE;
+	if (setup_can_queue > 0)
+		tpnt->can_queue = setup_can_queue;
+	if (setup_cmd_per_lun > 0)
+		tpnt->cmd_per_lun = setup_cmd_per_lun;
+	if (setup_sg_tablesize >= 0)
+		tpnt->sg_tablesize = setup_sg_tablesize;
 
 	if (setup_hostid >= 0)
 		tpnt->this_id = setup_hostid;
@@ -257,7 +257,7 @@ static int __init sun3scsi_detect(struct
 #endif
 #ifdef SUPPORT_TAGS
 	if (setup_use_tagged_queuing < 0)
-		setup_use_tagged_queuing = USE_TAGGED_QUEUING;
+		setup_use_tagged_queuing = 1;
 #endif
 
 	instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
@@ -683,10 +683,10 @@ static struct scsi_host_template driver_
 	.queuecommand		= sun3scsi_queue_command,
 	.eh_abort_handler      	= sun3scsi_abort,
 	.eh_bus_reset_handler  	= sun3scsi_bus_reset,
-	.can_queue		= CAN_QUEUE,
+	.can_queue		= 16,
 	.this_id		= 7,
-	.sg_tablesize		= SG_TABLESIZE,
-	.cmd_per_lun		= CMD_PER_LUN,
+	.sg_tablesize		= SG_NONE,
+	.cmd_per_lun		= 2,
 	.use_clustering		= DISABLE_CLUSTERING
 };
 
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:10.000000000 +1000
@@ -31,25 +31,7 @@
 
 #define IOBASE_SUN3_VMESCSI 0xff200000
 
-#ifndef CMD_PER_LUN
-#define CMD_PER_LUN 2
-#endif
-
-#ifndef CAN_QUEUE
-#define CAN_QUEUE 16
-#endif
-
-#ifndef SG_TABLESIZE
-#define SG_TABLESIZE SG_NONE
-#endif
-
-#ifndef MAX_TAGS
 #define MAX_TAGS 32
-#endif
-
-#ifndef USE_TAGGED_QUEUING
-#define	USE_TAGGED_QUEUING 1
-#endif
 
 #include <scsi/scsicam.h>
 
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:10.000000000 +1000
@@ -611,7 +611,7 @@ static int __init atari_scsi_detect(stru
 
 #ifdef SUPPORT_TAGS
 	if (setup_use_tagged_queuing < 0)
-		setup_use_tagged_queuing = DEFAULT_USE_TAGGED_QUEUING;
+		setup_use_tagged_queuing = 0;
 #endif
 #ifdef REAL_DMA
 	/* If running on a Falcon and if there's TT-Ram (i.e., more than one
Index: linux/drivers/scsi/atari_scsi.h
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.h	2014-10-02 16:56:10.000000000 +1000
@@ -36,9 +36,6 @@
 #define ATARI_FALCON_CMD_PER_LUN	1
 #define ATARI_FALCON_SG_TABLESIZE	SG_NONE
 
-#define	DEFAULT_USE_TAGGED_QUEUING	0
-
-
 #define	NCR5380_implementation_fields	/* none */
 
 #define NCR5380_read(reg)		  atari_scsi_reg_read( reg )

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 15/29] ncr5380: Remove *_RELEASE macros
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-remove-RELEASE-macros --]
[-- Type: text/plain, Size: 11247 bytes --]

The *_RELEASE macros don't tell me anything. In some cases the version in
the macro contradicts the version in the comments. Anyway, the Linux kernel
version is sufficient information. Remove these macros to improve readability.

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

---
 drivers/scsi/NCR5380.c       |   18 ------------------
 drivers/scsi/NCR5380.h       |    5 -----
 drivers/scsi/arm/cumana_1.c  |    2 --
 drivers/scsi/arm/oak.c       |    2 --
 drivers/scsi/atari_NCR5380.c |    4 ----
 drivers/scsi/dtc.c           |    5 -----
 drivers/scsi/dtc.h           |    2 --
 drivers/scsi/g_NCR5380.c     |    2 --
 drivers/scsi/g_NCR5380.h     |    5 -----
 drivers/scsi/mac_scsi.c      |    2 --
 drivers/scsi/mac_scsi.h      |    4 ----
 drivers/scsi/pas16.h         |    2 --
 drivers/scsi/sun3_NCR5380.c  |    4 ----
 drivers/scsi/sun3_scsi.c     |    2 --
 drivers/scsi/sun3_scsi.h     |    4 ----
 drivers/scsi/t128.c          |    2 --
 drivers/scsi/t128.h          |    4 ----
 17 files changed, 69 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:56:09.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:11.000000000 +1000
@@ -11,8 +11,6 @@
  *      drew@colorado.edu
  *      +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -736,22 +734,6 @@ static int __maybe_unused NCR5380_show_i
 
 	hostdata = (struct NCR5380_hostdata *) instance->hostdata;
 
-	SPRINTF("NCR5380 core release=%d.   ", NCR5380_PUBLIC_RELEASE);
-	if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400)
-		SPRINTF("ncr53c400 release=%d.  ", NCR53C400_PUBLIC_RELEASE);
-#ifdef DTC_PUBLIC_RELEASE
-	SPRINTF("DTC 3180/3280 release %d", DTC_PUBLIC_RELEASE);
-#endif
-#ifdef T128_PUBLIC_RELEASE
-	SPRINTF("T128 release %d", T128_PUBLIC_RELEASE);
-#endif
-#ifdef GENERIC_NCR5380_PUBLIC_RELEASE
-	SPRINTF("Generic5380 release %d", GENERIC_NCR5380_PUBLIC_RELEASE);
-#endif
-#ifdef PAS16_PUBLIC_RELEASE
-	SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE);
-#endif
-
 #ifdef PSEUDO_DMA
 	SPRINTF("Highwater I/O busy spin counts: write %d, read %d\n",
 	        hostdata->spin_max_w, hostdata->spin_max_r);
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
@@ -11,8 +11,6 @@
  *	drew@colorado.edu
  *	+1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6.
- *
  * For more information, please consult
  *
  * NCR 5380 Family
@@ -739,7 +737,6 @@ static void NCR5380_print_status(struct
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-	printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
 	local_irq_save(flags);
 	printk("NCR5380: coroutine is%s running.\n",
 		main_running ? "" : "n't");
@@ -783,7 +780,6 @@ static int __maybe_unused NCR5380_show_i
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-	seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
 	local_irq_save(flags);
 	seq_printf(m, "NCR5380: coroutine is%s running.\n",
 		main_running ? "" : "n't");
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
@@ -13,8 +13,6 @@
  * 	drew@colorado.edu
  *	+1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -685,7 +683,6 @@ static void NCR5380_print_status(struct
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-	printk("\nNCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
 	local_irq_save(flags);
 	printk("NCR5380: coroutine is%s running.\n",
 		main_running ? "" : "n't");
@@ -729,7 +726,6 @@ static int __maybe_unused NCR5380_show_i
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
 
-	seq_printf(m, "NCR5380 core release=%d.\n", NCR5380_PUBLIC_RELEASE);
 	local_irq_save(flags);
 	seq_printf(m, "NCR5380: coroutine is%s running.\n",
 		main_running ? "" : "n't");
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:09.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:11.000000000 +1000
@@ -7,8 +7,6 @@
  * 	drew@colorado.edu
  *      +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 7
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -27,9 +25,6 @@
 #include <linux/interrupt.h>
 #include <scsi/scsi_eh.h>
 
-#define NCR5380_PUBLIC_RELEASE 7
-#define NCR53C400_PUBLIC_RELEASE 2
-
 #define NDEBUG_ARBITRATION	0x1
 #define NDEBUG_AUTOSENSE	0x2
 #define NDEBUG_DMA		0x4
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/arm/cumana_1.c	2014-10-02 16:56:11.000000000 +1000
@@ -20,8 +20,6 @@
 
 #define PSEUDO_DMA
 
-#define CUMANASCSI_PUBLIC_RELEASE 1
-
 #define priv(host)			((struct NCR5380_hostdata *)(host)->hostdata)
 #define NCR5380_local_declare()		struct Scsi_Host *_instance
 #define NCR5380_setup(instance)		_instance = instance
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:56:09.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:56:11.000000000 +1000
@@ -18,8 +18,6 @@
 #include <scsi/scsi_host.h>
 
 /*#define PSEUDO_DMA*/
-
-#define OAKSCSI_PUBLIC_RELEASE 1
 #define DONT_USE_INTR
 
 #define priv(host)			((struct NCR5380_hostdata *)(host)->hostdata)
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:56:09.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:11.000000000 +1000
@@ -17,8 +17,6 @@
  *	(Unix and Linux consulting and custom programming)
  *	drew@colorado.edu
  *      +1 (303) 440-4894
- *
- * DISTRIBUTION RELEASE 1.
  */
 
 /*
@@ -66,9 +64,6 @@
 #define AUTOPROBE_IRQ
 #include "NCR5380.h"
 
-
-#define DTC_PUBLIC_RELEASE 2
-
 /*
  * The DTC3180 & 3280 boards are memory mapped.
  * 
Index: linux/drivers/scsi/g_NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.h	2014-10-02 16:56:11.000000000 +1000
@@ -9,16 +9,11 @@
  *
  * NCR53C400 extensions (c) 1994,1995,1996, Kevin Lentin
  *    K.Lentin@cs.monash.edu.au
- *
- * ALPHA RELEASE 1. 
  */
 
 #ifndef GENERIC_NCR5380_H
 #define GENERIC_NCR5380_H
 
-
-#define GENERIC_NCR5380_PUBLIC_RELEASE 1
-
 #ifdef NCR53C400
 #define BIOSPARAM
 #define NCR5380_BIOSPARAM generic_NCR5380_biosparam
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.h	2014-10-02 16:56:11.000000000 +1000
@@ -6,15 +6,11 @@
  *	(Unix and Linux consulting and custom programming)
  *	drew@colorado.edu
  *      +1 (303) 440-4894
- *
- * ALPHA RELEASE 1.
  */
 
 #ifndef MAC_NCR5380_H
 #define MAC_NCR5380_H
 
-#define MACSCSI_PUBLIC_RELEASE 2
-
 #ifndef ASM
 
 #include <scsi/scsicam.h>
Index: linux/drivers/scsi/pas16.h
===================================================================
--- linux.orig/drivers/scsi/pas16.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/pas16.h	2014-10-02 16:56:11.000000000 +1000
@@ -24,8 +24,6 @@
 #ifndef PAS16_H
 #define PAS16_H
 
-#define PAS16_PUBLIC_RELEASE 3
-
 #define PDEBUG_INIT	0x1
 #define PDEBUG_TRANSFER 0x2
 
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:11.000000000 +1000
@@ -13,15 +13,11 @@
  *	(Unix and Linux consulting and custom programming)
  *	drew@colorado.edu
  *      +1 (303) 440-4894
- *
- * ALPHA RELEASE 1.
  */
 
 #ifndef SUN3_SCSI_H
 #define SUN3_SCSI_H
 
-#define SUN3SCSI_PUBLIC_RELEASE 1
-
 /*
  * Int: level 2 autovector
  * IO: type 1, base 0x00140000, 5 bits phys space: A<4..0>
Index: linux/drivers/scsi/t128.h
===================================================================
--- linux.orig/drivers/scsi/t128.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/t128.h	2014-10-02 16:56:11.000000000 +1000
@@ -8,8 +8,6 @@
  *	drew@colorado.edu
  *      +1 (303) 440-4894
  *
- * DISTRIBUTION RELEASE 3.
- *
  * For more information, please consult
  *
  * Trantor Systems, Ltd.
@@ -25,8 +23,6 @@
 #ifndef T128_H
 #define T128_H
 
-#define T128_PUBLIC_RELEASE 3
-
 #define TDEBUG		0
 #define TDEBUG_INIT	0x1
 #define TDEBUG_TRANSFER 0x2
Index: linux/drivers/scsi/dtc.h
===================================================================
--- linux.orig/drivers/scsi/dtc.h	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/dtc.h	2014-10-02 16:56:11.000000000 +1000
@@ -5,8 +5,6 @@
  *	(Unix and Linux consulting and custom programming)
  *	drew@colorado.edu
  *      +1 (303) 440-4894
- *
- * DISTRIBUTION RELEASE 2. 
  */
 
 #ifndef DTC3280_H
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
@@ -18,8 +18,6 @@
  *
  * Added ISAPNP support for DTC436 adapters,
  * Thomas Sailer, sailer@ife.ee.ethz.ch
- *
- * ALPHA RELEASE 1. 
  */
 
 /* 
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:11.000000000 +1000
@@ -9,8 +9,6 @@
  * Generic Generic NCR5380 driver
  *
  * Copyright 1995, Russell King
- *
- * ALPHA RELEASE 1.
  */
 
 #include <linux/types.h>
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:11.000000000 +1000
@@ -20,8 +20,6 @@
  * Generic Generic NCR5380 driver
  *
  * Copyright 1995, Russell King
- *
- * ALPHA RELEASE 1.
  */
 
 #include <linux/types.h>
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:56:11.000000000 +1000
@@ -11,8 +11,6 @@
  *	drew@colorado.edu
  *      +1 (303) 440-4894
  *
- * DISTRIBUTION RELEASE 3.
- *
  * For more information, please consult 
  *
  * Trantor Systems, Ltd.

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 15/29] ncr5380: Remove *_RELEASE macros
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-RELEASE-macros
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/473c1b6a/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 16/29] ncr5380: Drop legacy scsi.h include
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
@ 2014-10-02  6:56   ` Finn Thain
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
                     ` (27 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

[-- Attachment #1: ncr5380-drop-legacy-scsi-h-include --]
[-- Type: text/plain, Size: 36120 bytes --]

Convert Scsi_Cmnd to struct scsi_cmnd and drop the #include "scsi.h".
The sun3_NCR5380.c core driver already uses struct scsi_cmnd so converting
the other core drivers reduces the diff which makes them easier to unify.

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

---

Line length issues have not been addressed here because comparison of the
three core drivers (NCR5380.c, atari_NCR5380.c and sun3_NCR5380.c) becomes
too messy. These lines get shorter once the type casting is fixed (work in
progress).

---
 drivers/scsi/NCR5380.c       |   70 +++++++++++++++--------------
 drivers/scsi/NCR5380.h       |   10 ++--
 drivers/scsi/arm/cumana_1.c  |    1 
 drivers/scsi/arm/oak.c       |    1 
 drivers/scsi/atari_NCR5380.c |  102 +++++++++++++++++++++----------------------
 drivers/scsi/atari_scsi.c    |    5 --
 drivers/scsi/dmx3191d.c      |    1 
 drivers/scsi/dtc.c           |    1 
 drivers/scsi/g_NCR5380.c     |    1 
 drivers/scsi/mac_scsi.c      |    1 
 drivers/scsi/pas16.c         |    1 
 drivers/scsi/sun3_NCR5380.c  |   20 ++++----
 drivers/scsi/sun3_scsi.c     |    1 
 drivers/scsi/t128.c          |    1 
 14 files changed, 105 insertions(+), 111 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/NCR5380.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/NCR5380.c	2014-10-02 16:56:14.000000000 +1000
@@ -277,7 +277,7 @@ static void do_reset(struct Scsi_Host *h
  *	Set up the internal fields in the SCSI command.
  */
 
-static __inline__ void initialize_SCp(Scsi_Cmnd * cmd)
+static inline void initialize_SCp(struct scsi_cmnd *cmd)
 {
 	/* 
 	 * Initialize the Scsi Pointer field so that all of the commands in the 
@@ -720,7 +720,7 @@ static int __maybe_unused NCR5380_write_
 #undef SPRINTF
 #define SPRINTF(args...) seq_printf(m, ## args)
 static
-void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m);
+void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m);
 static
 void lprint_command(unsigned char *cmd, struct seq_file *m);
 static
@@ -730,7 +730,7 @@ static int __maybe_unused NCR5380_show_i
 	struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
-	Scsi_Cmnd *ptr;
+	struct scsi_cmnd *ptr;
 
 	hostdata = (struct NCR5380_hostdata *) instance->hostdata;
 
@@ -742,19 +742,19 @@ static int __maybe_unused NCR5380_show_i
 	if (!hostdata->connected)
 		SPRINTF("scsi%d: no currently connected command\n", instance->host_no);
 	else
-		lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
+		lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m);
 	SPRINTF("scsi%d: issue_queue\n", instance->host_no);
-	for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
+	for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = (struct scsi_cmnd *) ptr->host_scribble)
 		lprint_Scsi_Cmnd(ptr, m);
 
 	SPRINTF("scsi%d: disconnected_queue\n", instance->host_no);
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble)
+	for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = (struct scsi_cmnd *) ptr->host_scribble)
 		lprint_Scsi_Cmnd(ptr, m);
 	spin_unlock_irq(instance->host_lock);
 	return 0;
 }
 
-static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m)
+static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
 {
 	SPRINTF("scsi%d : destination target %d, lun %d\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun);
 	SPRINTF("        command = ");
@@ -913,11 +913,11 @@ static void NCR5380_exit(struct Scsi_Hos
  *	Locks: host lock taken by caller
  */
 
-static int NCR5380_queue_command_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *))
+static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *))
 {
 	struct Scsi_Host *instance = cmd->device->host;
 	struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
-	Scsi_Cmnd *tmp;
+	struct scsi_cmnd *tmp;
 
 #if (NDEBUG & NDEBUG_NO_WRITE)
 	switch (cmd->cmnd[0]) {
@@ -951,7 +951,7 @@ static int NCR5380_queue_command_lck(Scs
 		cmd->host_scribble = (unsigned char *) hostdata->issue_queue;
 		hostdata->issue_queue = cmd;
 	} else {
-		for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble);
+		for (tmp = (struct scsi_cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (struct scsi_cmnd *) tmp->host_scribble);
 		LIST(cmd, tmp);
 		tmp->host_scribble = (unsigned char *) cmd;
 	}
@@ -982,7 +982,7 @@ static void NCR5380_main(struct work_str
 	struct NCR5380_hostdata *hostdata =
 		container_of(work, struct NCR5380_hostdata, coroutine.work);
 	struct Scsi_Host *instance = hostdata->host;
-	Scsi_Cmnd *tmp, *prev;
+	struct scsi_cmnd *tmp, *prev;
 	int done;
 	
 	spin_lock_irq(instance->host_lock);
@@ -995,7 +995,7 @@ static void NCR5380_main(struct work_str
 			 * Search through the issue_queue for a command destined
 			 * for a target that's not busy.
 			 */
-			for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) 
+			for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (struct scsi_cmnd *) tmp->host_scribble)
 			{
 				if (prev != tmp)
 					dprintk(NDEBUG_LISTS, "MAIN tmp=%p   target=%d   busy=%d lun=%d\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], tmp->device->lun);
@@ -1006,7 +1006,7 @@ static void NCR5380_main(struct work_str
 						prev->host_scribble = tmp->host_scribble;
 					} else {
 						REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble);
-						hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble;
+						hostdata->issue_queue = (struct scsi_cmnd *) tmp->host_scribble;
 					}
 					tmp->host_scribble = NULL;
 
@@ -1053,7 +1053,7 @@ static void NCR5380_main(struct work_str
 			/* exited locked */
 		}	/* if (!hostdata->connected) */
 		if (hostdata->selecting) {
-			tmp = (Scsi_Cmnd *) hostdata->selecting;
+			tmp = (struct scsi_cmnd *) hostdata->selecting;
 			/* Selection will drop and retake the lock */
 			if (!NCR5380_select(instance, tmp)) {
 				/* Ok ?? */
@@ -1175,7 +1175,8 @@ static irqreturn_t NCR5380_intr(int dumm
 #endif 
 
 /* 
- * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
+ * Function : int NCR5380_select(struct Scsi_Host *instance,
+ *                               struct scsi_cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  *      including ARBITRATION, SELECTION, and initial message out for 
@@ -1204,7 +1205,7 @@ static irqreturn_t NCR5380_intr(int dumm
  *	Locks: caller holds hostdata lock in IRQ mode
  */
  
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd)
+static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
 {
 	NCR5380_local_declare();
 	struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
@@ -2011,7 +2012,7 @@ static void NCR5380_information_transfer
 #endif
 	unsigned char *data;
 	unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
-	Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
+	struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
 	/* RvC: we need to set the end of the polling time */
 	unsigned long poll_time = jiffies + USLEEP_POLL;
 
@@ -2201,7 +2202,7 @@ static void NCR5380_information_transfer
 						LIST(cmd, hostdata->issue_queue);
 						cmd->host_scribble = (unsigned char *)
 						    hostdata->issue_queue;
-						hostdata->issue_queue = (Scsi_Cmnd *) cmd;
+						hostdata->issue_queue = (struct scsi_cmnd *) cmd;
 						dprintk(NDEBUG_QUEUES, "scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no);
 					} else {
 						cmd->scsi_done(cmd);
@@ -2398,7 +2399,7 @@ static void NCR5380_information_transfer
  * Function : void NCR5380_reselect (struct Scsi_Host *instance)
  *
  * Purpose : does reselection, initializing the instance->connected 
- *      field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q 
+ *      field to point to the scsi_cmnd for which the I_T_L or I_T_L_Q
  *      nexus has been reestablished,
  *      
  * Inputs : instance - this instance of the NCR5380.
@@ -2415,7 +2416,7 @@ static void NCR5380_reselect(struct Scsi
 	int len;
 	unsigned char msg[3];
 	unsigned char *data;
-	Scsi_Cmnd *tmp = NULL, *prev;
+	struct scsi_cmnd *tmp = NULL, *prev;
 	int abort = 0;
 	NCR5380_setup(instance);
 
@@ -2481,7 +2482,7 @@ static void NCR5380_reselect(struct Scsi
 		 */
 
 
-		for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble)
+		for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (struct scsi_cmnd *) tmp->host_scribble)
 			if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
 			    ) {
 				if (prev) {
@@ -2489,7 +2490,7 @@ static void NCR5380_reselect(struct Scsi
 					prev->host_scribble = tmp->host_scribble;
 				} else {
 					REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble);
-					hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble;
+					hostdata->disconnected_queue = (struct scsi_cmnd *) tmp->host_scribble;
 				}
 				tmp->host_scribble = NULL;
 				break;
@@ -2520,7 +2521,7 @@ static void NCR5380_reselect(struct Scsi
  *
  * Inputs : instance - this instance of the NCR5380.
  *
- * Returns : pointer to the Scsi_Cmnd structure for which the I_T_L
+ * Returns : pointer to the scsi_cmnd structure for which the I_T_L
  *      nexus has been reestablished, on failure NULL is returned.
  */
 
@@ -2562,11 +2563,11 @@ static void NCR5380_dma_complete(NCR5380
 #endif				/* def REAL_DMA */
 
 /*
- * Function : int NCR5380_abort (Scsi_Cmnd *cmd)
+ * Function : int NCR5380_abort (struct scsi_cmnd *cmd)
  *
  * Purpose : abort a command
  *
- * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the 
+ * Inputs : cmd - the scsi_cmnd to abort, code - code to set the
  *      host byte of the result field to, if zero DID_ABORTED is 
  *      used.
  *
@@ -2580,11 +2581,12 @@ static void NCR5380_dma_complete(NCR5380
  * Locks: host lock taken by caller
  */
 
-static int NCR5380_abort(Scsi_Cmnd * cmd) {
+static int NCR5380_abort(struct scsi_cmnd *cmd)
+{
 	NCR5380_local_declare();
 	struct Scsi_Host *instance = cmd->device->host;
 	struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
-	Scsi_Cmnd *tmp, **prev;
+	struct scsi_cmnd *tmp, **prev;
 	
 	printk(KERN_WARNING "scsi%d : aborting command\n", instance->host_no);
 	scsi_print_command(cmd);
@@ -2633,10 +2635,10 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
  */
  
 	dprintk(NDEBUG_ABORT, "scsi%d : abort going into loop.\n", instance->host_no);
-	for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue), tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble)
+	for (prev = (struct scsi_cmnd **) &(hostdata->issue_queue), tmp = (struct scsi_cmnd *) hostdata->issue_queue; tmp; prev = (struct scsi_cmnd **) &(tmp->host_scribble), tmp = (struct scsi_cmnd *) tmp->host_scribble)
 		if (cmd == tmp) {
 			REMOVE(5, *prev, tmp, tmp->host_scribble);
-			(*prev) = (Scsi_Cmnd *) tmp->host_scribble;
+			(*prev) = (struct scsi_cmnd *) tmp->host_scribble;
 			tmp->host_scribble = NULL;
 			tmp->result = DID_ABORT << 16;
 			dprintk(NDEBUG_ABORT, "scsi%d : abort removed command from issue queue.\n", instance->host_no);
@@ -2689,7 +2691,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
  * it from the disconnected queue.
  */
 
-	for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; tmp = (Scsi_Cmnd *) tmp->host_scribble)
+	for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp; tmp = (struct scsi_cmnd *) tmp->host_scribble)
 		if (cmd == tmp) {
 			dprintk(NDEBUG_ABORT, "scsi%d : aborting disconnected command.\n", instance->host_no);
 
@@ -2699,10 +2701,10 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
 
 			do_abort(instance);
 
-			for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue), tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble)
+			for (prev = (struct scsi_cmnd **) &(hostdata->disconnected_queue), tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp; prev = (struct scsi_cmnd **) &(tmp->host_scribble), tmp = (struct scsi_cmnd *) tmp->host_scribble)
 				if (cmd == tmp) {
 					REMOVE(5, *prev, tmp, tmp->host_scribble);
-					*prev = (Scsi_Cmnd *) tmp->host_scribble;
+					*prev = (struct scsi_cmnd *) tmp->host_scribble;
 					tmp->host_scribble = NULL;
 					tmp->result = DID_ABORT << 16;
 					tmp->scsi_done(tmp);
@@ -2725,7 +2727,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
 
 
 /* 
- * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd)
+ * Function : int NCR5380_bus_reset (struct scsi_cmnd *cmd)
  * 
  * Purpose : reset the SCSI bus.
  *
@@ -2734,7 +2736,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd
  * Locks: host lock taken by caller
  */
 
-static int NCR5380_bus_reset(Scsi_Cmnd * cmd)
+static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *instance = cmd->device->host;
 
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:14.000000000 +1000
@@ -251,9 +251,9 @@ struct NCR5380_hostdata {
 	volatile int dma_len;			/* requested length of DMA */
 #endif
 	volatile unsigned char last_message;	/* last message OUT */
-	volatile Scsi_Cmnd *connected;		/* currently connected command */
-	volatile Scsi_Cmnd *issue_queue;	/* waiting to be issued */
-	volatile Scsi_Cmnd *disconnected_queue;	/* waiting for reconnect */
+	volatile struct scsi_cmnd *connected;	/* currently connected command */
+	volatile struct scsi_cmnd *issue_queue;	/* waiting to be issued */
+	volatile struct scsi_cmnd *disconnected_queue;	/* waiting for reconnect */
 	volatile int restart_select;		/* we have disconnected,
 						   used to restart 
 						   NCR5380_select() */
@@ -261,7 +261,7 @@ struct NCR5380_hostdata {
 	int flags;
 	unsigned long time_expires;		/* in jiffies, set prior to sleeping */
 	int select_time;			/* timer in select for target response */
-	volatile Scsi_Cmnd *selecting;
+	volatile struct scsi_cmnd *selecting;
 	struct delayed_work coroutine;		/* our co-routine */
 	struct scsi_eh_save ses;
 	char info[256];
@@ -305,7 +305,7 @@ static irqreturn_t NCR5380_intr(int irq,
 static void NCR5380_main(struct work_struct *work);
 static const char *NCR5380_info(struct Scsi_Host *instance);
 static void NCR5380_reselect(struct Scsi_Host *instance);
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd);
+static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd);
 #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL)
 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
 #endif
Index: linux/drivers/scsi/arm/cumana_1.c
===================================================================
--- linux.orig/drivers/scsi/arm/cumana_1.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/arm/cumana_1.c	2014-10-02 16:56:14.000000000 +1000
@@ -13,7 +13,6 @@
 #include <asm/ecard.h>
 #include <asm/io.h>
 
-#include "../scsi.h"
 #include <scsi/scsi_host.h>
 
 #include <scsi/scsicam.h>
Index: linux/drivers/scsi/arm/oak.c
===================================================================
--- linux.orig/drivers/scsi/arm/oak.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/arm/oak.c	2014-10-02 16:56:14.000000000 +1000
@@ -14,7 +14,6 @@
 #include <asm/ecard.h>
 #include <asm/io.h>
 
-#include "../scsi.h"
 #include <scsi/scsi_host.h>
 
 /*#define PSEUDO_DMA*/
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:14.000000000 +1000
@@ -262,9 +262,9 @@ static struct scsi_host_template *the_te
 	(struct NCR5380_hostdata *)(in)->hostdata
 #define	HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata)
 
-#define	NEXT(cmd)		((Scsi_Cmnd *)(cmd)->host_scribble)
+#define	NEXT(cmd)		((struct scsi_cmnd *)(cmd)->host_scribble)
 #define	SET_NEXT(cmd,next)	((cmd)->host_scribble = (void *)(next))
-#define	NEXTADDR(cmd)		((Scsi_Cmnd **)&(cmd)->host_scribble)
+#define	NEXTADDR(cmd)		((struct scsi_cmnd **)&(cmd)->host_scribble)
 
 #define	HOSTNO		instance->host_no
 #define	H_NO(cmd)	(cmd)->device->host->host_no
@@ -345,7 +345,7 @@ static void __init init_tags(void)
  * conditions.
  */
 
-static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged)
+static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged)
 {
 	SETUP_HOSTDATA(cmd->device->host);
 
@@ -369,7 +369,7 @@ static int is_lun_busy(Scsi_Cmnd *cmd, i
  * untagged.
  */
 
-static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged)
+static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged)
 {
 	SETUP_HOSTDATA(cmd->device->host);
 
@@ -400,7 +400,7 @@ static void cmd_get_tag(Scsi_Cmnd *cmd,
  * unlock the LUN.
  */
 
-static void cmd_free_tag(Scsi_Cmnd *cmd)
+static void cmd_free_tag(struct scsi_cmnd *cmd)
 {
 	SETUP_HOSTDATA(cmd->device->host);
 
@@ -442,18 +442,18 @@ static void free_all_tags(void)
 
 
 /*
- * Function: void merge_contiguous_buffers( Scsi_Cmnd *cmd )
+ * Function: void merge_contiguous_buffers( struct scsi_cmnd *cmd )
  *
  * Purpose: Try to merge several scatter-gather requests into one DMA
  *    transfer. This is possible if the scatter buffers lie on
  *    physical contiguous addresses.
  *
- * Parameters: Scsi_Cmnd *cmd
+ * Parameters: struct scsi_cmnd *cmd
  *    The command to work on. The first scatter buffer's data are
  *    assumed to be already transferred into ptr/this_residual.
  */
 
-static void merge_contiguous_buffers(Scsi_Cmnd *cmd)
+static void merge_contiguous_buffers(struct scsi_cmnd *cmd)
 {
 	unsigned long endaddr;
 #if (NDEBUG & NDEBUG_MERGING)
@@ -482,15 +482,15 @@ static void merge_contiguous_buffers(Scs
 }
 
 /*
- * Function : void initialize_SCp(Scsi_Cmnd *cmd)
+ * Function : void initialize_SCp(struct scsi_cmnd *cmd)
  *
  * Purpose : initialize the saved data pointers for cmd to point to the
  *	start of the buffer.
  *
- * Inputs : cmd - Scsi_Cmnd structure to have pointers reset.
+ * Inputs : cmd - scsi_cmnd structure to have pointers reset.
  */
 
-static inline void initialize_SCp(Scsi_Cmnd *cmd)
+static inline void initialize_SCp(struct scsi_cmnd *cmd)
 {
 	/*
 	 * Initialize the Scsi Pointer field so that all of the commands in the
@@ -712,7 +712,7 @@ static void prepare_info(struct Scsi_Hos
  * Inputs : instance, pointer to this instance.
  */
 
-static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd)
+static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd)
 {
 	int i, s;
 	unsigned char *command;
@@ -729,7 +729,7 @@ static void lprint_Scsi_Cmnd(Scsi_Cmnd *
 static void NCR5380_print_status(struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
-	Scsi_Cmnd *ptr;
+	struct scsi_cmnd *ptr;
 	unsigned long flags;
 
 	NCR5380_dprint(NDEBUG_ANY, instance);
@@ -743,13 +743,13 @@ static void NCR5380_print_status(struct
 	if (!hostdata->connected)
 		printk("scsi%d: no currently connected command\n", HOSTNO);
 	else
-		lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected);
+		lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected);
 	printk("scsi%d: issue_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
+	for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
 		lprint_Scsi_Cmnd(ptr);
 
 	printk("scsi%d: disconnected_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
+	for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
 	     ptr = NEXT(ptr))
 		lprint_Scsi_Cmnd(ptr);
 
@@ -757,7 +757,7 @@ static void NCR5380_print_status(struct
 	printk("\n");
 }
 
-static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m)
+static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
 {
 	int i, s;
 	unsigned char *command;
@@ -775,7 +775,7 @@ static int __maybe_unused NCR5380_show_i
                                             struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
-	Scsi_Cmnd *ptr;
+	struct scsi_cmnd *ptr;
 	unsigned long flags;
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
@@ -786,13 +786,13 @@ static int __maybe_unused NCR5380_show_i
 	if (!hostdata->connected)
 		seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO);
 	else
-		show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
+		show_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m);
 	seq_printf(m, "scsi%d: issue_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
+	for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
 		show_Scsi_Cmnd(ptr, m);
 
 	seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
+	for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
 	     ptr = NEXT(ptr))
 		show_Scsi_Cmnd(ptr, m);
 
@@ -860,8 +860,8 @@ static void NCR5380_exit(struct Scsi_Hos
 }
 
 /*
- * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd,
- *	void (*done)(Scsi_Cmnd *))
+ * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd,
+ *	void (*done)(struct scsi_cmnd *))
  *
  * Purpose :  enqueues a SCSI command
  *
@@ -877,10 +877,11 @@ static void NCR5380_exit(struct Scsi_Hos
  *
  */
 
-static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
+static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd,
+                                     void (*done)(struct scsi_cmnd *))
 {
 	SETUP_HOSTDATA(cmd->device->host);
-	Scsi_Cmnd *tmp;
+	struct scsi_cmnd *tmp;
 	unsigned long flags;
 
 #if (NDEBUG & NDEBUG_NO_WRITE)
@@ -935,7 +936,7 @@ static int NCR5380_queue_command_lck(Scs
 		SET_NEXT(cmd, hostdata->issue_queue);
 		hostdata->issue_queue = cmd;
 	} else {
-		for (tmp = (Scsi_Cmnd *)hostdata->issue_queue;
+		for (tmp = (struct scsi_cmnd *)hostdata->issue_queue;
 		     NEXT(tmp); tmp = NEXT(tmp))
 			;
 		LIST(cmd, tmp);
@@ -976,7 +977,7 @@ static DEF_SCSI_QCMD(NCR5380_queue_comma
 
 static void NCR5380_main(struct work_struct *work)
 {
-	Scsi_Cmnd *tmp, *prev;
+	struct scsi_cmnd *tmp, *prev;
 	struct Scsi_Host *instance = first_instance;
 	struct NCR5380_hostdata *hostdata = HOSTDATA(instance);
 	int done;
@@ -1019,7 +1020,7 @@ static void NCR5380_main(struct work_str
 			 * for a target that's not busy.
 			 */
 #if (NDEBUG & NDEBUG_LISTS)
-			for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL;
+			for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL;
 			     tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp))
 				;
 			/*printk("%p  ", tmp);*/
@@ -1027,7 +1028,7 @@ static void NCR5380_main(struct work_str
 				printk(" LOOP\n");
 			/* else printk("\n"); */
 #endif
-			for (tmp = (Scsi_Cmnd *) hostdata->issue_queue,
+			for (tmp = (struct scsi_cmnd *) hostdata->issue_queue,
 			     prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) {
 
 #if (NDEBUG & NDEBUG_LISTS)
@@ -1288,7 +1289,8 @@ static irqreturn_t NCR5380_intr(int irq,
 }
 
 /*
- * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd)
+ * Function : int NCR5380_select(struct Scsi_Host *instance,
+ *                               struct scsi_cmnd *cmd)
  *
  * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command,
  *	including ARBITRATION, SELECTION, and initial message out for
@@ -1315,7 +1317,7 @@ static irqreturn_t NCR5380_intr(int irq,
  *		cmd->result host byte set to DID_BAD_TARGET.
  */
 
-static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd)
+static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd)
 {
 	SETUP_HOSTDATA(instance);
 	unsigned char tmp[3], phase;
@@ -1914,7 +1916,7 @@ static void NCR5380_information_transfer
 #endif
 	unsigned char *data;
 	unsigned char phase, tmp, extended_msg[10], old_phase = 0xff;
-	Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected;
+	struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected;
 
 	while (1) {
 		tmp = NCR5380_read(STATUS_REG);
@@ -2151,7 +2153,7 @@ static void NCR5380_information_transfer
 						local_irq_save(flags);
 						LIST(cmd,hostdata->issue_queue);
 						SET_NEXT(cmd, hostdata->issue_queue);
-						hostdata->issue_queue = (Scsi_Cmnd *) cmd;
+						hostdata->issue_queue = (struct scsi_cmnd *) cmd;
 						local_irq_restore(flags);
 						dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 							  "issue queue\n", H_NO(cmd));
@@ -2375,7 +2377,7 @@ static void NCR5380_information_transfer
  * Function : void NCR5380_reselect (struct Scsi_Host *instance)
  *
  * Purpose : does reselection, initializing the instance->connected
- *	field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q
+ *	field to point to the scsi_cmnd for which the I_T_L or I_T_L_Q
  *	nexus has been reestablished,
  *
  * Inputs : instance - this instance of the NCR5380.
@@ -2394,7 +2396,7 @@ static void NCR5380_reselect(struct Scsi
 #endif
 	unsigned char msg[3];
 	unsigned char *data;
-	Scsi_Cmnd *tmp = NULL, *prev;
+	struct scsi_cmnd *tmp = NULL, *prev;
 /*	unsigned long flags; */
 
 	/*
@@ -2468,7 +2470,7 @@ static void NCR5380_reselect(struct Scsi
 	 * just reestablished, and remove it from the disconnected queue.
 	 */
 
-	for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL;
+	for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL;
 	     tmp; prev = tmp, tmp = NEXT(tmp)) {
 		if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun)
 #ifdef SUPPORT_TAGS
@@ -2519,11 +2521,11 @@ static void NCR5380_reselect(struct Scsi
 
 
 /*
- * Function : int NCR5380_abort (Scsi_Cmnd *cmd)
+ * Function : int NCR5380_abort (struct scsi_cmnd *cmd)
  *
  * Purpose : abort a command
  *
- * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the
+ * Inputs : cmd - the scsi_cmnd to abort, code - code to set the
  *	host byte of the result field to, if zero DID_ABORTED is
  *	used.
  *
@@ -2536,11 +2538,11 @@ static void NCR5380_reselect(struct Scsi
  */
 
 static
-int NCR5380_abort(Scsi_Cmnd *cmd)
+int NCR5380_abort(struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *instance = cmd->device->host;
 	SETUP_HOSTDATA(instance);
-	Scsi_Cmnd *tmp, **prev;
+	struct scsi_cmnd *tmp, **prev;
 	unsigned long flags;
 
 	printk(KERN_NOTICE "scsi%d: aborting command\n", HOSTNO);
@@ -2610,8 +2612,8 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 * Case 2 : If the command hasn't been issued yet, we simply remove it
 	 *	    from the issue queue.
 	 */
-	for (prev = (Scsi_Cmnd **)&(hostdata->issue_queue),
-	     tmp = (Scsi_Cmnd *)hostdata->issue_queue;
+	for (prev = (struct scsi_cmnd **)&(hostdata->issue_queue),
+	     tmp = (struct scsi_cmnd *)hostdata->issue_queue;
 	     tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
 		if (cmd == tmp) {
 			REMOVE(5, *prev, tmp, NEXT(tmp));
@@ -2671,7 +2673,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 	 * it from the disconnected queue.
 	 */
 
-	for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp;
+	for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp;
 	     tmp = NEXT(tmp)) {
 		if (cmd == tmp) {
 			local_irq_restore(flags);
@@ -2685,8 +2687,8 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 			do_abort(instance);
 
 			local_irq_save(flags);
-			for (prev = (Scsi_Cmnd **)&(hostdata->disconnected_queue),
-			     tmp = (Scsi_Cmnd *)hostdata->disconnected_queue;
+			for (prev = (struct scsi_cmnd **)&(hostdata->disconnected_queue),
+			     tmp = (struct scsi_cmnd *)hostdata->disconnected_queue;
 			     tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) {
 				if (cmd == tmp) {
 					REMOVE(5, *prev, tmp, NEXT(tmp));
@@ -2735,7 +2737,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
 
 
 /*
- * Function : int NCR5380_reset (Scsi_Cmnd *cmd)
+ * Function : int NCR5380_reset (struct scsi_cmnd *cmd)
  *
  * Purpose : reset the SCSI bus.
  *
@@ -2743,13 +2745,13 @@ int NCR5380_abort(Scsi_Cmnd *cmd)
  *
  */
 
-static int NCR5380_bus_reset(Scsi_Cmnd *cmd)
+static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
 {
 	SETUP_HOSTDATA(cmd->device->host);
 	int i;
 	unsigned long flags;
 #if defined(RESET_RUN_DONE)
-	Scsi_Cmnd *connected, *disconnected_queue;
+	struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
 	if (!IS_A_TT() && !falcon_got_lock)
@@ -2791,9 +2793,9 @@ static int NCR5380_bus_reset(Scsi_Cmnd *
 	 * remembered in local variables first.
 	 */
 	local_irq_save(flags);
-	connected = (Scsi_Cmnd *)hostdata->connected;
+	connected = (struct scsi_cmnd *)hostdata->connected;
 	hostdata->connected = NULL;
-	disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue;
+	disconnected_queue = (struct scsi_cmnd *)hostdata->disconnected_queue;
 	hostdata->disconnected_queue = NULL;
 #ifdef SUPPORT_TAGS
 	free_all_tags();
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:14.000000000 +1000
@@ -93,7 +93,6 @@
 #include <asm/irq.h>
 #include <asm/traps.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "atari_scsi.h"
 #include "NCR5380.h"
@@ -880,7 +879,7 @@ static long atari_scsi_dma_residual(stru
 #define	CMD_SURELY_BYTE_MODE	1
 #define	CMD_MODE_UNKNOWN		2
 
-static int falcon_classify_cmd(Scsi_Cmnd *cmd)
+static int falcon_classify_cmd(struct scsi_cmnd *cmd)
 {
 	unsigned char opcode = cmd->cmnd[0];
 
@@ -912,7 +911,7 @@ static int falcon_classify_cmd(Scsi_Cmnd
  */
 
 static unsigned long atari_dma_xfer_len(unsigned long wanted_len,
-					Scsi_Cmnd *cmd, int write_flag)
+					struct scsi_cmnd *cmd, int write_flag)
 {
 	unsigned long	possible_len, limit;
 
Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:56:05.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:56:14.000000000 +1000
@@ -45,7 +45,6 @@
  * Includes needed for NCR5380.[ch] (XXX: Move them to NCR5380.h)
  */
 #include <linux/delay.h>
-#include "scsi.h"
 
 #include "NCR5380.h"
 #include "NCR5380.c"
Index: linux/drivers/scsi/dtc.c
===================================================================
--- linux.orig/drivers/scsi/dtc.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/dtc.c	2014-10-02 16:56:14.000000000 +1000
@@ -58,7 +58,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "dtc.h"
 #define AUTOPROBE_IRQ
Index: linux/drivers/scsi/g_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/g_NCR5380.c	2014-10-02 16:56:14.000000000 +1000
@@ -72,7 +72,6 @@
 #include <asm/io.h>
 #include <linux/signal.h>
 #include <linux/blkdev.h>
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "g_NCR5380.h"
 #include "NCR5380.h"
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:14.000000000 +1000
@@ -30,7 +30,6 @@
 #include <asm/macints.h>
 #include <asm/mac_via.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "mac_scsi.h"
 
Index: linux/drivers/scsi/pas16.c
===================================================================
--- linux.orig/drivers/scsi/pas16.c	2014-10-02 16:56:09.000000000 +1000
+++ linux/drivers/scsi/pas16.c	2014-10-02 16:56:14.000000000 +1000
@@ -81,7 +81,6 @@
 #include <linux/stat.h>
 #include <linux/init.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "pas16.h"
 #define AUTOPROBE_IRQ
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:14.000000000 +1000
@@ -658,7 +658,7 @@ static void prepare_info(struct Scsi_Hos
  * Inputs : instance, pointer to this instance.  
  */
 
-static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd)
+static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd)
 {
 	int i, s;
 	unsigned char *command;
@@ -675,7 +675,7 @@ static void lprint_Scsi_Cmnd(Scsi_Cmnd *
 static void NCR5380_print_status(struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
-	Scsi_Cmnd *ptr;
+	struct scsi_cmnd *ptr;
 	unsigned long flags;
 
 	NCR5380_dprint(NDEBUG_ANY, instance);
@@ -689,13 +689,13 @@ static void NCR5380_print_status(struct
 	if (!hostdata->connected)
 		printk("scsi%d: no currently connected command\n", HOSTNO);
 	else
-		lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected);
+		lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected);
 	printk("scsi%d: issue_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
+	for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
 		lprint_Scsi_Cmnd(ptr);
 
 	printk("scsi%d: disconnected_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
+	for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
 	     ptr = NEXT(ptr))
 		lprint_Scsi_Cmnd(ptr);
 
@@ -703,7 +703,7 @@ static void NCR5380_print_status(struct
 	printk("\n");
 }
 
-static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m)
+static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m)
 {
 	int i, s;
 	unsigned char *command;
@@ -721,7 +721,7 @@ static int __maybe_unused NCR5380_show_i
                                             struct Scsi_Host *instance)
 {
 	struct NCR5380_hostdata *hostdata;
-	Scsi_Cmnd *ptr;
+	struct scsi_cmnd *ptr;
 	unsigned long flags;
 
 	hostdata = (struct NCR5380_hostdata *)instance->hostdata;
@@ -732,13 +732,13 @@ static int __maybe_unused NCR5380_show_i
 	if (!hostdata->connected)
 		seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO);
 	else
-		show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m);
+		show_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m);
 	seq_printf(m, "scsi%d: issue_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
+	for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr))
 		show_Scsi_Cmnd(ptr, m);
 
 	seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO);
-	for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr;
+	for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr;
 	     ptr = NEXT(ptr))
 		show_Scsi_Cmnd(ptr, m);
 
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:14.000000000 +1000
@@ -43,7 +43,6 @@
 /* dma on! */
 #define REAL_DMA
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
 #include "NCR5380.h"
Index: linux/drivers/scsi/t128.c
===================================================================
--- linux.orig/drivers/scsi/t128.c	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/t128.c	2014-10-02 16:56:14.000000000 +1000
@@ -77,7 +77,6 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 
-#include "scsi.h"
 #include <scsi/scsi_host.h>
 #include "t128.h"
 #define AUTOPROBE_IRQ

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 16/29] ncr5380: Drop legacy scsi.h include
@ 2014-10-02  6:56   ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: linux-arm-kernel

An embedded and charset-unspecified text was scrubbed...
Name: ncr5380-drop-legacy-scsi-h-include
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/af42c230/attachment.ksh>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 17/29] dmx3191d: Use IRQ_NONE
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (15 preceding siblings ...)
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  8:41   ` Geert Uytterhoeven
  2014-10-02  6:56 ` [PATCH 18/29] mac_scsi: Remove header Finn Thain
                   ` (11 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: dmx3191d-use-IRQ_NONE --]
[-- Type: text/plain, Size: 2398 bytes --]

Testing shows that the Domex 3191D card never asserts its IRQ. Hence it is
non-functional with Linux (worse, the EH bugs in the core driver are fatal but
that's a problem for another patch). Perhaps the DT-536 chip needs special
setup? I can't find documentation for it. The NetBSD driver uses polling
apparently because of this issue.

Set host->irq = IRQ_NONE so the core driver will prevent targets from
disconnecting. Don't request the irq.

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

---
 drivers/scsi/dmx3191d.c |   25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

Index: linux/drivers/scsi/dmx3191d.c
===================================================================
--- linux.orig/drivers/scsi/dmx3191d.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/dmx3191d.c	2014-10-02 16:56:16.000000000 +1000
@@ -34,6 +34,8 @@
  * Definitions for the generic 5380 driver.
  */
 
+#define DONT_USE_INTR
+
 #define NCR5380_read(reg)		inb(port + reg)
 #define NCR5380_write(reg, value)	outb(value, port + reg)
 
@@ -89,32 +91,23 @@ static int dmx3191d_probe_one(struct pci
 	if (!shost)
 		goto out_release_region;       
 	shost->io_port = io;
-	shost->irq = pdev->irq;
 
-	NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
+	/* This card does not seem to raise an interrupt on pdev->irq.
+	 * Steam-powered SCSI controllers run without an IRQ anyway.
+	 */
+	shost->irq = IRQ_NONE;
 
-	if (request_irq(pdev->irq, NCR5380_intr, IRQF_SHARED,
-				DMX3191D_DRIVER_NAME, shost)) {
-		/*
-		 * Steam powered scsi controllers run without an IRQ anyway
-		 */
-		printk(KERN_WARNING "dmx3191: IRQ %d not available - "
-				    "switching to polled mode.\n", pdev->irq);
-		shost->irq = IRQ_NONE;
-	}
+	NCR5380_init(shost, FLAG_NO_PSEUDO_DMA | FLAG_DTC3181E);
 
 	pci_set_drvdata(pdev, shost);
 
 	error = scsi_add_host(shost, &pdev->dev);
 	if (error)
-		goto out_free_irq;
+		goto out_release_region;
 
 	scsi_scan_host(shost);
 	return 0;
 
- out_free_irq:
-	if (shost->irq != IRQ_NONE)
-		free_irq(shost->irq, shost);
  out_release_region:
 	release_region(io, DMX3191D_REGION_LEN);
  out_disable_device:
@@ -131,8 +124,6 @@ static void dmx3191d_remove_one(struct p
 
 	NCR5380_exit(shost);
 
-	if (shost->irq != IRQ_NONE)
-		free_irq(shost->irq, shost);
 	release_region(shost->io_port, DMX3191D_REGION_LEN);
 	pci_disable_device(pdev);
 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 18/29] mac_scsi: Remove header
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (16 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 17/29] dmx3191d: Use IRQ_NONE Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 19/29] mac_scsi: Add module option to Kconfig Finn Thain
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: mac_scsi-remove-header --]
[-- Type: text/plain, Size: 3104 bytes --]

The #defines in mac_scsi.h are intended to influence subsequent #includes in
mac_scsi.c. IMHO, that's too convoluted.

Remove mac_scsi.h by moving those macro definitions to mac_scsi.c, consistent
with other NCR5380 drivers.

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

---
 drivers/scsi/mac_scsi.c |   21 ++++++++++++++++++++-
 drivers/scsi/mac_scsi.h |   42 ------------------------------------------
 2 files changed, 20 insertions(+), 43 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:17.000000000 +1000
@@ -31,10 +31,29 @@
 #include <asm/mac_via.h>
 
 #include <scsi/scsi_host.h>
-#include "mac_scsi.h"
+
+/* Definitions for the core NCR5380 driver. */
 
 #define PSEUDO_DMA
 
+#define NCR5380_implementation_fields   /* none */
+#define NCR5380_local_declare()         struct Scsi_Host *_instance
+#define NCR5380_setup(instance)         _instance = instance
+
+#define NCR5380_read(reg)               macscsi_read(_instance, reg)
+#define NCR5380_write(reg, value)       macscsi_write(_instance, reg, value)
+
+#define NCR5380_pread                   macscsi_pread
+#define NCR5380_pwrite                  macscsi_pwrite
+
+#define NCR5380_intr                    macscsi_intr
+#define NCR5380_queue_command           macscsi_queue_command
+#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"
 
 #define RESET_BOOT
Index: linux/drivers/scsi/mac_scsi.h
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.h	2014-10-02 16:56:11.000000000 +1000
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-/*
- * Cumana Generic NCR5380 driver defines
- *
- * Copyright 1993, Drew Eckhardt
- *	Visionary Computing
- *	(Unix and Linux consulting and custom programming)
- *	drew@colorado.edu
- *      +1 (303) 440-4894
- */
-
-#ifndef MAC_NCR5380_H
-#define MAC_NCR5380_H
-
-#ifndef ASM
-
-#include <scsi/scsicam.h>
-
-#define NCR5380_implementation_fields /* none */
-
-#define NCR5380_local_declare() \
-        struct Scsi_Host *_instance
-
-#define NCR5380_setup(instance) \
-        _instance = instance
-
-#define NCR5380_read(reg) macscsi_read(_instance, reg)
-#define NCR5380_write(reg, value) macscsi_write(_instance, reg, value)
-
-#define NCR5380_pread 	macscsi_pread
-#define NCR5380_pwrite 	macscsi_pwrite
-	
-#define NCR5380_intr macscsi_intr
-#define NCR5380_queue_command macscsi_queue_command
-#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
-
-#endif /* ndef ASM */
-#endif /* MAC_NCR5380_H */
-

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 19/29] mac_scsi: Add module option to Kconfig
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (17 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 18/29] mac_scsi: Remove header Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  8:44   ` Geert Uytterhoeven
  2014-10-02  6:56 ` [PATCH 20/29] mac_scsi: Cleanup PDMA code Finn Thain
                   ` (9 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: mac_scsi-module-option --]
[-- Type: text/plain, Size: 5624 bytes --]

Allow mac_scsi to be built as a module. Replace the old validation of
__setup options with code that validates both module and __setup options.

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

---
 drivers/scsi/Kconfig    |    2 
 drivers/scsi/mac_scsi.c |  112 +++++++++++++++---------------------------------
 2 files changed, 38 insertions(+), 76 deletions(-)

Index: linux/drivers/scsi/Kconfig
===================================================================
--- linux.orig/drivers/scsi/Kconfig	2014-10-02 16:55:28.000000000 +1000
+++ linux/drivers/scsi/Kconfig	2014-10-02 16:56:17.000000000 +1000
@@ -1644,7 +1644,7 @@ config ATARI_SCSI_RESET_BOOT
 	  that leave the devices with SCSI operations partway completed.
 
 config MAC_SCSI
-	bool "Macintosh NCR5380 SCSI"
+	tristate "Macintosh NCR5380 SCSI"
 	depends on MAC && SCSI=y
 	select SCSI_SPI_ATTRS
 	help
Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:17.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:17.000000000 +1000
@@ -62,15 +62,18 @@
 static void mac_scsi_reset_boot(struct Scsi_Host *instance);
 #endif
 
-static int setup_called = 0;
 static int setup_can_queue = -1;
+module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
+module_param(setup_cmd_per_lun, int, 0);
 static int setup_sg_tablesize = -1;
+module_param(setup_sg_tablesize, int, 0);
 static int setup_use_pdma = -1;
-#ifdef SUPPORT_TAGS
+module_param(setup_use_pdma, int, 0);
 static int setup_use_tagged_queuing = -1;
-#endif
+module_param(setup_use_tagged_queuing, int, 0);
 static int setup_hostid = -1;
+module_param(setup_hostid, int, 0);
 
 /* Time (in jiffies) to wait after a reset; the SCSI standard calls for 250ms,
  * we usually do 0.5s to be on the safe side. But Toshiba CD-ROMs once more
@@ -102,72 +105,34 @@ static __inline__ void macscsi_write(str
   out_8(instance->io_port + (reg<<4), value);
 }
 
-/*
- * Function : mac_scsi_setup(char *str)
- *
- * Purpose : booter command line initialization of the overrides array,
- *
- * Inputs : str - comma delimited list of options
- *
- */
-
-static int __init mac_scsi_setup(char *str) {
+#ifndef MODULE
+static int __init mac_scsi_setup(char *str)
+{
 	int ints[7];
-	
-	(void)get_options( str, ARRAY_SIZE(ints), ints);
-	
-	if (setup_called++ || ints[0] < 1 || ints[0] > 6) {
-	    printk(KERN_WARNING "scsi: <mac5380>"
-		" Usage: mac5380=<can_queue>[,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>,<use_pdma>]\n");
-	    printk(KERN_ALERT "scsi: <mac5380> Bad Penguin parameters?\n");
-	    return 0;
-	}
-	    
-	if (ints[0] >= 1) {
-		if (ints[1] > 0)
-			/* no limits on this, just > 0 */
-			setup_can_queue = ints[1];
-	}
-	if (ints[0] >= 2) {
-		if (ints[2] > 0)
-			setup_cmd_per_lun = ints[2];
-	}
-	if (ints[0] >= 3) {
-		if (ints[3] >= 0) {
-			setup_sg_tablesize = ints[3];
-			/* Must be <= SG_ALL (255) */
-			if (setup_sg_tablesize > SG_ALL)
-				setup_sg_tablesize = SG_ALL;
-		}
-	}
-	if (ints[0] >= 4) {
-		/* Must be between 0 and 7 */
-		if (ints[4] >= 0 && ints[4] <= 7)
-			setup_hostid = ints[4];
-		else if (ints[4] > 7)
-			printk(KERN_WARNING "mac_scsi_setup: invalid host ID %d !\n", ints[4] );
-	}
-#ifdef SUPPORT_TAGS	
-	if (ints[0] >= 5) {
-		if (ints[5] >= 0)
-			setup_use_tagged_queuing = !!ints[5];
+
+	(void)get_options(str, ARRAY_SIZE(ints), ints);
+
+	if (ints[0] < 1 || ints[0] > 6) {
+		pr_err("Usage: mac5380=<can_queue>[,<cmd_per_lun>[,<sg_tablesize>[,<hostid>[,<use_tags>[,<use_pdma>]]]]]\n");
+		return 0;
 	}
-	
-	if (ints[0] == 6) {
-	    if (ints[6] >= 0)
+	if (ints[0] >= 1)
+		setup_can_queue = ints[1];
+	if (ints[0] >= 2)
+		setup_cmd_per_lun = ints[2];
+	if (ints[0] >= 3)
+		setup_sg_tablesize = ints[3];
+	if (ints[0] >= 4)
+		setup_hostid = ints[4];
+	if (ints[0] >= 5)
+		setup_use_tagged_queuing = ints[5];
+	if (ints[0] >= 6)
 		setup_use_pdma = ints[6];
-	}
-#else
-	if (ints[0] == 5) {
-	    if (ints[5] >= 0)
-		setup_use_pdma = ints[5];
-	}
-#endif /* SUPPORT_TAGS */
-	
 	return 1;
 }
 
 __setup("mac5380=", mac_scsi_setup);
+#endif /* !MODULE */
 
 /*
  * Function : int macscsi_detect(struct scsi_host_template * tpnt)
@@ -199,13 +164,8 @@ int __init macscsi_detect(struct scsi_ho
 		tpnt->cmd_per_lun = setup_cmd_per_lun;
 	if (setup_sg_tablesize >= 0)
 		tpnt->sg_tablesize = setup_sg_tablesize;
-
-    if (setup_hostid >= 0)
-	tpnt->this_id = setup_hostid;
-    else {
-	/* use 7 as default */
-	tpnt->this_id = 7;
-    }
+	if (setup_hostid >= 0)
+		tpnt->this_id = setup_hostid & 7;
 
 #ifdef SUPPORT_TAGS
     if (setup_use_tagged_queuing < 0)
@@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho
 	return 0;
 
     if (macintosh_config->ident == MAC_MODEL_IIFX) {
-	mac_scsi_regp  = via1+0x8000;
-	mac_scsi_drq   = via1+0xE000;
-	mac_scsi_nodrq = via1+0xC000;
+	mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
+	mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
+	mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
 	/* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */
 	flags = FLAG_NO_PSEUDO_DMA;
     } else {
-	mac_scsi_regp  = via1+0x10000;
-	mac_scsi_drq   = via1+0x6000;
-	mac_scsi_nodrq = via1+0x12000;
+	mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x10000;
+	mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
+	mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
     }
 
     if (! setup_use_pdma)
@@ -520,3 +480,5 @@ static struct scsi_host_template driver_
 
 
 #include "scsi_module.c"
+
+MODULE_LICENSE("GPL");



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 20/29] mac_scsi: Cleanup PDMA code
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (18 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 19/29] mac_scsi: Add module option to Kconfig Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 21/29] mac_scsi: Convert to platform device Finn Thain
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: mac_scsi-pdma-cleanup --]
[-- Type: text/plain, Size: 4437 bytes --]

Fix whitespace, remove pointless volatile qualifiers and improve code style
by use of INPUT_DATA_REG and OUTPUT_DATA_REG macros.

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

---
 drivers/scsi/mac_scsi.c |  122 ++++++++++++++++++++++++------------------------
 1 file changed, 62 insertions(+), 60 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:17.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:18.000000000 +1000
@@ -86,9 +86,9 @@ module_param(setup_hostid, int, 0);
 #define	AFTER_RESET_DELAY	(HZ/2)
 #endif
 
-static volatile unsigned char *mac_scsi_regp = NULL;
-static volatile unsigned char *mac_scsi_drq  = NULL;
-static volatile unsigned char *mac_scsi_nodrq = NULL;
+static unsigned char *mac_scsi_regp;
+static unsigned char *mac_scsi_drq;
+static unsigned char *mac_scsi_nodrq;
 
 
 /*
@@ -262,6 +262,7 @@ static void mac_scsi_reset_boot(struct S
 }
 #endif
 
+#ifdef PSEUDO_DMA
 /* 
    Pseudo-DMA: (Ove Edlund)
    The code attempts to catch bus errors that occur if one for example
@@ -331,38 +332,38 @@ __asm__ __volatile__					\
      : "0"(s), "1"(d), "2"(len)				\
      : "d0")
 
-
-static int macscsi_pread (struct Scsi_Host *instance,
-			  unsigned char *dst, int len)
+static int macscsi_pread(struct Scsi_Host *instance,
+                         unsigned char *dst, int len)
 {
-   unsigned char *d;
-   volatile unsigned char *s;
+	unsigned char *d;
+	unsigned char *s;
+
+	NCR5380_local_declare();
+	NCR5380_setup(instance);
+
+	s = mac_scsi_drq + (INPUT_DATA_REG << 4);
+	d = dst;
 
-   NCR5380_local_declare();
-   NCR5380_setup(instance);
+	/* These conditions are derived from MacOS */
 
-   s = mac_scsi_drq+0x60;
-   d = dst;
+	while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+	       !(NCR5380_read(STATUS_REG) & SR_REQ))
+		;
+
+	if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+	    (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) {
+		pr_err("Error in macscsi_pread\n");
+		return -1;
+	}
 
-/* These conditions are derived from MacOS */
-
-   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
-         && !(NCR5380_read(STATUS_REG) & SR_REQ))
-      ;
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
-         && (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)) {
-      printk(KERN_ERR "Error in macscsi_pread\n");
-      return -1;
-   }
-
-   CP_IO_TO_MEM(s, d, len);
-   
-   if (len != 0) {
-      printk(KERN_NOTICE "Bus error in macscsi_pread\n");
-      return -1;
-   }
-   
-   return 0;
+	CP_IO_TO_MEM(s, d, len);
+
+	if (len != 0) {
+		pr_notice("Bus error in macscsi_pread\n");
+		return -1;
+	}
+
+	return 0;
 }
 
 
@@ -424,39 +425,40 @@ __asm__ __volatile__					\
      : "0"(s), "1"(d), "2"(len)				\
      : "d0")
 
-static int macscsi_pwrite (struct Scsi_Host *instance,
-				  unsigned char *src, int len)
+static int macscsi_pwrite(struct Scsi_Host *instance,
+                          unsigned char *src, int len)
 {
-   unsigned char *s;
-   volatile unsigned char *d;
+	unsigned char *s;
+	unsigned char *d;
+
+	NCR5380_local_declare();
+	NCR5380_setup(instance);
 
-   NCR5380_local_declare();
-   NCR5380_setup(instance);
+	s = src;
+	d = mac_scsi_drq + (OUTPUT_DATA_REG << 4);
 
-   s = src;
-   d = mac_scsi_drq;
-   
-/* These conditions are derived from MacOS */
-
-   while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) 
-         && (!(NCR5380_read(STATUS_REG) & SR_REQ) 
-            || (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))) 
-      ;
-   if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) {
-      printk(KERN_ERR "Error in macscsi_pwrite\n");
-      return -1;
-   }
-
-   CP_MEM_TO_IO(s, d, len);   
-
-   if (len != 0) {
-      printk(KERN_NOTICE "Bus error in macscsi_pwrite\n");
-      return -1;
-   }
-   
-   return 0;
-}
+	/* These conditions are derived from MacOS */
+
+	while (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ) &&
+	       (!(NCR5380_read(STATUS_REG) & SR_REQ) ||
+	        (NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH)))
+		;
+
+	if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_DRQ)) {
+		pr_err("Error in macscsi_pwrite\n");
+		return -1;
+	}
+
+	CP_MEM_TO_IO(s, d, len);
 
+	if (len != 0) {
+		pr_notice("Bus error in macscsi_pwrite\n");
+		return -1;
+	}
+
+	return 0;
+}
+#endif
 
 #include "NCR5380.c"
 



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 21/29] mac_scsi: Convert to platform device
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (19 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 20/29] mac_scsi: Cleanup PDMA code Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  9:08   ` Geert Uytterhoeven
  2014-10-02  6:56 ` [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon Finn Thain
                   ` (7 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k, Geert Uytterhoeven

[-- Attachment #1: mac_scsi-convert-to-platform-device --]
[-- Type: text/plain, Size: 17768 bytes --]

Convert mac_scsi to platform device and eliminate scsi_register().

Platform resources for chip registers now follow the documentation. This
should fix issues with the Mac IIci (and possibly other models too).

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

---

The new hwreg_present() call is not protected by local_irq_save/restore.
This assumes Geert's patch, "Disable/restore interrupts in
hwreg_present()/hwreg_write()":
http://marc.info/?l=linux-kernel&m=141189640826704&w=2

---
 arch/m68k/include/asm/macintosh.h |    3 
 arch/m68k/mac/config.c            |  101 +++++++++++++--
 drivers/scsi/mac_scsi.c           |  248 +++++++++++++++++++-------------------
 3 files changed, 221 insertions(+), 131 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===================================================================
--- linux.orig/drivers/scsi/mac_scsi.c	2014-10-02 16:56:18.000000000 +1000
+++ linux/drivers/scsi/mac_scsi.c	2014-10-02 16:56:19.000000000 +1000
@@ -12,23 +12,18 @@
  */
 
 #include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/ctype.h>
 #include <linux/delay.h>
-
 #include <linux/module.h>
-#include <linux/signal.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
+#include <linux/platform_device.h>
 
+#include <asm/hwtest.h>
 #include <asm/io.h>
-#include <asm/irq.h>
-
-#include <asm/macintosh.h>
 #include <asm/macints.h>
-#include <asm/mac_via.h>
+#include <asm/setup.h>
 
 #include <scsi/scsi_host.h>
 
@@ -36,7 +31,7 @@
 
 #define PSEUDO_DMA
 
-#define NCR5380_implementation_fields   /* none */
+#define NCR5380_implementation_fields   unsigned char *pdma_base
 #define NCR5380_local_declare()         struct Scsi_Host *_instance
 #define NCR5380_setup(instance)         _instance = instance
 
@@ -58,10 +53,6 @@
 
 #define RESET_BOOT
 
-#ifdef RESET_BOOT
-static void mac_scsi_reset_boot(struct Scsi_Host *instance);
-#endif
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
@@ -86,23 +77,18 @@ module_param(setup_hostid, int, 0);
 #define	AFTER_RESET_DELAY	(HZ/2)
 #endif
 
-static unsigned char *mac_scsi_regp;
-static unsigned char *mac_scsi_drq;
-static unsigned char *mac_scsi_nodrq;
-
-
 /*
  * NCR 5380 register access functions
  */
 
-static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
+static inline char macscsi_read(struct Scsi_Host *instance, int reg)
 {
-  return in_8(instance->io_port + (reg<<4));
+	return in_8(instance->base + (reg << 4));
 }
 
-static __inline__ void macscsi_write(struct Scsi_Host *instance, int reg, int value)
+static inline void macscsi_write(struct Scsi_Host *instance, int reg, int value)
 {
-  out_8(instance->io_port + (reg<<4), value);
+	out_8(instance->base + (reg << 4), value);
 }
 
 #ifndef MODULE
@@ -134,96 +120,6 @@ static int __init mac_scsi_setup(char *s
 __setup("mac5380=", mac_scsi_setup);
 #endif /* !MODULE */
 
-/*
- * Function : int macscsi_detect(struct scsi_host_template * tpnt)
- *
- * Purpose : initializes mac NCR5380 driver based on the
- *	command line / compile time port and irq definitions.
- *
- * Inputs : tpnt - template for this SCSI adapter.
- *
- * Returns : 1 if a host adapter was found, 0 if not.
- *
- */
- 
-int __init macscsi_detect(struct scsi_host_template * tpnt)
-{
-    static int called = 0;
-    int flags = 0;
-    struct Scsi_Host *instance;
-
-    if (!MACH_IS_MAC || called)
-	return( 0 );
-
-    if (macintosh_config->scsi_type != MAC_SCSI_OLD)
-	return( 0 );
-
-	if (setup_can_queue > 0)
-		tpnt->can_queue = setup_can_queue;
-	if (setup_cmd_per_lun > 0)
-		tpnt->cmd_per_lun = setup_cmd_per_lun;
-	if (setup_sg_tablesize >= 0)
-		tpnt->sg_tablesize = setup_sg_tablesize;
-	if (setup_hostid >= 0)
-		tpnt->this_id = setup_hostid & 7;
-
-#ifdef SUPPORT_TAGS
-    if (setup_use_tagged_queuing < 0)
-	setup_use_tagged_queuing = 0;
-#endif
-
-    /* Once we support multiple 5380s (e.g. DuoDock) we'll do
-       something different here */
-    instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
-    if (instance == NULL)
-	return 0;
-
-    if (macintosh_config->ident == MAC_MODEL_IIFX) {
-	mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
-	mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
-	mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
-	/* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */
-	flags = FLAG_NO_PSEUDO_DMA;
-    } else {
-	mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x10000;
-	mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
-	mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
-    }
-
-    if (! setup_use_pdma)
-	flags = FLAG_NO_PSEUDO_DMA;
-	
-    instance->io_port = (unsigned long) mac_scsi_regp;
-    instance->irq = IRQ_MAC_SCSI;
-
-#ifdef RESET_BOOT   
-    mac_scsi_reset_boot(instance);
-#endif
-    
-    NCR5380_init(instance, flags);
-
-    instance->n_io_port = 255;
-
-    if (instance->irq != IRQ_NONE)
-	if (request_irq(instance->irq, NCR5380_intr, 0, "ncr5380", instance)) {
-	    printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
-		   instance->host_no, instance->irq);
-	    instance->irq = IRQ_NONE;
-	}
-
-    called = 1;
-    return 1;
-}
-
-int macscsi_release (struct Scsi_Host *shpnt)
-{
-	if (shpnt->irq != IRQ_NONE)
-		free_irq(shpnt->irq, shpnt);
-	NCR5380_exit(shpnt);
-
-	return 0;
-}
-
 #ifdef RESET_BOOT
 /*
  * Our 'bus reset on boot' function
@@ -335,13 +231,14 @@ __asm__ __volatile__					\
 static int macscsi_pread(struct Scsi_Host *instance,
                          unsigned char *dst, int len)
 {
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	unsigned char *d;
 	unsigned char *s;
 
 	NCR5380_local_declare();
 	NCR5380_setup(instance);
 
-	s = mac_scsi_drq + (INPUT_DATA_REG << 4);
+	s = hostdata->pdma_base + (INPUT_DATA_REG << 4);
 	d = dst;
 
 	/* These conditions are derived from MacOS */
@@ -428,6 +325,7 @@ __asm__ __volatile__					\
 static int macscsi_pwrite(struct Scsi_Host *instance,
                           unsigned char *src, int len)
 {
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	unsigned char *s;
 	unsigned char *d;
 
@@ -435,7 +333,7 @@ static int macscsi_pwrite(struct Scsi_Ho
 	NCR5380_setup(instance);
 
 	s = src;
-	d = mac_scsi_drq + (OUTPUT_DATA_REG << 4);
+	d = hostdata->pdma_base + (OUTPUT_DATA_REG << 4);
 
 	/* These conditions are derived from MacOS */
 
@@ -462,13 +360,15 @@ static int macscsi_pwrite(struct Scsi_Ho
 
 #include "NCR5380.c"
 
-static struct scsi_host_template driver_template = {
-	.proc_name			= "Mac5380",
+#define DRV_MODULE_NAME         "mac_scsi"
+#define PFX                     DRV_MODULE_NAME ": "
+
+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",
-	.detect				= macscsi_detect,
-	.release			= macscsi_release,
 	.info				= macscsi_info,
 	.queuecommand			= macscsi_queue_command,
 	.eh_abort_handler		= macscsi_abort,
@@ -480,7 +380,117 @@ static struct scsi_host_template driver_
 	.use_clustering			= DISABLE_CLUSTERING
 };
 
+static int __init mac_scsi_probe(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance;
+	int error;
+	int host_flags = 0;
+	struct resource *irq, *pio_mem, *pdma_mem = NULL;
+
+	if (!MACH_IS_MAC)
+		return -ENODEV;
+
+	pio_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	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);
+
+	if (!hwreg_present((unsigned char *)pio_mem->start +
+	                   (STATUS_REG << 4))) {
+		pr_info(PFX "no device detected at %pap\n", &pio_mem->start);
+		return -ENODEV;
+	}
+
+	if (setup_can_queue > 0)
+		mac_scsi_template.can_queue = setup_can_queue;
+	if (setup_cmd_per_lun > 0)
+		mac_scsi_template.cmd_per_lun = setup_cmd_per_lun;
+	if (setup_sg_tablesize >= 0)
+		mac_scsi_template.sg_tablesize = setup_sg_tablesize;
+	if (setup_hostid >= 0)
+		mac_scsi_template.this_id = setup_hostid & 7;
+#ifdef SUPPORT_TAGS
+	if (setup_use_tagged_queuing < 0)
+		setup_use_tagged_queuing = 0;
+#endif
+	if (setup_use_pdma < 0)
+		setup_use_pdma = 0;
+
+	instance = scsi_host_alloc(&mac_scsi_template,
+	                           sizeof(struct NCR5380_hostdata));
+	if (!instance)
+		return -ENOMEM;
+
+	instance->base = pio_mem->start;
+	if (irq)
+		instance->irq = irq->start;
+	else
+		instance->irq = IRQ_NONE;
+
+	if (pdma_mem && setup_use_pdma) {
+		struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+		hostdata->pdma_base = (unsigned char *)pdma_mem->start;
+	} else
+		host_flags |= FLAG_NO_PSEUDO_DMA;
+
+#ifdef RESET_BOOT
+	mac_scsi_reset_boot(instance);
+#endif
+
+	NCR5380_init(instance, host_flags);
+
+	if (instance->irq != IRQ_NONE) {
+		error = request_irq(instance->irq, macscsi_intr, 0,
+		                    "NCR5380", instance);
+		if (error)
+			goto fail_irq;
+	}
+
+	error = scsi_add_host(instance, NULL);
+	if (error)
+		goto fail_host;
+
+	platform_set_drvdata(pdev, instance);
+
+	scsi_scan_host(instance);
+	return 0;
+
+fail_host:
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+fail_irq:
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+	return error;
+}
+
+static int __exit mac_scsi_remove(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance = platform_get_drvdata(pdev);
+
+	scsi_remove_host(instance);
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+	return 0;
+}
+
+static struct platform_driver mac_scsi_driver = {
+	.remove = __exit_p(mac_scsi_remove),
+	.driver = {
+		.name	= DRV_MODULE_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
 
-#include "scsi_module.c"
+module_platform_driver_probe(mac_scsi_driver, mac_scsi_probe);
 
+MODULE_ALIAS("platform:" DRV_MODULE_NAME);
 MODULE_LICENSE("GPL");
Index: linux/arch/m68k/mac/config.c
===================================================================
--- linux.orig/arch/m68k/mac/config.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/mac/config.c	2014-10-02 16:56:19.000000000 +1000
@@ -278,7 +278,7 @@ static struct mac_model mac_data_table[]
 		.name		= "IIfx",
 		.adb_type	= MAC_ADB_IOP,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_IIFX,
 		.scc_type	= MAC_SCC_IOP,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_IOP,
@@ -329,7 +329,7 @@ static struct mac_model mac_data_table[]
 		.name		= "Color Classic",
 		.adb_type	= MAC_ADB_CUDA,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_CCL,
 		.scc_type	= MAC_SCC_II,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -338,7 +338,7 @@ static struct mac_model mac_data_table[]
 		.name		= "Color Classic II",
 		.adb_type	= MAC_ADB_CUDA,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_CCL,
 		.scc_type	= MAC_SCC_II,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -526,7 +526,7 @@ static struct mac_model mac_data_table[]
 		.name		= "Performa 520",
 		.adb_type	= MAC_ADB_CUDA,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_CCL,
 		.scc_type	= MAC_SCC_II,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -535,7 +535,7 @@ static struct mac_model mac_data_table[]
 		.name		= "Performa 550",
 		.adb_type	= MAC_ADB_CUDA,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_CCL,
 		.scc_type	= MAC_SCC_II,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -567,7 +567,7 @@ static struct mac_model mac_data_table[]
 		.name		= "TV",
 		.adb_type	= MAC_ADB_CUDA,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_CCL,
 		.scc_type	= MAC_SCC_II,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -740,7 +740,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 210",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -749,7 +749,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 230",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -758,7 +758,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 250",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -767,7 +767,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 270c",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -776,7 +776,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 280",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -785,7 +785,7 @@ static struct mac_model mac_data_table[]
 		.name		= "PowerBook Duo 280c",
 		.adb_type	= MAC_ADB_PB2,
 		.via_type	= MAC_VIA_IICI,
-		.scsi_type	= MAC_SCSI_OLD,
+		.scsi_type	= MAC_SCSI_DUO,
 		.scc_type	= MAC_SCC_QUADRA,
 		.nubus_type	= MAC_NUBUS,
 		.floppy_type	= MAC_FLOPPY_SWIM_ADDR2,
@@ -929,6 +929,36 @@ static struct platform_device swim_pdev
 	.resource	= &swim_rsrc,
 };
 
+static struct resource mac_scsi_0_rsrc[] = {
+	{
+		.flags = IORESOURCE_IRQ,
+		.start = IRQ_MAC_SCSI,
+		.end   = IRQ_MAC_SCSI,
+	},
+	{ .flags = IORESOURCE_MEM },
+	{ .flags = IORESOURCE_MEM },
+};
+
+static struct resource mac_scsi_1_rsrc[] = {
+	/* IRQ_NUBUS_E maybe? */
+	{ .flags = IORESOURCE_MEM },
+	{ .flags = IORESOURCE_MEM },
+};
+
+static struct platform_device mac_scsi_0_pdev = {
+	.name		= "mac_scsi",
+	.id		= 0,
+	.resource	= mac_scsi_0_rsrc,
+	.num_resources  = ARRAY_SIZE(mac_scsi_0_rsrc),
+};
+
+static struct platform_device mac_scsi_1_pdev = {
+	.name		= "mac_scsi",
+	.id		= 1,
+	.resource	= mac_scsi_1_rsrc,
+	.num_resources	= ARRAY_SIZE(mac_scsi_1_rsrc),
+};
+
 static struct platform_device esp_0_pdev = {
 	.name		= "mac_esp",
 	.id		= 0,
@@ -1000,6 +1030,53 @@ int __init mac_platform_init(void)
 		    (macintosh_config->ident == MAC_MODEL_Q950))
 			platform_device_register(&esp_1_pdev);
 		break;
+	case MAC_SCSI_IIFX:
+		/* Addresses from The Guide to Mac Family Hardware. */
+		mac_scsi_0_rsrc[1].start = 0x50008000; /* SCSI DMA */
+		mac_scsi_0_rsrc[1].end = mac_scsi_0_rsrc[1].start + 0x1FFF;
+		/* $5000 E000 - $5000 FFFF: Alternate SCSI (Hsk) */
+		/* $5000 C000 - $5000 DFFF: Alternate SCSI (DMA) */
+		/* The SCSI DMA custom IC embeds the 53C80 core. mac_scsi does
+		 * not make use of its DMA or hardware handshaking logic.
+		 */
+		mac_scsi_0_pdev.num_resources--;
+		platform_device_register(&mac_scsi_0_pdev);
+		break;
+	case MAC_SCSI_DUO:
+		/* Addresses from the Duo Dock II Developer Note. */
+		mac_scsi_1_rsrc[0].start = 0xFEE02000; /* normal mode */
+		mac_scsi_1_rsrc[0].end = mac_scsi_1_rsrc[0].start + 0x1FFF;
+		mac_scsi_1_rsrc[1].start = 0xFEE06000;/* pseudo DMA with /DRQ */
+		mac_scsi_1_rsrc[1].end = mac_scsi_1_rsrc[1].start + 0x1FFF;
+		/* $FEE0 4000 - $FEE0 5FFF: pseudo DMA without /DRQ */
+		platform_device_register(&mac_scsi_1_pdev);
+		/* fall through */
+	case MAC_SCSI_OLD:
+		/* Addresses from Developer Notes for Duo System,
+		 * PowerBook 180 & 160, 140 & 170, Macintosh IIsi
+		 * and also from The Guide to Mac Family Hardware for
+		 * SE/30, II, IIx, IIcx, IIci.
+		 * GMFH says that $5000 0000 - $50FF FFFF "wraps
+		 * $5000 0000 - $5001 FFFF eight times"...
+		 * mess.org says IIci and Color Classic do not alias
+		 * I/O address space.
+		 */
+		mac_scsi_0_rsrc[1].start = 0x50010000; /* normal mode */
+		mac_scsi_0_rsrc[1].end = mac_scsi_0_rsrc[1].start + 0x1FFF;
+		mac_scsi_0_rsrc[2].start = 0x50006000;/* pseudo DMA with /DRQ */
+		mac_scsi_0_rsrc[2].end = mac_scsi_0_rsrc[2].start + 0x1FFF;
+		/* $5001 2000 - $5001 3FFF: pseudo DMA without /DRQ */
+		platform_device_register(&mac_scsi_0_pdev);
+		break;
+	case MAC_SCSI_CCL:
+		/* Addresses from the Color Classic Developer Note. */
+		mac_scsi_0_rsrc[1].start = 0x50F10000; /* SCSI */
+		mac_scsi_0_rsrc[1].end = mac_scsi_0_rsrc[1].start + 0x1FFF;
+		mac_scsi_0_rsrc[2].start = 0x50F06000; /* SCSI handshake */
+		mac_scsi_0_rsrc[2].end = mac_scsi_0_rsrc[2].start + 0x1FFF;
+		/* $50F1 2000 - $50F1 3FFF: SCSI DMA */
+		platform_device_register(&mac_scsi_0_pdev);
+		break;
 	}
 
 	/*
Index: linux/arch/m68k/include/asm/macintosh.h
===================================================================
--- linux.orig/arch/m68k/include/asm/macintosh.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/include/asm/macintosh.h	2014-10-02 16:56:19.000000000 +1000
@@ -53,6 +53,9 @@ struct mac_model
 #define MAC_SCSI_QUADRA		2
 #define MAC_SCSI_QUADRA2	3
 #define MAC_SCSI_QUADRA3	4
+#define MAC_SCSI_IIFX		5
+#define MAC_SCSI_DUO		6
+#define MAC_SCSI_CCL		7
 
 #define MAC_IDE_NONE		0
 #define MAC_IDE_QUADRA		1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (20 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 21/29] mac_scsi: Convert to platform device Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  9:19   ` Geert Uytterhoeven
  2014-10-02  6:56 ` [PATCH 23/29] atari_scsi: Convert to platform device Finn Thain
                   ` (6 subsequent siblings)
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k, Geert Uytterhoeven

[-- Attachment #1: atari_scsi-stdma_try_lock --]
[-- Type: text/plain, Size: 11875 bytes --]

Don't disable irqs when waiting for the ST DMA lock; its release may
require an interrupt.

Introduce stdma_try_lock() for use in soft irq context. atari_scsi now tells
the SCSI mid-layer to defer queueing a command if the ST DMA "lock" is not
available, as per Michael's patch:
http://marc.info/?l=linux-m68k&m=139095335824863&w=2

The falcon_got_lock variable is race prone: we can't disable IRQs while
waiting to acquire the lock so after acquiring it there has to be some
interval during which falcon_got_lock remains false. Introduce
stdma_is_locked_by() to replace falcon_got_lock.

The falcon_got_lock tests in EH handlers are not correct these days. It can
happen that an EH handler is called after a command completes normally.
Remove these checks along with falcon_got_lock.

Also remove the complicated and racy fairness wait queues. If fairness is an
issue (when SCSI competes with IDE for the ST DMA interrupt), the solution
is likely to be a lower value for host->can_queue.

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

---
 arch/m68k/atari/stdma.c             |   62 +++++++++++++++++++----------
 arch/m68k/include/asm/atari_stdma.h |    4 -
 drivers/scsi/atari_NCR5380.c        |   35 +++++-----------
 drivers/scsi/atari_scsi.c           |   76 +++++++-----------------------------
 4 files changed, 70 insertions(+), 107 deletions(-)

Index: linux/arch/m68k/atari/stdma.c
===================================================================
--- linux.orig/arch/m68k/atari/stdma.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/atari/stdma.c	2014-10-02 16:56:20.000000000 +1000
@@ -59,6 +59,31 @@ static irqreturn_t stdma_int (int irq, v
 /************************* End of Prototypes **************************/
 
 
+/**
+ * stdma_try_lock - attempt to acquire ST DMA interrupt "lock"
+ * @handler: interrupt handler to use after acquisition
+ *
+ * Returns !0 if lock was acquired; otherwise 0.
+ */
+
+int stdma_try_lock(irq_handler_t handler, void *data)
+{
+	unsigned long flags;
+
+	local_irq_save(flags);
+	if (stdma_locked) {
+		local_irq_restore(flags);
+		return 0;
+	}
+
+	stdma_locked   = 1;
+	stdma_isr      = handler;
+	stdma_isr_data = data;
+	local_irq_restore(flags);
+	return 1;
+}
+EXPORT_SYMBOL(stdma_try_lock);
+
 
 /*
  * Function: void stdma_lock( isrfunc isr, void *data )
@@ -78,19 +103,10 @@ static irqreturn_t stdma_int (int irq, v
 
 void stdma_lock(irq_handler_t handler, void *data)
 {
-	unsigned long flags;
-
-	local_irq_save(flags);		/* protect lock */
-
 	/* Since the DMA is used for file system purposes, we
 	 have to sleep uninterruptible (there may be locked
 	 buffers) */
-	wait_event(stdma_wait, !stdma_locked);
-
-	stdma_locked   = 1;
-	stdma_isr      = handler;
-	stdma_isr_data = data;
-	local_irq_restore(flags);
+	wait_event(stdma_wait, stdma_try_lock(handler, data));
 }
 EXPORT_SYMBOL(stdma_lock);
 
@@ -122,22 +138,26 @@ void stdma_release(void)
 EXPORT_SYMBOL(stdma_release);
 
 
-/*
- * Function: int stdma_others_waiting( void )
- *
- * Purpose: Check if someone waits for the ST-DMA lock.
- *
- * Inputs: none
- *
- * Returns: 0 if no one is waiting, != 0 otherwise
+/**
+ * stdma_is_locked_by - allow lock holder to check whether it needs to release.
+ * @handler: interrupt handler previously used to acquire lock.
  *
+ * Returns !0 if locked for the given handler; 0 otherwise.
  */
 
-int stdma_others_waiting(void)
+int stdma_is_locked_by(irq_handler_t handler)
 {
-	return waitqueue_active(&stdma_wait);
+	unsigned long flags;
+
+	local_irq_save(flags);
+	if (stdma_locked && (stdma_isr == handler)) {
+		local_irq_restore(flags);
+		return 1;
+	}
+	local_irq_restore(flags);
+	return 0;
 }
-EXPORT_SYMBOL(stdma_others_waiting);
+EXPORT_SYMBOL(stdma_is_locked_by);
 
 
 /*
Index: linux/arch/m68k/include/asm/atari_stdma.h
===================================================================
--- linux.orig/arch/m68k/include/asm/atari_stdma.h	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/include/asm/atari_stdma.h	2014-10-02 16:56:20.000000000 +1000
@@ -8,11 +8,11 @@
 
 /***************************** Prototypes *****************************/
 
+int stdma_try_lock(irq_handler_t, void *);
 void stdma_lock(irq_handler_t handler, void *data);
 void stdma_release( void );
-int stdma_others_waiting( void );
 int stdma_islocked( void );
-void *stdma_locked_by( void );
+int stdma_is_locked_by(irq_handler_t);
 void stdma_init( void );
 
 /************************* End of Prototypes **************************/
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:20.000000000 +1000
@@ -877,10 +877,10 @@ static void NCR5380_exit(struct Scsi_Hos
  *
  */
 
-static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd,
-                                     void (*done)(struct scsi_cmnd *))
+static int NCR5380_queue_command(struct Scsi_Host *instance,
+                                 struct scsi_cmnd *cmd)
 {
-	SETUP_HOSTDATA(cmd->device->host);
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	struct scsi_cmnd *tmp;
 	unsigned long flags;
 
@@ -891,7 +891,7 @@ static int NCR5380_queue_command_lck(str
 		printk(KERN_NOTICE "scsi%d: WRITE attempted with NO_WRITE debugging flag set\n",
 		       H_NO(cmd));
 		cmd->result = (DID_ERROR << 16);
-		done(cmd);
+		cmd->scsi_done(cmd);
 		return 0;
 	}
 #endif /* (NDEBUG & NDEBUG_NO_WRITE) */
@@ -902,8 +902,6 @@ static int NCR5380_queue_command_lck(str
 	 */
 
 	SET_NEXT(cmd, NULL);
-	cmd->scsi_done = done;
-
 	cmd->result = 0;
 
 	/*
@@ -913,7 +911,6 @@ static int NCR5380_queue_command_lck(str
 	 * sense data is only guaranteed to be valid while the condition exists.
 	 */
 
-	local_irq_save(flags);
 	/* ++guenther: now that the issue queue is being set up, we can lock ST-DMA.
 	 * Otherwise a running NCR5380_main may steal the lock.
 	 * Lock before actually inserting due to fairness reasons explained in
@@ -926,11 +923,13 @@ static int NCR5380_queue_command_lck(str
 	 * because also a timer int can trigger an abort or reset, which would
 	 * alter queues and touch the lock.
 	 */
-	if (!IS_A_TT()) {
-		/* perhaps stop command timer here */
-		falcon_get_lock();
-		/* perhaps restart command timer here */
-	}
+	/* perhaps stop command timer here */
+	if (!falcon_get_lock())
+		return SCSI_MLQUEUE_HOST_BUSY;
+	/* perhaps restart command timer here */
+
+	local_irq_save(flags);
+
 	if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) {
 		LIST(cmd, hostdata->issue_queue);
 		SET_NEXT(cmd, hostdata->issue_queue);
@@ -954,15 +953,13 @@ static int NCR5380_queue_command_lck(str
 	 * If we're not in an interrupt, we can call NCR5380_main()
 	 * unconditionally, because it cannot be already running.
 	 */
-	if (in_interrupt() || ((flags >> 8) & 7) >= 6)
+	if (in_interrupt() || irqs_disabled())
 		queue_main();
 	else
 		NCR5380_main(NULL);
 	return 0;
 }
 
-static DEF_SCSI_QCMD(NCR5380_queue_command)
-
 /*
  * Function : NCR5380_main (void)
  *
@@ -2552,10 +2549,6 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 
 	local_irq_save(flags);
 
-	if (!IS_A_TT() && !falcon_got_lock)
-		printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_abort\n",
-		       HOSTNO);
-
 	dprintk(NDEBUG_ABORT, "scsi%d: abort called basr 0x%02x, sr 0x%02x\n", HOSTNO,
 		    NCR5380_read(BUS_AND_STATUS_REG),
 		    NCR5380_read(STATUS_REG));
@@ -2754,10 +2747,6 @@ static int NCR5380_bus_reset(struct scsi
 	struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
-	if (!IS_A_TT() && !falcon_got_lock)
-		printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n",
-		       H_NO(cmd));
-
 	NCR5380_print_status(cmd->device->host);
 
 	/* get in phase */
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:20.000000000 +1000
@@ -184,7 +184,7 @@ static void atari_scsi_fetch_restbytes(v
 static irqreturn_t scsi_tt_intr(int irq, void *dummy);
 static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
 static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
-static void falcon_get_lock(void);
+static int falcon_get_lock(void);
 #ifdef CONFIG_ATARI_SCSI_RESET_BOOT
 static void atari_scsi_reset_boot(void);
 #endif
@@ -473,17 +473,10 @@ static void atari_scsi_fetch_restbytes(v
 #endif /* REAL_DMA */
 
 
-static int falcon_got_lock = 0;
-static DECLARE_WAIT_QUEUE_HEAD(falcon_fairness_wait);
-static int falcon_trying_lock = 0;
-static DECLARE_WAIT_QUEUE_HEAD(falcon_try_wait);
 static int falcon_dont_release = 0;
 
 /* This function releases the lock on the DMA chip if there is no
- * connected command and the disconnected queue is empty. On
- * releasing, instances of falcon_get_lock are awoken, that put
- * themselves to sleep for fairness. They can now try to get the lock
- * again (but others waiting longer more probably will win).
+ * connected command and the disconnected queue is empty.
  */
 
 static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata)
@@ -495,20 +488,12 @@ static void falcon_release_lock_if_possi
 
 	local_irq_save(flags);
 
-	if (falcon_got_lock && !hostdata->disconnected_queue &&
-	    !hostdata->issue_queue && !hostdata->connected) {
-
-		if (falcon_dont_release) {
-#if 0
-			printk("WARNING: Lock release not allowed. Ignored\n");
-#endif
-			local_irq_restore(flags);
-			return;
-		}
-		falcon_got_lock = 0;
+	if (!hostdata->disconnected_queue &&
+	    !hostdata->issue_queue &&
+	    !hostdata->connected &&
+	    !falcon_dont_release &&
+	    stdma_is_locked_by(scsi_falcon_intr))
 		stdma_release();
-		wake_up(&falcon_fairness_wait);
-	}
 
 	local_irq_restore(flags);
 }
@@ -517,51 +502,20 @@ static void falcon_release_lock_if_possi
  * If the DMA isn't locked already for SCSI, it tries to lock it by
  * calling stdma_lock(). But if the DMA is locked by the SCSI code and
  * there are other drivers waiting for the chip, we do not issue the
- * command immediately but wait on 'falcon_fairness_queue'. We will be
- * waked up when the DMA is unlocked by some SCSI interrupt. After that
- * we try to get the lock again.
- * But we must be prepared that more than one instance of
- * falcon_get_lock() is waiting on the fairness queue. They should not
- * try all at once to call stdma_lock(), one is enough! For that, the
- * first one sets 'falcon_trying_lock', others that see that variable
- * set wait on the queue 'falcon_try_wait'.
- * Complicated, complicated.... Sigh...
+ * command immediately but tell the SCSI mid-layer to defer.
  */
 
-static void falcon_get_lock(void)
+static int falcon_get_lock(void)
 {
-	unsigned long flags;
-
 	if (IS_A_TT())
-		return;
+		return 1;
 
-	local_irq_save(flags);
-
-	wait_event_cmd(falcon_fairness_wait,
-		in_interrupt() || !falcon_got_lock || !stdma_others_waiting(),
-		local_irq_restore(flags),
-		local_irq_save(flags));
-
-	while (!falcon_got_lock) {
-		if (in_irq())
-			panic("Falcon SCSI hasn't ST-DMA lock in interrupt");
-		if (!falcon_trying_lock) {
-			falcon_trying_lock = 1;
-			stdma_lock(scsi_falcon_intr, NULL);
-			falcon_got_lock = 1;
-			falcon_trying_lock = 0;
-			wake_up(&falcon_try_wait);
-		} else {
-			wait_event_cmd(falcon_try_wait,
-				falcon_got_lock && !falcon_trying_lock,
-				local_irq_restore(flags),
-				local_irq_save(flags));
-		}
+	if (in_interrupt()) {
+		return stdma_try_lock(scsi_falcon_intr, NULL);
+	} else {
+		stdma_lock(scsi_falcon_intr, NULL);
+		return 1;
 	}
-
-	local_irq_restore(flags);
-	if (!falcon_got_lock)
-		panic("Falcon SCSI: someone stole the lock :-(\n");
 }
 
 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (21 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-03  9:34   ` Geert Uytterhoeven
  2014-10-20  7:33   ` Michael Schmitz
  2014-10-02  6:56 ` [PATCH 24/29] atari_scsi: Remove header Finn Thain
                   ` (5 subsequent siblings)
  28 siblings, 2 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k, Geert Uytterhoeven

[-- Attachment #1: atari_scsi-convert-to-platform-device --]
[-- Type: text/plain, Size: 16911 bytes --]

Convert atari_scsi to platform device and eliminate scsi_register().

Validate __setup options later on so that module options are checked as well.

Remove the comment about the scsi mid-layer disabling the host irq as it
is no longer true (AFAICT). Also remove the obsolete slow interrupt stuff
(IRQ_TYPE_SLOW == 0 anyway).

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

---
 arch/m68k/atari/config.c  |    5 
 drivers/scsi/atari_scsi.c |  426 ++++++++++++++++++++++------------------------
 drivers/scsi/atari_scsi.h |   17 -
 3 files changed, 217 insertions(+), 231 deletions(-)

Index: linux/arch/m68k/atari/config.c
===================================================================
--- linux.orig/arch/m68k/atari/config.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/atari/config.c	2014-10-02 16:56:21.000000000 +1000
@@ -892,6 +892,11 @@ int __init atari_platform_init(void)
 	}
 #endif
 
+#ifdef CONFIG_ATARI_SCSI
+	if (ATARIHW_PRESENT(ST_SCSI) || ATARIHW_PRESENT(TT_SCSI))
+		platform_device_register_simple("atari_scsi", -1, NULL, 0);
+#endif
+
 	return rv;
 }
 
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:20.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:21.000000000 +1000
@@ -74,33 +74,26 @@
 #define	MAX_TAGS 32
 
 #include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/ctype.h>
 #include <linux/delay.h>
-#include <linux/mm.h>
 #include <linux/blkdev.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/nvram.h>
 #include <linux/bitops.h>
 #include <linux/wait.h>
+#include <linux/platform_device.h>
 
 #include <asm/setup.h>
 #include <asm/atarihw.h>
 #include <asm/atariints.h>
-#include <asm/page.h>
-#include <asm/pgtable.h>
-#include <asm/irq.h>
-#include <asm/traps.h>
-
-#include <scsi/scsi_host.h>
-#include "atari_scsi.h"
-#include "NCR5380.h"
 #include <asm/atari_stdma.h>
 #include <asm/atari_stram.h>
 #include <asm/io.h>
 
-#include <linux/stat.h>
+#include <scsi/scsi_host.h>
+
+#include "atari_scsi.h"
+#include "NCR5380.h"
 
 #define	IS_A_TT()	ATARIHW_PRESENT(TT_SCSI)
 
@@ -176,25 +169,9 @@ static inline void DISABLE_IRQ(void)
 #define	AFTER_RESET_DELAY	(5*HZ/2)
 #endif
 
-/***************************** Prototypes *****************************/
-
 #ifdef REAL_DMA
 static void atari_scsi_fetch_restbytes(void);
 #endif
-static irqreturn_t scsi_tt_intr(int irq, void *dummy);
-static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
-static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
-static int falcon_get_lock(void);
-#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
-static void atari_scsi_reset_boot(void);
-#endif
-static unsigned char atari_scsi_tt_reg_read(unsigned char reg);
-static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value);
-static unsigned char atari_scsi_falcon_reg_read(unsigned char reg);
-static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value);
-
-/************************* End of Prototypes **************************/
-
 
 static struct Scsi_Host *atari_scsi_host;
 static unsigned char (*atari_scsi_reg_read)(unsigned char reg);
@@ -518,160 +495,12 @@ static int falcon_get_lock(void)
 	}
 }
 
-
-static int __init atari_scsi_detect(struct scsi_host_template *host)
-{
-	static int called = 0;
-	struct Scsi_Host *instance;
-
-	if (!MACH_IS_ATARI ||
-	    (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) ||
-	    called)
-		return 0;
-
-	host->proc_name = "Atari";
-
-	atari_scsi_reg_read  = IS_A_TT() ? atari_scsi_tt_reg_read :
-					   atari_scsi_falcon_reg_read;
-	atari_scsi_reg_write = IS_A_TT() ? atari_scsi_tt_reg_write :
-					   atari_scsi_falcon_reg_write;
-
-	/* setup variables */
-	host->can_queue =
-		(setup_can_queue > 0) ? setup_can_queue :
-		IS_A_TT() ? ATARI_TT_CAN_QUEUE : ATARI_FALCON_CAN_QUEUE;
-	host->cmd_per_lun =
-		(setup_cmd_per_lun > 0) ? setup_cmd_per_lun :
-		IS_A_TT() ? ATARI_TT_CMD_PER_LUN : ATARI_FALCON_CMD_PER_LUN;
-	/* Force sg_tablesize to 0 on a Falcon! */
-	host->sg_tablesize =
-		!IS_A_TT() ? ATARI_FALCON_SG_TABLESIZE :
-		(setup_sg_tablesize >= 0) ? setup_sg_tablesize : ATARI_TT_SG_TABLESIZE;
-
-	if (setup_hostid >= 0)
-		host->this_id = setup_hostid;
-	else {
-		/* use 7 as default */
-		host->this_id = 7;
-		/* Test if a host id is set in the NVRam */
-		if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) {
-			unsigned char b = nvram_read_byte( 14 );
-			/* Arbitration enabled? (for TOS) If yes, use configured host ID */
-			if (b & 0x80)
-				host->this_id = b & 7;
-		}
-	}
-
-#ifdef SUPPORT_TAGS
-	if (setup_use_tagged_queuing < 0)
-		setup_use_tagged_queuing = 0;
-#endif
-#ifdef REAL_DMA
-	/* If running on a Falcon and if there's TT-Ram (i.e., more than one
-	 * memory block, since there's always ST-Ram in a Falcon), then allocate a
-	 * STRAM_BUFFER_SIZE byte dribble buffer for transfers from/to alternative
-	 * Ram.
-	 */
-	if (MACH_IS_ATARI && ATARIHW_PRESENT(ST_SCSI) &&
-	    !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) {
-		atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
-		if (!atari_dma_buffer) {
-			printk(KERN_ERR "atari_scsi_detect: can't allocate ST-RAM "
-					"double buffer\n");
-			return 0;
-		}
-		atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
-		atari_dma_orig_addr = 0;
-	}
-#endif
-	instance = scsi_register(host, sizeof(struct NCR5380_hostdata));
-	if (instance == NULL) {
-		atari_stram_free(atari_dma_buffer);
-		atari_dma_buffer = 0;
-		return 0;
-	}
-	atari_scsi_host = instance;
-	/*
-	 * Set irq to 0, to avoid that the mid-level code disables our interrupt
-	 * during queue_command calls. This is completely unnecessary, and even
-	 * worse causes bad problems on the Falcon, where the int is shared with
-	 * IDE and floppy!
-	 */
-       instance->irq = 0;
-
-#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
-	atari_scsi_reset_boot();
-#endif
-	NCR5380_init(instance, 0);
-
-	if (IS_A_TT()) {
-
-		/* This int is actually "pseudo-slow", i.e. it acts like a slow
-		 * interrupt after having cleared the pending flag for the DMA
-		 * interrupt. */
-		if (request_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW,
-				 "SCSI NCR5380", instance)) {
-			printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting",IRQ_TT_MFP_SCSI);
-			scsi_unregister(atari_scsi_host);
-			atari_stram_free(atari_dma_buffer);
-			atari_dma_buffer = 0;
-			return 0;
-		}
-		tt_mfp.active_edge |= 0x80;		/* SCSI int on L->H */
-#ifdef REAL_DMA
-		tt_scsi_dma.dma_ctrl = 0;
-		atari_dma_residual = 0;
-
-		if (MACH_IS_MEDUSA) {
-			/* While the read overruns (described by Drew Eckhardt in
-			 * NCR5380.c) never happened on TTs, they do in fact on the Medusa
-			 * (This was the cause why SCSI didn't work right for so long
-			 * there.) Since handling the overruns slows down a bit, I turned
-			 * the #ifdef's into a runtime condition.
-			 *
-			 * In principle it should be sufficient to do max. 1 byte with
-			 * PIO, but there is another problem on the Medusa with the DMA
-			 * rest data register. So 'atari_read_overruns' is currently set
-			 * to 4 to avoid having transfers that aren't a multiple of 4. If
-			 * the rest data bug is fixed, this can be lowered to 1.
-			 */
-			atari_read_overruns = 4;
-		}
-#endif /*REAL_DMA*/
-	} else { /* ! IS_A_TT */
-
-		/* Nothing to do for the interrupt: the ST-DMA is initialized
-		 * already by atari_init_INTS()
-		 */
-
-#ifdef REAL_DMA
-		atari_dma_residual = 0;
-		atari_dma_active = 0;
-		atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
-					: 0xff000000);
-#endif
-	}
-
-	called = 1;
-	return 1;
-}
-
-static int atari_scsi_release(struct Scsi_Host *sh)
-{
-	if (IS_A_TT())
-		free_irq(IRQ_TT_MFP_SCSI, sh);
-	if (atari_dma_buffer)
-		atari_stram_free(atari_dma_buffer);
-	NCR5380_exit(sh);
-	return 1;
-}
-
 #ifndef MODULE
 static int __init atari_scsi_setup(char *str)
 {
 	/* Format of atascsi parameter is:
 	 *   atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
-	 * Defaults depend on TT or Falcon, hostid determined at run time.
+	 * Defaults depend on TT or Falcon, determined at run time.
 	 * Negative values mean don't change.
 	 */
 	int ints[6];
@@ -682,36 +511,17 @@ static int __init atari_scsi_setup(char
 		printk("atari_scsi_setup: no arguments!\n");
 		return 0;
 	}
-
-	if (ints[0] >= 1) {
-		if (ints[1] > 0)
-			/* no limits on this, just > 0 */
-			setup_can_queue = ints[1];
-	}
-	if (ints[0] >= 2) {
-		if (ints[2] > 0)
-			setup_cmd_per_lun = ints[2];
-	}
-	if (ints[0] >= 3) {
-		if (ints[3] >= 0) {
-			setup_sg_tablesize = ints[3];
-			/* Must be <= SG_ALL (255) */
-			if (setup_sg_tablesize > SG_ALL)
-				setup_sg_tablesize = SG_ALL;
-		}
-	}
-	if (ints[0] >= 4) {
-		/* Must be between 0 and 7 */
-		if (ints[4] >= 0 && ints[4] <= 7)
-			setup_hostid = ints[4];
-		else if (ints[4] > 7)
-			printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]);
-	}
+	if (ints[0] >= 1)
+		setup_can_queue = ints[1];
+	if (ints[0] >= 2)
+		setup_cmd_per_lun = ints[2];
+	if (ints[0] >= 3)
+		setup_sg_tablesize = ints[3];
+	if (ints[0] >= 4)
+		setup_hostid = ints[4];
 #ifdef SUPPORT_TAGS
-	if (ints[0] >= 5) {
-		if (ints[5] >= 0)
-			setup_use_tagged_queuing = !!ints[5];
-	}
+	if (ints[0] >= 5)
+		setup_use_tagged_queuing = ints[5];
 #endif
 
 	return 1;
@@ -1020,23 +830,211 @@ static int atari_scsi_bus_reset(struct s
 	return rv;
 }
 
-static struct scsi_host_template driver_template = {
+#define DRV_MODULE_NAME         "atari_scsi"
+#define PFX                     DRV_MODULE_NAME ": "
+
+static struct scsi_host_template atari_scsi_template = {
+	.module			= THIS_MODULE,
+	.proc_name		= DRV_MODULE_NAME,
 	.show_info		= atari_scsi_show_info,
 	.name			= "Atari native SCSI",
-	.detect			= atari_scsi_detect,
-	.release		= atari_scsi_release,
 	.info			= atari_scsi_info,
 	.queuecommand		= atari_scsi_queue_command,
 	.eh_abort_handler	= atari_scsi_abort,
 	.eh_bus_reset_handler	= atari_scsi_bus_reset,
-	.can_queue		= 0, /* initialized at run-time */
-	.this_id		= 0, /* initialized at run-time */
-	.sg_tablesize		= 0, /* initialized at run-time */
-	.cmd_per_lun		= 0, /* initialized at run-time */
+	.this_id		= 7,
 	.use_clustering		= DISABLE_CLUSTERING
 };
 
+static int __init atari_scsi_probe(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance;
+	int error;
+
+	if (!MACH_IS_ATARI)
+		return -ENODEV;
+
+	if (ATARIHW_PRESENT(TT_SCSI)) {
+		atari_scsi_reg_read  = atari_scsi_tt_reg_read;
+		atari_scsi_reg_write = atari_scsi_tt_reg_write;
+	} else if (ATARIHW_PRESENT(ST_SCSI)) {
+		atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
+		atari_scsi_reg_write = atari_scsi_falcon_reg_write;
+	} else
+		return -ENODEV;
+
+	/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary.
+	 * Higher values should work, too; try it!
+	 * (But cmd_per_lun costs memory!)
+	 *
+	 * But there seems to be a bug somewhere that requires CAN_QUEUE to be
+	 * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
+	 * changed CMD_PER_LUN...
+	 *
+	 * Note: The Falcon currently uses 8/1 setting due to unsolved problems
+	 * with cmd_per_lun != 1
+	 */
+	if (IS_A_TT()) {
+		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;
+	}
+
+	if (setup_can_queue > 0)
+		atari_scsi_template.can_queue = setup_can_queue;
+
+	if (setup_cmd_per_lun > 0)
+		atari_scsi_template.cmd_per_lun = setup_cmd_per_lun;
+
+	/* Leave sg_tablesize at 0 on a Falcon! */
+	if (IS_A_TT() && setup_sg_tablesize >= 0)
+		atari_scsi_template.sg_tablesize = setup_sg_tablesize;
+
+	if (setup_hostid >= 0) {
+		atari_scsi_template.this_id = setup_hostid & 7;
+	} else {
+		/* Test if a host id is set in the NVRam */
+		if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) {
+			unsigned char b = nvram_read_byte(14);
+
+			/* Arbitration enabled? (for TOS)
+			 * If yes, use configured host ID
+			 */
+			if (b & 0x80)
+				atari_scsi_template.this_id = b & 7;
+		}
+	}
+
+#ifdef SUPPORT_TAGS
+	if (setup_use_tagged_queuing < 0)
+		setup_use_tagged_queuing = 0;
+#endif
+
+#ifdef REAL_DMA
+	/* If running on a Falcon and if there's TT-Ram (i.e., more than one
+	 * memory block, since there's always ST-Ram in a Falcon), then
+	 * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
+	 * from/to alternative Ram.
+	 */
+	if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
+	    m68k_num_memory > 1) {
+		atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
+		if (!atari_dma_buffer) {
+			pr_err(PFX "can't allocate ST-RAM double buffer\n");
+			return -ENOMEM;
+		}
+		atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
+		atari_dma_orig_addr = 0;
+	}
+#endif
+
+	instance = scsi_host_alloc(&atari_scsi_template,
+	                           sizeof(struct NCR5380_hostdata));
+	if (!instance) {
+		error = -ENOMEM;
+		goto fail_alloc;
+	}
+	atari_scsi_host = instance;
+
+#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
+	atari_scsi_reset_boot();
+#endif
+
+	if (IS_A_TT())
+		instance->irq = IRQ_TT_MFP_SCSI;
+	else
+		instance->irq = IRQ_NONE;
+
+	NCR5380_init(instance, 0);
+
+	if (IS_A_TT()) {
+		error = request_irq(instance->irq, scsi_tt_intr, 0,
+		                    "NCR5380", instance);
+		if (error) {
+			pr_err(PFX "request irq %d failed, aborting\n",
+			       instance->irq);
+			goto fail_irq;
+		}
+		tt_mfp.active_edge |= 0x80;	/* SCSI int on L->H */
+#ifdef REAL_DMA
+		tt_scsi_dma.dma_ctrl = 0;
+		atari_dma_residual = 0;
+
+		/* While the read overruns (described by Drew Eckhardt in
+		 * NCR5380.c) never happened on TTs, they do in fact on the
+		 * Medusa (This was the cause why SCSI didn't work right for
+		 * so long there.) Since handling the overruns slows down
+		 * a bit, I turned the #ifdef's into a runtime condition.
+		 *
+		 * In principle it should be sufficient to do max. 1 byte with
+		 * PIO, but there is another problem on the Medusa with the DMA
+		 * rest data register. So 'atari_read_overruns' is currently set
+		 * to 4 to avoid having transfers that aren't a multiple of 4.
+		 * If the rest data bug is fixed, this can be lowered to 1.
+		 */
+		if (MACH_IS_MEDUSA)
+			atari_read_overruns = 4;
+#endif
+	} else {
+		/* Nothing to do for the interrupt: the ST-DMA is initialized
+		 * already.
+		 */
+#ifdef REAL_DMA
+		atari_dma_residual = 0;
+		atari_dma_active = 0;
+		atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
+					: 0xff000000);
+#endif
+	}
+
+	error = scsi_add_host(instance, NULL);
+	if (error)
+		goto fail_host;
+
+	platform_set_drvdata(pdev, instance);
+
+	scsi_scan_host(instance);
+	return 0;
+
+fail_host:
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+fail_irq:
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+fail_alloc:
+	if (atari_dma_buffer)
+		atari_stram_free(atari_dma_buffer);
+	return error;
+}
+
+static int __exit atari_scsi_remove(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance = platform_get_drvdata(pdev);
+
+	scsi_remove_host(instance);
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+	if (atari_dma_buffer)
+		atari_stram_free(atari_dma_buffer);
+	return 0;
+}
+
+static struct platform_driver atari_scsi_driver = {
+	.remove = __exit_p(atari_scsi_remove),
+	.driver = {
+		.name	= DRV_MODULE_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
 
-#include "scsi_module.c"
+module_platform_driver_probe(atari_scsi_driver, atari_scsi_probe);
 
+MODULE_ALIAS("platform:" DRV_MODULE_NAME);
 MODULE_LICENSE("GPL");
Index: linux/drivers/scsi/atari_scsi.h
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:56:10.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.h	2014-10-02 16:56:21.000000000 +1000
@@ -18,23 +18,6 @@
 /* (I_HAVE_OVERRUNS stuff removed) */
 
 #ifndef ASM
-/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher
- * values should work, too; try it! (but cmd_per_lun costs memory!) */
-
-/* But there seems to be a bug somewhere that requires CAN_QUEUE to be
- * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
- * changed CMD_PER_LUN... */
-
-/* Note: The Falcon currently uses 8/1 setting due to unsolved problems with
- * cmd_per_lun != 1 */
-
-#define ATARI_TT_CAN_QUEUE		16
-#define ATARI_TT_CMD_PER_LUN		8
-#define ATARI_TT_SG_TABLESIZE		SG_ALL
-
-#define ATARI_FALCON_CAN_QUEUE		8
-#define ATARI_FALCON_CMD_PER_LUN	1
-#define ATARI_FALCON_SG_TABLESIZE	SG_NONE
 
 #define	NCR5380_implementation_fields	/* none */
 



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 24/29] atari_scsi: Remove header
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (22 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 23/29] atari_scsi: Convert to platform device Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 25/29] sun3_scsi: Convert to platform device Finn Thain
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: atari_scsi-remove-header --]
[-- Type: text/plain, Size: 3879 bytes --]

The #defines in atari_scsi.h are intended to influence subsequent #includes
in atari_scsi.c. IMHO, that's too convoluted.

Remove atari_scsi.h by moving those macro definitions to atari_scsi.c,
consistent with other NCR5380 drivers.

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

---
 drivers/scsi/atari_scsi.c |   35 ++++++++++++++++++++++++++---------
 drivers/scsi/atari_scsi.h |   40 ----------------------------------------
 2 files changed, 26 insertions(+), 49 deletions(-)

Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:21.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:22.000000000 +1000
@@ -64,15 +64,7 @@
 /**************************************************************************/
 
 
-
 #include <linux/module.h>
-
-/* For the Atari version, use only polled IO or REAL_DMA */
-#define	REAL_DMA
-/* Support tagged queuing? (on devices that are able to... :-) */
-#define	SUPPORT_TAGS
-#define	MAX_TAGS 32
-
 #include <linux/types.h>
 #include <linux/delay.h>
 #include <linux/blkdev.h>
@@ -92,9 +84,34 @@
 
 #include <scsi/scsi_host.h>
 
-#include "atari_scsi.h"
+/* Definitions for the core NCR5380 driver. */
+
+#define REAL_DMA
+#define SUPPORT_TAGS
+#define MAX_TAGS                        32
+
+#define NCR5380_implementation_fields   /* none */
+
+#define NCR5380_read(reg)               atari_scsi_reg_read(reg)
+#define NCR5380_write(reg, value)       atari_scsi_reg_write(reg, value)
+
+#define NCR5380_queue_command           atari_scsi_queue_command
+#define NCR5380_abort                   atari_scsi_abort
+#define NCR5380_show_info               atari_scsi_show_info
+#define NCR5380_info                    atari_scsi_info
+
+#define NCR5380_dma_read_setup(instance, data, count) \
+        atari_scsi_dma_setup(instance, data, count, 0)
+#define NCR5380_dma_write_setup(instance, data, count) \
+        atari_scsi_dma_setup(instance, data, count, 1)
+#define NCR5380_dma_residual(instance) \
+        atari_scsi_dma_residual(instance)
+#define NCR5380_dma_xfer_len(instance, cmd, phase) \
+        atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO))
+
 #include "NCR5380.h"
 
+
 #define	IS_A_TT()	ATARIHW_PRESENT(TT_SCSI)
 
 #define	SCSI_DMA_WRITE_P(elt,val)				\
Index: linux/drivers/scsi/atari_scsi.h
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:56:21.000000000 +1000
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-/*
- * atari_scsi.h -- Header file for the Atari native SCSI driver
- *
- * Copyright 1994 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
- *
- * (Loosely based on the work of Robert De Vries' team)
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
- *
- */
-
-
-#ifndef ATARI_SCSI_H
-#define ATARI_SCSI_H
-
-/* (I_HAVE_OVERRUNS stuff removed) */
-
-#ifndef ASM
-
-#define	NCR5380_implementation_fields	/* none */
-
-#define NCR5380_read(reg)		  atari_scsi_reg_read( reg )
-#define NCR5380_write(reg, value) atari_scsi_reg_write( reg, value )
-
-#define NCR5380_queue_command atari_scsi_queue_command
-#define NCR5380_abort atari_scsi_abort
-#define NCR5380_show_info atari_scsi_show_info
-#define NCR5380_info atari_scsi_info
-#define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0)
-#define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1)
-#define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst )
-#define	NCR5380_dma_xfer_len(i,cmd,phase) \
-	atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
-
-#endif /* ndef ASM */
-#endif /* ATARI_SCSI_H */
-
-



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 25/29] sun3_scsi: Convert to platform device
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (23 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 24/29] atari_scsi: Remove header Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 26/29] sun3_scsi: Move macro definitions Finn Thain
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k, Geert Uytterhoeven

[-- Attachment #1: sun3_scsi-convert-to-platform-device --]
[-- Type: text/plain, Size: 12931 bytes --]

Convert sun3_scsi to platform device and eliminate scsi_register().

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

---
 arch/m68k/sun3/config.c  |   11 +
 drivers/scsi/sun3_scsi.c |  405 +++++++++++++++++++++++------------------------
 drivers/scsi/sun3_scsi.h |    8 
 3 files changed, 214 insertions(+), 210 deletions(-)

Index: linux/arch/m68k/sun3/config.c
===================================================================
--- linux.orig/arch/m68k/sun3/config.c	2014-10-02 16:55:28.000000000 +1000
+++ linux/arch/m68k/sun3/config.c	2014-10-02 16:56:22.000000000 +1000
@@ -16,6 +16,7 @@
 #include <linux/console.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/platform_device.h>
 
 #include <asm/oplib.h>
 #include <asm/setup.h>
@@ -169,3 +170,13 @@ static void __init sun3_sched_init(irq_h
         intersil_clear();
 }
 
+#ifdef CONFIG_SUN3_SCSI
+int __init sun3_platform_init(void)
+{
+	platform_device_register_simple("sun3_scsi", -1, NULL, 0);
+	platform_device_register_simple("sun3_scsi_vme", -1, NULL, 0);
+	return 0;
+}
+
+arch_initcall(sun3_platform_init);
+#endif
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:22.000000000 +1000
@@ -23,18 +23,14 @@
  */
 
 #include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/ctype.h>
 #include <linux/delay.h>
-
 #include <linux/module.h>
-#include <linux/signal.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/blkdev.h>
+#include <linux/platform_device.h>
 
 #include <asm/io.h>
-
 #include <asm/sun3ints.h>
 #include <asm/dvma.h>
 #include <asm/idprom.h>
@@ -59,8 +55,6 @@ extern int sun3_map_test(unsigned long,
 #endif
 
 
-static irqreturn_t scsi_sun3_intr(int irq, void *dummy);
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;
@@ -89,15 +83,14 @@ static struct scsi_cmnd *sun3_dma_setup_
 /* minimum number of bytes to do dma on */
 #define SUN3_DMA_MINSIZE 128
 
-static volatile unsigned char *sun3_scsi_regp;
+static unsigned char *sun3_scsi_regp;
 static volatile struct sun3_dma_regs *dregs;
-#ifndef SUN3_SCSI_VME
-static struct sun3_udc_regs *udc_regs = NULL;
-#endif
+static struct sun3_udc_regs *udc_regs;
 static unsigned char *sun3_dma_orig_addr = NULL;
 static unsigned long sun3_dma_orig_count = 0;
 static int sun3_dma_active = 0;
 static unsigned long last_residual = 0;
+static struct Scsi_Host *default_instance;
 
 /*
  * NCR 5380 register access functions
@@ -105,12 +98,12 @@ static unsigned long last_residual = 0;
 
 static inline unsigned char sun3scsi_read(int reg)
 {
-	return( sun3_scsi_regp[reg] );
+	return in_8(sun3_scsi_regp + reg);
 }
 
 static inline void sun3scsi_write(int reg, int value)
 {
-	sun3_scsi_regp[reg] = value;
+	out_8(sun3_scsi_regp + reg, value);
 }
 
 #ifndef SUN3_SCSI_VME
@@ -137,192 +130,7 @@ static inline void sun3_udc_write(unsign
 }
 #endif
 
-/*
- * XXX: status debug
- */
-static struct Scsi_Host *default_instance;
-
-/*
- * Function : int sun3scsi_detect(struct scsi_host_template * tpnt)
- *
- * Purpose : initializes mac NCR5380 driver based on the
- *	command line / compile time port and irq definitions.
- *
- * Inputs : tpnt - template for this SCSI adapter.
- *
- * Returns : 1 if a host adapter was found, 0 if not.
- *
- */
- 
-static int __init sun3scsi_detect(struct scsi_host_template *tpnt)
-{
-	unsigned long ioaddr, irq;
-	static int called = 0;
-	struct Scsi_Host *instance;
-#ifdef SUN3_SCSI_VME
-	int i;
-	unsigned long addrs[3] = { IOBASE_SUN3_VMESCSI,
-				   IOBASE_SUN3_VMESCSI + 0x4000,
-				   0 };
-	unsigned long vecs[3] = { SUN3_VEC_VMESCSI0,
-				  SUN3_VEC_VMESCSI1,
-				  0 };
-#endif
-
-	/* check that this machine has an onboard 5380 */
-	switch(idprom->id_machtype) {
-#ifdef SUN3_SCSI_VME
-	case SM_SUN3|SM_3_160:
-	case SM_SUN3|SM_3_260:
-		break;
-#else
-	case SM_SUN3|SM_3_50:
-	case SM_SUN3|SM_3_60:
-		break;
-#endif
-
-	default:
-		return 0;
-	}
-
-	if(called)
-		return 0;
-
-#ifdef SUN3_SCSI_VME
-	tpnt->proc_name = "Sun3 5380 VME SCSI";
-#else
-	tpnt->proc_name = "Sun3 5380 SCSI";
-#endif
-
-	/* setup variables */
-	if (setup_can_queue > 0)
-		tpnt->can_queue = setup_can_queue;
-	if (setup_cmd_per_lun > 0)
-		tpnt->cmd_per_lun = setup_cmd_per_lun;
-	if (setup_sg_tablesize >= 0)
-		tpnt->sg_tablesize = setup_sg_tablesize;
-
-	if (setup_hostid >= 0)
-		tpnt->this_id = setup_hostid;
-	else {
-		/* use 7 as default */
-		tpnt->this_id = 7;
-	}
-
-#ifdef SUN3_SCSI_VME
-	ioaddr = 0;
-	for (i = 0; addrs[i] != 0; i++) {
-		unsigned char x;
-
-		ioaddr = (unsigned long)sun3_ioremap(addrs[i], PAGE_SIZE,
-						     SUN3_PAGE_TYPE_VME16);
-		irq = vecs[i];
-		sun3_scsi_regp = (unsigned char *)ioaddr;
-
-		dregs = (struct sun3_dma_regs *)(((unsigned char *)ioaddr) + 8);
-
-		if (sun3_map_test((unsigned long)dregs, &x)) {
-			unsigned short oldcsr;
-
-			oldcsr = dregs->csr;
-			dregs->csr = 0;
-			udelay(SUN3_DMA_DELAY);
-			if (dregs->csr == 0x1400)
-				break;
-
-			dregs->csr = oldcsr;
-		}
-
-		iounmap((void *)ioaddr);
-		ioaddr = 0;
-	}
-
-	if (!ioaddr)
-		return 0;
-#else
-	irq = IRQ_SUN3_SCSI;
-	ioaddr = (unsigned long)ioremap(IOBASE_SUN3_SCSI, PAGE_SIZE);
-	sun3_scsi_regp = (unsigned char *)ioaddr;
-
-	dregs = (struct sun3_dma_regs *)(((unsigned char *)ioaddr) + 8);
-
-	if((udc_regs = dvma_malloc(sizeof(struct sun3_udc_regs)))
-	   == NULL) {
-	     printk("SUN3 Scsi couldn't allocate DVMA memory!\n");
-	     return 0;
-	}
-#endif
-#ifdef SUPPORT_TAGS
-	if (setup_use_tagged_queuing < 0)
-		setup_use_tagged_queuing = 1;
-#endif
-
-	instance = scsi_register (tpnt, sizeof(struct NCR5380_hostdata));
-	if(instance == NULL)
-		return 0;
-		
-	default_instance = instance;
-
-        instance->io_port = (unsigned long) ioaddr;
-	instance->irq = irq;
-
-	NCR5380_init(instance, 0);
-
-	instance->n_io_port = 32;
-
-	if (request_irq(instance->irq, scsi_sun3_intr,
-			     0, "Sun3SCSI-5380", instance)) {
-#ifndef REAL_DMA
-		printk("scsi%d: IRQ%d not free, interrupts disabled\n",
-		       instance->host_no, instance->irq);
-		instance->irq = IRQ_NONE;
-#else
-		printk("scsi%d: IRQ%d not free, bailing out\n",
-		       instance->host_no, instance->irq);
-		return 0;
-#endif
-	}
-	
-	dregs->csr = 0;
-	udelay(SUN3_DMA_DELAY);
-	dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR;
-	udelay(SUN3_DMA_DELAY);
-	dregs->fifo_count = 0;
-#ifdef SUN3_SCSI_VME
-	dregs->fifo_count_hi = 0;
-	dregs->dma_addr_hi = 0;
-	dregs->dma_addr_lo = 0;
-	dregs->dma_count_hi = 0;
-	dregs->dma_count_lo = 0;
-
-	dregs->ivect = VME_DATA24 | (instance->irq & 0xff);
-#endif
-
-	called = 1;
-
 #ifdef RESET_BOOT
-	sun3_scsi_reset_boot(instance);
-#endif
-
-	return 1;
-}
-
-static int sun3scsi_release(struct Scsi_Host *shpnt)
-{
-	if (shpnt->irq != IRQ_NONE)
-		free_irq(shpnt->irq, shpnt);
-
-	iounmap((void *)sun3_scsi_regp);
-
-	NCR5380_exit(shpnt);
-	return 0;
-}
-
-#ifdef RESET_BOOT
-/*
- * Our 'bus reset on boot' function
- */
-
 static void sun3_scsi_reset_boot(struct Scsi_Host *instance)
 {
 	unsigned long end;
@@ -671,11 +479,21 @@ static int sun3scsi_dma_finish(int write
 	
 #include "sun3_NCR5380.c"
 
-static struct scsi_host_template driver_template = {
+#ifdef SUN3_SCSI_VME
+#define SUN3_SCSI_NAME          "Sun3 NCR5380 VME SCSI"
+#define DRV_MODULE_NAME         "sun3_scsi_vme"
+#else
+#define SUN3_SCSI_NAME          "Sun3 NCR5380 SCSI"
+#define DRV_MODULE_NAME         "sun3_scsi"
+#endif
+
+#define PFX                     DRV_MODULE_NAME ": "
+
+static struct scsi_host_template sun3_scsi_template = {
+	.module			= THIS_MODULE,
+	.proc_name		= DRV_MODULE_NAME,
 	.show_info		= sun3scsi_show_info,
 	.name			= SUN3_SCSI_NAME,
-	.detect			= sun3scsi_detect,
-	.release		= sun3scsi_release,
 	.info			= sun3scsi_info,
 	.queuecommand		= sun3scsi_queue_command,
 	.eh_abort_handler      	= sun3scsi_abort,
@@ -687,7 +505,190 @@ static struct scsi_host_template driver_
 	.use_clustering		= DISABLE_CLUSTERING
 };
 
+static int __init sun3_scsi_probe(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance;
+	int error;
+	unsigned char *ioaddr;
+	unsigned int irq;
+#ifdef SUN3_SCSI_VME
+	int i;
+	unsigned long addrs[3] = {
+		IOBASE_SUN3_VMESCSI,
+		IOBASE_SUN3_VMESCSI + 0x4000,
+		0
+	};
+	unsigned long vecs[3] = {
+		SUN3_VEC_VMESCSI0,
+		SUN3_VEC_VMESCSI1,
+		0
+	};
+#endif
+
+	/* check that this machine has an onboard 5380 */
+	switch (idprom->id_machtype) {
+#ifdef SUN3_SCSI_VME
+	case SM_SUN3|SM_3_160:
+	case SM_SUN3|SM_3_260:
+		break;
+#else
+	case SM_SUN3|SM_3_50:
+	case SM_SUN3|SM_3_60:
+		break;
+#endif
+	default:
+		return -ENODEV;
+	}
+
+	if (setup_can_queue > 0)
+		sun3_scsi_template.can_queue = setup_can_queue;
+	if (setup_cmd_per_lun > 0)
+		sun3_scsi_template.cmd_per_lun = setup_cmd_per_lun;
+	if (setup_sg_tablesize >= 0)
+		sun3_scsi_template.sg_tablesize = setup_sg_tablesize;
+	if (setup_hostid >= 0)
+		sun3_scsi_template.this_id = setup_hostid & 7;
+
+#ifdef SUPPORT_TAGS
+	if (setup_use_tagged_queuing < 0)
+		setup_use_tagged_queuing = 1;
+#endif
+
+#ifdef SUN3_SCSI_VME
+	ioaddr = NULL;
+	for (i = 0; addrs[i] != 0; i++) {
+		unsigned char x;
+
+		irq = vecs[i];
+		ioaddr = sun3_ioremap(addrs[i], PAGE_SIZE,
+		                      SUN3_PAGE_TYPE_VME16);
+		dregs = (struct sun3_dma_regs *)(ioaddr + 8);
+
+		if (sun3_map_test((unsigned long)dregs, &x)) {
+			unsigned short oldcsr;
+
+			oldcsr = dregs->csr;
+			dregs->csr = 0;
+			udelay(SUN3_DMA_DELAY);
+			if (dregs->csr == 0x1400)
+				break;
+
+			dregs->csr = oldcsr;
+		}
+
+		iounmap(ioaddr);
+		ioaddr = NULL;
+	}
+	if (!ioaddr)
+		return -ENODEV;
+#else
+	irq = IRQ_SUN3_SCSI;
+	ioaddr = ioremap(IOBASE_SUN3_SCSI, PAGE_SIZE);
+	dregs = (struct sun3_dma_regs *)(ioaddr + 8);
+
+	udc_regs = dvma_malloc(sizeof(struct sun3_udc_regs));
+	if (!udc_regs) {
+		pr_err(PFX "couldn't allocate DVMA memory!\n");
+		iounmap(ioaddr);
+		return -ENOMEM;
+	}
+#endif
+
+	sun3_scsi_regp = ioaddr;
+
+	instance = scsi_host_alloc(&sun3_scsi_template,
+	                           sizeof(struct NCR5380_hostdata));
+	if (!instance) {
+		error = -ENOMEM;
+		goto fail_alloc;
+	}
+	default_instance = instance;
+
+	instance->io_port = (unsigned long)ioaddr;
+	instance->n_io_port = 32;
+	instance->irq = irq;
+
+	NCR5380_init(instance, 0);
+
+	error = request_irq(instance->irq, scsi_sun3_intr, 0,
+	                    "NCR5380", instance);
+	if (error) {
+#ifdef REAL_DMA
+		pr_err(PFX "scsi%d: IRQ %d not free, bailing out\n",
+		       instance->host_no, instance->irq);
+		goto fail_irq;
+#else
+		pr_warn(PFX "scsi%d: IRQ %d not free, interrupts disabled\n",
+		        instance->host_no, instance->irq);
+		instance->irq = IRQ_NONE;
+#endif
+	}
+
+	dregs->csr = 0;
+	udelay(SUN3_DMA_DELAY);
+	dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR;
+	udelay(SUN3_DMA_DELAY);
+	dregs->fifo_count = 0;
+#ifdef SUN3_SCSI_VME
+	dregs->fifo_count_hi = 0;
+	dregs->dma_addr_hi = 0;
+	dregs->dma_addr_lo = 0;
+	dregs->dma_count_hi = 0;
+	dregs->dma_count_lo = 0;
+
+	dregs->ivect = VME_DATA24 | (instance->irq & 0xff);
+#endif
+
+#ifdef RESET_BOOT
+	sun3_scsi_reset_boot(instance);
+#endif
+
+	error = scsi_add_host(instance, NULL);
+	if (error)
+		goto fail_host;
+
+	platform_set_drvdata(pdev, instance);
+
+	scsi_scan_host(instance);
+	return 0;
+
+fail_host:
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+fail_irq:
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+fail_alloc:
+	if (udc_regs)
+		dvma_free(udc_regs);
+	iounmap(sun3_scsi_regp);
+	return error;
+}
+
+static int __exit sun3_scsi_remove(struct platform_device *pdev)
+{
+	struct Scsi_Host *instance = platform_get_drvdata(pdev);
+
+	scsi_remove_host(instance);
+	if (instance->irq != IRQ_NONE)
+		free_irq(instance->irq, instance);
+	NCR5380_exit(instance);
+	scsi_host_put(instance);
+	if (udc_regs)
+		dvma_free(udc_regs);
+	iounmap(sun3_scsi_regp);
+	return 0;
+}
+
+static struct platform_driver sun3_scsi_driver = {
+	.remove = __exit_p(sun3_scsi_remove),
+	.driver = {
+		.name	= DRV_MODULE_NAME,
+		.owner	= THIS_MODULE,
+	},
+};
 
-#include "scsi_module.c"
+module_platform_driver_probe(sun3_scsi_driver, sun3_scsi_probe);
 
+MODULE_ALIAS("platform:" DRV_MODULE_NAME);
 MODULE_LICENSE("GPL");
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:11.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:22.000000000 +1000
@@ -29,14 +29,6 @@
 
 #define MAX_TAGS 32
 
-#include <scsi/scsicam.h>
-
-#ifdef SUN3_SCSI_VME
-#define SUN3_SCSI_NAME "Sun3 NCR5380 VME SCSI"
-#else
-#define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI"
-#endif
-
 #define NCR5380_implementation_fields /* none */
 
 #define NCR5380_local_declare() \



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 26/29] sun3_scsi: Move macro definitions
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (24 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 25/29] sun3_scsi: Convert to platform device Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 27/29] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros Finn Thain
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: sun3_scsi-move-macro-definitions --]
[-- Type: text/plain, Size: 4680 bytes --]

The #defines in sun3_scsi.h are intended to influence subsequent #includes
in sun3_scsi.c. IMHO, that's too convoluted.

Move sun3_scsi.h macro definitions to sun3_scsi.c, consistent with other
NCR5380 drivers.

Omit the unused NCR5380_local_declare() and NCR5380_setup() macros.

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

---
 drivers/scsi/sun3_scsi.c |   45 ++++++++++++++++++++++++++++++++-------------
 drivers/scsi/sun3_scsi.h |   25 -------------------------
 2 files changed, 32 insertions(+), 38 deletions(-)

Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:22.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:23.000000000 +1000
@@ -36,18 +36,42 @@
 #include <asm/idprom.h>
 #include <asm/machines.h>
 
-/* dma on! */
-#define REAL_DMA
-
 #include <scsi/scsi_host.h>
 #include "sun3_scsi.h"
-#include "NCR5380.h"
 
-extern int sun3_map_test(unsigned long, char *);
+/* Definitions for the core NCR5380 driver. */
 
-/*#define RESET_BOOT */
+#define REAL_DMA
+#define RESET_RUN_DONE
 /* #define SUPPORT_TAGS */
 
+/* #define MAX_TAGS                     32 */
+
+#define NCR5380_implementation_fields   /* none */
+
+#define NCR5380_read(reg)               sun3scsi_read(reg)
+#define NCR5380_write(reg, value)       sun3scsi_write(reg, value)
+
+#define NCR5380_queue_command           sun3scsi_queue_command
+#define NCR5380_bus_reset               sun3scsi_bus_reset
+#define NCR5380_abort                   sun3scsi_abort
+#define NCR5380_show_info               sun3scsi_show_info
+#define NCR5380_info                    sun3scsi_info
+
+#define NCR5380_dma_read_setup(instance, data, count) \
+        sun3scsi_dma_setup(data, count, 0)
+#define NCR5380_dma_write_setup(instance, data, count) \
+        sun3scsi_dma_setup(data, count, 1)
+#define NCR5380_dma_residual(instance) \
+        sun3scsi_dma_residual(instance)
+#define NCR5380_dma_xfer_len(instance, cmd, phase) \
+        sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO))
+
+#include "NCR5380.h"
+
+
+extern int sun3_map_test(unsigned long, char *);
+
 #ifdef SUN3_SCSI_VME
 #define ENABLE_IRQ()
 #else
@@ -68,9 +92,7 @@ module_param(setup_use_tagged_queuing, i
 static int setup_hostid = -1;
 module_param(setup_hostid, int, 0);
 
-static struct scsi_cmnd *sun3_dma_setup_done = NULL;
-
-#define	RESET_RUN_DONE
+/* #define RESET_BOOT */
 
 #define	AFTER_RESET_DELAY	(HZ/2)
 
@@ -83,6 +105,7 @@ static struct scsi_cmnd *sun3_dma_setup_
 /* minimum number of bytes to do dma on */
 #define SUN3_DMA_MINSIZE 128
 
+static struct scsi_cmnd *sun3_dma_setup_done;
 static unsigned char *sun3_scsi_regp;
 static volatile struct sun3_dma_regs *dregs;
 static struct sun3_udc_regs *udc_regs;
@@ -134,9 +157,6 @@ static inline void sun3_udc_write(unsign
 static void sun3_scsi_reset_boot(struct Scsi_Host *instance)
 {
 	unsigned long end;
-
-	NCR5380_local_declare();
-	NCR5380_setup(instance);
 	
 	/*
 	 * Do a SCSI reset to clean up the bus during initialization. No
@@ -213,7 +233,6 @@ static irqreturn_t scsi_sun3_intr(int ir
 void sun3_sun3_debug (void)
 {
 	unsigned long flags;
-	NCR5380_local_declare();
 
 	if (default_instance) {
 			local_irq_save(flags);
Index: linux/drivers/scsi/sun3_scsi.h
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:22.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.h	2014-10-02 16:56:23.000000000 +1000
@@ -27,31 +27,6 @@
 
 #define IOBASE_SUN3_VMESCSI 0xff200000
 
-#define MAX_TAGS 32
-
-#define NCR5380_implementation_fields /* none */
-
-#define NCR5380_local_declare() \
-        struct Scsi_Host *_instance
-
-#define NCR5380_setup(instance) \
-        _instance = instance
-
-#define NCR5380_read(reg) sun3scsi_read(reg)
-#define NCR5380_write(reg, value) sun3scsi_write(reg, value)
-
-#define NCR5380_queue_command sun3scsi_queue_command
-#define NCR5380_bus_reset sun3scsi_bus_reset
-#define NCR5380_abort sun3scsi_abort
-#define NCR5380_show_info sun3scsi_show_info
-#define NCR5380_info sun3scsi_info
-#define NCR5380_dma_xfer_len(i, cmd, phase) \
-        sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1)
-
-#define NCR5380_dma_write_setup(instance, data, count) sun3scsi_dma_setup(data, count, 1)
-#define NCR5380_dma_read_setup(instance, data, count) sun3scsi_dma_setup(data, count, 0)
-#define NCR5380_dma_residual sun3scsi_dma_residual
-
 /* additional registers - mainly DMA control regs */
 /* these start at regbase + 8 -- directly after the NCR regs */
 struct sun3_dma_regs {

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 27/29] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (25 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 26/29] sun3_scsi: Move macro definitions Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-02  6:56 ` [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases Finn Thain
  2014-10-02  6:56 ` [PATCH 29/29] atari_NCR5380: Refactor Falcon locking Finn Thain
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: ncr5380-remove-ENABLE_IRQ-DISABLE_IRQ --]
[-- Type: text/plain, Size: 3649 bytes --]

atari_NCR5380.c enables its IRQ when it is already enabled. Sun3 doesn't
use the ENABLE_IRQ/DISABLE_IRQ cruft. Remove it.

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

---
 drivers/scsi/atari_NCR5380.c |    2 --
 drivers/scsi/atari_scsi.c    |   21 ---------------------
 drivers/scsi/sun3_NCR5380.c  |    2 --
 drivers/scsi/sun3_scsi.c     |    7 -------
 4 files changed, 32 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:20.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:24.000000000 +1000
@@ -1226,7 +1226,6 @@ static irqreturn_t NCR5380_intr(int irq,
 		NCR5380_dprint(NDEBUG_INTR, instance);
 		if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {
 			done = 0;
-			ENABLE_IRQ();
 			dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO);
 			NCR5380_reselect(instance);
 			(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -1256,7 +1255,6 @@ static irqreturn_t NCR5380_intr(int irq,
 				dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO);
 				NCR5380_dma_complete( instance );
 				done = 0;
-				ENABLE_IRQ();
 			} else
 #endif /* REAL_DMA */
 			{
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:22.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:24.000000000 +1000
@@ -157,23 +157,6 @@ static inline unsigned long SCSI_DMA_GET
 	return adr;
 }
 
-static inline void ENABLE_IRQ(void)
-{
-	if (IS_A_TT())
-		atari_enable_irq(IRQ_TT_MFP_SCSI);
-	else
-		atari_enable_irq(IRQ_MFP_FSCSI);
-}
-
-static inline void DISABLE_IRQ(void)
-{
-	if (IS_A_TT())
-		atari_disable_irq(IRQ_TT_MFP_SCSI);
-	else
-		atari_disable_irq(IRQ_MFP_FSCSI);
-}
-
-
 #define HOSTDATA_DMALEN		(((struct NCR5380_hostdata *) \
 				(atari_scsi_host->hostdata))->dma_len)
 
@@ -373,10 +356,6 @@ static irqreturn_t scsi_tt_intr(int irq,
 
 	NCR5380_intr(irq, dummy);
 
-#if 0
-	/* To be sure the int is not masked */
-	atari_enable_irq(IRQ_TT_MFP_SCSI);
-#endif
 	return IRQ_HANDLED;
 }
 
Index: linux/drivers/scsi/sun3_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/sun3_NCR5380.c	2014-10-02 16:56:24.000000000 +1000
@@ -1153,7 +1153,6 @@ static irqreturn_t NCR5380_intr (int irq
 	NCR5380_dprint(NDEBUG_INTR, instance);
 	if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) {
 	    done = 0;
-//	    ENABLE_IRQ();
 	    dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO);
 	    NCR5380_reselect(instance);
 	    (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG);
@@ -1186,7 +1185,6 @@ static irqreturn_t NCR5380_intr (int irq
 		dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO);
 		NCR5380_dma_complete( instance );
 		done = 0;
-//		ENABLE_IRQ();
 	    } else
 #endif /* REAL_DMA */
 	    {
Index: linux/drivers/scsi/sun3_scsi.c
===================================================================
--- linux.orig/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:23.000000000 +1000
+++ linux/drivers/scsi/sun3_scsi.c	2014-10-02 16:56:24.000000000 +1000
@@ -72,13 +72,6 @@
 
 extern int sun3_map_test(unsigned long, char *);
 
-#ifdef SUN3_SCSI_VME
-#define ENABLE_IRQ()
-#else
-#define	ENABLE_IRQ()	enable_irq( IRQ_SUN3_SCSI ); 
-#endif
-
-
 static int setup_can_queue = -1;
 module_param(setup_can_queue, int, 0);
 static int setup_cmd_per_lun = -1;



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (26 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 27/29] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  2014-10-06  9:28   ` Hannes Reinecke
  2014-10-02  6:56 ` [PATCH 29/29] atari_NCR5380: Refactor Falcon locking Finn Thain
  28 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: atari_NCR5380-refactor-falcon-special-case --]
[-- Type: text/plain, Size: 8539 bytes --]

Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others
by moving some of the Falcon-specific code out of the core driver: !IS_A_TT,
atari_read_overruns and falcon_dont_release. Replace these with hostdata 
variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c
so don't set it.

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

---
 drivers/scsi/NCR5380.h       |    4 ++++
 drivers/scsi/atari_NCR5380.c |   30 +++++++++++++++---------------
 drivers/scsi/atari_scsi.c    |   21 ++++++++++++---------
 3 files changed, 31 insertions(+), 24 deletions(-)

Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:24.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:25.000000000 +1000
@@ -196,8 +196,6 @@ static char		*atari_dma_orig_addr;
 /* mask for address bits that can't be used with the ST-DMA */
 static unsigned long	atari_dma_stram_mask;
 #define STRAM_ADDR(a)	(((a) & atari_dma_stram_mask) == 0)
-/* number of bytes to cut from a transfer to handle NCR overruns */
-static int atari_read_overruns;
 #endif
 
 static int setup_can_queue = -1;
@@ -446,8 +444,6 @@ static void atari_scsi_fetch_restbytes(v
 #endif /* REAL_DMA */
 
 
-static int falcon_dont_release = 0;
-
 /* This function releases the lock on the DMA chip if there is no
  * connected command and the disconnected queue is empty.
  */
@@ -464,7 +460,7 @@ static void falcon_release_lock_if_possi
 	if (!hostdata->disconnected_queue &&
 	    !hostdata->issue_queue &&
 	    !hostdata->connected &&
-	    !falcon_dont_release &&
+	    !hostdata->retain_dma_intr &&
 	    stdma_is_locked_by(scsi_falcon_intr))
 		stdma_release();
 
@@ -846,6 +842,7 @@ static int __init atari_scsi_probe(struc
 {
 	struct Scsi_Host *instance;
 	int error;
+	int host_flags = 0;
 
 	if (!MACH_IS_ATARI)
 		return -ENODEV;
@@ -945,7 +942,9 @@ static int __init atari_scsi_probe(struc
 	else
 		instance->irq = IRQ_NONE;
 
-	NCR5380_init(instance, 0);
+	host_flags |= IS_A_TT() ? 0 : FLAG_LATE_DMA_SETUP;
+
+	NCR5380_init(instance, host_flags);
 
 	if (IS_A_TT()) {
 		error = request_irq(instance->irq, scsi_tt_intr, 0,
@@ -968,12 +967,16 @@ static int __init atari_scsi_probe(struc
 		 *
 		 * In principle it should be sufficient to do max. 1 byte with
 		 * PIO, but there is another problem on the Medusa with the DMA
-		 * rest data register. So 'atari_read_overruns' is currently set
+		 * rest data register. So read_overruns is currently set
 		 * to 4 to avoid having transfers that aren't a multiple of 4.
 		 * If the rest data bug is fixed, this can be lowered to 1.
 		 */
-		if (MACH_IS_MEDUSA)
-			atari_read_overruns = 4;
+		if (MACH_IS_MEDUSA) {
+			struct NCR5380_hostdata *hostdata =
+				shost_priv(instance);
+
+			hostdata->read_overruns = 4;
+		}
 #endif
 	} else {
 		/* Nothing to do for the interrupt: the ST-DMA is initialized
Index: linux/drivers/scsi/NCR5380.h
===================================================================
--- linux.orig/drivers/scsi/NCR5380.h	2014-10-02 16:56:14.000000000 +1000
+++ linux/drivers/scsi/NCR5380.h	2014-10-02 16:56:25.000000000 +1000
@@ -237,6 +237,7 @@
 #define FLAG_NCR53C400			4	/* NCR53c400 */
 #define FLAG_NO_PSEUDO_DMA		8	/* Inhibit DMA */
 #define FLAG_DTC3181E			16	/* DTC3181E */
+#define FLAG_LATE_DMA_SETUP		32	/* Setup NCR before DMA H/W */
 
 #ifndef ASM
 struct NCR5380_hostdata {
@@ -265,6 +266,9 @@ struct NCR5380_hostdata {
 	struct delayed_work coroutine;		/* our co-routine */
 	struct scsi_eh_save ses;
 	char info[256];
+	int read_overruns;                /* number of bytes to cut from a
+	                                   * transfer to handle chip overruns */
+	int retain_dma_intr;
 #ifdef PSEUDO_DMA
 	unsigned spin_max_r;
 	unsigned spin_max_w;
Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:24.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:25.000000000 +1000
@@ -837,7 +837,7 @@ static int __init NCR5380_init(struct Sc
 	hostdata->connected = NULL;
 	hostdata->issue_queue = NULL;
 	hostdata->disconnected_queue = NULL;
-	hostdata->flags = FLAG_CHECK_LAST_BYTE_SENT;
+	hostdata->flags = flags;
 
 	if (!the_template) {
 		the_template = instance->hostt;
@@ -1053,7 +1053,7 @@ static void NCR5380_main(struct work_str
 						hostdata->issue_queue = NEXT(tmp);
 					}
 					SET_NEXT(tmp, NULL);
-					falcon_dont_release++;
+					hostdata->retain_dma_intr++;
 
 					/* reenable interrupts after finding one */
 					local_irq_restore(flags);
@@ -1081,7 +1081,7 @@ static void NCR5380_main(struct work_str
 					cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE);
 #endif
 					if (!NCR5380_select(instance, tmp)) {
-						falcon_dont_release--;
+						hostdata->retain_dma_intr--;
 						/* release if target did not response! */
 						falcon_release_lock_if_possible(hostdata);
 						break;
@@ -1093,7 +1093,7 @@ static void NCR5380_main(struct work_str
 #ifdef SUPPORT_TAGS
 						cmd_free_tag(tmp);
 #endif
-						falcon_dont_release--;
+						hostdata->retain_dma_intr--;
 						local_irq_restore(flags);
 						dprintk(NDEBUG_MAIN, "scsi%d: main(): select() failed, "
 							    "returned to issue_queue\n", HOSTNO);
@@ -1150,7 +1150,7 @@ static void NCR5380_dma_complete(struct
 		return;
 	}
 
-	if (atari_read_overruns) {
+	if (hostdata->read_overruns) {
 		p = hostdata->connected->SCp.phase;
 		if (p & SR_IO) {
 			udelay(10);
@@ -1180,9 +1180,9 @@ static void NCR5380_dma_complete(struct
 	*data += transfered;
 	*count -= transfered;
 
-	if (atari_read_overruns) {
+	if (hostdata->read_overruns) {
 		if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) {
-			cnt = toPIO = atari_read_overruns;
+			cnt = toPIO = hostdata->read_overruns;
 			if (overrun) {
 				dprintk(NDEBUG_DMA, "Got an input overrun, using saved byte\n");
 				*(*data)++ = saved_data;
@@ -1837,8 +1837,8 @@ static int NCR5380_transfer_dma(struct S
 		return -1;
 	}
 
-	if (atari_read_overruns && (p & SR_IO))
-		c -= atari_read_overruns;
+	if (hostdata->read_overruns && (p & SR_IO))
+		c -= hostdata->read_overruns;
 
 	dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n",
 		   HOSTNO, (p & SR_IO) ? "reading" : "writing",
@@ -1850,7 +1850,7 @@ static int NCR5380_transfer_dma(struct S
 	NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY);
 #endif /* def REAL_DMA  */
 
-	if (IS_A_TT()) {
+	if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) {
 		/* On the Medusa, it is a must to initialize the DMA before
 		 * starting the NCR. This is also the cleaner way for the TT.
 		 */
@@ -1868,7 +1868,7 @@ static int NCR5380_transfer_dma(struct S
 		NCR5380_write(START_DMA_SEND_REG, 0);
 	}
 
-	if (!IS_A_TT()) {
+	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!
 		 */
@@ -2083,7 +2083,7 @@ static void NCR5380_information_transfer
 					/* Accept message by clearing ACK */
 					NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
 					/* ++guenther: possible race with Falcon locking */
-					falcon_dont_release++;
+					hostdata->retain_dma_intr++;
 					hostdata->connected = NULL;
 					dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %d "
 						  "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
@@ -2166,7 +2166,7 @@ static void NCR5380_information_transfer
 					while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
 						barrier();
 
-					falcon_dont_release--;
+					hostdata->retain_dma_intr--;
 					/* ++roman: For Falcon SCSI, release the lock on the
 					 * ST-DMA here if no other commands are waiting on the
 					 * disconnected queue.
@@ -2473,7 +2473,7 @@ static void NCR5380_reselect(struct Scsi
 #endif
 		    ) {
 			/* ++guenther: prevent race with falcon_release_lock */
-			falcon_dont_release++;
+			hostdata->retain_dma_intr++;
 			if (prev) {
 				REMOVE(prev, NEXT(prev), tmp, NEXT(tmp));
 				SET_NEXT(prev, NEXT(tmp));
@@ -2511,7 +2511,7 @@ static void NCR5380_reselect(struct Scsi
 	hostdata->connected = tmp;
 	dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
 		   HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
-	falcon_dont_release--;
+	hostdata->retain_dma_intr--;
 }
 
 



^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 29/29] atari_NCR5380: Refactor Falcon locking
  2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
                   ` (27 preceding siblings ...)
  2014-10-02  6:56 ` [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases Finn Thain
@ 2014-10-02  6:56 ` Finn Thain
  28 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-02  6:56 UTC (permalink / raw)
  To: James E.J. Bottomley; +Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

[-- Attachment #1: atari_NCR5380-refactor-falcon-locking --]
[-- Type: text/plain, Size: 11690 bytes --]

Simplify falcon_release_lock_if_possible() by making callers responsible for
disabling local IRQ's, which they must do anyway to correctly synchronize
the ST DMA "lock" with core driver data structures. Move this synchronization
logic to the core driver with which it is tightly coupled.

Other LLD's like sun3_scsi and mac_scsi that can make use of this core driver
can just stub out the NCR5380_acquire_dma_irq() and NCR5380_release_dma_irq()
calls so the compiler will eliminate the ST DMA code.

Remove a redundant local_irq_save/restore pair (irq's are disabled for
interrupt handlers these days). Revise the locking for atari_scsi_bus_reset():
use local_irq_save/restore() instead of atari_turnoff/turnon_irq(). There is
no guarantee that atari_scsi still holds the ST DMA "lock" during EH, so
atari_turnoff/turnon_irq() could end up dropping an IDE or floppy interrupt.

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

---
 drivers/scsi/atari_NCR5380.c |   72 ++++++++++++++++++++++++++-----------------
 drivers/scsi/atari_scsi.c    |   47 ++++++++++------------------
 2 files changed, 62 insertions(+), 57 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===================================================================
--- linux.orig/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:25.000000000 +1000
+++ linux/drivers/scsi/atari_NCR5380.c	2014-10-02 16:56:26.000000000 +1000
@@ -924,7 +924,7 @@ static int NCR5380_queue_command(struct
 	 * alter queues and touch the lock.
 	 */
 	/* perhaps stop command timer here */
-	if (!falcon_get_lock())
+	if (!NCR5380_acquire_dma_irq(instance))
 		return SCSI_MLQUEUE_HOST_BUSY;
 	/* perhaps restart command timer here */
 
@@ -960,6 +960,18 @@ 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 (!hostdata->disconnected_queue &&
+	    !hostdata->issue_queue &&
+	    !hostdata->connected &&
+	    !hostdata->retain_dma_intr)
+		NCR5380_release_dma_irq(instance);
+}
+
 /*
  * Function : NCR5380_main (void)
  *
@@ -1081,9 +1093,11 @@ static void NCR5380_main(struct work_str
 					cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE);
 #endif
 					if (!NCR5380_select(instance, tmp)) {
+						local_irq_disable();
 						hostdata->retain_dma_intr--;
 						/* release if target did not response! */
-						falcon_release_lock_if_possible(hostdata);
+						maybe_release_dma_irq(instance);
+						local_irq_restore(flags);
 						break;
 					} else {
 						local_irq_disable();
@@ -2082,11 +2096,12 @@ static void NCR5380_information_transfer
 				case COMMAND_COMPLETE:
 					/* Accept message by clearing ACK */
 					NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
-					/* ++guenther: possible race with Falcon locking */
-					hostdata->retain_dma_intr++;
-					hostdata->connected = NULL;
 					dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %d "
 						  "completed\n", HOSTNO, cmd->device->id, cmd->device->lun);
+
+					local_irq_save(flags);
+					hostdata->retain_dma_intr++;
+					hostdata->connected = NULL;
 #ifdef SUPPORT_TAGS
 					cmd_free_tag(cmd);
 					if (status_byte(cmd->SCp.Status) == QUEUE_FULL) {
@@ -2145,17 +2160,17 @@ static void NCR5380_information_transfer
 
 						dprintk(NDEBUG_AUTOSENSE, "scsi%d: performing request sense\n", HOSTNO);
 
-						local_irq_save(flags);
 						LIST(cmd,hostdata->issue_queue);
 						SET_NEXT(cmd, hostdata->issue_queue);
 						hostdata->issue_queue = (struct scsi_cmnd *) cmd;
-						local_irq_restore(flags);
 						dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of "
 							  "issue queue\n", H_NO(cmd));
 					} else {
 						cmd->scsi_done(cmd);
 					}
 
+					local_irq_restore(flags);
+
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
 					/*
 					 * Restore phase bits to 0 so an interrupted selection,
@@ -2166,12 +2181,14 @@ static void NCR5380_information_transfer
 					while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected)
 						barrier();
 
+					local_irq_save(flags);
 					hostdata->retain_dma_intr--;
 					/* ++roman: For Falcon SCSI, release the lock on the
 					 * ST-DMA here if no other commands are waiting on the
 					 * disconnected queue.
 					 */
-					falcon_release_lock_if_possible(hostdata);
+					maybe_release_dma_irq(instance);
+					local_irq_restore(flags);
 					return;
 				case MESSAGE_REJECT:
 					/* Accept message by clearing ACK */
@@ -2330,6 +2347,7 @@ static void NCR5380_information_transfer
 				hostdata->last_message = msgout;
 				NCR5380_transfer_pio(instance, &phase, &len, &data);
 				if (msgout == ABORT) {
+					local_irq_save(flags);
 #ifdef SUPPORT_TAGS
 					cmd_free_tag(cmd);
 #else
@@ -2337,9 +2355,10 @@ static void NCR5380_information_transfer
 #endif
 					hostdata->connected = NULL;
 					cmd->result = DID_ERROR << 16;
-					cmd->scsi_done(cmd);
 					NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask);
-					falcon_release_lock_if_possible(hostdata);
+					maybe_release_dma_irq(instance);
+					local_irq_restore(flags);
+					cmd->scsi_done(cmd);
 					return;
 				}
 				msgout = NOP;
@@ -2392,7 +2411,6 @@ static void NCR5380_reselect(struct Scsi
 	unsigned char msg[3];
 	unsigned char *data;
 	struct scsi_cmnd *tmp = NULL, *prev;
-/*	unsigned long flags; */
 
 	/*
 	 * Disable arbitration, etc. since the host adapter obviously
@@ -2472,8 +2490,6 @@ static void NCR5380_reselect(struct Scsi
 		    && (tag == tmp->tag)
 #endif
 		    ) {
-			/* ++guenther: prevent race with falcon_release_lock */
-			hostdata->retain_dma_intr++;
 			if (prev) {
 				REMOVE(prev, NEXT(prev), tmp, NEXT(tmp));
 				SET_NEXT(prev, NEXT(tmp));
@@ -2511,7 +2527,6 @@ static void NCR5380_reselect(struct Scsi
 	hostdata->connected = tmp;
 	dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %d, tag = %d\n",
 		   HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag);
-	hostdata->retain_dma_intr--;
 }
 
 
@@ -2587,12 +2602,12 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 #else
 			hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
 #endif
+			maybe_release_dma_irq(instance);
 			local_irq_restore(flags);
 			cmd->scsi_done(cmd);
-			falcon_release_lock_if_possible(hostdata);
 			return SUCCESS;
 		} else {
-/*			local_irq_restore(flags); */
+			local_irq_restore(flags);
 			printk("scsi%d: abort of connected command failed!\n", HOSTNO);
 			return FAILED;
 		}
@@ -2611,13 +2626,13 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 			(*prev) = NEXT(tmp);
 			SET_NEXT(tmp, NULL);
 			tmp->result = DID_ABORT << 16;
+			maybe_release_dma_irq(instance);
 			local_irq_restore(flags);
 			dprintk(NDEBUG_ABORT, "scsi%d: abort removed command from issue queue.\n",
 				    HOSTNO);
 			/* Tagged queuing note: no tag to free here, hasn't been assigned
 			 * yet... */
 			tmp->scsi_done(tmp);
-			falcon_release_lock_if_possible(hostdata);
 			return SUCCESS;
 		}
 	}
@@ -2695,15 +2710,22 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 #else
 					hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);
 #endif
+					maybe_release_dma_irq(instance);
 					local_irq_restore(flags);
 					tmp->scsi_done(tmp);
-					falcon_release_lock_if_possible(hostdata);
 					return SUCCESS;
 				}
 			}
 		}
 	}
 
+	/* Maybe it is sufficient just to release the ST-DMA lock... (if
+	 * possible at all) At least, we should check if the lock could be
+	 * released after the abort, in case it is kept due to some bug.
+	 */
+	maybe_release_dma_irq(instance);
+	local_irq_restore(flags);
+
 	/*
 	 * Case 5 : If we reached this point, the command was not found in any of
 	 *	    the queues.
@@ -2714,15 +2736,8 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 	 * broke.
 	 */
 
-	local_irq_restore(flags);
 	printk(KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n", HOSTNO);
 
-	/* Maybe it is sufficient just to release the ST-DMA lock... (if
-	 * possible at all) At least, we should check if the lock could be
-	 * released after the abort, in case it is kept due to some bug.
-	 */
-	falcon_release_lock_if_possible(hostdata);
-
 	return FAILED;
 }
 
@@ -2738,14 +2753,15 @@ int NCR5380_abort(struct scsi_cmnd *cmd)
 
 static int NCR5380_bus_reset(struct scsi_cmnd *cmd)
 {
-	SETUP_HOSTDATA(cmd->device->host);
+	struct Scsi_Host *instance = cmd->device->host;
+	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	int i;
 	unsigned long flags;
 #if defined(RESET_RUN_DONE)
 	struct scsi_cmnd *connected, *disconnected_queue;
 #endif
 
-	NCR5380_print_status(cmd->device->host);
+	NCR5380_print_status(instance);
 
 	/* get in phase */
 	NCR5380_write(TARGET_COMMAND_REG,
@@ -2870,6 +2886,8 @@ static int NCR5380_bus_reset(struct scsi
 #ifdef REAL_DMA
 	hostdata->dma_len = 0;
 #endif
+
+	maybe_release_dma_irq(instance);
 	local_irq_restore(flags);
 
 	/* we did no complete reset of all commands, so a wakeup is required */
Index: linux/drivers/scsi/atari_scsi.c
===================================================================
--- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:25.000000000 +1000
+++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:26.000000000 +1000
@@ -109,6 +109,9 @@
 #define NCR5380_dma_xfer_len(instance, cmd, phase) \
         atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO))
 
+#define NCR5380_acquire_dma_irq(instance)      falcon_get_lock()
+#define NCR5380_release_dma_irq(instance)      falcon_release_lock()
+
 #include "NCR5380.h"
 
 
@@ -448,23 +451,13 @@ static void atari_scsi_fetch_restbytes(v
  * connected command and the disconnected queue is empty.
  */
 
-static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata)
+static void falcon_release_lock(void)
 {
-	unsigned long flags;
-
 	if (IS_A_TT())
 		return;
 
-	local_irq_save(flags);
-
-	if (!hostdata->disconnected_queue &&
-	    !hostdata->issue_queue &&
-	    !hostdata->connected &&
-	    !hostdata->retain_dma_intr &&
-	    stdma_is_locked_by(scsi_falcon_intr))
+	if (stdma_is_locked_by(scsi_falcon_intr))
 		stdma_release();
-
-	local_irq_restore(flags);
 }
 
 /* This function manages the locking of the ST-DMA.
@@ -788,36 +781,30 @@ static void atari_scsi_falcon_reg_write(
 static int atari_scsi_bus_reset(struct scsi_cmnd *cmd)
 {
 	int rv;
-	struct NCR5380_hostdata *hostdata = shost_priv(cmd->device->host);
+	unsigned long flags;
+
+	local_irq_save(flags);
 
-	/* For doing the reset, SCSI interrupts must be disabled first,
-	 * since the 5380 raises its IRQ line while _RST is active and we
-	 * can't disable interrupts completely, since we need the timer.
-	 */
-	/* And abort a maybe active DMA transfer */
-	if (IS_A_TT()) {
-		atari_turnoff_irq(IRQ_TT_MFP_SCSI);
 #ifdef REAL_DMA
+	/* Abort a maybe active DMA transfer */
+	if (IS_A_TT()) {
 		tt_scsi_dma.dma_ctrl = 0;
-#endif
 	} else {
-		atari_turnoff_irq(IRQ_MFP_FSCSI);
-#ifdef REAL_DMA
 		st_dma.dma_mode_status = 0x90;
 		atari_dma_active = 0;
 		atari_dma_orig_addr = NULL;
-#endif
 	}
+#endif
 
 	rv = NCR5380_bus_reset(cmd);
 
-	if (IS_A_TT())
-		atari_turnon_irq(IRQ_TT_MFP_SCSI);
-	else
-		atari_turnon_irq(IRQ_MFP_FSCSI);
+	/* The 5380 raises its IRQ line while _RST is active but the ST DMA
+	 * "lock" has been released so this interrupt may end up handled by
+	 * floppy or IDE driver (if one of them holds the lock). The NCR5380
+	 * interrupt flag has been cleared already.
+	 */
 
-	if (rv == SUCCESS)
-		falcon_release_lock_if_possible(hostdata);
+	local_irq_restore(flags);
 
 	return rv;
 }



^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
  2014-10-02  6:56 ` [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros Finn Thain
@ 2014-10-03  8:09   ` Geert Uytterhoeven
  2014-10-03 10:12     ` Finn Thain
  2014-10-06  9:19   ` Hannes Reinecke
  1 sibling, 1 reply; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:09 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> --- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:55:55.000000000 +1000
> +++ linux/drivers/scsi/NCR5380.h        2014-10-02 16:55:57.000000000 +1000
> @@ -224,14 +224,11 @@
>  #define DISCONNECT_LONG                2
>
>  /*
> - * These are "special" values for the tag parameter passed to NCR5380_select.
> + * "Special" value for the (unsigned char) command tag, to indicate
> + * I_T_L nexus instead of I_T_L_Q.
>   */

I guess the above comment can just be removed instead of changed, as
the I_T_L nexus definitions below are removed?

> -#define TAG_NEXT       -1      /* Use next free tag */
> -#define TAG_NONE       -2      /*
> -                                * Establish I_T_L nexus instead of I_T_L_Q
> -                                * even on SCSI-II devices.
> -                                */
> +#define TAG_NONE       0xff
>
>  /*
>   * These are "special" values for the irq and dma_channel fields of the
> @@ -323,7 +320,7 @@ static irqreturn_t NCR5380_intr(int irq,

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs
  2014-10-02  6:56 ` [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs Finn Thain
@ 2014-10-03  8:22   ` Geert Uytterhoeven
  2014-10-03 10:42     ` Finn Thain
  0 siblings, 1 reply; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:22 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than
> SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE
> if it is to issue IDENTIFY commands that prevent target disconnection.
>
> Other drivers, when they can't get an IRQ or can't use one, will set
> host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will
> attempt to free IRQ 255 which was never requested.
>
> Fix these bugs by using IRQ_NONE in place of SCSI_IRQ_NONE. This means
> IRQ 0 is no longer probed by ISA drivers but I don't think this matters.

IRQ_NONE is part of enum irqreturn. I guess you meant NO_IRQ?

But NO_IRQ is deprecated, and not available on all architectures.
The recommended way is to just use 0, like in "if (instance->irq) ...".

Note that some drivers do

#ifndef NO_IRQ
#define NO_IRQ  (-1)
#endif

and others do

#ifndef NO_IRQ
#define NO_IRQ  0
#endif

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 12/29] ncr5380: Cleanup host info() methods
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-03  8:32     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:32 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi,
	Linux/m68k, Russell King, linux-arm-kernel

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> +static void prepare_info(struct Scsi_Host *instance)
> +{
> +       struct NCR5380_hostdata *hostdata = shost_priv(instance);
> +
> +       snprintf(hostdata->info, sizeof(hostdata->info),

[...]

> +                "");
> +       hostdata->info[sizeof(hostdata->info) - 1] = '\0';

snprintf() will make sure the string is zero-terminated, so doing this manually
is not needed.

This applies to all three occurrences.

>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 12/29] ncr5380: Cleanup host info() methods
@ 2014-10-03  8:32     ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> +static void prepare_info(struct Scsi_Host *instance)
> +{
> +       struct NCR5380_hostdata *hostdata = shost_priv(instance);
> +
> +       snprintf(hostdata->info, sizeof(hostdata->info),

[...]

> +                "");
> +       hostdata->info[sizeof(hostdata->info) - 1] = '\0';

snprintf() will make sure the string is zero-terminated, so doing this manually
is not needed.

This applies to all three occurrences.

>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 17/29] dmx3191d: Use IRQ_NONE
  2014-10-02  6:56 ` [PATCH 17/29] dmx3191d: Use IRQ_NONE Finn Thain
@ 2014-10-03  8:41   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:41 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Testing shows that the Domex 3191D card never asserts its IRQ. Hence it is
> non-functional with Linux (worse, the EH bugs in the core driver are fatal but
> that's a problem for another patch). Perhaps the DT-536 chip needs special
> setup? I can't find documentation for it. The NetBSD driver uses polling
> apparently because of this issue.
>
> Set host->irq = IRQ_NONE so the core driver will prevent targets from
> disconnecting. Don't request the irq.

Please use plain 0 instead of IRQ_NONE (which is related to irqreturn_t).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 19/29] mac_scsi: Add module option to Kconfig
  2014-10-02  6:56 ` [PATCH 19/29] mac_scsi: Add module option to Kconfig Finn Thain
@ 2014-10-03  8:44   ` Geert Uytterhoeven
  2014-10-03 10:49     ` Finn Thain
  0 siblings, 1 reply; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  8:44 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Allow mac_scsi to be built as a module. Replace the old validation of
> __setup options with code that validates both module and __setup options.

> --- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:17.000000000 +1000
> +++ linux/drivers/scsi/mac_scsi.c       2014-10-02 16:56:17.000000000 +1000

> @@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho
>         return 0;
>
>      if (macintosh_config->ident == MAC_MODEL_IIFX) {
> -       mac_scsi_regp  = via1+0x8000;
> -       mac_scsi_drq   = via1+0xE000;
> -       mac_scsi_nodrq = via1+0xC000;
> +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
> +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
> +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
>         /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */
>         flags = FLAG_NO_PSEUDO_DMA;
>      } else {
> -       mac_scsi_regp  = via1+0x10000;
> -       mac_scsi_drq   = via1+0x6000;
> -       mac_scsi_nodrq = via1+0x12000;
> +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x10000;
> +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
> +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
>      }
>
>      if (! setup_use_pdma)

I don't think the above chunk belongs in this patch.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 21/29] mac_scsi: Convert to platform device
  2014-10-02  6:56 ` [PATCH 21/29] mac_scsi: Convert to platform device Finn Thain
@ 2014-10-03  9:08   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  9:08 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Convert mac_scsi to platform device and eliminate scsi_register().
>
> Platform resources for chip registers now follow the documentation. This
> should fix issues with the Mac IIci (and possibly other models too).
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
>
> ---
>
> The new hwreg_present() call is not protected by local_irq_save/restore.
> This assumes Geert's patch, "Disable/restore interrupts in
> hwreg_present()/hwreg_write()":
> http://marc.info/?l=linux-kernel&m=141189640826704&w=2

OK, so this cannot go in before v3.18-rc1.

> --- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:18.000000000 +1000
> +++ linux/drivers/scsi/mac_scsi.c       2014-10-02 16:56:19.000000000 +1000

> @@ -480,7 +380,117 @@ static struct scsi_host_template driver_
>         .use_clustering                 = DISABLE_CLUSTERING
>  };
>
> +static int __init mac_scsi_probe(struct platform_device *pdev)
> +{
> +       struct Scsi_Host *instance;
> +       int error;
> +       int host_flags = 0;
> +       struct resource *irq, *pio_mem, *pdma_mem = NULL;
> +
> +       if (!MACH_IS_MAC)
> +               return -ENODEV;

This check is not needed, asuming you'll only instantiate the platform
device when running on a Mac.

> --- linux.orig/arch/m68k/mac/config.c   2014-10-02 16:55:28.000000000 +1000
> +++ linux/arch/m68k/mac/config.c        2014-10-02 16:56:19.000000000 +1000

> @@ -929,6 +929,36 @@ static struct platform_device swim_pdev
>         .resource       = &swim_rsrc,
>  };
>
> +static struct resource mac_scsi_0_rsrc[] = {
> +       {
> +               .flags = IORESOURCE_IRQ,
> +               .start = IRQ_MAC_SCSI,
> +               .end   = IRQ_MAC_SCSI,
> +       },
> +       { .flags = IORESOURCE_MEM },
> +       { .flags = IORESOURCE_MEM },
> +};
> +
> +static struct resource mac_scsi_1_rsrc[] = {
> +       /* IRQ_NUBUS_E maybe? */
> +       { .flags = IORESOURCE_MEM },
> +       { .flags = IORESOURCE_MEM },
> +};
> +
> +static struct platform_device mac_scsi_0_pdev = {
> +       .name           = "mac_scsi",
> +       .id             = 0,
> +       .resource       = mac_scsi_0_rsrc,
> +       .num_resources  = ARRAY_SIZE(mac_scsi_0_rsrc),
> +};
> +
> +static struct platform_device mac_scsi_1_pdev = {
> +       .name           = "mac_scsi",
> +       .id             = 1,
> +       .resource       = mac_scsi_1_rsrc,
> +       .num_resources  = ARRAY_SIZE(mac_scsi_1_rsrc),
> +};
> +
>  static struct platform_device esp_0_pdev = {
>         .name           = "mac_esp",
>         .id             = 0,
> @@ -1000,6 +1030,53 @@ int __init mac_platform_init(void)
>                     (macintosh_config->ident == MAC_MODEL_Q950))
>                         platform_device_register(&esp_1_pdev);
>                 break;
> +       case MAC_SCSI_IIFX:
> +               /* Addresses from The Guide to Mac Family Hardware. */
> +               mac_scsi_0_rsrc[1].start = 0x50008000; /* SCSI DMA */
> +               mac_scsi_0_rsrc[1].end = mac_scsi_0_rsrc[1].start + 0x1FFF;
> +               /* $5000 E000 - $5000 FFFF: Alternate SCSI (Hsk) */
> +               /* $5000 C000 - $5000 DFFF: Alternate SCSI (DMA) */
> +               /* The SCSI DMA custom IC embeds the 53C80 core. mac_scsi does
> +                * not make use of its DMA or hardware handshaking logic.
> +                */
> +               mac_scsi_0_pdev.num_resources--;
> +               platform_device_register(&mac_scsi_0_pdev);

What about removing the static mac_scsi_0_pdev and mac_scsi_1_pdev,
and calling platform_device_register_simple() instead?
That way you
(a) don't have to fiddle with mac_scsi_0_pdev.num_resources, and
(b) the resources can become const and __initconst, as a copy will be
    allocated dynamically.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon
  2014-10-02  6:56 ` [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon Finn Thain
@ 2014-10-03  9:19   ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  9:19 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> --- linux.orig/arch/m68k/atari/stdma.c  2014-10-02 16:55:28.000000000 +1000
> +++ linux/arch/m68k/atari/stdma.c       2014-10-02 16:56:20.000000000 +1000

> -int stdma_others_waiting(void)
> +int stdma_is_locked_by(irq_handler_t handler)
>  {
> -       return waitqueue_active(&stdma_wait);
> +       unsigned long flags;
> +
> +       local_irq_save(flags);
> +       if (stdma_locked && (stdma_isr == handler)) {
> +               local_irq_restore(flags);
> +               return 1;
> +       }
> +       local_irq_restore(flags);
> +       return 0;
>  }

This can be written shorter:

int stdma_is_locked_by(irq_handler_t handler)
{
        unsigned long flags;
        int res;

        local_irq_save(flags);
        res = stdma_locked && (stdma_isr == handler);
        local_irq_restore(flags);

        return res;
}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-02  6:56 ` [PATCH 23/29] atari_scsi: Convert to platform device Finn Thain
@ 2014-10-03  9:34   ` Geert Uytterhoeven
  2014-10-03 11:10     ` Finn Thain
  2014-10-20  7:33   ` Michael Schmitz
  1 sibling, 1 reply; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03  9:34 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> Convert atari_scsi to platform device and eliminate scsi_register().
>
> Validate __setup options later on so that module options are checked as well.
>
> Remove the comment about the scsi mid-layer disabling the host irq as it
> is no longer true (AFAICT). Also remove the obsolete slow interrupt stuff
> (IRQ_TYPE_SLOW == 0 anyway).

> --- linux.orig/drivers/scsi/atari_scsi.c        2014-10-02 16:56:20.000000000 +1000
> +++ linux/drivers/scsi/atari_scsi.c     2014-10-02 16:56:21.000000000 +1000

> +static int __init atari_scsi_probe(struct platform_device *pdev)
> +{
> +       struct Scsi_Host *instance;
> +       int error;
> +
> +       if (!MACH_IS_ATARI)
> +               return -ENODEV;

This test is not needed.

> +       if (ATARIHW_PRESENT(TT_SCSI)) {
> +               atari_scsi_reg_read  = atari_scsi_tt_reg_read;
> +               atari_scsi_reg_write = atari_scsi_tt_reg_write;
> +       } else if (ATARIHW_PRESENT(ST_SCSI)) {
> +               atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
> +               atari_scsi_reg_write = atari_scsi_falcon_reg_write;

Can these be handled through the platform_device's resources?

> +       } else
> +               return -ENODEV;

This branch should not be there.

> +       /* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary.
> +        * Higher values should work, too; try it!
> +        * (But cmd_per_lun costs memory!)
> +        *
> +        * But there seems to be a bug somewhere that requires CAN_QUEUE to be
> +        * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
> +        * changed CMD_PER_LUN...
> +        *
> +        * Note: The Falcon currently uses 8/1 setting due to unsolved problems
> +        * with cmd_per_lun != 1
> +        */
> +       if (IS_A_TT()) {
> +               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;
> +       }

Shouldn't this be in platform data?

> +       /* Leave sg_tablesize at 0 on a Falcon! */
> +       if (IS_A_TT() && setup_sg_tablesize >= 0)
> +               atari_scsi_template.sg_tablesize = setup_sg_tablesize;

I think the IS_A_TT() check can just be removed.

> +#ifdef REAL_DMA
> +       /* If running on a Falcon and if there's TT-Ram (i.e., more than one
> +        * memory block, since there's always ST-Ram in a Falcon), then
> +        * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
> +        * from/to alternative Ram.
> +        */
> +       if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
> +           m68k_num_memory > 1) {
> +               atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
> +               if (!atari_dma_buffer) {
> +                       pr_err(PFX "can't allocate ST-RAM double buffer\n");
> +                       return -ENOMEM;
> +               }
> +               atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
> +               atari_dma_orig_addr = 0;
> +       }
> +#endif

More platform data?

> +       if (IS_A_TT())
> +               instance->irq = IRQ_TT_MFP_SCSI;
> +       else
> +               instance->irq = IRQ_NONE;

platform_device resource?

(and IRQ_NONE is wrong, you should use 0)

> +       if (IS_A_TT()) {

Check for instance->irq instead?

> +               error = request_irq(instance->irq, scsi_tt_intr, 0,
> +                                   "NCR5380", instance);
> +               if (error) {
> +                       pr_err(PFX "request irq %d failed, aborting\n",
> +                              instance->irq);
> +                       goto fail_irq;
> +               }
> +               tt_mfp.active_edge |= 0x80;     /* SCSI int on L->H */
> +#ifdef REAL_DMA
> +               tt_scsi_dma.dma_ctrl = 0;
> +               atari_dma_residual = 0;
> +
> +               /* While the read overruns (described by Drew Eckhardt in
> +                * NCR5380.c) never happened on TTs, they do in fact on the
> +                * Medusa (This was the cause why SCSI didn't work right for
> +                * so long there.) Since handling the overruns slows down
> +                * a bit, I turned the #ifdef's into a runtime condition.
> +                *
> +                * In principle it should be sufficient to do max. 1 byte with
> +                * PIO, but there is another problem on the Medusa with the DMA
> +                * rest data register. So 'atari_read_overruns' is currently set
> +                * to 4 to avoid having transfers that aren't a multiple of 4.
> +                * If the rest data bug is fixed, this can be lowered to 1.
> +                */
> +               if (MACH_IS_MEDUSA)
> +                       atari_read_overruns = 4;
> +#endif
> +       } else {
> +               /* Nothing to do for the interrupt: the ST-DMA is initialized
> +                * already.
> +                */
> +#ifdef REAL_DMA
> +               atari_dma_residual = 0;
> +               atari_dma_active = 0;
> +               atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
> +                                       : 0xff000000);
> +#endif
> +       }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
  2014-10-03  8:09   ` Geert Uytterhoeven
@ 2014-10-03 10:12     ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-03 10:12 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k


On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:

> On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> > --- linux.orig/drivers/scsi/NCR5380.h   2014-10-02 16:55:55.000000000 +1000
> > +++ linux/drivers/scsi/NCR5380.h        2014-10-02 16:55:57.000000000 +1000
> > @@ -224,14 +224,11 @@
> >  #define DISCONNECT_LONG                2
> >
> >  /*
> > - * These are "special" values for the tag parameter passed to NCR5380_select.
> > + * "Special" value for the (unsigned char) command tag, to indicate
> > + * I_T_L nexus instead of I_T_L_Q.
> >   */
> 
> I guess the above comment can just be removed instead of changed, as the 
> I_T_L nexus definitions below are removed?

When I wrote this patch I didn't realize that the tag member in struct 
scsi_cmnd was going to be removed in favour of cmd->request.tag. I will 
rewrite this patch to remove all of the cmd->tag stuff.

When I sent this patch I knew I'd have to revise it, but I wanted to get 
the entire series out there anyway to avoid further duplication of effort.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs
  2014-10-03  8:22   ` Geert Uytterhoeven
@ 2014-10-03 10:42     ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-03 10:42 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k


On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:

> On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> 
> wrote:
> > Oak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than
> > SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE
> > if it is to issue IDENTIFY commands that prevent target disconnection.
> >
> > Other drivers, when they can't get an IRQ or can't use one, will set
> > host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will
> > attempt to free IRQ 255 which was never requested.
> >
> > Fix these bugs by using IRQ_NONE in place of SCSI_IRQ_NONE. This means
> > IRQ 0 is no longer probed by ISA drivers but I don't think this matters.
> 
> IRQ_NONE is part of enum irqreturn. I guess you meant NO_IRQ?
> 
> But NO_IRQ is deprecated, and not available on all architectures.
> The recommended way is to just use 0, like in "if (instance->irq) ...".
> 
> Note that some drivers do
> 
> #ifndef NO_IRQ
> #define NO_IRQ  (-1)
> #endif
> 
> and others do
> 
> #ifndef NO_IRQ
> #define NO_IRQ  0
> #endif
> 

Well, the question becomes, is it better to replace SCSI_IRQ_NONE with 0 
or with NO_IRQ?

I guess drivers use #ifndef in case the architecture brings its own 
definition of NO_IRQ (presumably because it can't use 0).

Since NCR5380 drivers cover a variety of architectures (ARM, m68k, ISA, 
PCI...) it seems that the more prudent option is,

#ifndef NO_IRQ
#define NO_IRQ  0
#endif

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 19/29] mac_scsi: Add module option to Kconfig
  2014-10-03  8:44   ` Geert Uytterhoeven
@ 2014-10-03 10:49     ` Finn Thain
  2014-10-03 11:31       ` Geert Uytterhoeven
  0 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-03 10:49 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k


On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:

> On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> > Allow mac_scsi to be built as a module. Replace the old validation of
> > __setup options with code that validates both module and __setup options.
> 
> > --- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:17.000000000 +1000
> > +++ linux/drivers/scsi/mac_scsi.c       2014-10-02 16:56:17.000000000 +1000
> 
> > @@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho
> >         return 0;
> >
> >      if (macintosh_config->ident == MAC_MODEL_IIFX) {
> > -       mac_scsi_regp  = via1+0x8000;
> > -       mac_scsi_drq   = via1+0xE000;
> > -       mac_scsi_nodrq = via1+0xC000;
> > +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
> > +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
> > +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
> >         /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */
> >         flags = FLAG_NO_PSEUDO_DMA;
> >      } else {
> > -       mac_scsi_regp  = via1+0x10000;
> > -       mac_scsi_drq   = via1+0x6000;
> > -       mac_scsi_nodrq = via1+0x12000;
> > +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x10000;
> > +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
> > +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
> >      }
> >
> >      if (! setup_use_pdma)
> 
> I don't think the above chunk belongs in this patch.
> 

via1 is not an exported symbol, so this allows mac_scsi to be linked as a 
module.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-03  9:34   ` Geert Uytterhoeven
@ 2014-10-03 11:10     ` Finn Thain
  2014-10-04 23:43       ` Michael Schmitz
  0 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-03 11:10 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k


On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:

> > +       if (ATARIHW_PRESENT(TT_SCSI)) {
> > +               atari_scsi_reg_read  = atari_scsi_tt_reg_read;
> > +               atari_scsi_reg_write = atari_scsi_tt_reg_write;
> > +       } else if (ATARIHW_PRESENT(ST_SCSI)) {
> > +               atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
> > +               atari_scsi_reg_write = atari_scsi_falcon_reg_write;
> 
> Can these be handled through the platform_device's resources?
> 

I don't know.

> > +       /* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary.
> > +        * Higher values should work, too; try it!
> > +        * (But cmd_per_lun costs memory!)
> > +        *
> > +        * But there seems to be a bug somewhere that requires CAN_QUEUE to be
> > +        * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
> > +        * changed CMD_PER_LUN...
> > +        *
> > +        * Note: The Falcon currently uses 8/1 setting due to unsolved problems
> > +        * with cmd_per_lun != 1
> > +        */
> > +       if (IS_A_TT()) {
> > +               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;
> > +       }
> 
> Shouldn't this be in platform data?
> 
> > +       /* Leave sg_tablesize at 0 on a Falcon! */
> > +       if (IS_A_TT() && setup_sg_tablesize >= 0)
> > +               atari_scsi_template.sg_tablesize = setup_sg_tablesize;
> 
> I think the IS_A_TT() check can just be removed.

Well, ST DMA will break if scatter/gather is enabled by the user.

> 
> > +#ifdef REAL_DMA
> > +       /* If running on a Falcon and if there's TT-Ram (i.e., more than one
> > +        * memory block, since there's always ST-Ram in a Falcon), then
> > +        * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
> > +        * from/to alternative Ram.
> > +        */
> > +       if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
> > +           m68k_num_memory > 1) {
> > +               atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
> > +               if (!atari_dma_buffer) {
> > +                       pr_err(PFX "can't allocate ST-RAM double buffer\n");
> > +                       return -ENOMEM;
> > +               }
> > +               atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
> > +               atari_dma_orig_addr = 0;
> > +       }
> > +#endif
> 
> More platform data?
> 
> > +       if (IS_A_TT())
> > +               instance->irq = IRQ_TT_MFP_SCSI;
> > +       else
> > +               instance->irq = IRQ_NONE;
> 
> platform_device resource?

If I thought it possible to parameterize the driver such that it never had 
to test IS_A_TT(), I'd probably agree that this would be more elegant.

Otherwise I'd prefer not to have parts of the logic separated off into the 
platform resources while the remaining logic remains in the driver itself.

While I don't think platform resources are desirable in this driver, I 
would like to hear Michael's views.

Aside from TT and ST, is there a third configuration that might benefit 
from a more data driven configuration?

> 
> (and IRQ_NONE is wrong, you should use 0)
> 
> > +       if (IS_A_TT()) {
> 
> Check for instance->irq instead?

Yes, you'd think so, but a later patch (not in this set) would have 
to change it back to IS_A_TT().

Further patches align atari_NCR5380.c with NCR5380.c, such that the core 
driver then checks host->irq to find out whether an IRQ is in use. For 
Atari ST, request_irq() is not called even though the ST DMA irq is in 
use.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 19/29] mac_scsi: Add module option to Kconfig
  2014-10-03 10:49     ` Finn Thain
@ 2014-10-03 11:31       ` Geert Uytterhoeven
  0 siblings, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-03 11:31 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, scsi, Linux/m68k

On Fri, Oct 3, 2014 at 12:49 PM, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:
>> On Thu, Oct 2, 2014 at 8:56 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
>> > Allow mac_scsi to be built as a module. Replace the old validation of
>> > __setup options with code that validates both module and __setup options.
>>
>> > --- linux.orig/drivers/scsi/mac_scsi.c  2014-10-02 16:56:17.000000000 +1000
>> > +++ linux/drivers/scsi/mac_scsi.c       2014-10-02 16:56:17.000000000 +1000
>>
>> > @@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho
>> >         return 0;
>> >
>> >      if (macintosh_config->ident == MAC_MODEL_IIFX) {
>> > -       mac_scsi_regp  = via1+0x8000;
>> > -       mac_scsi_drq   = via1+0xE000;
>> > -       mac_scsi_nodrq = via1+0xC000;
>> > +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x8000;
>> > +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0xE000;
>> > +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000;
>> >         /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */
>> >         flags = FLAG_NO_PSEUDO_DMA;
>> >      } else {
>> > -       mac_scsi_regp  = via1+0x10000;
>> > -       mac_scsi_drq   = via1+0x6000;
>> > -       mac_scsi_nodrq = via1+0x12000;
>> > +       mac_scsi_regp  = (unsigned char *) VIA1_BASE + 0x10000;
>> > +       mac_scsi_drq   = (unsigned char *) VIA1_BASE + 0x6000;
>> > +       mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000;
>> >      }
>> >
>> >      if (! setup_use_pdma)
>>
>> I don't think the above chunk belongs in this patch.
>
> via1 is not an exported symbol, so this allows mac_scsi to be linked as a
> module.

OK.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-03 11:10     ` Finn Thain
@ 2014-10-04 23:43       ` Michael Schmitz
  2014-10-06  7:05         ` Finn Thain
  0 siblings, 1 reply; 70+ messages in thread
From: Michael Schmitz @ 2014-10-04 23:43 UTC (permalink / raw)
  To: Finn Thain
  Cc: Geert Uytterhoeven, James E.J. Bottomley, Sam Creasey, scsi, Linux/m68k

Finn,
> On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:
>
>   
>>> +       if (ATARIHW_PRESENT(TT_SCSI)) {
>>> +               atari_scsi_reg_read  = atari_scsi_tt_reg_read;
>>> +               atari_scsi_reg_write = atari_scsi_tt_reg_write;
>>> +       } else if (ATARIHW_PRESENT(ST_SCSI)) {
>>> +               atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
>>> +               atari_scsi_reg_write = atari_scsi_falcon_reg_write;
>>>       
>> Can these be handled through the platform_device's resources?
>>
>>     
>
> I don't know.
>   

Should be possible - I've seen that used in the ISP116x HCD driver 
(arch-dependent post-register access delay function passed via platform 
data).

>>     
>>> +       /* Leave sg_tablesize at 0 on a Falcon! */
>>> +       if (IS_A_TT() && setup_sg_tablesize >= 0)
>>> +               atari_scsi_template.sg_tablesize = setup_sg_tablesize;
>>>       
>> I think the IS_A_TT() check can just be removed.
>>     
>
> Well, ST DMA will break if scatter/gather is enabled by the user.
>   

Concur - we'd have to make certain the SG buffers are contiguous in 
physical memory before allowing SG on Falcon.

>   
>>> +#ifdef REAL_DMA
>>> +       /* If running on a Falcon and if there's TT-Ram (i.e., more than one
>>> +        * memory block, since there's always ST-Ram in a Falcon), then
>>> +        * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
>>> +        * from/to alternative Ram.
>>> +        */
>>> +       if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
>>> +           m68k_num_memory > 1) {
>>> +               atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
>>> +               if (!atari_dma_buffer) {
>>> +                       pr_err(PFX "can't allocate ST-RAM double buffer\n");
>>> +                       return -ENOMEM;
>>> +               }
>>> +               atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
>>> +               atari_dma_orig_addr = 0;
>>> +       }
>>> +#endif
>>>       
>> More platform data?
>>     

Perhaps.

>>     
>>> +       if (IS_A_TT())
>>> +               instance->irq = IRQ_TT_MFP_SCSI;
>>> +       else
>>> +               instance->irq = IRQ_NONE;
>>>       
>> platform_device resource?
>>     
>
> If I thought it possible to parameterize the driver such that it never had 
> to test IS_A_TT(), I'd probably agree that this would be more elegant.
>
> Otherwise I'd prefer not to have parts of the logic separated off into the 
> platform resources while the remaining logic remains in the driver itself.
>
> While I don't think platform resources are desirable in this driver, I 
> would like to hear Michael's views.
>   

The IRQ is a good candidate to be passed via platform data. Register 
access primitives can be done via platform data as well. Likewise, the 
ST-DMA locking primitives. That still leaves the DMA setup and 
completion code - Falcon and TT differ here in that they require a 
different order of DMA setup and NCR setup (the Falcon SCSI chip is 
hooked up via the ST-DMA, the TT one memory mapped so DMA setup must 
come last on Falcon, and DMA completion check first. TT has that 
reversed. That's a bit more hassle and might require  lib_NCR5380 
approach similar to the ESP SCSI driver.

> Aside from TT and ST, is there a third configuration that might benefit 
> from a more data driven configuration?
>   

TT and Falcon, not sure any of the ST/STE series ever had a SCSI 
adapter. Medusa is TT compatible

>> (and IRQ_NONE is wrong, you should use 0)
>>
>>     
>>> +       if (IS_A_TT()) {
>>>       
>> Check for instance->irq instead?
>>     
>
> Yes, you'd think so, but a later patch (not in this set) would have 
> to change it back to IS_A_TT().
>
> Further patches align atari_NCR5380.c with NCR5380.c, such that the core 
> driver then checks host->irq to find out whether an IRQ is in use. For 
> Atari ST, request_irq() is not called even though the ST DMA irq is in 
> use.
>   
That's why the IRQ is set to 0, I guess? Works for me. The old code 
states that setting instance->irq = 0 keeps the midlevel from tampering 
with the SCSI IRQ during queuecmd which would interfere with IDE and 
floppy. I guess this is still relevant - I would not have seen the 
ST-DMA locked by IDE during SCSI queuecmd otherwise.

Won't be able to test any of this for a while, sorry.

Cheers,

    Michael

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-04 23:43       ` Michael Schmitz
@ 2014-10-06  7:05         ` Finn Thain
  2014-10-06  8:14           ` Michael Schmitz
  2014-10-06  8:36           ` Geert Uytterhoeven
  0 siblings, 2 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-06  7:05 UTC (permalink / raw)
  To: Michael Schmitz
  Cc: Geert Uytterhoeven, James E.J. Bottomley, Sam Creasey, scsi, Linux/m68k


On Sun, 5 Oct 2014, Michael Schmitz wrote:

> > On Fri, 3 Oct 2014, Geert Uytterhoeven wrote:
> >
> >   
> > > > +       if (ATARIHW_PRESENT(TT_SCSI)) {
> > > > +               atari_scsi_reg_read  = atari_scsi_tt_reg_read;
> > > > +               atari_scsi_reg_write = atari_scsi_tt_reg_write;
> > > > +       } else if (ATARIHW_PRESENT(ST_SCSI)) {
> > > > +               atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
> > > > +               atari_scsi_reg_write = atari_scsi_falcon_reg_write;
> > > >       
> > > Can these be handled through the platform_device's resources?
> > >
> > >     
> >
> > I don't know.
> >   
> 
> Should be possible - I've seen that used in the ISP116x HCD driver 
> (arch-dependent post-register access delay function passed via platform 
> data).

Yes, possible, but is it desirable?

> >   
> > > > +#ifdef REAL_DMA
> > > > +       /* If running on a Falcon and if there's TT-Ram (i.e., more than
> > > > one
> > > > +        * memory block, since there's always ST-Ram in a Falcon), then
> > > > +        * allocate a STRAM_BUFFER_SIZE byte dribble buffer for
> > > > transfers
> > > > +        * from/to alternative Ram.
> > > > +        */
> > > > +       if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
> > > > +           m68k_num_memory > 1) {
> > > > +               atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE,
> > > > "SCSI");
> > > > +               if (!atari_dma_buffer) {
> > > > +                       pr_err(PFX "can't allocate ST-RAM double
> > > > buffer\n");
> > > > +                       return -ENOMEM;
> > > > +               }
> > > > +               atari_dma_phys_buffer =
> > > > atari_stram_to_phys(atari_dma_buffer);
> > > > +               atari_dma_orig_addr = 0;
> > > > +       }
> > > > +#endif
> > > >       
> > > More platform data?
> > >     
> 
> Perhaps.
> 
> > >     
> > > > +       if (IS_A_TT())
> > > > +               instance->irq = IRQ_TT_MFP_SCSI;
> > > > +       else
> > > > +               instance->irq = IRQ_NONE;
> > > >       
> > > platform_device resource?
> > >     
> >
> > If I thought it possible to parameterize the driver such that it never 
> > had to test IS_A_TT(), I'd probably agree that this would be more 
> > elegant.
> >
> > Otherwise I'd prefer not to have parts of the logic separated off into 
> > the platform resources while the remaining logic remains in the driver 
> > itself.
> >
> > While I don't think platform resources are desirable in this driver, I 
> > would like to hear Michael's views.
> >   
> 
> The IRQ is a good candidate to be passed via platform data.

Geert didn't say so, but after thinking about his review comments I 
imagine that he wants all the Atari IRQ numbers kept in one place and all 
the Mac IRQ numbers in a different place, and so on. Makes sense.

> Register access primitives can be done via platform data as well. 
> Likewise, the ST-DMA locking primitives. That still leaves the DMA setup 
> and completion code - Falcon and TT differ here in that they require a 
> different order of DMA setup and NCR setup (the Falcon SCSI chip is 
> hooked up via the ST-DMA, the TT one memory mapped so DMA setup must 
> come last on Falcon, and DMA completion check first. TT has that 
> reversed. That's a bit more hassle and might require lib_NCR5380 
> approach similar to the ESP SCSI driver.
> 
> > Aside from TT and ST, is there a third configuration that might benefit from
> > a more data driven configuration?
> >   
> 
> TT and Falcon, not sure any of the ST/STE series ever had a SCSI adapter.
> Medusa is TT compatible

If there's no third configuration then I see little to be gained from 
completely parameterizing the driver using a bunch of resources.

What am I missing? Why would it be desirable to have bits of driver code 
in arch/m68k/ and other bits of the same driver kept elsewhere in the 
tree (in drivers/)?

> 
> > > (and IRQ_NONE is wrong, you should use 0)
> > >
> > >     
> > > > +       if (IS_A_TT()) {
> > > >       
> > > Check for instance->irq instead?
> > >     
> >
> > Yes, you'd think so, but a later patch (not in this set) would have to 
> > change it back to IS_A_TT().
> >
> > Further patches align atari_NCR5380.c with NCR5380.c, such that the 
> > core driver then checks host->irq to find out whether an IRQ is in 
> > use. For Atari ST, request_irq() is not called even though the ST DMA 
> > irq is in use.
> >   
> That's why the IRQ is set to 0, I guess? Works for me.

My patch tests for IS_A_TT not 0 because 0 has a different meaning 
depending on which core driver you use. I don't want to support three 
forks of NCR5380.c. One of the objectives of this patch series is to try 
to move toward convergence on a common core driver.

> The old code states that setting instance->irq = 0 keeps the midlevel 
> from tampering with the SCSI IRQ during queuecmd which would interfere 
> with IDE and floppy.

I don't know what you mean. AFAIK, the SCSI mid layer doesn't care about 
instance->irq.

> I guess this is still relevant - I would not have seen the ST-DMA locked 
> by IDE during SCSI queuecmd otherwise.

Lock-ups were due to disabling local IRQs. Please see,

[PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon

in this series and (from our personal correspondence) the patch called
ncr5380-atari_scsi-stdma_try_lock

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-06  7:05         ` Finn Thain
@ 2014-10-06  8:14           ` Michael Schmitz
  2014-10-08 11:59             ` Finn Thain
  2014-10-06  8:36           ` Geert Uytterhoeven
  1 sibling, 1 reply; 70+ messages in thread
From: Michael Schmitz @ 2014-10-06  8:14 UTC (permalink / raw)
  To: Finn Thain
  Cc: Geert Uytterhoeven, James E.J. Bottomley, Sam Creasey, scsi, Linux/m68k

Hi Finn,

>>>> Can these be handled through the platform_device's resources?
>>>>
>>>>     
>>>>         
>>> I don't know.
>>>   
>>>       
>> Should be possible - I've seen that used in the ISP116x HCD driver 
>> (arch-dependent post-register access delay function passed via platform 
>> data).
>>     
>
> Yes, possible, but is it desirable?
>   

Only long term, i.e. if we can find a way to fold all the separate 
*_NCR5380 drivers into a core one.


>
> If there's no third configuration then I see little to be gained from 
> completely parameterizing the driver using a bunch of resources.
>
> What am I missing? Why would it be desirable to have bits of driver code 
> in arch/m68k/ and other bits of the same driver kept elsewhere in the 
> tree (in drivers/)?
>
>   

Again, only makes sense if the goal is to reduce the driver to a core 
driver with implementation bits separate.

>>>> (and IRQ_NONE is wrong, you should use 0)
>>>>
>>>>     
>>>>         
>>>>> +       if (IS_A_TT()) {
>>>>>       
>>>>>           
>>>> Check for instance->irq instead?
>>>>     
>>>>         
>>> Yes, you'd think so, but a later patch (not in this set) would have to 
>>> change it back to IS_A_TT().
>>>
>>> Further patches align atari_NCR5380.c with NCR5380.c, such that the 
>>> core driver then checks host->irq to find out whether an IRQ is in 
>>> use. For Atari ST, request_irq() is not called even though the ST DMA 
>>> irq is in use.
>>>   
>>>       
>> That's why the IRQ is set to 0, I guess? Works for me.
>>     
>
> My patch tests for IS_A_TT not 0 because 0 has a different meaning 
> depending on which core driver you use. I don't want to support three 
> forks of NCR5380.c. One of the objectives of this patch series is to try 
> to move toward convergence on a common core driver.
>   

I wasn't talking about the use of IS_A_TT() here, rather about what 
host->irq = 0 achieves. Anyway, in the context of atari_scsi.c, 
host->irq == 0 is synonymous with !IS_A_TT(). If
host->irq == 0 is problematic with the long term goal of a singe 5380 
core driver, we'll just have to pick a value which means 'driver uses 
IRQ but you're not to fiddle with it'.
>> The old code states that setting instance->irq = 0 keeps the midlevel 
>> from tampering with the SCSI IRQ during queuecmd which would interfere 
>> with IDE and floppy.
>>     
>
> I don't know what you mean. AFAIK, the SCSI mid layer doesn't care about 
> instance->irq.
>   

You're right - that's another obsolete comment then. The midlevel uses 
spinlocks now for ages, this means we can set instance->irq to the 
actual IRQ used.

>> I guess this is still relevant - I would not have seen the ST-DMA locked 
>> by IDE during SCSI queuecmd otherwise.
>>     
>
> Lock-ups were due to disabling local IRQs. Please see,
>   

Absolutely right, but that's not what I meant. I assumed the midlevel 
disabled interrupts during queuecommand - it does not, so the point is 
moot. If using the actual IRQ for instance->irq helps at all, no 
objection to that.

SCSI commands can still be queued while IDE IO is in flight - that is 
what the 'ST-DMA locked by IDE' above refers to.

Cheers,

    Michael

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-06  7:05         ` Finn Thain
  2014-10-06  8:14           ` Michael Schmitz
@ 2014-10-06  8:36           ` Geert Uytterhoeven
  1 sibling, 0 replies; 70+ messages in thread
From: Geert Uytterhoeven @ 2014-10-06  8:36 UTC (permalink / raw)
  To: Finn Thain
  Cc: Michael Schmitz, James E.J. Bottomley, Sam Creasey, scsi, Linux/m68k

On Mon, Oct 6, 2014 at 9:05 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
>> > > > +       if (IS_A_TT())
>> > > > +               instance->irq = IRQ_TT_MFP_SCSI;
>> > > > +       else
>> > > > +               instance->irq = IRQ_NONE;
>> > > >
>> > > platform_device resource?
>> > >
>> >
>> > If I thought it possible to parameterize the driver such that it never
>> > had to test IS_A_TT(), I'd probably agree that this would be more
>> > elegant.
>> >
>> > Otherwise I'd prefer not to have parts of the logic separated off into
>> > the platform resources while the remaining logic remains in the driver
>> > itself.
>> >
>> > While I don't think platform resources are desirable in this driver, I
>> > would like to hear Michael's views.
>> >
>>
>> The IRQ is a good candidate to be passed via platform data.
>
> Geert didn't say so, but after thinking about his review comments I
> imagine that he wants all the Atari IRQ numbers kept in one place and all
> the Mac IRQ numbers in a different place, and so on. Makes sense.

In the end, it's the same SCSI chip.

The "only" differences are resources, interrupts, DMA, and glue logic.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 01/29] ncr5380: Use printk() not pr_debug()
  2014-10-02  6:56 ` [PATCH 01/29] ncr5380: Use printk() not pr_debug() Finn Thain
@ 2014-10-06  9:11   ` Hannes Reinecke
  0 siblings, 0 replies; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:11 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Having defined NDEBUG, and having set the console log level, I'd like to see
> some output. Don't use pr_debug(), it's annoying to have to define DEBUG as
> well.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
> ---
> 
> Use of pr_debug() here was a bad idea of mine. Joe was right when
> he questioned it.
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 02/29] ncr5380: Remove unused hostdata fields
  2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
@ 2014-10-06  9:12   ` Hannes Reinecke
  0 siblings, 0 replies; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:12 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Remove unused fields from hostdata structs declared with the
> NCR5380_implementation_fields macro.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
  2014-10-02  6:56 ` [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros Finn Thain
  2014-10-03  8:09   ` Geert Uytterhoeven
@ 2014-10-06  9:19   ` Hannes Reinecke
  2014-10-06 12:26     ` Finn Thain
  1 sibling, 1 reply; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:19 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Both atari_NCR5380.c and sun3_NCR5380.c core drivers #undef TAG_NONE and then
> redefine it. But the original definition is unused because NCR5380.c lacks
> support for tagged queueing. So just define it once.
> 
> The TAG_NEXT macro only appears in the arguments to NCR5380_select() calls.
> But that routine doesn't use its tag argument as the tag was already assigned
> in NCR5380_main(). So remove the unused argument and the macro.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
Why not use 'SCSI_NO_TAG' from include/scsi/scsi_tcq.h ?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options
  2014-10-02  6:56 ` [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options Finn Thain
@ 2014-10-06  9:19   ` Hannes Reinecke
  0 siblings, 0 replies; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:19 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Some __setup() options mentioned in Documentation/scsi don't work because
> a few lines of code went missing sometime since Linux 2.4. Fix the options
> and thus fix some compiler warnings for both the non-modular case,
> 
>     CC      drivers/scsi/dtc.o
> drivers/scsi/dtc.c:176:20: warning: 'dtc_setup' defined but not used [-Wunused-function]
> 
> and the modular case,
> 
>     CC [M]  drivers/scsi/pas16.o
> drivers/scsi/pas16.c:335:20: warning: 'pas16_setup' defined but not used [-Wunused-function]
>     CC [M]  drivers/scsi/t128.o
> drivers/scsi/t128.c:147:20: warning: 't128_setup' defined but not used [-Wunused-function]
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 04/29] ncr5380: Remove unused macros
  2014-10-02  6:56   ` Finn Thain
@ 2014-10-06  9:21     ` Hannes Reinecke
  -1 siblings, 0 replies; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:21 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k,
	Russell King, linux-arm-kernel

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and USE_WRAPPER; and 
> in some drivers, NCR5380_intr and NCR5380_proc_info). DRIVER_SETUP serves no
> purpose anymore. Remove these macro definitions.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [PATCH 04/29] ncr5380: Remove unused macros
@ 2014-10-06  9:21     ` Hannes Reinecke
  0 siblings, 0 replies; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:21 UTC (permalink / raw)
  To: linux-arm-kernel

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and USE_WRAPPER; and 
> in some drivers, NCR5380_intr and NCR5380_proc_info). DRIVER_SETUP serves no
> purpose anymore. Remove these macro definitions.
> 
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare at suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: J. Hawn, J. Guild, F. Imend?rffer, HRB 16746 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
  2014-10-02  6:56 ` [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases Finn Thain
@ 2014-10-06  9:28   ` Hannes Reinecke
  2014-10-06 11:34     ` Finn Thain
  0 siblings, 1 reply; 70+ messages in thread
From: Hannes Reinecke @ 2014-10-06  9:28 UTC (permalink / raw)
  To: Finn Thain, James E.J. Bottomley
  Cc: Michael Schmitz, Sam Creasey, linux-scsi, linux-m68k

On 10/02/2014 08:56 AM, Finn Thain wrote:
> Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others
> by moving some of the Falcon-specific code out of the core driver: !IS_A_TT,
> atari_read_overruns and falcon_dont_release. Replace these with hostdata 
> variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c
> so don't set it.
> 
Hmm. Shouldn't there be some more patches for sun3_scsi and mac_scsi
to actually make use of this?

I'd _love_ to get rid of all of this NCR5380 code duplication ...

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
  2014-10-06  9:28   ` Hannes Reinecke
@ 2014-10-06 11:34     ` Finn Thain
  2014-10-06 13:41       ` Ondrej Zary
  0 siblings, 1 reply; 70+ messages in thread
From: Finn Thain @ 2014-10-06 11:34 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, linux-scsi,
	linux-m68k


On Mon, 6 Oct 2014, Hannes Reinecke wrote:

> On 10/02/2014 08:56 AM, Finn Thain wrote:
> > Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and 
> > others by moving some of the Falcon-specific code out of the core 
> > driver: !IS_A_TT, atari_read_overruns and falcon_dont_release. Replace 
> > these with hostdata variables and flags. FLAG_CHECK_LAST_BYTE_SENT is 
> > unused in atari_NCR5380.c so don't set it.
> > 
> Hmm. Shouldn't there be some more patches for sun3_scsi and mac_scsi to 
> actually make use of this?

Yes, I think you are right, some of those patches should be included.

I've done some testing of mac_scsi and dmx3191d using the atari_NCR5380.c 
core driver but this isn't working adequately yet. It's not yet a proof of 
concept.

To convert sun3_scsi to use the atari_NCR5380 core driver is easier.

If I had atari and sun3 hardware to test on, everything would be done in 
one patch set and I could test the end result rather than asking others to 
test it in stages on the appropriate hardware.

Anyway, I will include more patches when I re-submit: not just the 
sun3_NCR5380.c removal (which is ugly but hopefully Sam can simplify it) 
but also some more work on atari_NCR5380.c (to minimise testing effort).

> 
> I'd _love_ to get rid of all of this NCR5380 code duplication ...

My reading is that if mac_scsi can work with atari_NCR5380 then the same 
is very likely true for the ARM drivers (oak, cumana_1) and also dmx3191d.

To merge atari_NCR5380.c with NCR5380.c would be much more difficult. If 
someone who has the hardware were to take an interest in the remaining 
drivers (just the ISA card drivers, dtc, pas16, g_NCR5380, t128), perhaps 
it would be feasible.

-- 

> 
> Cheers,
> 
> Hannes
> 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
  2014-10-06  9:19   ` Hannes Reinecke
@ 2014-10-06 12:26     ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-06 12:26 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: James E.J. Bottomley, Michael Schmitz, Sam Creasey, linux-scsi,
	linux-m68k


On Mon, 6 Oct 2014, Hannes Reinecke wrote:

> On 10/02/2014 08:56 AM, Finn Thain wrote:
> > Both atari_NCR5380.c and sun3_NCR5380.c core drivers #undef TAG_NONE 
> > and then redefine it. But the original definition is unused because 
> > NCR5380.c lacks support for tagged queueing. So just define it once.
> > 
> > The TAG_NEXT macro only appears in the arguments to NCR5380_select() 
> > calls. But that routine doesn't use its tag argument as the tag was 
> > already assigned in NCR5380_main(). So remove the unused argument and 
> > the macro.
> > 
> > Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
> > 
> Why not use 'SCSI_NO_TAG' from include/scsi/scsi_tcq.h ?

I didn't use SCSI_NO_TAG because it seemed to relate to the int tag member 
in struct request and not the unsigned char tag member in struct 
scsi_cmnd.

In light of the plan to remove the tag member from struct scsi_cmnd, I 
don't know what to do with this patch. It doesn't really help with that 
plan so I figured it would be NAK'd.

I haven't given any thought to the problem of converting drivers to block 
layer tags (which might involve SCSI_NO_TAG, I guess). I have too much 
other work in progress. That's why I suggested commenting out #define 
SUPPORT_TAGS until they could be converted.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
  2014-10-06 11:34     ` Finn Thain
@ 2014-10-06 13:41       ` Ondrej Zary
  0 siblings, 0 replies; 70+ messages in thread
From: Ondrej Zary @ 2014-10-06 13:41 UTC (permalink / raw)
  To: Finn Thain
  Cc: Hannes Reinecke, James E.J. Bottomley, Michael Schmitz,
	Sam Creasey, linux-scsi, linux-m68k

On Monday 06 October 2014, Finn Thain wrote:
> On Mon, 6 Oct 2014, Hannes Reinecke wrote:
> > On 10/02/2014 08:56 AM, Finn Thain wrote:
> > > Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and
> > > others by moving some of the Falcon-specific code out of the core
> > > driver: !IS_A_TT, atari_read_overruns and falcon_dont_release. Replace
> > > these with hostdata variables and flags. FLAG_CHECK_LAST_BYTE_SENT is
> > > unused in atari_NCR5380.c so don't set it.
> >
> > Hmm. Shouldn't there be some more patches for sun3_scsi and mac_scsi to
> > actually make use of this?
>
> Yes, I think you are right, some of those patches should be included.
>
> I've done some testing of mac_scsi and dmx3191d using the atari_NCR5380.c
> core driver but this isn't working adequately yet. It's not yet a proof of
> concept.
>
> To convert sun3_scsi to use the atari_NCR5380 core driver is easier.
>
> If I had atari and sun3 hardware to test on, everything would be done in
> one patch set and I could test the end result rather than asking others to
> test it in stages on the appropriate hardware.
>
> Anyway, I will include more patches when I re-submit: not just the
> sun3_NCR5380.c removal (which is ugly but hopefully Sam can simplify it)
> but also some more work on atari_NCR5380.c (to minimise testing effort).
>
> > I'd _love_ to get rid of all of this NCR5380 code duplication ...
>
> My reading is that if mac_scsi can work with atari_NCR5380 then the same
> is very likely true for the ARM drivers (oak, cumana_1) and also dmx3191d.
>
> To merge atari_NCR5380.c with NCR5380.c would be much more difficult. If
> someone who has the hardware were to take an interest in the remaining
> drivers (just the ISA card drivers, dtc, pas16, g_NCR5380, t128), perhaps
> it would be feasible.

I have some NCR5380 ISA cards and did some fixes to the driver a couple of 
years ago.

-- 
Ondrej Zary

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-06  8:14           ` Michael Schmitz
@ 2014-10-08 11:59             ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-08 11:59 UTC (permalink / raw)
  To: Michael Schmitz
  Cc: Geert Uytterhoeven, James E.J. Bottomley, Sam Creasey, scsi,
	Linux/m68k, Ondrej Zary


On Mon, 6 Oct 2014, Michael Schmitz wrote:

> > > > > Can these be handled through the platform_device's resources?
> > > > 
> > > > I don't know.
> > > 
> > > Should be possible - I've seen that used in the ISP116x HCD driver 
> > > (arch-dependent post-register access delay function passed via 
> > > platform data).
> >
> > Yes, possible, but is it desirable?
> 
> Only long term, i.e. if we can find a way to fold all the separate 
> *_NCR5380 drivers into a core one.

But would it improve the ISA drivers to paramaterize the core driver using 
platform data? I don't know the answer, so I tend to think of code 
duplication as a separate issue.

> >
> > If there's no third configuration then I see little to be gained from 
> > completely parameterizing the driver using a bunch of resources.
> >
> > What am I missing? Why would it be desirable to have bits of driver 
> > code in arch/m68k/ and other bits of the same driver kept elsewhere in 
> > the tree (in drivers/)?
> 
> Again, only makes sense if the goal is to reduce the driver to a core 
> driver with implementation bits separate.
> 

I think it makes sense if it completely eliminates modules like 
{atari,mac,sun3}_scsi and replaces them with a generic ncr5380 platform 
driver entirely parameterized by mac/atari/sun3 platform data.

Or maybe that would only amount to a complicated renaming, as the 
{atari,mac,sun3}_scsi driver logic would presumably just move from 
drivers/scsi to arch/m68k.

Anyway, that's a long way off. To begin with, it would require the 
elimination of all the macros (e.g. SUN3_SCSI_VME, REAL_DMA etc, and
NCR5380_{read,write,dma_read_setup,etc}) and all the static variables 
(setup_use_tagged_queuing, atari_read_overruns etc).

I have written patches that eliminate static variables because that 
enables atari_NCR5380.c to support multiple chips, and it helps fix a 
compiler warning, and also helps cleanup the *RELEASE macros.

Replacing all the macros with flags and an ops struct/plataform data is 
not too difficult for atari_NCR5380.c at present but will be more 
difficult after sun3_NCR5380.c is merged into it.

The same goes for NCR5380.c and the ISA drivers.

I don't yet see a good way to merge all three core drivers, and if I did, 
I wouldn't be able to test the results. Hence I've taken a more gradual 
approach. This patch set eliminates scsi_register() from 
{atari,mac,sun3}_scsi at least.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-02  6:56 ` [PATCH 23/29] atari_scsi: Convert to platform device Finn Thain
  2014-10-03  9:34   ` Geert Uytterhoeven
@ 2014-10-20  7:33   ` Michael Schmitz
  2014-10-20 11:22     ` Finn Thain
  1 sibling, 1 reply; 70+ messages in thread
From: Michael Schmitz @ 2014-10-20  7:33 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Sam Creasey, linux-scsi, linux-m68k,
	Geert Uytterhoeven

Hi Finn,

not certain it is related to this exact patch - the driver crashes 
pretty much on the spot when selecting the first target on the bus.

Panic log:
Atari SCSI: resetting the SCSI bus... done
scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 
0, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, options { 
REAL_DMA SUPPORT_TAGS }
blk_queue_max_segments: set to minimum 1
blk_queue_max_segments: set to minimum 1
blk_queue_max_segments: set to minimum 1
Unable to handle kernel NULL pointer dereference at virtual address 00000158
Oops: 00000000
Modules linked in:
PC: [<000cd87e>] do_coredump+0x3a/0xbe4
SR: 2204  SP: 20803c8c  a2: 00a70000
d0: 00000000    d1: 003c0000    d2: 00000006    d3: 20803dbc
d4: 00025930    d5: 20802000    a0: 00b59c70    a1: 20802000
Process kworker/0:1 (pid: 69, task=00a70000)
Frame format=4 fault addr=00000158 fslw=01050200
Stack from 20803cc8:
        00000006 20803dbc 00025930 20802000 0002b9be 0000001f 20803dd0 
0002aa56
        00a3c540 00b59c70 0008d3e0 00a07cc0 003a8074 00c75000 0002a664 
00000007
        00a7035c 20803dd0 20803e80 00000000 00000000 00000000 00000000 
00000000
        00a70374 0002a9d0 00c75000 00002200 20803dd0 00a70000 00000007 
00a7035c
        0002a5fe 00a70000 0002aa82 00002200 20803dbc 20803dd0 0002aa56 
00a3c540
        0002c5da 00b59c70 0002c6c4 20803dd0 00002200 20803f06 20803f00 
00000000
Call Trace: [<00025930>] do_group_exit+0x0/0x9e
 [<0002b9be>] do_signal_stop+0x0/0x186
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<0008d3e0>] kmem_cache_free+0x10a/0x128
 [<0002a664>] __sigqueue_free+0x32/0x3a
 [<0002a9d0>] __dequeue_signal+0xaa/0x130
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0002a5fe>] recalc_sigpending+0x6/0x1e
 [<0002aa82>] dequeue_signal+0x2c/0x118
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<0002c5da>] get_signal+0x7e/0x4aa
 [<0002c6c4>] get_signal+0x168/0x4aa
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
 [<000308b6>] move_linked_works+0x0/0x9c
 [<0000428c>] do_signal+0x1a/0x1d8
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019d390>] NCR5380_main+0x9c6/0xd98
 [<00046030>] handle_simple_irq+0x36/0x56
 [<00002c36>] do_IRQ+0x26/0x32
[<00002200>] do_one_initcall+0x18c/0x1d4
 [<00002b1c>] auto_irqhandler_fixup+0x4/0xc
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<00004a1a>] do_notify_resume+0x3a/0x44
 [<00002ac8>] do_signal_return+0x10/0x1a
 [<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019d390>] NCR5380_main+0x9c6/0xd98
 [<00030a2a>] worker_enter_idle+0x0/0x146
 [<00032a08>] process_one_work+0x0/0x2a8
 [<00032cb0>] process_scheduled_works+0x0/0x30
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00032cb0>] process_scheduled_works+0x0/0x30
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00081c00>] change_protection_range+0x150/0x1cc
 [<00032b14>] process_one_work+0x10c/0x2a8
 [<002254bc>] schedule+0x0/0x58
 [<00032dea>] worker_thread+0x10a/0x4d0
 [<0003ee30>] __init_waitqueue_head+0x0/0xc
 [<00032ce0>] worker_thread+0x0/0x4d0
 [<0003ee30>] __init_waitqueue_head+0x0/0xc
 [<00036ee0>] kthread+0xa4/0xc0
 [<00036e3c>] kthread+0x0/0xc0
 [<0000299c>] ret_from_kernel_thread+0xc/0x14

Code: 026c ffa4 206a 0354 2028 0170 2d40 ffac <202b> 0158 2d40 ffb0 286b 
014c 4a8c 670c 4aac 0014 6706 e8c0 0782 660a 4cee 38fc
Disabling lock debugging due to kernel taint

Unable to handle kernel NULL pointer dereference at virtual address 00000158
Oops: 00000000
Modules linked in:
PC: [<000372c2>] kthread_data+0x8/0x10
SR: 2700  SP: 20803af0  a2: 00a70000
d0: 00000003    d1: faf65c54    d2: 00a70000    d3: 00a701e8
d4: 00025930    d5: 20802000    a0: 00000000    a1: 00a90474
Process kworker/0:1 (pid: 69, task=00a70000)
Frame format=4 fault addr=fffffff0 fslw=01050020
Stack from 20803b2c:
        00033976 00a70000 002252a6 00a70000 00000000 00000001 20803b98 
00025930
        20802000 00a70164 0000001f 00a70000 20803b98 00a6fff8 000255b8 
00a90000
        00025526 01050200 20803dbc 00025930 20802000 0002b9be 0000001f 
20803c8c
        00223674 20803dd0 20803d6c 20803b98 20803b98 00a701ac 0000581c 
0000000b
        00000007 00000001 00274ae2 0026dce5 0026e477 00000000 20803c8c 
00006806
        0026e477 20803c8c 00000000 0026e45f 00000158 20803c8c 0002aa56 
00000007
Call Trace: [<00033976>] wq_worker_sleeping+0xa/0x82
 [<002252a6>] __schedule+0x21e/0x394
 [<00025930>] do_group_exit+0x0/0x9e
 [<000255b8>] do_exit+0x550/0x846
 [<00025526>] do_exit+0x4be/0x846
 [<00025930>] do_group_exit+0x0/0x9e
 [<0002b9be>] do_signal_stop+0x0/0x186
 [<00223674>] printk+0x0/0x24
 [<0000581c>] bad_super_trap+0x0/0xb2
 [<00006806>] send_fault_sig+0xaa/0xea
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<00005e5e>] buserr_c+0x254/0x390
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<00002950>] buserr+0x20/0x28
 [<00025930>] do_group_exit+0x0/0x9e
 [<00025930>] do_group_exit+0x0/0x9e
 [<0002b9be>] do_signal_stop+0x0/0x186
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<0008d3e0>] kmem_cache_free+0x10a/0x128
 [<0002a664>] __sigqueue_free+0x32/0x3a
 [<0002a9d0>] __dequeue_signal+0xaa/0x130
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0002a5fe>] recalc_sigpending+0x6/0x1e
 [<0002aa82>] dequeue_signal+0x2c/0x118
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0002aa56>] dequeue_signal+0x0/0x118
 [<0002c5da>] get_signal+0x7e/0x4aa
[<0002c6c4>] get_signal+0x168/0x4aa
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
 [<000308b6>] move_linked_works+0x0/0x9c
 [<0000428c>] do_signal+0x1a/0x1d8
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019d390>] NCR5380_main+0x9c6/0xd98
 [<00046030>] handle_simple_irq+0x36/0x56
 [<00002c36>] do_IRQ+0x26/0x32
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<00002b1c>] auto_irqhandler_fixup+0x4/0xc
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<00004a1a>] do_notify_resume+0x3a/0x44
 [<00002ac8>] do_signal_return+0x10/0x1a
 [<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00002200>] do_one_initcall+0x18c/0x1d4
 [<0019d390>] NCR5380_main+0x9c6/0xd98
 [<00030a2a>] worker_enter_idle+0x0/0x146
 [<00032a08>] process_one_work+0x0/0x2a8
 [<00032cb0>] process_scheduled_works+0x0/0x30
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00032cb0>] process_scheduled_works+0x0/0x30
 [<000308b6>] move_linked_works+0x0/0x9c
 [<00081c00>] change_protection_range+0x150/0x1cc
 [<00032b14>] process_one_work+0x10c/0x2a8
 [<002254bc>] schedule+0x0/0x58
 [<00032dea>] worker_thread+0x10a/0x4d0
 [<0003ee30>] __init_waitqueue_head+0x0/0xc
 [<00032ce0>] worker_thread+0x0/0x4d0
 [<0003ee30>] __init_waitqueue_head+0x0/0xc
 [<00036ee0>] kthread+0xa4/0xc0
 [<00036e3c>] kthread+0x0/0xc0
 [<0000299c>] ret_from_kernel_thread+0xc/0x14

Code: e9e8 0141 ffeb 4e75 206f 0004 2068 01bc <2068> fff0 2008 4e75 598f 
2f0e 206f 000c 2068 01bc 4def 0008 42a6 4878 0004 4868
Fixing recursive fault but reboot is needed!

(loops until reset)

Same kernel version (Geert's m68k tree as of yesterday) with your 
earlier patch series applied runs OK. 

Cheers,

    Michael

> Convert atari_scsi to platform device and eliminate scsi_register().
>
> Validate __setup options later on so that module options are checked as well.
>
> Remove the comment about the scsi mid-layer disabling the host irq as it
> is no longer true (AFAICT). Also remove the obsolete slow interrupt stuff
> (IRQ_TYPE_SLOW == 0 anyway).
>
> Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
>
> ---
>  arch/m68k/atari/config.c  |    5 
>  drivers/scsi/atari_scsi.c |  426 ++++++++++++++++++++++------------------------
>  drivers/scsi/atari_scsi.h |   17 -
>  3 files changed, 217 insertions(+), 231 deletions(-)
>
> Index: linux/arch/m68k/atari/config.c
> ===================================================================
> --- linux.orig/arch/m68k/atari/config.c	2014-10-02 16:55:28.000000000 +1000
> +++ linux/arch/m68k/atari/config.c	2014-10-02 16:56:21.000000000 +1000
> @@ -892,6 +892,11 @@ int __init atari_platform_init(void)
>  	}
>  #endif
>  
> +#ifdef CONFIG_ATARI_SCSI
> +	if (ATARIHW_PRESENT(ST_SCSI) || ATARIHW_PRESENT(TT_SCSI))
> +		platform_device_register_simple("atari_scsi", -1, NULL, 0);
> +#endif
> +
>  	return rv;
>  }
>  
> Index: linux/drivers/scsi/atari_scsi.c
> ===================================================================
> --- linux.orig/drivers/scsi/atari_scsi.c	2014-10-02 16:56:20.000000000 +1000
> +++ linux/drivers/scsi/atari_scsi.c	2014-10-02 16:56:21.000000000 +1000
> @@ -74,33 +74,26 @@
>  #define	MAX_TAGS 32
>  
>  #include <linux/types.h>
> -#include <linux/stddef.h>
> -#include <linux/ctype.h>
>  #include <linux/delay.h>
> -#include <linux/mm.h>
>  #include <linux/blkdev.h>
>  #include <linux/interrupt.h>
>  #include <linux/init.h>
>  #include <linux/nvram.h>
>  #include <linux/bitops.h>
>  #include <linux/wait.h>
> +#include <linux/platform_device.h>
>  
>  #include <asm/setup.h>
>  #include <asm/atarihw.h>
>  #include <asm/atariints.h>
> -#include <asm/page.h>
> -#include <asm/pgtable.h>
> -#include <asm/irq.h>
> -#include <asm/traps.h>
> -
> -#include <scsi/scsi_host.h>
> -#include "atari_scsi.h"
> -#include "NCR5380.h"
>  #include <asm/atari_stdma.h>
>  #include <asm/atari_stram.h>
>  #include <asm/io.h>
>  
> -#include <linux/stat.h>
> +#include <scsi/scsi_host.h>
> +
> +#include "atari_scsi.h"
> +#include "NCR5380.h"
>  
>  #define	IS_A_TT()	ATARIHW_PRESENT(TT_SCSI)
>  
> @@ -176,25 +169,9 @@ static inline void DISABLE_IRQ(void)
>  #define	AFTER_RESET_DELAY	(5*HZ/2)
>  #endif
>  
> -/***************************** Prototypes *****************************/
> -
>  #ifdef REAL_DMA
>  static void atari_scsi_fetch_restbytes(void);
>  #endif
> -static irqreturn_t scsi_tt_intr(int irq, void *dummy);
> -static irqreturn_t scsi_falcon_intr(int irq, void *dummy);
> -static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata);
> -static int falcon_get_lock(void);
> -#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
> -static void atari_scsi_reset_boot(void);
> -#endif
> -static unsigned char atari_scsi_tt_reg_read(unsigned char reg);
> -static void atari_scsi_tt_reg_write(unsigned char reg, unsigned char value);
> -static unsigned char atari_scsi_falcon_reg_read(unsigned char reg);
> -static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value);
> -
> -/************************* End of Prototypes **************************/
> -
>  
>  static struct Scsi_Host *atari_scsi_host;
>  static unsigned char (*atari_scsi_reg_read)(unsigned char reg);
> @@ -518,160 +495,12 @@ static int falcon_get_lock(void)
>  	}
>  }
>  
> -
> -static int __init atari_scsi_detect(struct scsi_host_template *host)
> -{
> -	static int called = 0;
> -	struct Scsi_Host *instance;
> -
> -	if (!MACH_IS_ATARI ||
> -	    (!ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(TT_SCSI)) ||
> -	    called)
> -		return 0;
> -
> -	host->proc_name = "Atari";
> -
> -	atari_scsi_reg_read  = IS_A_TT() ? atari_scsi_tt_reg_read :
> -					   atari_scsi_falcon_reg_read;
> -	atari_scsi_reg_write = IS_A_TT() ? atari_scsi_tt_reg_write :
> -					   atari_scsi_falcon_reg_write;
> -
> -	/* setup variables */
> -	host->can_queue =
> -		(setup_can_queue > 0) ? setup_can_queue :
> -		IS_A_TT() ? ATARI_TT_CAN_QUEUE : ATARI_FALCON_CAN_QUEUE;
> -	host->cmd_per_lun =
> -		(setup_cmd_per_lun > 0) ? setup_cmd_per_lun :
> -		IS_A_TT() ? ATARI_TT_CMD_PER_LUN : ATARI_FALCON_CMD_PER_LUN;
> -	/* Force sg_tablesize to 0 on a Falcon! */
> -	host->sg_tablesize =
> -		!IS_A_TT() ? ATARI_FALCON_SG_TABLESIZE :
> -		(setup_sg_tablesize >= 0) ? setup_sg_tablesize : ATARI_TT_SG_TABLESIZE;
> -
> -	if (setup_hostid >= 0)
> -		host->this_id = setup_hostid;
> -	else {
> -		/* use 7 as default */
> -		host->this_id = 7;
> -		/* Test if a host id is set in the NVRam */
> -		if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) {
> -			unsigned char b = nvram_read_byte( 14 );
> -			/* Arbitration enabled? (for TOS) If yes, use configured host ID */
> -			if (b & 0x80)
> -				host->this_id = b & 7;
> -		}
> -	}
> -
> -#ifdef SUPPORT_TAGS
> -	if (setup_use_tagged_queuing < 0)
> -		setup_use_tagged_queuing = 0;
> -#endif
> -#ifdef REAL_DMA
> -	/* If running on a Falcon and if there's TT-Ram (i.e., more than one
> -	 * memory block, since there's always ST-Ram in a Falcon), then allocate a
> -	 * STRAM_BUFFER_SIZE byte dribble buffer for transfers from/to alternative
> -	 * Ram.
> -	 */
> -	if (MACH_IS_ATARI && ATARIHW_PRESENT(ST_SCSI) &&
> -	    !ATARIHW_PRESENT(EXTD_DMA) && m68k_num_memory > 1) {
> -		atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
> -		if (!atari_dma_buffer) {
> -			printk(KERN_ERR "atari_scsi_detect: can't allocate ST-RAM "
> -					"double buffer\n");
> -			return 0;
> -		}
> -		atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
> -		atari_dma_orig_addr = 0;
> -	}
> -#endif
> -	instance = scsi_register(host, sizeof(struct NCR5380_hostdata));
> -	if (instance == NULL) {
> -		atari_stram_free(atari_dma_buffer);
> -		atari_dma_buffer = 0;
> -		return 0;
> -	}
> -	atari_scsi_host = instance;
> -	/*
> -	 * Set irq to 0, to avoid that the mid-level code disables our interrupt
> -	 * during queue_command calls. This is completely unnecessary, and even
> -	 * worse causes bad problems on the Falcon, where the int is shared with
> -	 * IDE and floppy!
> -	 */
> -       instance->irq = 0;
> -
> -#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
> -	atari_scsi_reset_boot();
> -#endif
> -	NCR5380_init(instance, 0);
> -
> -	if (IS_A_TT()) {
> -
> -		/* This int is actually "pseudo-slow", i.e. it acts like a slow
> -		 * interrupt after having cleared the pending flag for the DMA
> -		 * interrupt. */
> -		if (request_irq(IRQ_TT_MFP_SCSI, scsi_tt_intr, IRQ_TYPE_SLOW,
> -				 "SCSI NCR5380", instance)) {
> -			printk(KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting",IRQ_TT_MFP_SCSI);
> -			scsi_unregister(atari_scsi_host);
> -			atari_stram_free(atari_dma_buffer);
> -			atari_dma_buffer = 0;
> -			return 0;
> -		}
> -		tt_mfp.active_edge |= 0x80;		/* SCSI int on L->H */
> -#ifdef REAL_DMA
> -		tt_scsi_dma.dma_ctrl = 0;
> -		atari_dma_residual = 0;
> -
> -		if (MACH_IS_MEDUSA) {
> -			/* While the read overruns (described by Drew Eckhardt in
> -			 * NCR5380.c) never happened on TTs, they do in fact on the Medusa
> -			 * (This was the cause why SCSI didn't work right for so long
> -			 * there.) Since handling the overruns slows down a bit, I turned
> -			 * the #ifdef's into a runtime condition.
> -			 *
> -			 * In principle it should be sufficient to do max. 1 byte with
> -			 * PIO, but there is another problem on the Medusa with the DMA
> -			 * rest data register. So 'atari_read_overruns' is currently set
> -			 * to 4 to avoid having transfers that aren't a multiple of 4. If
> -			 * the rest data bug is fixed, this can be lowered to 1.
> -			 */
> -			atari_read_overruns = 4;
> -		}
> -#endif /*REAL_DMA*/
> -	} else { /* ! IS_A_TT */
> -
> -		/* Nothing to do for the interrupt: the ST-DMA is initialized
> -		 * already by atari_init_INTS()
> -		 */
> -
> -#ifdef REAL_DMA
> -		atari_dma_residual = 0;
> -		atari_dma_active = 0;
> -		atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
> -					: 0xff000000);
> -#endif
> -	}
> -
> -	called = 1;
> -	return 1;
> -}
> -
> -static int atari_scsi_release(struct Scsi_Host *sh)
> -{
> -	if (IS_A_TT())
> -		free_irq(IRQ_TT_MFP_SCSI, sh);
> -	if (atari_dma_buffer)
> -		atari_stram_free(atari_dma_buffer);
> -	NCR5380_exit(sh);
> -	return 1;
> -}
> -
>  #ifndef MODULE
>  static int __init atari_scsi_setup(char *str)
>  {
>  	/* Format of atascsi parameter is:
>  	 *   atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
> -	 * Defaults depend on TT or Falcon, hostid determined at run time.
> +	 * Defaults depend on TT or Falcon, determined at run time.
>  	 * Negative values mean don't change.
>  	 */
>  	int ints[6];
> @@ -682,36 +511,17 @@ static int __init atari_scsi_setup(char
>  		printk("atari_scsi_setup: no arguments!\n");
>  		return 0;
>  	}
> -
> -	if (ints[0] >= 1) {
> -		if (ints[1] > 0)
> -			/* no limits on this, just > 0 */
> -			setup_can_queue = ints[1];
> -	}
> -	if (ints[0] >= 2) {
> -		if (ints[2] > 0)
> -			setup_cmd_per_lun = ints[2];
> -	}
> -	if (ints[0] >= 3) {
> -		if (ints[3] >= 0) {
> -			setup_sg_tablesize = ints[3];
> -			/* Must be <= SG_ALL (255) */
> -			if (setup_sg_tablesize > SG_ALL)
> -				setup_sg_tablesize = SG_ALL;
> -		}
> -	}
> -	if (ints[0] >= 4) {
> -		/* Must be between 0 and 7 */
> -		if (ints[4] >= 0 && ints[4] <= 7)
> -			setup_hostid = ints[4];
> -		else if (ints[4] > 7)
> -			printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]);
> -	}
> +	if (ints[0] >= 1)
> +		setup_can_queue = ints[1];
> +	if (ints[0] >= 2)
> +		setup_cmd_per_lun = ints[2];
> +	if (ints[0] >= 3)
> +		setup_sg_tablesize = ints[3];
> +	if (ints[0] >= 4)
> +		setup_hostid = ints[4];
>  #ifdef SUPPORT_TAGS
> -	if (ints[0] >= 5) {
> -		if (ints[5] >= 0)
> -			setup_use_tagged_queuing = !!ints[5];
> -	}
> +	if (ints[0] >= 5)
> +		setup_use_tagged_queuing = ints[5];
>  #endif
>  
>  	return 1;
> @@ -1020,23 +830,211 @@ static int atari_scsi_bus_reset(struct s
>  	return rv;
>  }
>  
> -static struct scsi_host_template driver_template = {
> +#define DRV_MODULE_NAME         "atari_scsi"
> +#define PFX                     DRV_MODULE_NAME ": "
> +
> +static struct scsi_host_template atari_scsi_template = {
> +	.module			= THIS_MODULE,
> +	.proc_name		= DRV_MODULE_NAME,
>  	.show_info		= atari_scsi_show_info,
>  	.name			= "Atari native SCSI",
> -	.detect			= atari_scsi_detect,
> -	.release		= atari_scsi_release,
>  	.info			= atari_scsi_info,
>  	.queuecommand		= atari_scsi_queue_command,
>  	.eh_abort_handler	= atari_scsi_abort,
>  	.eh_bus_reset_handler	= atari_scsi_bus_reset,
> -	.can_queue		= 0, /* initialized at run-time */
> -	.this_id		= 0, /* initialized at run-time */
> -	.sg_tablesize		= 0, /* initialized at run-time */
> -	.cmd_per_lun		= 0, /* initialized at run-time */
> +	.this_id		= 7,
>  	.use_clustering		= DISABLE_CLUSTERING
>  };
>  
> +static int __init atari_scsi_probe(struct platform_device *pdev)
> +{
> +	struct Scsi_Host *instance;
> +	int error;
> +
> +	if (!MACH_IS_ATARI)
> +		return -ENODEV;
> +
> +	if (ATARIHW_PRESENT(TT_SCSI)) {
> +		atari_scsi_reg_read  = atari_scsi_tt_reg_read;
> +		atari_scsi_reg_write = atari_scsi_tt_reg_write;
> +	} else if (ATARIHW_PRESENT(ST_SCSI)) {
> +		atari_scsi_reg_read  = atari_scsi_falcon_reg_read;
> +		atari_scsi_reg_write = atari_scsi_falcon_reg_write;
> +	} else
> +		return -ENODEV;
> +
> +	/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary.
> +	 * Higher values should work, too; try it!
> +	 * (But cmd_per_lun costs memory!)
> +	 *
> +	 * But there seems to be a bug somewhere that requires CAN_QUEUE to be
> +	 * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
> +	 * changed CMD_PER_LUN...
> +	 *
> +	 * Note: The Falcon currently uses 8/1 setting due to unsolved problems
> +	 * with cmd_per_lun != 1
> +	 */
> +	if (IS_A_TT()) {
> +		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;
> +	}
> +
> +	if (setup_can_queue > 0)
> +		atari_scsi_template.can_queue = setup_can_queue;
> +
> +	if (setup_cmd_per_lun > 0)
> +		atari_scsi_template.cmd_per_lun = setup_cmd_per_lun;
> +
> +	/* Leave sg_tablesize at 0 on a Falcon! */
> +	if (IS_A_TT() && setup_sg_tablesize >= 0)
> +		atari_scsi_template.sg_tablesize = setup_sg_tablesize;
> +
> +	if (setup_hostid >= 0) {
> +		atari_scsi_template.this_id = setup_hostid & 7;
> +	} else {
> +		/* Test if a host id is set in the NVRam */
> +		if (ATARIHW_PRESENT(TT_CLK) && nvram_check_checksum()) {
> +			unsigned char b = nvram_read_byte(14);
> +
> +			/* Arbitration enabled? (for TOS)
> +			 * If yes, use configured host ID
> +			 */
> +			if (b & 0x80)
> +				atari_scsi_template.this_id = b & 7;
> +		}
> +	}
> +
> +#ifdef SUPPORT_TAGS
> +	if (setup_use_tagged_queuing < 0)
> +		setup_use_tagged_queuing = 0;
> +#endif
> +
> +#ifdef REAL_DMA
> +	/* If running on a Falcon and if there's TT-Ram (i.e., more than one
> +	 * memory block, since there's always ST-Ram in a Falcon), then
> +	 * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers
> +	 * from/to alternative Ram.
> +	 */
> +	if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
> +	    m68k_num_memory > 1) {
> +		atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI");
> +		if (!atari_dma_buffer) {
> +			pr_err(PFX "can't allocate ST-RAM double buffer\n");
> +			return -ENOMEM;
> +		}
> +		atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer);
> +		atari_dma_orig_addr = 0;
> +	}
> +#endif
> +
> +	instance = scsi_host_alloc(&atari_scsi_template,
> +	                           sizeof(struct NCR5380_hostdata));
> +	if (!instance) {
> +		error = -ENOMEM;
> +		goto fail_alloc;
> +	}
> +	atari_scsi_host = instance;
> +
> +#ifdef CONFIG_ATARI_SCSI_RESET_BOOT
> +	atari_scsi_reset_boot();
> +#endif
> +
> +	if (IS_A_TT())
> +		instance->irq = IRQ_TT_MFP_SCSI;
> +	else
> +		instance->irq = IRQ_NONE;
> +
> +	NCR5380_init(instance, 0);
> +
> +	if (IS_A_TT()) {
> +		error = request_irq(instance->irq, scsi_tt_intr, 0,
> +		                    "NCR5380", instance);
> +		if (error) {
> +			pr_err(PFX "request irq %d failed, aborting\n",
> +			       instance->irq);
> +			goto fail_irq;
> +		}
> +		tt_mfp.active_edge |= 0x80;	/* SCSI int on L->H */
> +#ifdef REAL_DMA
> +		tt_scsi_dma.dma_ctrl = 0;
> +		atari_dma_residual = 0;
> +
> +		/* While the read overruns (described by Drew Eckhardt in
> +		 * NCR5380.c) never happened on TTs, they do in fact on the
> +		 * Medusa (This was the cause why SCSI didn't work right for
> +		 * so long there.) Since handling the overruns slows down
> +		 * a bit, I turned the #ifdef's into a runtime condition.
> +		 *
> +		 * In principle it should be sufficient to do max. 1 byte with
> +		 * PIO, but there is another problem on the Medusa with the DMA
> +		 * rest data register. So 'atari_read_overruns' is currently set
> +		 * to 4 to avoid having transfers that aren't a multiple of 4.
> +		 * If the rest data bug is fixed, this can be lowered to 1.
> +		 */
> +		if (MACH_IS_MEDUSA)
> +			atari_read_overruns = 4;
> +#endif
> +	} else {
> +		/* Nothing to do for the interrupt: the ST-DMA is initialized
> +		 * already.
> +		 */
> +#ifdef REAL_DMA
> +		atari_dma_residual = 0;
> +		atari_dma_active = 0;
> +		atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000
> +					: 0xff000000);
> +#endif
> +	}
> +
> +	error = scsi_add_host(instance, NULL);
> +	if (error)
> +		goto fail_host;
> +
> +	platform_set_drvdata(pdev, instance);
> +
> +	scsi_scan_host(instance);
> +	return 0;
> +
> +fail_host:
> +	if (instance->irq != IRQ_NONE)
> +		free_irq(instance->irq, instance);
> +fail_irq:
> +	NCR5380_exit(instance);
> +	scsi_host_put(instance);
> +fail_alloc:
> +	if (atari_dma_buffer)
> +		atari_stram_free(atari_dma_buffer);
> +	return error;
> +}
> +
> +static int __exit atari_scsi_remove(struct platform_device *pdev)
> +{
> +	struct Scsi_Host *instance = platform_get_drvdata(pdev);
> +
> +	scsi_remove_host(instance);
> +	if (instance->irq != IRQ_NONE)
> +		free_irq(instance->irq, instance);
> +	NCR5380_exit(instance);
> +	scsi_host_put(instance);
> +	if (atari_dma_buffer)
> +		atari_stram_free(atari_dma_buffer);
> +	return 0;
> +}
> +
> +static struct platform_driver atari_scsi_driver = {
> +	.remove = __exit_p(atari_scsi_remove),
> +	.driver = {
> +		.name	= DRV_MODULE_NAME,
> +		.owner	= THIS_MODULE,
> +	},
> +};
>  
> -#include "scsi_module.c"
> +module_platform_driver_probe(atari_scsi_driver, atari_scsi_probe);
>  
> +MODULE_ALIAS("platform:" DRV_MODULE_NAME);
>  MODULE_LICENSE("GPL");
> Index: linux/drivers/scsi/atari_scsi.h
> ===================================================================
> --- linux.orig/drivers/scsi/atari_scsi.h	2014-10-02 16:56:10.000000000 +1000
> +++ linux/drivers/scsi/atari_scsi.h	2014-10-02 16:56:21.000000000 +1000
> @@ -18,23 +18,6 @@
>  /* (I_HAVE_OVERRUNS stuff removed) */
>  
>  #ifndef ASM
> -/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher
> - * values should work, too; try it! (but cmd_per_lun costs memory!) */
> -
> -/* But there seems to be a bug somewhere that requires CAN_QUEUE to be
> - * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since
> - * changed CMD_PER_LUN... */
> -
> -/* Note: The Falcon currently uses 8/1 setting due to unsolved problems with
> - * cmd_per_lun != 1 */
> -
> -#define ATARI_TT_CAN_QUEUE		16
> -#define ATARI_TT_CMD_PER_LUN		8
> -#define ATARI_TT_SG_TABLESIZE		SG_ALL
> -
> -#define ATARI_FALCON_CAN_QUEUE		8
> -#define ATARI_FALCON_CMD_PER_LUN	1
> -#define ATARI_FALCON_SG_TABLESIZE	SG_NONE
>  
>  #define	NCR5380_implementation_fields	/* none */
>  
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-20  7:33   ` Michael Schmitz
@ 2014-10-20 11:22     ` Finn Thain
  2014-10-20 18:34       ` Michael Schmitz
  2014-10-26  7:37       ` Michael Schmitz
  0 siblings, 2 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-20 11:22 UTC (permalink / raw)
  To: Michael Schmitz
  Cc: James E.J. Bottomley, Sam Creasey, linux-scsi, linux-m68k,
	Geert Uytterhoeven


On Mon, 20 Oct 2014, Michael Schmitz wrote:

> Hi Finn,
> 
> not certain it is related to this exact patch - the driver crashes 
> pretty much on the spot when selecting the first target on the bus.

If it isn't that exact patch then it will probably be one of the other 
atari_scsi patches. Most of the other relevant stuff was covered by my own 
testing.

Anyway, thanks for testing and for sending the backtrace. I'll figure out 
what went wrong and fix it before I send a new patch set.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-20 11:22     ` Finn Thain
@ 2014-10-20 18:34       ` Michael Schmitz
  2014-10-26  7:37       ` Michael Schmitz
  1 sibling, 0 replies; 70+ messages in thread
From: Michael Schmitz @ 2014-10-20 18:34 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Sam Creasey, scsi, Linux/m68k, Geert Uytterhoeven

Hi Finn,

>> not certain it is related to this exact patch - the driver crashes
>> pretty much on the spot when selecting the first target on the bus.
>
> If it isn't that exact patch then it will probably be one of the other
> atari_scsi patches. Most of the other relevant stuff was covered by my own
> testing.
>
> Anyway, thanks for testing and for sending the backtrace. I'll figure out
> what went wrong and fix it before I send a new patch set.

Let me know what I can do to help - e.g. can the platform device patch
be backed out without upsetting the rest of the series?

Cheers,

  Michael

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-20 11:22     ` Finn Thain
  2014-10-20 18:34       ` Michael Schmitz
@ 2014-10-26  7:37       ` Michael Schmitz
  2014-10-27  0:15         ` Finn Thain
  1 sibling, 1 reply; 70+ messages in thread
From: Michael Schmitz @ 2014-10-26  7:37 UTC (permalink / raw)
  To: Finn Thain
  Cc: James E.J. Bottomley, Sam Creasey, linux-scsi, linux-m68k,
	Geert Uytterhoeven

Finn,
> On Mon, 20 Oct 2014, Michael Schmitz wrote:
>
>   
>> Hi Finn,
>>
>> not certain it is related to this exact patch - the driver crashes 
>> pretty much on the spot when selecting the first target on the bus.
>>     
>
> If it isn't that exact patch then it will probably be one of the other 
> atari_scsi patches. Most of the other relevant stuff was covered by my own 
> testing.
>
> Anyway, thanks for testing and for sending the backtrace. I'll figure out 
> what went wrong and fix it before I send a new patch set.
>
>   

Turns out I missed a reject in patch 29 of the series (hunk #4) which 
caused a local_irq_save(flags) to go AWOL. Both commenting out the 
resulting lone local_irq_restore(flags), as well as fixing the reject 
properly makes the driver behave as it should.

No locking races, and no more warnings about bytes stuck in the DMA 
fifo. We might be on to a winner here :-)

Cheers,

    Michael

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [PATCH 23/29] atari_scsi: Convert to platform device
  2014-10-26  7:37       ` Michael Schmitz
@ 2014-10-27  0:15         ` Finn Thain
  0 siblings, 0 replies; 70+ messages in thread
From: Finn Thain @ 2014-10-27  0:15 UTC (permalink / raw)
  To: Michael Schmitz
  Cc: James E.J. Bottomley, Sam Creasey, linux-scsi, linux-m68k,
	Geert Uytterhoeven


On Sun, 26 Oct 2014, Michael Schmitz wrote:

> > On Mon, 20 Oct 2014, Michael Schmitz wrote:
> >
> > > not certain it is related to this exact patch - the driver crashes 
> > > pretty much on the spot when selecting the first target on the bus.
> > >     
> > ...
> 
> Turns out I missed a reject in patch 29 of the series (hunk #4) which 
> caused a local_irq_save(flags) to go AWOL. Both commenting out the 
> resulting lone local_irq_restore(flags), as well as fixing the reject 
> properly makes the driver behave as it should.
> 
> No locking races, and no more warnings about bytes stuck in the DMA 
> fifo. We might be on to a winner here :-)

That's good to hear. Thanks for testing v1. I'll send v2 when I'm done 
testing it.

-- 

^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2014-10-27  0:16 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-02  6:56 [PATCH 00/29] Fixes, cleanups and modernization for NCR5380 drivers Finn Thain
2014-10-02  6:56 ` [PATCH 01/29] ncr5380: Use printk() not pr_debug() Finn Thain
2014-10-06  9:11   ` Hannes Reinecke
2014-10-02  6:56 ` [PATCH 02/29] ncr5380: Remove unused hostdata fields Finn Thain
2014-10-06  9:12   ` Hannes Reinecke
2014-10-02  6:56 ` [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options Finn Thain
2014-10-06  9:19   ` Hannes Reinecke
2014-10-02  6:56 ` [PATCH 04/29] ncr5380: Remove unused macros Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-06  9:21   ` Hannes Reinecke
2014-10-06  9:21     ` Hannes Reinecke
2014-10-02  6:56 ` [PATCH 05/29] ncr5380: Remove useless prototypes Finn Thain
2014-10-02  6:56 ` [PATCH 06/29] ncr5380: Remove more " Finn Thain
2014-10-02  6:56 ` [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros Finn Thain
2014-10-03  8:09   ` Geert Uytterhoeven
2014-10-03 10:12     ` Finn Thain
2014-10-06  9:19   ` Hannes Reinecke
2014-10-06 12:26     ` Finn Thain
2014-10-02  6:56 ` [PATCH 08/29] ncr5380: Remove redundant AUTOSENSE macro Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-02  6:56 ` [PATCH 09/29] ncr5380: Remove duplicate comments Finn Thain
2014-10-02  6:56 ` [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs Finn Thain
2014-10-03  8:22   ` Geert Uytterhoeven
2014-10-03 10:42     ` Finn Thain
2014-10-02  6:56 ` [PATCH 11/29] ncr5380: Remove NCR5380_STATS Finn Thain
2014-10-02  6:56 ` [PATCH 12/29] ncr5380: Cleanup host info() methods Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-03  8:32   ` Geert Uytterhoeven
2014-10-03  8:32     ` Geert Uytterhoeven
2014-10-02  6:56 ` [PATCH 13/29] ncr5380: Move static PDMA spin counters to host data Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-02  6:56 ` [PATCH 14/29] ncr5380: Remove pointless compiler command line override macros Finn Thain
2014-10-02  6:56 ` [PATCH 15/29] ncr5380: Remove *_RELEASE macros Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-02  6:56 ` [PATCH 16/29] ncr5380: Drop legacy scsi.h include Finn Thain
2014-10-02  6:56   ` Finn Thain
2014-10-02  6:56 ` [PATCH 17/29] dmx3191d: Use IRQ_NONE Finn Thain
2014-10-03  8:41   ` Geert Uytterhoeven
2014-10-02  6:56 ` [PATCH 18/29] mac_scsi: Remove header Finn Thain
2014-10-02  6:56 ` [PATCH 19/29] mac_scsi: Add module option to Kconfig Finn Thain
2014-10-03  8:44   ` Geert Uytterhoeven
2014-10-03 10:49     ` Finn Thain
2014-10-03 11:31       ` Geert Uytterhoeven
2014-10-02  6:56 ` [PATCH 20/29] mac_scsi: Cleanup PDMA code Finn Thain
2014-10-02  6:56 ` [PATCH 21/29] mac_scsi: Convert to platform device Finn Thain
2014-10-03  9:08   ` Geert Uytterhoeven
2014-10-02  6:56 ` [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon Finn Thain
2014-10-03  9:19   ` Geert Uytterhoeven
2014-10-02  6:56 ` [PATCH 23/29] atari_scsi: Convert to platform device Finn Thain
2014-10-03  9:34   ` Geert Uytterhoeven
2014-10-03 11:10     ` Finn Thain
2014-10-04 23:43       ` Michael Schmitz
2014-10-06  7:05         ` Finn Thain
2014-10-06  8:14           ` Michael Schmitz
2014-10-08 11:59             ` Finn Thain
2014-10-06  8:36           ` Geert Uytterhoeven
2014-10-20  7:33   ` Michael Schmitz
2014-10-20 11:22     ` Finn Thain
2014-10-20 18:34       ` Michael Schmitz
2014-10-26  7:37       ` Michael Schmitz
2014-10-27  0:15         ` Finn Thain
2014-10-02  6:56 ` [PATCH 24/29] atari_scsi: Remove header Finn Thain
2014-10-02  6:56 ` [PATCH 25/29] sun3_scsi: Convert to platform device Finn Thain
2014-10-02  6:56 ` [PATCH 26/29] sun3_scsi: Move macro definitions Finn Thain
2014-10-02  6:56 ` [PATCH 27/29] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros Finn Thain
2014-10-02  6:56 ` [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases Finn Thain
2014-10-06  9:28   ` Hannes Reinecke
2014-10-06 11:34     ` Finn Thain
2014-10-06 13:41       ` Ondrej Zary
2014-10-02  6:56 ` [PATCH 29/29] atari_NCR5380: Refactor Falcon locking Finn Thain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.