Re: [PATCH 0/6] various fixes for UFS-PM series

2014-10-27 Thread Christoph Hellwig
On Sun, Oct 26, 2014 at 11:04:06AM -, Dolev Raviv wrote:
  Btw, MAINTAINERS doesn't mention you for the ufs driver, should it?
 
 No it shouldn't.

It seems like I'm getting a lot of the series from you and your signoff,
why shouldn't you be listed in MAINTAINERS?  From the list activity it
seems like you and Sujit are the defator maintainers.

Santosh just send a patch to remove himself, and I only see very little
activity from Vinayak, with his last ACK in early July and a few
more earlier in the year.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH scsi] libcxgbi : support ipv6 address host_param

2014-10-27 Thread h...@infradead.org
On Sat, Oct 25, 2014 at 12:06:32AM +, Anish Bhatt wrote:
 Pinging for visibility.

I've queued this up for 3.18, but I'm still waiting for review on
the other patches I'd like to throw into that tree.
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 02/36] ncr5380: Remove unused hostdata fields

2014-10-27 Thread Finn Thain
Remove unused fields from hostdata structs declared with the
NCR5380_implementation_fields macro.

Signed-off-by: Finn Thain fth...@telegraphics.com.au
Reviewed-by: Hannes Reinecke h...@suse.de

---
 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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/dmx3191d.c   2014-10-27 16:25:07.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:07.0 +1100
@@ -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 + (reg4));
-  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 + (reg4), value);
-  CTRL(iobase, 0x40);
-}
-#else
-
-/* Fast versions */
 static __inline__ char macscsi_read(struct Scsi_Host *instance, int reg)
 {
   return in_8(instance-io_port + (reg4));
@@ -131,8 +102,6 @@ static __inline__ void macscsi_write(str
 {
   out_8(instance-io_port + (reg4), 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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/mac_scsi.h   2014-10-27 16:25:07.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:07.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/sun3_scsi.h  2014-10-27 16:25:07.0 +1100
@@ -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


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 04/36] ncr5380: Remove unused macros

2014-10-27 Thread Finn Thain
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 fth...@telegraphics.com.au
Reviewed-by: Hannes Reinecke h...@suse.de

---
 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-27 16:25:07.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:09.0 +1100
@@ -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-27 16:25:07.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:09.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:09.0 +1100
@@ -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-27 16:25:08.0 +1100
+++ linux/drivers/scsi/pas16.c  2014-10-27 16:25:09.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-27 16:25:09.0 +1100
@@ -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 @@
  */
 
 /* 

[PATCH v2 00/36] Fixes, cleanups and modernization for NCR5380 drivers

2014-10-27 Thread Finn Thain

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.

These patches remove a lot of duplicated code and C pre-processor abuse.
There are also 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 so it can be used by sun3_scsi.c (and others).

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 for the testing I did and may be
helpful to other testers. Let me know if so.

Changes since v1:
- Re-based to v3.17.
- Addressed issues raised in code review (see relevant patches for details).
- Added patches 30 to 36, to remove sun3_NCR5380.c entirely and remove more
  static variables from atari_NCR5380.c.

This patch set stops short of parameterizing the drivers with platform_data
and/or ops struct. IMHO, it would be premature to do such refactoring before
drivers have been purged of static variables and certain #ifdefs. After
that is done, entire modules could be replaced with platform devices.

Several patches in this set address issues with the tagged command queueing
code (see patches 7, 33 and 34). I've since learned from recent discussions
on the linux-scsi list that use of the tag member in struct scsi_cmnd is
deprecated. If removal of the tag member is imminent then it may be better
to remove TCQ support from all of the NCR5380 drivers instead of this
cleanup. Or it could be done separately.

Removal of TCQ code might make re-unification easier, by bringing
atari_NCR5380.c closer to NCR5380.c and eliminating some #ifdefs.
Changes to the TCQ code would affect atari_scsi, being the only driver to
#define SUPPORT_TAGS.

---
 MAINTAINERS |1 
 arch/m68k/atari/config.c|   27 
 arch/m68k/atari/stdma.c |   61 
 arch/m68k/include/asm/atari_stdma.h |4 
 arch/m68k/include/asm/macintosh.h   |4 
 arch/m68k/mac/config.c  |  146 +
 arch/m68k/sun3/config.c |   60 
 drivers/scsi/Kconfig|2 
 drivers/scsi/NCR5380.c  |  295 +--
 drivers/scsi/NCR5380.h  |   78 
 drivers/scsi/arm/cumana_1.c |   18 
 drivers/scsi/arm/oak.c  |   23 
 drivers/scsi/atari_NCR5380.c|  981 +---
 drivers/scsi/atari_scsi.c   |  676 +++-
 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 |  542 ++
 drivers/scsi/mac_scsi.h |   74 
 drivers/scsi/pas16.c|  106 -
 drivers/scsi/pas16.h|   21 
 drivers/scsi/sun3_NCR5380.c | 2933 
 drivers/scsi/sun3_scsi.c|  512 ++
 drivers/scsi/sun3_scsi.h|   84 -
 drivers/scsi/t128.c |   83 -
 drivers/scsi/t128.h |   23 
 29 files changed, 1745 insertions(+), 5461 deletions(-)




--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/36] ncr5380: Fix SCSI_IRQ_NONE bugs

2014-10-27 Thread Finn Thain
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.
And, as Geert points out, IRQ_NONE is part of enum irqreturn.

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 NO_IRQ in place of SCSI_IRQ_NONE and IRQ_NONE.
That 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 fth...@telegraphics.com.au

---

Changes since v1:
- Define NO_IRQ macro and use that instead of IRQ_NONE.

---
 drivers/scsi/NCR5380.c   |   12 ++--
 drivers/scsi/NCR5380.h   |5 -
 drivers/scsi/arm/oak.c   |2 +-
 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 +-
 10 files changed, 66 insertions(+), 48 deletions(-)

Index: linux/drivers/scsi/dtc.c
===
--- linux.orig/drivers/scsi/dtc.c   2014-10-27 16:25:20.0 +1100
+++ linux/drivers/scsi/dtc.c2014-10-27 16:25:22.0 +1100
@@ -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 = NO_IRQ;
+
 #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 != NO_IRQ)
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 = NO_IRQ;
}
 
-   if (instance-irq == SCSI_IRQ_NONE) {
+   if (instance-irq == NO_IRQ) {
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 != NO_IRQ)
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 = NO_IRQ;
 #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 == NO_IRQ)
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 == NO_IRQ)
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 == NO_IRQ)
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 != NO_IRQ)
free_irq(shost-irq, shost);
 

[PATCH v2 26/36] sun3_scsi: Move macro definitions

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:50.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:51.0 +1100
@@ -33,18 +33,42 @@
 #include asm/io.h
 #include asm/dvma.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_infosun3scsi_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
@@ -65,9 +89,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;
-
-#defineRESET_RUN_DONE
+/* #define RESET_BOOT */
 
 #defineAFTER_RESET_DELAY   (HZ/2)
 
@@ -80,6 +102,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;
@@ -131,9 +154,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
@@ -210,7 +230,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-27 16:25:50.0 +1100
+++ linux/drivers/scsi/sun3_scsi.h  2014-10-27 16:25:51.0 +1100
@@ -18,31 +18,6 @@
 #ifndef SUN3_SCSI_H
 #define SUN3_SCSI_H
 
-#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 {


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 09/36] ncr5380: Remove duplicate comments

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:17.0 +1100
+++ linux/drivers/scsi/dtc.c2014-10-27 16:25:20.0 +1100
@@ -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-27 16:25:17.0 +1100
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-27 16:25:20.0 +1100
@@ -20,18 +20,6 @@
  * Thomas Sailer, sai...@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-27 16:25:17.0 +1100
+++ linux/drivers/scsi/pas16.c  2014-10-27 16:25:20.0 +1100
@@ -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-27 16:25:17.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:20.0 +1100
@@ -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 

[PATCH v2 11/36] ncr5380: Remove NCR5380_STATS

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:22.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:24.0 +1100
@@ -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 
@@ -1207,35 +1176,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)
  *
@@ -1464,7 +1404,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);
@@ -2216,7 +2155,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 %llu linked request done, calling scsi_done().\n, instance-host_no, 
cmd-device-id, cmd-device-lun);
-   collect_stats(hostdata, cmd);

[PATCH v2 30/36] atari_NCR5380: Merge from sun3_NCR5380.c

2014-10-27 Thread Finn Thain
There is very little difference between the sun3_NCR5380.c core driver
and atari_NCR5380.c. The former is a fork of the latter.

Merge the sun3_NCR5380.c core driver into atari_NCR5380.c so that
sun3_scsi.c can adopt the latter and the former can be deleted.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---

This patch brings some undesirable #ifdef's to atari_NCR5380. It's a small
price to pay for the elimination of so much duplication. Eventually, with
some testing, it should be possible to remove many of these.

Elimination of the SUN3_SCSI_VME macro is necessary to reach the goal of a
single platform driver to replace the {atari,mac,sun3,sun3_vme}_scsi modules.

Elimination of the #ifdef CONFIG_SUN3 tests is not necessary. But some of
these would go away if the sun3 driver followed the atari logic more
closely, such as use of PIO vs DMA for certain phases and transfer sizes.

After applying this patch it is easy to compare the new atari_NCR5380.c
with sun3_NCR5380.c, to check that they are equivalent. E.g.

$ cp drivers/scsi/{sun3,atari}_NCR5380.c /tmp
$ sed -i -e 's/  *$//'  /tmp/{sun3,atari}_NCR5380.c
$ scripts/Lindent -l96 -hnl /tmp/{sun3,atari}_NCR5380.c
$ meld  /tmp/{sun3,atari}_NCR5380.c

One can see that the two implementations of tagged command queueing have
diverged since the fork. The atari version has been updated and the sun3
implementation is unused as sun3_scsi.c does not define SUPPORT_TAGS.

The remaining differences are merge_contiguous_buffers() and the falcon
locking code. The falcon code disappears when suitable macro definitions are
provided in sun3_scsi.c. merge_contiguous_buffers() could be a problem
for sun3 (due to a DMA setup in an odd place) so it is #ifdef'd for sun3
until the DMA setup discrepancies can be reconciled or moved out of
the core driver.

---
 drivers/scsi/atari_NCR5380.c |  210 +++
 drivers/scsi/atari_scsi.c|1 
 2 files changed, 195 insertions(+), 16 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:25:55.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:56.0 +1100
@@ -71,6 +71,9 @@
  * 1.  Test linked command handling code after Eric is ready with
  * the high level code.
  */
+
+/* Adapted for the sun3 by Sam Creasey. */
+
 #include scsi/scsi_dbg.h
 #include scsi/scsi_transport_spi.h
 
@@ -458,6 +461,7 @@ static void free_all_tags(void)
 
 static void merge_contiguous_buffers(struct scsi_cmnd *cmd)
 {
+#if !defined(CONFIG_SUN3)
unsigned long endaddr;
 #if (NDEBUG  NDEBUG_MERGING)
unsigned long oldlen = cmd-SCp.this_residual;
@@ -482,6 +486,7 @@ static void merge_contiguous_buffers(str
dprintk(NDEBUG_MERGING, merged %d buffers from %p, new length 
%08x\n,
   cnt, cmd-SCp.ptr, cmd-SCp.this_residual);
 #endif
+#endif /* !defined(CONFIG_SUN3) */
 }
 
 /*
@@ -1043,12 +1048,10 @@ static void NCR5380_main(struct work_str
 prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) {
u8 lun = tmp-device-lun;
 
-#if (NDEBUG  NDEBUG_LISTS)
-   if (prev != tmp)
-   printk(MAIN tmp=%p   target=%d   
busy=%d lun=%llu\n,
-  tmp, tmp-device-id, 
hostdata-busy[tmp-device-id],
-  lun);
-#endif
+   dprintk(NDEBUG_LISTS,
+   MAIN tmp=%p target=%d busy=%d 
lun=%d\n,
+   tmp, scmd_id(tmp), 
hostdata-busy[scmd_id(tmp)],
+   lun);
/*  When we find one, remove it from the issue 
queue. */
/* ++guenther: possible race with Falcon 
locking */
if (
@@ -1157,9 +1160,11 @@ static void NCR5380_main(struct work_str
 static void NCR5380_dma_complete(struct Scsi_Host *instance)
 {
SETUP_HOSTDATA(instance);
-   int transfered, saved_data = 0, overrun = 0, cnt, toPIO;
-   unsigned char **data, p;
+   int transfered;
+   unsigned char **data;
volatile int *count;
+   int saved_data = 0, overrun = 0;
+   unsigned char p;
 
if (!hostdata-connected) {
printk(KERN_WARNING scsi%d: received end of DMA interrupt with 

@@ -1185,6 +1190,26 @@ static void NCR5380_dma_complete(struct
   HOSTNO, NCR5380_read(BUS_AND_STATUS_REG),
   NCR5380_read(STATUS_REG));
 
+#if defined(CONFIG_SUN3)
+   if ((sun3scsi_dma_finish(rq_data_dir(hostdata-connected-request {
+   pr_err(scsi%d: overrun in UDC counter -- not prepared to deal 
with this!\n,
+  

[PATCH v2 17/36] dmx3191d: Use NO_IRQ

2014-10-27 Thread Finn Thain
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 = NO_IRQ so the core driver will prevent targets from
disconnecting. Don't request host-irq.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---

Changes since v1:
- Use NO_IRQ instead of IRQ_NONE.

---
 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-27 16:25:36.0 +1100
+++ linux/drivers/scsi/dmx3191d.c   2014-10-27 16:25:40.0 +1100
@@ -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 = NO_IRQ;
 
-   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 = NO_IRQ;
-   }
+   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 != NO_IRQ)
-   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 != NO_IRQ)
-   free_irq(shost-irq, shost);
release_region(shost-io_port, DMX3191D_REGION_LEN);
pci_disable_device(pdev);
 


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 12/36] ncr5380: Cleanup host info() methods

2014-10-27 Thread Finn Thain
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 fth...@telegraphics.com.au

---

Changes since v1:
- Dropped explicit NULL termination of snprintf() buffers.

---
 drivers/scsi/NCR5380.c   |   74 ++-
 drivers/scsi/NCR5380.h   |3 
 drivers/scsi/arm/cumana_1.c  |   14 
 drivers/scsi/arm/oak.c   |   14 
 drivers/scsi/atari_NCR5380.c |   57 +++---
 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  |   59 +++---
 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, 134 insertions(+), 320 deletions(-)

Index: linux/drivers/scsi/arm/cumana_1.c
===
--- linux.orig/drivers/scsi/arm/cumana_1.c  2014-10-27 16:25:17.0 
+1100
+++ linux/drivers/scsi/arm/cumana_1.c   2014-10-27 16:25:26.0 +1100
@@ -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)  0x))
@@ -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-27 16:25:22.0 +1100
+++ linux/drivers/scsi/arm/oak.c2014-10-27 16:25:26.0 +1100
@@ -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.c2014-10-27 16:25:17.0 
+1100
+++ linux/drivers/scsi/atari_scsi.c 2014-10-27 16:25:26.0 +1100
@@ -699,21 +699,6 

[PATCH v2 34/36] atari_NCR5380: Move static TagAlloc array to host data

2014-10-27 Thread Finn Thain
The atari_NCR5380.c core driver keeps some per-host data in a static
variable which limits the driver to a single instance. Fix this by moving
TagAlloc to the hostdata struct.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 drivers/scsi/NCR5380.h   |   12 
 drivers/scsi/atari_NCR5380.c |   27 +--
 2 files changed, 21 insertions(+), 18 deletions(-)

Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-27 16:26:00.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:26:02.0 +1100
@@ -245,6 +245,15 @@
 #define FLAG_TAGGED_QUEUING64  /* as X3T9.2 spelled it */
 
 #ifndef ASM
+
+#ifdef SUPPORT_TAGS
+struct tag_alloc {
+   DECLARE_BITMAP(allocated, MAX_TAGS);
+   int nr_allocated;
+   int queue_size;
+};
+#endif
+
 struct NCR5380_hostdata {
NCR5380_implementation_fields;  /* implementation specific */
struct Scsi_Host *host; /* Host backpointer */
@@ -274,6 +283,9 @@ struct NCR5380_hostdata {
int read_overruns;/* number of bytes to cut from a
   * transfer to handle chip overruns */
int retain_dma_intr;
+#ifdef SUPPORT_TAGS
+   struct tag_alloc TagAlloc[8][8];/* 8 targets and 8 LUNs */
+#endif
 #ifdef PSEUDO_DMA
unsigned spin_max_r;
unsigned spin_max_w;
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:26:00.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:26:02.0 +1100
@@ -274,26 +274,17 @@ static struct scsi_host_template *the_te
  * important: the tag bit must be cleared before 'nr_allocated' is decreased.
  */
 
-typedef struct {
-   DECLARE_BITMAP(allocated, MAX_TAGS);
-   int nr_allocated;
-   int queue_size;
-} TAG_ALLOC;
-
-static TAG_ALLOC TagAlloc[8][8];   /* 8 targets and 8 LUNs */
-
-
 static void __init init_tags(struct NCR5380_hostdata *hostdata)
 {
int target, lun;
-   TAG_ALLOC *ta;
+   struct tag_alloc *ta;
 
if (!(hostdata-flags  FLAG_TAGGED_QUEUING))
return;
 
for (target = 0; target  8; ++target) {
for (lun = 0; lun  8; ++lun) {
-   ta = TagAlloc[target][lun];
+   ta = hostdata-TagAlloc[target][lun];
bitmap_zero(ta-allocated, MAX_TAGS);
ta-nr_allocated = 0;
/* At the beginning, assume the maximum queue size we 
could
@@ -324,8 +315,8 @@ static int is_lun_busy(struct scsi_cmnd
!(hostdata-flags  FLAG_TAGGED_QUEUING) ||
!cmd-device-tagged_supported)
return 0;
-   if (TagAlloc[cmd-device-id][lun].nr_allocated =
-   TagAlloc[cmd-device-id][lun].queue_size) {
+   if (hostdata-TagAlloc[scmd_id(cmd)][lun].nr_allocated =
+   hostdata-TagAlloc[scmd_id(cmd)][lun].queue_size) {
dprintk(NDEBUG_TAGS, scsi%d: target %d lun %d: no free tags\n,
   H_NO(cmd), cmd-device-id, lun);
return 1;
@@ -355,7 +346,7 @@ static void cmd_get_tag(struct scsi_cmnd
dprintk(NDEBUG_TAGS, scsi%d: target %d lun %d now allocated by 
untagged 
   command\n, H_NO(cmd), cmd-device-id, lun);
} else {
-   TAG_ALLOC *ta = TagAlloc[cmd-device-id][lun];
+   struct tag_alloc *ta = hostdata-TagAlloc[scmd_id(cmd)][lun];
 
cmd-tag = find_first_zero_bit(ta-allocated, MAX_TAGS);
set_bit(cmd-tag, ta-allocated);
@@ -385,7 +376,7 @@ static void cmd_free_tag(struct scsi_cmn
printk(KERN_NOTICE scsi%d: trying to free bad tag %d!\n,
   H_NO(cmd), cmd-tag);
} else {
-   TAG_ALLOC *ta = TagAlloc[cmd-device-id][lun];
+   struct tag_alloc *ta = hostdata-TagAlloc[scmd_id(cmd)][lun];
clear_bit(cmd-tag, ta-allocated);
ta-nr_allocated--;
dprintk(NDEBUG_TAGS, scsi%d: freed tag %d for target %d lun 
%d\n,
@@ -397,14 +388,14 @@ static void cmd_free_tag(struct scsi_cmn
 static void free_all_tags(struct NCR5380_hostdata *hostdata)
 {
int target, lun;
-   TAG_ALLOC *ta;
+   struct tag_alloc *ta;
 
if (!(hostdata-flags  FLAG_TAGGED_QUEUING))
return;
 
for (target = 0; target  8; ++target) {
for (lun = 0; lun  8; ++lun) {
-   ta = TagAlloc[target][lun];
+   ta = hostdata-TagAlloc[target][lun];
bitmap_zero(ta-allocated, MAX_TAGS);
ta-nr_allocated = 0;
}
@@ -2209,7 +2200,7 @@ static void 

[PATCH v2 28/36] atari_NCR5380: Refactor Falcon special cases

2014-10-27 Thread Finn Thain
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 fth...@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.c2014-10-27 16:25:52.0 
+1100
+++ linux/drivers/scsi/atari_scsi.c 2014-10-27 16:25:54.0 +1100
@@ -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();
 
@@ -847,6 +843,7 @@ static int __init atari_scsi_probe(struc
struct Scsi_Host *instance;
int error;
struct resource *irq;
+   int host_flags = 0;
 
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!irq)
@@ -943,7 +940,9 @@ static int __init atari_scsi_probe(struc
 
instance-irq = irq-start;
 
-   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,
@@ -966,12 +965,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-27 16:25:36.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:54.0 +1100
@@ -241,6 +241,7 @@
 #define FLAG_NCR53C400 4   /* NCR53c400 */
 #define FLAG_NO_PSEUDO_DMA 8   /* Inhibit DMA */
 #define FLAG_DTC3181E  16  /* DTC3181E */
+#define FLAG_LATE_DMA_SETUP32  /* Setup NCR before DMA H/W */
 
 #ifndef ASM
 struct NCR5380_hostdata {
@@ -269,6 +270,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-27 16:25:52.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:54.0 +1100
@@ -839,7 +839,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) {
   

[PATCH v2 15/36] ncr5380: Remove *_RELEASE macros

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:30.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:33.0 +1100
@@ -11,8 +11,6 @@
  *  d...@colorado.edu
  *  +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -735,22 +733,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-27 16:25:26.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:33.0 +1100
@@ -11,8 +11,6 @@
  * d...@colorado.edu
  * +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6.
- *
  * For more information, please consult
  *
  * NCR 5380 Family
@@ -741,7 +739,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);
@@ -785,7 +782,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-27 16:25:26.0 
+1100
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-27 16:25:33.0 +1100
@@ -13,8 +13,6 @@
  * d...@colorado.edu
  * +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 6. 
- *
  * For more information, please consult 
  *
  * NCR 5380 Family
@@ -687,7 +685,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);
@@ -731,7 +728,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-27 16:25:30.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:33.0 +1100
@@ -7,8 +7,6 @@
  * d...@colorado.edu
  *  +1 (303) 666-5836
  *
- * DISTRIBUTION RELEASE 7
- *
  * For more information, please consult 
  *
  * NCR 5380 

[PATCH v2 31/36] sun3_scsi: Adopt atari_NCR5380 core driver and remove sun3_NCR5380.c

2014-10-27 Thread Finn Thain
Given the preceding changes to atari_NCR5380.c, this patch should not change
behaviour of the sun3_scsi and sun3_scsi_vme modules.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 MAINTAINERS |1 
 drivers/scsi/sun3_NCR5380.c | 2849 
 drivers/scsi/sun3_scsi.c|   10 
 3 files changed, 6 insertions(+), 2854 deletions(-)

Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-27 16:25:52.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:58.0 +1100
@@ -41,6 +41,8 @@
 #define REAL_DMA
 #define RESET_RUN_DONE
 /* #define SUPPORT_TAGS */
+/* minimum number of bytes to do dma on */
+#define DMA_MIN_SIZE129
 
 /* #define MAX_TAGS 32 */
 
@@ -64,6 +66,9 @@
 #define NCR5380_dma_xfer_len(instance, cmd, phase) \
 sun3scsi_dma_xfer_len(cmd-SCp.this_residual, cmd, !((phase)  SR_IO))
 
+#define NCR5380_acquire_dma_irq(instance)(1)
+#define NCR5380_release_dma_irq(instance)
+
 #include NCR5380.h
 
 
@@ -92,9 +97,6 @@ module_param(setup_hostid, int, 0);
 /* dvma buffer to allocate -- 32k should hopefully be more than sufficient */
 #define SUN3_DVMA_BUFSIZE 0xe000
 
-/* 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;
@@ -486,7 +488,7 @@ static int sun3scsi_dma_finish(int write
 
 }

-#include sun3_NCR5380.c
+#include atari_NCR5380.c
 
 #ifdef SUN3_SCSI_VME
 #define SUN3_SCSI_NAME  Sun3 NCR5380 VME SCSI
Index: linux/MAINTAINERS
===
--- linux.orig/MAINTAINERS  2014-10-27 16:17:59.0 +1100
+++ linux/MAINTAINERS   2014-10-27 16:25:58.0 +1100
@@ -6171,7 +6171,6 @@ F:drivers/scsi/g_NCR5380.*
 F: drivers/scsi/g_NCR5380_mmio.c
 F: drivers/scsi/mac_scsi.*
 F: drivers/scsi/pas16.*
-F: drivers/scsi/sun3_NCR5380.c
 F: drivers/scsi/sun3_scsi.*
 F: drivers/scsi/sun3_scsi_vme.c
 F: drivers/scsi/t128.*
Index: linux/drivers/scsi/sun3_NCR5380.c
===
--- linux.orig/drivers/scsi/sun3_NCR5380.c  2014-10-27 16:25:52.0 
+1100
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,2849 +0,0 @@
-/* sun3_NCR5380.c -- adapted from atari_NCR5380.c for the sun3 by 
-   Sam Creasey. */ 
-/* 
- * NCR 5380 generic driver routines.  These should make it *trivial*
- * to implement 5380 SCSI drivers under Linux with a non-trantor
- * architecture.
- *
- * Note that these routines also work with NR53c400 family chips.
- *
- * Copyright 1993, Drew Eckhardt
- * Visionary Computing 
- * (Unix and Linux consulting and custom programming)
- * d...@colorado.edu
- * +1 (303) 666-5836
- *
- * 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
- */
-
-/*
- * ++roman: To port the 5380 driver to the Atari, I had to do some changes in
- * this file, too:
- *
- *  - Some of the debug statements were incorrect (undefined variables and the
- *like). I fixed that.
- *
- *  - In information_transfer(), I think a #ifdef was wrong. Looking at the
- *possible DMA transfer size should also happen for REAL_DMA. I added this
- *in the #if statement.
- *
- *  - When using real DMA, information_transfer() should return in a DATAOUT
- *phase after starting the DMA. It has nothing more to do.
- *
- *  - The interrupt service routine should run main after end of DMA, too (not
- *only after RESELECTION interrupts). Additionally, it should _not_ test
- *for more interrupts after running main, since a DMA process may have
- *been started and interrupts are turned on now. The new int could happen
- *inside the execution of NCR5380_intr(), leading to recursive
- *calls.
- *
- * - I've deleted all the stuff for AUTOPROBE_IRQ, REAL_DMA_POLL, PSEUDO_DMA
- *and USLEEP, because these were messing up readability and will never be
- *needed for Atari SCSI.
- * 
- * - I've revised the NCR5380_main() calling scheme (relax the 'main_running'
- *   stuff), and 'main' is executed in a bottom half if awoken by an
- *   interrupt.
- *
- * - The code was quite cluttered up by #if (NDEBUG  NDEBUG_*) printk...
- *   constructs. In my eyes, this made the source rather unreadable, so I
- *   finally replaced that by the *_PRINTK() macros.
- *
- */
-#include scsi/scsi_dbg.h
-#include scsi/scsi_transport_spi.h
-
-/*
- * Further development / testing that should be done : 
- * 1.  Test linked command handling code after Eric is ready with 
- *

[PATCH v2 33/36] atari_NCR5380: Introduce FLAG_TAGGED_QUEUING

2014-10-27 Thread Finn Thain
The static variable setup_use_tagged_queuing is declared in mac_scsi.c,
sun3_scsi.c and atari_scsi.c and doesn't belong in the core driver.
None of the other NCR5380 drivers suffer from this layering issue which
makes merging the core drivers more difficult and will likely hinder plans
for future use of platform data to configure the driver.

Replace the static variable with a host flag. This way it can be reported
along with the other flags.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 drivers/scsi/NCR5380.h   |1 +
 drivers/scsi/atari_NCR5380.c |   22 +-
 drivers/scsi/atari_scsi.c|8 
 drivers/scsi/mac_scsi.c  |8 
 drivers/scsi/sun3_scsi.c |   12 ++--
 5 files changed, 28 insertions(+), 23 deletions(-)

Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-27 16:25:54.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:26:00.0 +1100
@@ -242,6 +242,7 @@
 #define FLAG_NO_PSEUDO_DMA 8   /* Inhibit DMA */
 #define FLAG_DTC3181E  16  /* DTC3181E */
 #define FLAG_LATE_DMA_SETUP32  /* Setup NCR before DMA H/W */
+#define FLAG_TAGGED_QUEUING64  /* as X3T9.2 spelled it */
 
 #ifndef ASM
 struct NCR5380_hostdata {
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:25:59.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:26:00.0 +1100
@@ -283,12 +283,12 @@ typedef struct {
 static TAG_ALLOC TagAlloc[8][8];   /* 8 targets and 8 LUNs */
 
 
-static void __init init_tags(void)
+static void __init init_tags(struct NCR5380_hostdata *hostdata)
 {
int target, lun;
TAG_ALLOC *ta;
 
-   if (!setup_use_tagged_queuing)
+   if (!(hostdata-flags  FLAG_TAGGED_QUEUING))
return;
 
for (target = 0; target  8; ++target) {
@@ -321,7 +321,8 @@ static int is_lun_busy(struct scsi_cmnd
if (hostdata-busy[cmd-device-id]  (1  lun))
return 1;
if (!should_be_tagged ||
-   !setup_use_tagged_queuing || !cmd-device-tagged_supported)
+   !(hostdata-flags  FLAG_TAGGED_QUEUING) ||
+   !cmd-device-tagged_supported)
return 0;
if (TagAlloc[cmd-device-id][lun].nr_allocated =
TagAlloc[cmd-device-id][lun].queue_size) {
@@ -347,7 +348,8 @@ static void cmd_get_tag(struct scsi_cmnd
 * an untagged command.
 */
if (!should_be_tagged ||
-   !setup_use_tagged_queuing || !cmd-device-tagged_supported) {
+   !(hostdata-flags  FLAG_TAGGED_QUEUING) ||
+   !cmd-device-tagged_supported) {
cmd-tag = TAG_NONE;
hostdata-busy[cmd-device-id] |= (1  lun);
dprintk(NDEBUG_TAGS, scsi%d: target %d lun %d now allocated by 
untagged 
@@ -392,12 +394,12 @@ static void cmd_free_tag(struct scsi_cmn
 }
 
 
-static void free_all_tags(void)
+static void free_all_tags(struct NCR5380_hostdata *hostdata)
 {
int target, lun;
TAG_ALLOC *ta;
 
-   if (!setup_use_tagged_queuing)
+   if (!(hostdata-flags  FLAG_TAGGED_QUEUING))
return;
 
for (target = 0; target  8; ++target) {
@@ -653,11 +655,13 @@ static void prepare_info(struct Scsi_Hos
 base 0x%lx, irq %d, 
 can_queue %d, cmd_per_lun %d, 
 sg_tablesize %d, this_id %d, 
+flags { %s}, 
 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_TAGGED_QUEUING ? TAGGED_QUEUING  : ,
 #ifdef DIFFERENTIAL
 DIFFERENTIAL 
 #endif
@@ -799,7 +803,7 @@ static int __init NCR5380_init(struct Sc
for (i = 0; i  8; ++i)
hostdata-busy[i] = 0;
 #ifdef SUPPORT_TAGS
-   init_tags();
+   init_tags(hostdata);
 #endif
 #if defined (REAL_DMA)
hostdata-dma_len = 0;
@@ -2569,7 +2573,7 @@ static void NCR5380_reselect(struct Scsi
 * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus.
 */
tag = TAG_NONE;
-   if (phase == PHASE_MSGIN  setup_use_tagged_queuing) {
+   if (phase == PHASE_MSGIN  (hostdata-flags  FLAG_TAGGED_QUEUING)) {
/* Accept previous IDENTIFY message by clearing ACK */
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE);
len = 2;
@@ -3025,7 +3029,7 @@ static int NCR5380_bus_reset(struct scsi
hostdata-connected = NULL;
hostdata-disconnected_queue = NULL;
 #ifdef SUPPORT_TAGS
-   free_all_tags();
+   

[PATCH v2 08/36] ncr5380: Remove redundant AUTOSENSE macro

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:16.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:17.0 +1100
@@ -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);
@@ -2260,7 +2251,6 @@ static void NCR5380_information_transfer
else if (status_byte(cmd-SCp.Status) 
!= GOOD)
cmd-result = (cmd-result  
0x00) | (DID_ERROR  16);
 
-#ifdef AUTOSENSE
if ((cmd-cmnd[0] == REQUEST_SENSE) 
hostdata-ses.cmd_len) {
scsi_eh_restore_cmnd(cmd, 
hostdata-ses);
@@ -2277,9 +2267,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-27 16:25:16.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:17.0 +1100
@@ -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-27 16:18:00.0 
+1100
+++ linux/drivers/scsi/arm/cumana_1.c   2014-10-27 16:25:17.0 +1100
@@ -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-27 16:25:09.0 +1100
+++ linux/drivers/scsi/arm/oak.c2014-10-27 16:25:17.0 +1100
@@ -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-27 16:25:16.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 

[PATCH v2 29/36] atari_NCR5380: Refactor Falcon locking

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:54.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:55.0 +1100
@@ -926,7 +926,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 */
 
@@ -962,6 +962,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)
  *
@@ -1084,9 +1096,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();
@@ -2085,11 +2099,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 %llu 
  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) {
@@ -2148,17 +2163,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 
 

[PATCH v2 36/36] atari_NCR5380: Remove RESET_RUN_DONE macro

2014-10-27 Thread Finn Thain
There's no need to run the cmd-done callback for aborted commands. Remove
the old EH code and the RESET_RUN_DONE macro.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 drivers/scsi/atari_NCR5380.c |   88 ---
 drivers/scsi/sun3_scsi.c |1 
 2 files changed, 89 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:26:03.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:26:04.0 +1100
@@ -2881,9 +2881,6 @@ static int NCR5380_bus_reset(struct scsi
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(instance);
 
@@ -2902,89 +2899,6 @@ static int NCR5380_bus_reset(struct scsi
 * through anymore ... */
(void)NCR5380_read(RESET_PARITY_INTERRUPT_REG);
 
-   /* MSch 20140115 - looking at the generic NCR5380 driver, all of this
-* should go.
-* Catch-22: if we don't clear all queues, the SCSI driver lock will
-* not be reset by atari_scsi_reset()!
-*/
-
-#if defined(RESET_RUN_DONE)
-   /* XXX Should now be done by midlevel code, but it's broken XXX */
-   /* XXX see belowXXX */
-
-   /* MSch: old-style reset: actually abort all command processing here */
-
-   /* After the reset, there are no more connected or disconnected commands
-* and no busy units; to avoid problems with re-inserting the commands
-* into the issue_queue (via scsi_done()), the aborted commands are
-* remembered in local variables first.
-*/
-   local_irq_save(flags);
-   connected = (struct scsi_cmnd *)hostdata-connected;
-   hostdata-connected = NULL;
-   disconnected_queue = (struct scsi_cmnd *)hostdata-disconnected_queue;
-   hostdata-disconnected_queue = NULL;
-#ifdef SUPPORT_TAGS
-   free_all_tags();
-#endif
-   for (i = 0; i  8; ++i)
-   hostdata-busy[i] = 0;
-#ifdef REAL_DMA
-   hostdata-dma_len = 0;
-#endif
-   local_irq_restore(flags);
-
-   /* In order to tell the mid-level code which commands were aborted,
-* set the command status to DID_RESET and call scsi_done() !!!
-* This ultimately aborts processing of these commands in the mid-level.
-*/
-
-   if ((cmd = connected)) {
-   dprintk(NDEBUG_ABORT, scsi%d: reset aborted a connected 
command\n, H_NO(cmd));
-   cmd-result = (cmd-result  0x) | (DID_RESET  16);
-   cmd-scsi_done(cmd);
-   }
-
-   for (i = 0; (cmd = disconnected_queue); ++i) {
-   disconnected_queue = NEXT(cmd);
-   SET_NEXT(cmd, NULL);
-   cmd-result = (cmd-result  0x) | (DID_RESET  16);
-   cmd-scsi_done(cmd);
-   }
-   if (i  0)
-   dprintk(NDEBUG_ABORT, scsi: reset aborted %d disconnected 
command(s)\n, i);
-
-   /* The Falcon lock should be released after a reset...
-*/
-   /* ++guenther: moved to atari_scsi_reset(), to prevent a race between
-* unlocking and enabling dma interrupt.
-*/
-/* falcon_release_lock_if_possible( hostdata );*/
-
-   /* since all commands have been explicitly terminated, we need to tell
-* the midlevel code that the reset was SUCCESSFUL, and there is no
-* need to 'wake up' the commands by a request_sense
-*/
-   return SUCCESS;
-#else /* 1 */
-
-   /* MSch: new-style reset handling: let the mid-level do what it can */
-
-   /* ++guenther: MID-LEVEL IS STILL BROKEN.
-* Mid-level is supposed to requeue all commands that were active on the
-* various low-level queues. In fact it does this, but that's not enough
-* because all these commands are subject to timeout. And if a timeout
-* happens for any removed command, *_abort() is called but all queues
-* are now empty. Abort then gives up the falcon lock, which is fatal,
-* since the mid-level will queue more commands and must have the lock
-* (it's all happening inside timer interrupt handler!!).
-* Even worse, abort will return NOT_RUNNING for all those commands not
-* on any queue, so they won't be retried ...
-*
-* Conclusion: either scsi.c disables timeout for all resetted commands
-* immediately, or we lose!  As of linux-2.0.20 it doesn't.
-*/
-
/* After the reset, there are no more connected or disconnected commands
 * and no busy units; so clear the low-level status here to avoid
 * conflicts when the mid-level code tries to wake up the affected
@@ -3014,7 +2928,5 @@ static int NCR5380_bus_reset(struct 

[PATCH v2 32/36] atari_NCR5380: Merge from NCR5380.c

2014-10-27 Thread Finn Thain
The NCR5380.c core driver has moved on since atari_NCR5380.c was forked.
Some of those changes are also relevant to atari_NCR5380.c so apply them
there as well.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 drivers/scsi/atari_NCR5380.c |  209 +--
 1 file changed, 87 insertions(+), 122 deletions(-)

Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:25:56.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:59.0 +1100
@@ -104,27 +104,7 @@
 
 /*
  * Design
- * Issues :
  *
- * The other Linux SCSI drivers were written when Linux was Intel PC-only,
- * and specifically for each board rather than each chip.  This makes their
- * adaptation to platforms like the Mac (Some of which use NCR5380's)
- * more difficult than it has to be.
- *
- * Also, many of the SCSI drivers were written before the command queuing
- * routines were implemented, meaning their implementations of queued
- * commands were hacked on rather than designed in from the start.
- *
- * When I designed the Linux SCSI drivers I figured that
- * while having two different SCSI boards in a system might be useful
- * for debugging things, two of the same type wouldn't be used.
- * Well, I was wrong and a number of users have mailed me about running
- * multiple high-performance SCSI boards in a server.
- *
- * Finally, when I get questions from users, I have no idea what
- * revision of my driver they are running.
- *
- * This driver attempts to address these problems :
  * This is a generic 5380 driver.  To use it on a different platform,
  * one simply writes appropriate system specific macros (ie, data
  * transfer - some PC's will use the I/O bus, 68K's must use
@@ -139,11 +119,6 @@
  * allowing multiple commands to propagate all the way to a SCSI-II device
  * while a command is already executing.
  *
- * To solve the multiple-boards-in-the-same-system problem,
- * there is a separate instance structure for each instance
- * of a 5380 in the system.  So, multiple NCR5380 drivers will
- * be able to coexist with appropriate changes to the high level
- * SCSI code.
  *
  * Issues specific to the NCR5380 :
  *
@@ -168,19 +143,17 @@
  * Architecture :
  *
  * At the heart of the design is a coroutine, NCR5380_main,
- * which is started when not running by the interrupt handler,
- * timer, and queue command function.  It attempts to establish
- * I_T_L or I_T_L_Q nexuses by removing the commands from the
- * issue queue and calling NCR5380_select() if a nexus
- * is not established.
+ * which is started from a workqueue for each NCR5380 host in the
+ * system.  It attempts to establish I_T_L or I_T_L_Q nexuses by
+ * removing the commands from the issue queue and calling
+ * NCR5380_select() if a nexus is not established.
  *
  * Once a nexus is established, the NCR5380_information_transfer()
  * phase goes through the various phases as instructed by the target.
  * if the target goes into MSG IN and sends a DISCONNECT message,
  * the command structure is placed into the per instance disconnected
- * queue, and NCR5380_main tries to find more work.  If USLEEP
- * was defined, and the target is idle for too long, the system
- * will try to sleep.
+ * queue, and NCR5380_main tries to find more work.  If the target is
+ * idle for too long, the system will try to sleep.
  *
  * If a command has disconnected, eventually an interrupt will trigger,
  * calling NCR5380_intr()  which will in turn call NCR5380_reselect
@@ -206,6 +179,9 @@
  * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically
  * for commands that return with a CHECK CONDITION status.
  *
+ * DIFFERENTIAL - if defined, NCR53c81 chips will use external differential
+ * transceivers.
+ *
  * LINKED - if defined, linked commands are supported.
  *
  * REAL_DMA - if defined, REAL DMA is used during the data transfer phases.
@@ -218,6 +194,9 @@
  *
  * NCR5380_write(register, value) - write to the specific register
  *
+ * NCR5380_implementation_fields  - additional fields needed for this
+ *  specific implementation of the NCR5380
+ *
  * Either real DMA *or* pseudo DMA may be implemented
  * REAL functions :
  * NCR5380_REAL_DMA should be defined if real DMA is to be used.
@@ -236,20 +215,6 @@
  * NCR5380_pwrite(instance, src, count)
  * NCR5380_pread(instance, dst, count);
  *
- * If nothing specific to this implementation needs doing (ie, with external
- * hardware), you must also define
- *
- * NCR5380_queue_command
- * NCR5380_reset
- * NCR5380_abort
- *
- * to be the global entry points into the specific driver, ie
- * #define NCR5380_queue_command t128_queue_command.
- *
- * If this is not done, the routines will be defined as static functions
- * with the NCR5380* names and the user must provide a globally
- * accessible wrapper function.
- *
  * The 

[PATCH v2 27/36] ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:45.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:52.0 +1100
@@ -1229,7 +1229,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);
@@ -1259,7 +1258,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.c2014-10-27 16:25:49.0 
+1100
+++ linux/drivers/scsi/atari_scsi.c 2014-10-27 16:25:52.0 +1100
@@ -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-27 16:25:36.0 
+1100
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-27 16:25:52.0 +1100
@@ -1155,7 +1155,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);
@@ -1188,7 +1187,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-27 16:25:51.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:52.0 +1100
@@ -69,13 +69,6 @@
 
 extern int sun3_map_test(unsigned long, char *);
 
-#ifdef SUN3_SCSI_VME
-#define ENABLE_IRQ()
-#else
-#defineENABLE_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;


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 22/36] atari_scsi: Fix atari_scsi deadlocks on Falcon

2014-10-27 Thread Finn Thain
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-m68km=139095335824863w=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 must 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 the EH handlers are incorrect 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 fth...@telegraphics.com.au

---

Changes since v1:
- Use Geert's suggestion for simpler stdma_is_locked_by() implementation.

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

Index: linux/arch/m68k/atari/stdma.c
===
--- linux.orig/arch/m68k/atari/stdma.c  2014-10-27 16:17:59.0 +1100
+++ linux/arch/m68k/atari/stdma.c   2014-10-27 16:25:45.0 +1100
@@ -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,25 @@ 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;
+   int result;
+
+   local_irq_save(flags);
+   result = stdma_locked  (stdma_isr == handler);
+   local_irq_restore(flags);
+
+   return result;
 }
-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-27 
16:17:59.0 +1100
+++ linux/arch/m68k/include/asm/atari_stdma.h   2014-10-27 16:25:45.0 
+1100
@@ -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-27 16:25:36.0 
+1100
+++ 

[PATCH v2 07/36] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:14.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:25:16.0 +1100
@@ -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;
@@ -1118,9 +1114,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);
@@ -1351,17 +1345,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
@@ -1381,7 +1372,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;
@@ -2758,7 +2749,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-27 16:25:14.0 
+1100
+++ linux/drivers/scsi/sun3_NCR5380.c   2014-10-27 16:25:16.0 +1100
@@ -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!
@@ -1057,9 +1053,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 {
 

[PATCH v2 23/36] atari_scsi: Convert to platform device

2014-10-27 Thread Finn Thain
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 fth...@telegraphics.com.au

---

Changes since v1:
- Remove unnecessary return -ENODEV branch.
- Move IRQ constants to platform resources.
- Always assign instance-irq so that the atari_NCR5380.c core driver
  can adopt the NCR5380.c interpretation of instance-irq.

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

Index: linux/arch/m68k/atari/config.c
===
--- linux.orig/arch/m68k/atari/config.c 2014-10-27 16:17:59.0 +1100
+++ linux/arch/m68k/atari/config.c  2014-10-27 16:25:47.0 +1100
@@ -858,6 +858,24 @@ static struct platform_device *atari_net
 };
 #endif /* CONFIG_ATARI_ETHERNEC */
 
+#ifdef CONFIG_ATARI_SCSI
+static const struct resource atari_scsi_st_rsrc[] __initconst = {
+   {
+   .flags = IORESOURCE_IRQ,
+   .start = IRQ_MFP_FSCSI,
+   .end   = IRQ_MFP_FSCSI,
+   },
+};
+
+static const struct resource atari_scsi_tt_rsrc[] __initconst = {
+   {
+   .flags = IORESOURCE_IRQ,
+   .start = IRQ_TT_MFP_SCSI,
+   .end   = IRQ_TT_MFP_SCSI,
+   },
+};
+#endif
+
 int __init atari_platform_init(void)
 {
int rv = 0;
@@ -892,6 +910,15 @@ int __init atari_platform_init(void)
}
 #endif
 
+#ifdef CONFIG_ATARI_SCSI
+   if (ATARIHW_PRESENT(ST_SCSI))
+   platform_device_register_simple(atari_scsi, -1,
+   atari_scsi_st_rsrc, ARRAY_SIZE(atari_scsi_st_rsrc));
+   else if (ATARIHW_PRESENT(TT_SCSI))
+   platform_device_register_simple(atari_scsi, -1,
+   atari_scsi_tt_rsrc, ARRAY_SIZE(atari_scsi_tt_rsrc));
+#endif
+
return rv;
 }
 
Index: linux/drivers/scsi/atari_scsi.c
===
--- linux.orig/drivers/scsi/atari_scsi.c2014-10-27 16:25:45.0 
+1100
+++ linux/drivers/scsi/atari_scsi.c 2014-10-27 16:25:47.0 +1100
@@ -74,33 +74,26 @@
 #defineMAX_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
 
 #defineIS_A_TT()   ATARIHW_PRESENT(TT_SCSI)
 
@@ -176,25 +169,9 @@ static inline void DISABLE_IRQ(void)
 #defineAFTER_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 :
-  

[PATCH v2 14/36] ncr5380: Remove pointless compiler command line override macros

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:32.0 +1100
@@ -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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/mac_scsi.h   2014-10-27 16:25:32.0 +1100
@@ -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
-#defineUSE_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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:32.0 +1100
@@ -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 = 

[PATCH v2 21/36] mac_scsi: Convert to platform device

2014-10-27 Thread Finn Thain
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 fth...@telegraphics.com.au

---

The new hwreg_present() call site is not protected by local_irq_save/restore.
This assumes Geert's patch, Disable/restore interrupts in
hwreg_present()/hwreg_write(), which is commit e4dc601bf99ccd1c in 3.18-rc1.

Changes since v1:
- Use NO_IRQ instead of IRQ_NONE.
- Drop unnecessary MACH_IS_MAC() test.
- Remove static platform_device structs and call
  platform_device_register_simple() instead of platform_device_register().
- Platform resources now const and __initconst.
- Add MAC_SCSI_LATE platform resources to avoid PDMA on certain models.

---
 arch/m68k/include/asm/macintosh.h |4 
 arch/m68k/mac/config.c|  146 --
 drivers/scsi/mac_scsi.c   |  245 +++---
 3 files changed, 262 insertions(+), 133 deletions(-)

Index: linux/drivers/scsi/mac_scsi.c
===
--- linux.orig/drivers/scsi/mac_scsi.c  2014-10-27 16:25:43.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:44.0 +1100
@@ -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);
 #defineAFTER_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 + (reg4));
+   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 + (reg4), 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 + 

[PATCH v2 25/36] sun3_scsi: Convert to platform device

2014-10-27 Thread Finn Thain
Convert sun3_scsi to platform device and eliminate scsi_register().

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---

Changes since v1:
- Use NO_IRQ instead of IRQ_NONE.
- Move device IRQ and address constants to platform resources.
- Test idprom-id_machtype before registering platform device instead of
  during platform driver probe.
- Omit pointless instance-n_io_port assignment.

---
 arch/m68k/sun3/config.c  |   60 +++
 drivers/scsi/sun3_scsi.c |  390 ++-
 drivers/scsi/sun3_scsi.h |   17 --
 3 files changed, 245 insertions(+), 222 deletions(-)

Index: linux/arch/m68k/sun3/config.c
===
--- linux.orig/arch/m68k/sun3/config.c  2014-10-27 16:17:59.0 +1100
+++ linux/arch/m68k/sun3/config.c   2014-10-27 16:25:50.0 +1100
@@ -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
@@ -27,6 +28,7 @@
 #include asm/sun3mmu.h
 #include asm/rtc.h
 #include asm/machdep.h
+#include asm/machines.h
 #include asm/idprom.h
 #include asm/intersil.h
 #include asm/irq.h
@@ -169,3 +171,61 @@ static void __init sun3_sched_init(irq_h
 intersil_clear();
 }
 
+#ifdef CONFIG_SUN3_SCSI
+
+static const struct resource sun3_scsi_vme_rsrc[] __initconst = {
+   {
+   .flags = IORESOURCE_IRQ,
+   .start = SUN3_VEC_VMESCSI0,
+   .end   = SUN3_VEC_VMESCSI0,
+   }, {
+   .flags = IORESOURCE_MEM,
+   .start = 0xff20,
+   .end   = 0xff20 + PAGE_SIZE - 1,
+   }, {
+   .flags = IORESOURCE_IRQ,
+   .start = SUN3_VEC_VMESCSI1,
+   .end   = SUN3_VEC_VMESCSI1,
+   }, {
+   .flags = IORESOURCE_MEM,
+   .start = 0xff204000,
+   .end   = 0xff204000 + PAGE_SIZE - 1,
+   },
+};
+
+/*
+ * Int: level 2 autovector
+ * IO: type 1, base 0x0014, 5 bits phys space: A4..0
+ */
+static const struct resource sun3_scsi_rsrc[] __initconst = {
+   {
+   .flags = IORESOURCE_IRQ,
+   .start = 2,
+   .end   = 2,
+   }, {
+   .flags = IORESOURCE_MEM,
+   .start = 0x0014,
+   .end   = 0x0014 + PAGE_SIZE - 1,
+   },
+};
+
+int __init sun3_platform_init(void)
+{
+   switch (idprom-id_machtype) {
+   case SM_SUN3 | SM_3_160:
+   case SM_SUN3 | SM_3_260:
+   platform_device_register_simple(sun3_scsi_vme, -1,
+   sun3_scsi_vme_rsrc, ARRAY_SIZE(sun3_scsi_vme_rsrc));
+   break;
+   case SM_SUN3 | SM_3_50:
+   case SM_SUN3 | SM_3_60:
+   platform_device_register_simple(sun3_scsi, -1,
+   sun3_scsi_rsrc, ARRAY_SIZE(sun3_scsi_rsrc));
+   break;
+   }
+   return 0;
+}
+
+arch_initcall(sun3_platform_init);
+
+#endif
Index: linux/drivers/scsi/sun3_scsi.c
===
--- linux.orig/drivers/scsi/sun3_scsi.c 2014-10-27 16:25:36.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:50.0 +1100
@@ -23,22 +23,15 @@
  */
 
 #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
-#include asm/machines.h
 
 /* dma on! */
 #define REAL_DMA
@@ -59,8 +52,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 +80,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 +95,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 

[PATCH v2 13/36] ncr5380: Move static PDMA spin counters to host data

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:30.0 +1100
@@ -692,6 +692,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]
@@ -709,14 +710,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)
@@ -751,11 +751,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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:30.0 +1100
@@ -274,6 +274,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-27 16:25:26.0 +1100
+++ linux/drivers/scsi/dtc.c2014-10-27 16:25:30.0 +1100
@@ -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

[PATCH v2 35/36] atari_NCR5380: Move static co-routine variables to host data

2014-10-27 Thread Finn Thain
Unlike NCR5380.c, the atari_NCR5380.c core driver is limited to a single
instance because co-routine state is stored globally.

Fix this by removing the static scsi host pointer. For the co-routine,
obtain this pointer from the work_struct pointer instead. For the interrupt
handler, obtain it from the dev_id argument.

Signed-off-by: Finn Thain fth...@telegraphics.com.au

---
 drivers/scsi/NCR5380.h   |2 +
 drivers/scsi/atari_NCR5380.c |   61 +++
 drivers/scsi/atari_scsi.c|8 ++---
 3 files changed, 28 insertions(+), 43 deletions(-)

Index: linux/drivers/scsi/NCR5380.h
===
--- linux.orig/drivers/scsi/NCR5380.h   2014-10-27 16:26:02.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:26:03.0 +1100
@@ -283,6 +283,8 @@ struct NCR5380_hostdata {
int read_overruns;/* number of bytes to cut from a
   * transfer to handle chip overruns */
int retain_dma_intr;
+   struct work_struct main_task;
+   volatile int main_running;
 #ifdef SUPPORT_TAGS
struct tag_alloc TagAlloc[8][8];/* 8 targets and 8 LUNs */
 #endif
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:26:02.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2014-10-27 16:26:03.0 +1100
@@ -221,9 +221,6 @@
  * possible) function may be used.
  */
 
-static struct Scsi_Host *first_instance = NULL;
-static struct scsi_host_template *the_template = NULL;
-
 /* Macros ease life... :-) */
 #defineSETUP_HOSTDATA(in)  \
 struct NCR5380_hostdata *hostdata =\
@@ -595,32 +592,19 @@ static void NCR5380_print_phase(struct S
 #include linux/workqueue.h
 #include linux/interrupt.h
 
-static volatile int main_running;
-static DECLARE_WORK(NCR5380_tqueue, NCR5380_main);
-
-static inline void queue_main(void)
+static inline void queue_main(struct NCR5380_hostdata *hostdata)
 {
-   if (!main_running) {
+   if (!hostdata-main_running) {
/* If in interrupt and NCR5380_main() not already running,
   queue it on the 'immediate' task queue, to be processed
   immediately after the current interrupt processing has
   finished. */
-   schedule_work(NCR5380_tqueue);
+   schedule_work(hostdata-main_task);
}
/* else: nothing to do: the running NCR5380_main() will pick up
   any newly queued command. */
 }
 
-
-static inline void NCR5380_all_init(void)
-{
-   static int done = 0;
-   if (!done) {
-   dprintk(NDEBUG_INIT, scsi : NCR5380_all_init()\n);
-   done = 1;
-   }
-}
-
 /**
  * NCR58380_info - report driver and host information
  * @instance: relevant scsi host instance
@@ -703,7 +687,7 @@ static void NCR5380_print_status(struct
 
local_irq_save(flags);
printk(NCR5380: coroutine is%s running.\n,
-   main_running ?  : n't);
+   hostdata-main_running ?  : n't);
if (!hostdata-connected)
printk(scsi%d: no currently connected command\n, HOSTNO);
else
@@ -746,7 +730,7 @@ static int __maybe_unused NCR5380_show_i
 
local_irq_save(flags);
seq_printf(m, NCR5380: coroutine is%s running.\n,
-   main_running ?  : n't);
+   hostdata-main_running ?  : n't);
if (!hostdata-connected)
seq_printf(m, scsi%d: no currently connected command\n, 
HOSTNO);
else
@@ -783,8 +767,7 @@ static int __init NCR5380_init(struct Sc
int i;
SETUP_HOSTDATA(instance);
 
-   NCR5380_all_init();
-
+   hostdata-host = instance;
hostdata-aborted = 0;
hostdata-id_mask = 1  instance-this_id;
hostdata-id_higher_mask = 0;
@@ -805,10 +788,7 @@ static int __init NCR5380_init(struct Sc
hostdata-disconnected_queue = NULL;
hostdata-flags = flags;
 
-   if (!the_template) {
-   the_template = instance-hostt;
-   first_instance = instance;
-   }
+   INIT_WORK(hostdata-main_task, NCR5380_main);
 
prepare_info(instance);
 
@@ -829,7 +809,9 @@ static int __init NCR5380_init(struct Sc
 
 static void NCR5380_exit(struct Scsi_Host *instance)
 {
-   cancel_work_sync(NCR5380_tqueue);
+   struct NCR5380_hostdata *hostdata = shost_priv(instance);
+
+   cancel_work_sync(hostdata-main_task);
 }
 
 /**
@@ -926,9 +908,9 @@ static int NCR5380_queue_command(struct
 * unconditionally, because it cannot be already running.
 */
if (in_interrupt() || irqs_disabled())
-   queue_main();
+   queue_main(hostdata);
else
-   NCR5380_main(NULL);
+   

[PATCH v2 18/36] mac_scsi: Remove header

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:36.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:40.0 +1100
@@ -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_intrmacscsi_intr
+#define NCR5380_queue_command   macscsi_queue_command
+#define NCR5380_abort   macscsi_abort
+#define NCR5380_bus_reset   macscsi_bus_reset
+#define NCR5380_infomacscsi_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-27 16:25:33.0 +1100
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,42 +0,0 @@
-/*
- * Cumana Generic NCR5380 driver defines
- *
- * Copyright 1993, Drew Eckhardt
- * Visionary Computing
- * (Unix and Linux consulting and custom programming)
- * d...@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 */
-


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 20/36] mac_scsi: Cleanup PDMA code

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:42.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:43.0 +1100
@@ -86,9 +86,9 @@ module_param(setup_hostid, int, 0);
 #defineAFTER_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
 


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to 

[PATCH v2 06/36] ncr5380: Remove more useless prototypes

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:06.0 +1100
+++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:14.0 +1100
@@ -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-27 16:25:08.0 +1100
+++ linux/drivers/scsi/dtc.c2014-10-27 16:25:14.0 +1100
@@ -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-27 16:25:12.0 +1100
+++ linux/drivers/scsi/pas16.c  2014-10-27 16:25:14.0 +1100
@@ -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;
/*
@@ -620,6 +616,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-27 16:25:12.0 +1100
+++ linux/drivers/scsi/t128.c   2014-10-27 16:25:14.0 +1100
@@ -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,

[PATCH v2 24/36] atari_scsi: Remove header

2014-10-27 Thread Finn Thain
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 fth...@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.c2014-10-27 16:25:47.0 
+1100
+++ linux/drivers/scsi/atari_scsi.c 2014-10-27 16:25:49.0 +1100
@@ -64,15 +64,7 @@
 /**/
 
 
-
 #include linux/module.h
-
-/* For the Atari version, use only polled IO or REAL_DMA */
-#defineREAL_DMA
-/* Support tagged queuing? (on devices that are able to... :-) */
-#defineSUPPORT_TAGS
-#defineMAX_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_TAGS32
+
+#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_infoatari_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
 
+
 #defineIS_A_TT()   ATARIHW_PRESENT(TT_SCSI)
 
 #defineSCSI_DMA_WRITE_P(elt,val)   \
Index: linux/drivers/scsi/atari_scsi.h
===
--- linux.orig/drivers/scsi/atari_scsi.h2014-10-27 16:25:47.0 
+1100
+++ /dev/null   1970-01-01 00:00:00.0 +
@@ -1,40 +0,0 @@
-/*
- * atari_scsi.h -- Header file for the Atari native SCSI driver
- *
- * Copyright 1994 Roman Hodek roman.ho...@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
-
-#defineNCR5380_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 )
-#defineNCR5380_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 */
-
-


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 19/36] mac_scsi: Add module option to Kconfig

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:17:59.0 +1100
+++ linux/drivers/scsi/Kconfig  2014-10-27 16:25:42.0 +1100
@@ -1595,7 +1595,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-27 16:25:40.0 +1100
+++ linux/drivers/scsi/mac_scsi.c   2014-10-27 16:25:42.0 +1100
@@ -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 + (reg4), 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 = 

[PATCH v2 16/36] ncr5380: Drop legacy scsi.h include

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:33.0 +1100
+++ linux/drivers/scsi/NCR5380.c2014-10-27 16:25:36.0 +1100
@@ -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 
@@ -719,7 +719,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
@@ -729,7 +729,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;
 
@@ -741,19 +741,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 %llu\n, 
cmd-device-host-host_no, cmd-device-id, cmd-device-lun);
SPRINTF(command = );
@@ -912,11 +912,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]) {
@@ -950,7 +950,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;
}
@@ -981,7 +981,7 @@ static void NCR5380_main(struct work_str
struct NCR5380_hostdata *hostdata =

[PATCH v2 05/36] ncr5380: Remove useless prototypes

2014-10-27 Thread Finn Thain
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 fth...@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-27 16:25:09.0 +1100
+++ linux/drivers/scsi/g_NCR5380.c  2014-10-27 16:25:12.0 +1100
@@ -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-27 16:25:09.0 +1100
+++ linux/drivers/scsi/pas16.c  2014-10-27 16:25:12.0 +1100
@@ -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-27 16:25:09.0 +1100
+++ linux/drivers/scsi/sun3_scsi.c  2014-10-27 16:25:12.0 +1100
@@ -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-27 16:25:09.0 +1100
+++ linux/drivers/scsi/t128.c   2014-10-27 16:25:12.0 +1100
@@ -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-27 16:18:00.0 +1100
+++ linux/drivers/scsi/dtc.h2014-10-27 16:25:12.0 +1100
@@ -32,13 +32,6 @@
 #define DTCDEBUG_INIT  

[PATCH 1/2] ipr: Disable async aborts

2014-10-27 Thread Brian King

The ipr driver does not yet support async aborts, so disable this
for now.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ipr.c |1 +
 1 file changed, 1 insertion(+)

diff -puN drivers/scsi/ipr.c~ipr_no_async_eh drivers/scsi/ipr.c
--- linux/drivers/scsi/ipr.c~ipr_no_async_eh2014-10-24 08:57:53.169169509 
-0500
+++ linux-bjking1/drivers/scsi/ipr.c2014-10-24 08:57:53.175169579 -0500
@@ -6357,6 +6357,7 @@ static struct scsi_host_template driver_
.sdev_attrs = ipr_dev_attrs,
.proc_name = IPR_NAME,
.no_write_same = 1,
+   .no_async_abort = 1,
 };
 
 /**
_

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ipr: Wait for aborted command responses

2014-10-27 Thread Brian King

Fixes a race condition in abort handling that was injected
when multiple interrupt support was added. When only a single
interrupt is present, the adapter guarantees it will send
responses for aborted commands prior to the response for the
abort command itself. With multiple interrupts, these responses
generally come back on different interrupts, so we need to
ensure the abort thread waits until the aborted command is
complete so we don't perform a double completion.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
---

 drivers/scsi/ipr.c |   92 +
 drivers/scsi/ipr.h |1 
 2 files changed, 93 insertions(+)

diff -puN drivers/scsi/ipr.c~ipr_eh_wait drivers/scsi/ipr.c
--- linux/drivers/scsi/ipr.c~ipr_eh_wait2014-10-24 08:57:55.545196774 
-0500
+++ linux-bjking1/drivers/scsi/ipr.c2014-10-24 08:57:55.565197003 -0500
@@ -683,6 +683,7 @@ static void ipr_init_ipr_cmnd(struct ipr
ipr_reinit_ipr_cmnd(ipr_cmd);
ipr_cmd-u.scratch = 0;
ipr_cmd-sibling = NULL;
+   ipr_cmd-eh_comp = NULL;
ipr_cmd-fast_done = fast_done;
init_timer(ipr_cmd-timer);
 }
@@ -848,6 +849,8 @@ static void ipr_scsi_eh_done(struct ipr_
 
scsi_dma_unmap(ipr_cmd-scsi_cmd);
scsi_cmd-scsi_done(scsi_cmd);
+   if (ipr_cmd-eh_comp)
+   complete(ipr_cmd-eh_comp);
list_add_tail(ipr_cmd-queue, ipr_cmd-hrrq-hrrq_free_q);
 }
 
@@ -4853,6 +4856,84 @@ static int ipr_slave_alloc(struct scsi_d
return rc;
 }
 
+/**
+ * ipr_match_lun - Match function for specified LUN
+ * @ipr_cmd:   ipr command struct
+ * @device:device to match (sdev)
+ *
+ * Returns:
+ * 1 if command matches sdev / 0 if command does not match sdev
+ **/
+static int ipr_match_lun(struct ipr_cmnd *ipr_cmd, void *device)
+{
+   if (ipr_cmd-scsi_cmd  ipr_cmd-scsi_cmd-device == device)
+   return 1;
+   return 0;
+}
+
+/**
+ * ipr_wait_for_ops - Wait for matching commands to complete
+ * @ipr_cmd:   ipr command struct
+ * @device:device to match (sdev)
+ * @match: match function to use
+ *
+ * Returns:
+ * SUCCESS / FAILED
+ **/
+static int ipr_wait_for_ops(struct ipr_ioa_cfg *ioa_cfg, void *device,
+   int (*match) (struct ipr_cmnd *, void *))
+{
+   struct ipr_cmnd *ipr_cmd;
+   DECLARE_COMPLETION_ONSTACK(comp);
+   int wait;
+   unsigned long flags;
+   signed long timeout = IPR_ABORT_TASK_TIMEOUT;
+   struct ipr_hrr_queue *hrrq;
+
+   ENTER;
+   do {
+   wait = 0;
+
+   for_each_hrrq(hrrq, ioa_cfg) {
+   spin_lock_irqsave(hrrq-lock, flags);
+   list_for_each_entry(ipr_cmd, hrrq-hrrq_pending_q, 
queue) {
+   if (match(ipr_cmd, device)) {
+   ipr_cmd-eh_comp = comp;
+   wait++;
+   }
+   }
+   spin_unlock_irqrestore(hrrq-lock, flags);
+   }
+
+   if (wait) {
+   timeout = wait_for_completion_timeout(comp, timeout);
+
+   if (!timeout) {
+   wait = 0;
+
+   for_each_hrrq(hrrq, ioa_cfg) {
+   spin_lock_irqsave(hrrq-lock, flags);
+   list_for_each_entry(ipr_cmd, 
hrrq-hrrq_pending_q, queue) {
+   if (match(ipr_cmd, device)) {
+   ipr_cmd-eh_comp = NULL;
+   wait++;
+   }
+   }
+   spin_unlock_irqrestore(hrrq-lock, 
flags);
+   }
+
+   if (wait)
+   dev_err(ioa_cfg-pdev-dev, Timed out 
waiting for aborted commands\n);
+   LEAVE;
+   return wait ? FAILED : SUCCESS;
+   }
+   }
+   } while (wait);
+
+   LEAVE;
+   return SUCCESS;
+}
+
 static int ipr_eh_host_reset(struct scsi_cmnd *cmd)
 {
struct ipr_ioa_cfg *ioa_cfg;
@@ -5072,11 +5153,17 @@ static int __ipr_eh_dev_reset(struct scs
 static int ipr_eh_dev_reset(struct scsi_cmnd *cmd)
 {
int rc;
+   struct ipr_ioa_cfg *ioa_cfg;
+
+   ioa_cfg = (struct ipr_ioa_cfg *) cmd-device-host-hostdata;
 
spin_lock_irq(cmd-device-host-host_lock);
rc = __ipr_eh_dev_reset(cmd);
spin_unlock_irq(cmd-device-host-host_lock);
 
+   if (rc == SUCCESS)
+   rc = ipr_wait_for_ops(ioa_cfg, cmd-device, ipr_match_lun);
+
return rc;
 }
 
@@ -5254,13 +5341,18 @@ static 

Re: [PATCH 1/2] ipr: Disable async aborts

2014-10-27 Thread James Bottomley
On Mon, 2014-10-27 at 09:37 -0500, Brian King wrote:
 The ipr driver does not yet support async aborts, so disable this
 for now.
 
 Signed-off-by: Brian King brk...@linux.vnet.ibm.com

By does not yet support do you mean doesn't work with or merely not
tested with but seems to work OK?  if the former, then surely this
should be a fixes patch with a cc to stable for all the kernels async
abort is in (which is 3.14)

James

 ---
 
  drivers/scsi/ipr.c |1 +
  1 file changed, 1 insertion(+)
 
 diff -puN drivers/scsi/ipr.c~ipr_no_async_eh drivers/scsi/ipr.c
 --- linux/drivers/scsi/ipr.c~ipr_no_async_eh  2014-10-24 08:57:53.169169509 
 -0500
 +++ linux-bjking1/drivers/scsi/ipr.c  2014-10-24 08:57:53.175169579 -0500
 @@ -6357,6 +6357,7 @@ static struct scsi_host_template driver_
   .sdev_attrs = ipr_dev_attrs,
   .proc_name = IPR_NAME,
   .no_write_same = 1,
 + .no_async_abort = 1,
  };
  
  /**
 _
 
 --
 To unsubscribe from this list: send the line unsubscribe linux-scsi in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] osst: call scsi_set_medium_removal directly

2014-10-27 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/osst.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 8c28b49..9214e5d 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -3325,19 +3325,18 @@ static int osst_write_frame(struct osst_tape * STp, 
struct osst_request ** aSRpn
 /* Lock or unlock the drive door. Don't use when struct osst_request 
allocated. */
 static int do_door_lock(struct osst_tape * STp, int do_lock)
 {
-   int retval, cmd;
+   int retval;
 
-   cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK;
 #if DEBUG
printk(OSST_DEB_MSG %s:D: %socking drive door.\n, tape_name(STp), 
do_lock ? L : Unl);
 #endif
-   retval = scsi_ioctl(STp-device, cmd, NULL);
-   if (!retval) {
+
+   retval = scsi_set_medium_removal(STp-device,
+   do_lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW);
+   if (!retval)
STp-door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED;
-   }
-   else {
+   else
STp-door_locked = ST_LOCK_FAILS;
-   }
return retval;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] scsi: return EAGAIN when resetting a device under EH

2014-10-27 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/scsi_ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index d0cb33d..53e8fea 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -278,7 +278,7 @@ int scsi_ioctl_block_when_processing_errors(struct 
scsi_device *sdev, int cmd,
 {
if (cmd == SG_SCSI_RESET  ndelay) {
if (scsi_host_in_recovery(sdev-host))
-   return -ENODEV;
+   return -EAGAIN;
} else {
if (!scsi_block_when_processing_errors(sdev))
return -ENODEV;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] st: call scsi_set_medium_removal directly

2014-10-27 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/st.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 7270e3f..f501e5a 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -860,17 +860,16 @@ static int set_mode_densblk(struct scsi_tape * STp, 
struct st_modedef * STm)
 /* Lock or unlock the drive door. Don't use when st_request allocated. */
 static int do_door_lock(struct scsi_tape * STp, int do_lock)
 {
-   int retval, cmd;
+   int retval;
 
-   cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK;
DEBC_printk(STp, %socking drive door.\n, do_lock ? L : Unl);
-   retval = scsi_ioctl(STp-device, cmd, NULL);
-   if (!retval) {
+
+   retval = scsi_set_medium_removal(STp-device,
+   do_lock ? SCSI_REMOVAL_PREVENT : SCSI_REMOVAL_ALLOW);
+   if (!retval)
STp-door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED;
-   }
-   else {
+   else
STp-door_locked = ST_LOCK_FAILS;
-   }
return retval;
 }
 
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] scsi: split scsi_nonblockable_ioctl

2014-10-27 Thread Christoph Hellwig
The calling conventions for this function where bad as it could return
-ENODEV both for a device not currently online and a not recognized ioctl.

Add a new scsi_ioctl_block_when_processing_errors function that wraps
scsi_block_when_processing_errors with the a special case for the
SG_SCSI_RESET ioctl command, and handle the SG_SCSI_RESET case itself
in scsi_ioctl.  All callers of scsi_ioctl now must call the above helper
to check for the EH state, so that the ioctl handler itself doesn't
have to.

Reported-by: Robert Elliott elli...@hp.com
Signed-off-by: Christoph Hellwig h...@lst.de
---
 drivers/scsi/ch.c |  5 +
 drivers/scsi/osst.c   |  6 +++---
 drivers/scsi/scsi_ioctl.c | 47 +--
 drivers/scsi/sd.c |  6 +++---
 drivers/scsi/sg.c | 33 +++--
 drivers/scsi/sr.c | 15 +--
 drivers/scsi/st.c |  7 +++
 include/scsi/scsi_ioctl.h |  4 ++--
 8 files changed, 49 insertions(+), 74 deletions(-)

diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index ef5ae0d..fcd9327 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -616,6 +616,11 @@ static long ch_ioctl(struct file *file,
int retval;
void __user *argp = (void __user *)arg;
 
+   retval = scsi_ioctl_block_when_processing_errors(ch-device, cmd,
+   file-f_flags  O_NDELAY);
+   if (retval)
+   return retval;
+
switch (cmd) {
case CHIOGPARAMS:
{
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index dff37a25..8c28b49 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -4967,10 +4967,10 @@ static long osst_ioctl(struct file * file,
 * may try and take the device offline, in which case all further
 * access to the device is prohibited.
 */
-   if( !scsi_block_when_processing_errors(STp-device) ) {
-   retval = (-ENXIO);
+   retval = scsi_ioctl_block_when_processing_errors(STp-device, cmd_in,
+   file-f_flags  O_NDELAY);
+   if (retval)
goto out;
-   }
 
cmd_type = _IOC_TYPE(cmd_in);
cmd_nr   = _IOC_NR(cmd_in);
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 6dc61b0..d0cb33d 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -200,19 +200,6 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void 
__user *arg)
 {
char scsi_cmd[MAX_COMMAND_SIZE];
 
-   /* No idea how this happens */
-   if (!sdev)
-   return -ENXIO;
-
-   /*
-* If we are in the middle of error recovery, don't let anyone
-* else try and use this device.  Also, if error recovery fails, it
-* may try and take the device offline, in which case all further
-* access to the device is prohibited.
-*/
-   if (!scsi_block_when_processing_errors(sdev))
-   return -ENODEV;
-
/* Check for deprecated ioctls ... all the ioctls which don't
 * follow the new unique numbering scheme are deprecated */
switch (cmd) {
@@ -273,6 +260,8 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void 
__user *arg)
 START_STOP_TIMEOUT, NORMAL_RETRIES);
 case SCSI_IOCTL_GET_PCI:
 return scsi_ioctl_get_pci(sdev, arg);
+   case SG_SCSI_RESET:
+   return scsi_ioctl_reset(sdev, arg);
default:
if (sdev-host-hostt-ioctl)
return sdev-host-hostt-ioctl(sdev, cmd, arg);
@@ -281,30 +270,20 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void 
__user *arg)
 }
 EXPORT_SYMBOL(scsi_ioctl);
 
-/**
- * scsi_nonblockable_ioctl() - Handle SG_SCSI_RESET
- * @sdev: scsi device receiving ioctl
- * @cmd: Must be SC_SCSI_RESET
- * @arg: pointer to int containing SG_SCSI_RESET_{DEVICE,TARGET,BUS,HOST}
- *   possibly OR-ed with SG_SCSI_RESET_NO_ESCALATE
- * @ndelay: file mode O_NDELAY flag
+/*
+ * We can process a reset even when a device isn't fully operable.
  */
-int scsi_nonblockable_ioctl(struct scsi_device *sdev, int cmd,
-   void __user *arg, int ndelay)
+int scsi_ioctl_block_when_processing_errors(struct scsi_device *sdev, int cmd,
+   bool ndelay)
 {
-   /* The first set of iocts may be executed even if we're doing
-* error processing, as long as the device was opened
-* non-blocking */
-   if (ndelay) {
+   if (cmd == SG_SCSI_RESET  ndelay) {
if (scsi_host_in_recovery(sdev-host))
return -ENODEV;
-   } else if (!scsi_block_when_processing_errors(sdev))
-   return -ENODEV;
-
-   switch (cmd) {
-   case SG_SCSI_RESET:
-   return scsi_ioctl_reset(sdev, arg);
+   } else {
+   if (!scsi_block_when_processing_errors(sdev))
+   return -ENODEV;
}
-  

[PATCH 1/2] scsi: TUR path is down after adapter gets reset in multipath configuration(scsi_error.c)

2014-10-27 Thread wenxiong
After an ipr adapter gets reset, all disk array devices require a start
unit command to be issued to them before they will accept commands. So,
with the SCSI EH change, we now end up in a scenario with dual ipr
adapters where the TUR getting issued from the health checker returns
with a Not Ready response and since SCSI EH no longer triggers the Start
Unit in this scenario, the path never recovers.

Signed-off-by: Christoph Hellwig h...@infradead.org
Tested-by: Wen Xiong wenxi...@linux.vnet.ibm.com
---
 drivers/scsi/scsi_error.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

Index: b/drivers/scsi/scsi_error.c
===
--- a/drivers/scsi/scsi_error.c 2014-10-23 12:54:16.0 -0500
+++ b/drivers/scsi/scsi_error.c 2014-10-23 12:57:44.642078988 -0500
@@ -459,14 +459,6 @@ static int scsi_check_sense(struct scsi_
if (! scsi_command_normalize_sense(scmd, sshdr))
return FAILED;  /* no valid sense data */
 
-   if (scmd-cmnd[0] == TEST_UNIT_READY  scmd-scsi_done != scsi_eh_done)
-   /*
-* nasty: for mid-layer issued TURs, we need to return the
-* actual sense data without any recovery attempt.  For eh
-* issued ones, we need to try to recover and interpret
-*/
-   return SUCCESS;
-
scsi_report_sense(sdev, sshdr);
 
if (scsi_sense_is_deferred(sshdr))
@@ -482,6 +474,14 @@ static int scsi_check_sense(struct scsi_
/* handler does not care. Drop down to default handling */
}
 
+   if (scmd-cmnd[0] == TEST_UNIT_READY  scmd-scsi_done != scsi_eh_done)
+   /*
+* nasty: for mid-layer issued TURs, we need to return the
+* actual sense data without any recovery attempt.  For eh
+* issued ones, we need to try to recover and interpret
+*/
+   return SUCCESS;
+
/*
 * Previous logic looked for FILEMARK, EOM or ILI which are
 * mainly associated with tapes and returned SUCCESS.

-- 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] scsi: TUR path is down after adapter gets reset in multipath configuration(scsi_dh_alus.c)

2014-10-27 Thread wenxiong
This patch also fixes the 02/04/02 K/C/Q check in alua_check_sense
handler.

Signed-off-by: Brian King brk...@linux.vnet.ibm.com
Teste-by: Wen Xiong wenxi...@linux.vnet.ibm.com
---
 drivers/scsi/device_handler/scsi_dh_alua.c |7 +++
 1 file changed, 7 insertions(+)

Index: b/drivers/scsi/device_handler/scsi_dh_alua.c
===
--- a/drivers/scsi/device_handler/scsi_dh_alua.c2014-10-23 
13:00:45.0 -0500
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c2014-10-23 
13:04:16.152079004 -0500
@@ -474,6 +474,13 @@ static int alua_check_sense(struct scsi_
 * LUN Not Ready -- Offline
 */
return SUCCESS;
+   if (sdev-allow_restart 
+   (sense_hdr-asc == 0x04)  (sense_hdr-ascq == 0x02))
+   /*
+* if the device is not started, we need to wake
+* the error handler to start the motor
+*/
+   return FAILED;
break;
case UNIT_ATTENTION:
if (sense_hdr-asc == 0x29  sense_hdr-ascq == 0x00)

-- 
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/2] scsi: TUR path is down after adapter gets reset in multipath configuration(scsi_error.c)

2014-10-27 Thread Elliott, Robert (Server Storage)
 -Original Message-
 From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
 ow...@vger.kernel.org] On Behalf Of wenxi...@linux.vnet.ibm.com
 Sent: Monday, 27 October, 2014 1:02 PM
 To: james.bottom...@hansenpartnership.com
 Cc: h...@infradead.org; linux-scsi@vger.kernel.org;
 brk...@linux.vnet.ibm.com
 Subject: [PATCH 1/2] scsi: TUR path is down after adapter gets reset
 in multipath configuration(scsi_error.c)
 
 After an ipr adapter gets reset, all disk array devices require a
 start unit command to be issued to them before they will accept
 commands. So, with the SCSI EH change, we now end up in a scenario 
 with dual ipr adapters where the TUR getting issued from the health
 checker returns with a Not Ready response and since SCSI EH no
 longer triggers the Start Unit in this scenario, the path never
 recovers.
 

This description doesn't make sense without reading the thread:
[dm-devel] [PATCH 1/1] multipath-tools: Change path checker for IBM IPR devices

Example: what is the SCSI EH change?

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/2] scsi: TUR path is down after adapter gets reset in multipath configuration(scsi_dh_alus.c)

2014-10-27 Thread Elliott, Robert (Server Storage)
 -Original Message-
 From: linux-scsi-ow...@vger.kernel.org [mailto:linux-scsi-
 ow...@vger.kernel.org] On Behalf Of wenxi...@linux.vnet.ibm.com
 Sent: Monday, 27 October, 2014 1:02 PM
 To: james.bottom...@hansenpartnership.com
 Cc: h...@infradead.org; linux-scsi@vger.kernel.org;
 brk...@linux.vnet.ibm.com
 Subject: [PATCH 2/2] scsi: TUR path is down after adapter gets reset
 in multipath configuration(scsi_dh_alus.c)
 
 This patch also fixes the 02/04/02 K/C/Q check in alua_check_sense
 handler.
 
 Signed-off-by: Brian King brk...@linux.vnet.ibm.com
 Teste-by: Wen Xiong wenxi...@linux.vnet.ibm.com

Missing a d

 ---
  drivers/scsi/device_handler/scsi_dh_alua.c |7 +++
  1 file changed, 7 insertions(+)
 
 Index: b/drivers/scsi/device_handler/scsi_dh_alua.c
 ===
 --- a/drivers/scsi/device_handler/scsi_dh_alua.c  2014-10-23
 13:00:45.0 -0500
 +++ b/drivers/scsi/device_handler/scsi_dh_alua.c  2014-10-23
 13:04:16.152079004 -0500
 @@ -474,6 +474,13 @@ static int alua_check_sense(struct scsi_
* LUN Not Ready -- Offline
*/
   return SUCCESS;
 + if (sdev-allow_restart 
 + (sense_hdr-asc == 0x04)  (sense_hdr-ascq ==
 0x02))

The coding style in that function does not include the extra 
parenthesis, as shown by the next excerpt:

 + /*
 +  * if the device is not started, we need to wake
 +  * the error handler to start the motor
 +  */
 + return FAILED;
   break;
   case UNIT_ATTENTION:
   if (sense_hdr-asc == 0x29  sense_hdr-ascq == 0x00)

Thus function is used several places:
* installed as the scsi_device_handler .check_sense function 
* called to parse the response to REPORT TARGET PORT GROUPS
  in alua_rtpg
* called to parse the response to SET TARGET PORT GROUPS
  in stpg_endio

I'm not sure that adding NOT READY/LOGICAL UNIT NOT READY,
INITIALIZING COMMAND REQUIRED (2h/04h/02h) is a good idea
for the second case. The expected way to handle that 
response is to send START STOP UNIT with START=1.

There are conditions in which REPORT TARGET PORT GROUPS
is allowed and START STOP UNIT with START=1 is not allowed:
* CbCS (capabilities-based command security) only allows 
  START STOP UNIT if physical access (PHY ACC) is enabled,
  while REPORT TARGET PORT GROUPS is always allowed.
* the standby or unavailable asymmetric access states only 
  guarantee that REPORT TARGET PORT GROUPS is allowed, not
  START STOP UNIT.  The device is permitted to support START
  STOP UNIT, but it's not required.

So, it's really not a response that should be returned for
that command.

Any device that does return that response must also support
START STOP UNIT or it's misleading the application client.
In that case, falling through to the EH to send START STOP
UNIT is the right thing to do.

SET TARGET PORT GROUPS is questionable too; it also has 
different CbCS permissions and asymmetric access state
requirements than START STOP UNIT with START=1.

Perhaps that new return FAILED should be skipped if the
opcode is REPORT TARGET PORT GROUPS or SET TARGET PORT
GROUPS?

---
Rob ElliottHP Server Storage


--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] Revert block: all blk-mq requests are tagged

2014-10-27 Thread Martin K. Petersen
 Christoph == Christoph Hellwig h...@lst.de writes:

Christoph This reverts commit fb3ccb5da71273e7f0d50b50bc879e50cedd60e7.
Christoph SCSI-2/SPI actually needs the tagged/untagged flag in the
Christoph request to work properly.  Revert this patch and add a follow
Christoph on to set it in the right place.

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 0/5] Feature enhancements for ses module

2014-10-27 Thread Song Liu
Hi Doug, 

I agree what it is difficult to handle all elements, and thus using sg_ses 
probably makes more sense. However, it helps to handle some HDD related fields 
in the kernel, as the kernel can generate mapping between a device to the SES 
device element (or array device element): 

/sys/block/sdc/device/enclosure_deviceXXX/

With patch 5, we can easily power off a running HDD by 

echo off  /sys/block/sdc/device/enclosure_deviceXXX/power_status

This is very useful for systems like Cold Storage, where HDDs are being powered 
on/off frequently. 


In current code, ses_set_page2_descriptor already clear reserved field for all 
elements, and only send non-zero for the device element or array device. Patch 
5 also handles reserved field of these two elements in init_device_slot_control:

dest_desc[2] = 0xde;
dest_desc[3] = 0x3c;

So I think we can control fault, locate, active, and power_status of each HDD 
without issue. 

Please let me know your suggestion on this. 

Thanks,
Song

 -Original Message-
 From: Song Liu
 Sent: Wednesday, October 22, 2014 8:42 PM
 To: 'dgilb...@interlog.com'; Jens Axboe; linux-scsi@vger.kernel.org
 Cc: Hannes Reinecke; Dan Williams; Christoph Hellwig
 Subject: RE: [PATCH 0/5] Feature enhancements for ses module
 
 Hi Doug,
 
 The power on/off field together with fault, locate, and active are for 
 HDD
 (i.e. DeviceSlot and ArrayDeviceSlot). They are not for enclosure or other
 elements. So we are not dealing with power off duration, etc. here.
 
 Thanks,
 Song
 
  -Original Message-
  From: Douglas Gilbert [mailto:dgilb...@interlog.com]
  Sent: Wednesday, October 22, 2014 6:17 PM
  To: Song Liu; Jens Axboe; linux-scsi@vger.kernel.org
  Cc: Hannes Reinecke; Dan Williams; Christoph Hellwig
  Subject: Re: [PATCH 0/5] Feature enhancements for ses module
 
  On 14-10-23 01:01 AM, Song Liu wrote:
   Hi Doug,
  
   I am not sure whether I fully understand the scenario. Actually
   patch 5 tries to
  clear all reserved bits:
  
   + dest_desc[0] = 0;
   + /* only clear byte 1 for ENCLOSURE_COMPONENT_DEVICE */ if
   + (ecomp-type == ENCLOSURE_COMPONENT_DEVICE)
   +   dest_desc[1] = 0;
   + dest_desc[2] = 0xde;
   + dest_desc[3] = 0x3c;
  
   Would this work for device that rejects request with 1 in RESERVED areas?
 
 
  That is a pretty asymmetric element type, assuming we are talking
  about the enclosure control and enclosure status elements (i.e.
  etc=0xe). My guess would be:
 
   dest_desc[0] = 0x80 | (src_desc[0]  40);
   dest_desc[1] = 0x80  src_desc[1];
   dest_desc[2] = (pc_req  6) | pc_delay;
   dest_desc[3] = 0xff  src_desc[3]; or if you have a new
  power_off_duration:
   dest_desc[3] = (power_off_duration  2) | (src_desc[3]  0x3);
 
  In byte 0 the top bit (SELECT) must be set or the enclosure will
  ignore any other settings in that element. If the PRDFAIL bit is
  already set, then that setting will be maintained.
  SES-3 has a note about clearing DISABLE and SWAP.
 
  In byte 1 is if the identifier (LED ?) is active (saying blinking)
  prior to this power cycle request, then it will stay blinking until
  the power drops. If the enclosure was really clever it might keep
  blinking after the power cycle :-)
 
  Also notice that the requested power cycle can be cancelled up to the
  time until power cycle drops to zero.
 
   -Original Message-
   From: Douglas Gilbert [mailto:dgilb...@interlog.com]
   Sent: Wednesday, October 22, 2014 3:29 PM
   To: Jens Axboe; Song Liu; linux-scsi@vger.kernel.org
   Cc: Hannes Reinecke; Dan Williams; Christoph Hellwig
   Subject: Re: [PATCH 0/5] Feature enhancements for ses module
  
   On 14-10-22 09:12 PM, Jens Axboe wrote:
   On 08/25/2014 11:34 AM, Song Liu wrote:
   From: Song Liu [mailto:songliubrav...@fb.com]
   Sent: Monday, August 25, 2014 10:26 AM
   To: Song Liu
   Subject: [PATCH 0/5] Feature enhancements for ses module
  
   These patches include a few enhancements to ses module:
  
   1: close potential race condition by at enclosure race condition
  
   2,3,4: add enclosure id and device slot, so we can create symlink
in /dev/disk/by-slot:
   # ls -d /dev/disk/by-slot/*
 /dev/disk/by-slot/enclosure-0x5000ae41fc1310ff-slot0
  
   5: add ability to power on/off device with power_status file in
sysfs.
  
   Had a rude awakening with sg_ses recently when setting a field in
   the enclosure control dpage. That is what is being done in point 5: 
   above.
  
   The time honoured technique is to read the corresponding enclosure
   status dpage, find the correct element, twiddle the field of
   interest, set the SELECT bit and write it back. The idea is
   maintain any other
  field settings in that element.
   And this is what the ses module does.
  
   There is at least one SES device out there that rejects the write
   if there are bits set in RESERVED locations. According to SPC-4 a
   device may do that. Look at the status (read) and control 

Re: [PATCH v2 03/12] scsi-mq: Add support for multiple hardware queues

2014-10-27 Thread Martin K. Petersen
 Bart == Bart Van Assche bvanass...@acm.org writes:

Bart Allow a SCSI LLD to declare how many hardware queues it supports
Bart by setting Scsi_Host.nr_hw_queues before calling scsi_add_host().

Bart Note: it is assumed that each hardware queue has a queue depth of
Bart shost- can_queue. In other words, the total queue depth per host
Bart is (number of hardware queues) * (shost-can_queue).

I suggest you emphasize that assumption in the header file.

Also: What about the host template?

Reviewed-by: Martin K. Petersen martin.peter...@oracle.com

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv8 00/27] scsi logging update (the boring part)

2014-10-27 Thread Martin K. Petersen
 Hannes == Hannes Reinecke h...@suse.de writes:

Hannes here is now the eigth iteration of my scsi logging update.  With
Hannes this I've updated the patch to ratelimit I/O error messages as
Hannes suggested by Robert Elliott.  Additionally I've updated it to
Hannes core-for-3.19 and included the missing hunks for ufs as
Hannes requested by Christoph Hellwig.

I have read through these and nothing stuck out. Nice cleanup.

Do you have a git tree that I can use for testing?

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html