Fixes, cleanups and modernization for NCR5380 drivers
Subsystems (5)
cover Fixes, cleanups and modernization for NCR5380 drivers
This patch series has fixes for bugs and compiler warnings as well as code cleanup and modernization. It covers all ten NCR5380 drivers and the three core NCR5380 drivers so it's fairly large.
At the end of this series about a thousand lines (net) have been removed including two header files. A lot of C pre-processor abuse is eliminated. There are patches for scsi_add_host() conversion for atari_scsi, mac_scsi and sun3_scsi.
Some steps are taken toward re-unification of the NCR5380 core driver forks by reducing divergence between them. Also, the atari_NCR5380.c core driver is generalized such that it can be used by sun3_scsi.c. The next step is to remove sun_NCR5380.c by adopting atari_NCR5380.c.
I have compile-tested all of the NCR5380 drivers (x86, ARM and m68k) and executed mac_scsi and dmx3191d on suitable hardware. I found no regressions but the core NCR5380 drivers have bugs unrelated to these patches.
Testing mac_scsi and dmx3191d provides only limited code coverage for these patches. Some testing on Sun 3, Atari ST and/or Atari TT would be nice (I don't have the hardware).
There are old bugs relating to exception handling and autosense in the core NCR5380 drivers that can make testing difficult. I'm working on a series of patches to address these bugs. Those patches are not yet ready for submission but they were helpful in testing this patch series and may be helpful to other testers. Let me know if so.
--- arch/m68k/atari/config.c | 5 arch/m68k/atari/stdma.c | 62 ++- arch/m68k/include/asm/atari_stdma.h | 4 arch/m68k/include/asm/macintosh.h | 3 arch/m68k/mac/config.c | 101 ++++- arch/m68k/sun3/config.c | 11 drivers/scsi/Kconfig | 2 drivers/scsi/NCR5380.c | 296 +++++---------- drivers/scsi/NCR5380.h | 59 +-- drivers/scsi/arm/cumana_1.c | 18 drivers/scsi/arm/oak.c | 21 - drivers/scsi/atari_NCR5380.c | 383 ++++++++------------ drivers/scsi/atari_scsi.c | 677 +++++++++++++++--------------------- drivers/scsi/atari_scsi.h | 60 --- drivers/scsi/dmx3191d.c | 31 - drivers/scsi/dtc.c | 85 +--- drivers/scsi/dtc.h | 26 - drivers/scsi/g_NCR5380.c | 224 ----------- drivers/scsi/g_NCR5380.h | 26 - drivers/scsi/mac_scsi.c | 545 ++++++++++++---------------- drivers/scsi/mac_scsi.h | 74 --- drivers/scsi/pas16.c | 106 +---- drivers/scsi/pas16.h | 21 - drivers/scsi/sun3_NCR5380.c | 187 ++------- drivers/scsi/sun3_scsi.c | 518 ++++++++++++--------------- drivers/scsi/sun3_scsi.h | 75 --- drivers/scsi/t128.c | 83 +--- drivers/scsi/t128.h | 23 - 28 files changed, 1366 insertions(+), 2360 deletions(-)
PATCH 1/29 ncr5380: Use printk() not pr_debug()
Having defined NDEBUG, and having set the console log level, I'd like to see some output. Don't use pr_debug(), it's annoying to have to define DEBUG as well.
---
Use of pr_debug() here was a bad idea of mine. Joe was right when he questioned it.
--- drivers/scsi/NCR5380.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/NCR5380.h +2 -1
@@ -296,7 +296,8 @@ struct NCR5380_hostdata {#endif #define dprintk (flg, fmt, ...) \ - do { if ((NDEBUG) & (flg)) pr_debug(fmt, ## __VA_ARGS__); } while (0) + do { if ((NDEBUG) & (flg)) \ + printk(KERN_DEBUG fmt, ## __VA_ARGS__); } while (0)#if NDEBUG #define NCR5380_dprint (flg, arg) \
Re: [PATCH 01/29] ncr5380: Use printk() not pr_debug()
Quoted 11 lines · Finn Thain
Having defined NDEBUG, and having set the console log level, I'd like to see some output. Don't use
pr_debug(), it's annoying to have to define DEBUG as well.Signed-off-by Finn Thain <[email protected]>---
Use of
pr_debug()here was a bad idea of mine. Joe was right when he questioned it.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 2/29 ncr5380: Remove unused hostdata fields
In reply to Finn ThainRemove unused fields from hostdata structs declared with the NCR5380_implementation_fields macro.
--- 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(-)
drivers/scsi/dmx3191d.c +2 -2
@@ -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/*
drivers/scsi/mac_scsi.c +0 -33
@@ -93,35 +93,6 @@ static volatile unsigned char *mac_scsi_* NCR 5380 register access functions */ -#if 0 -/* Debug versions */ -#define CTRL (p,v) (*ctrl = (v)) - -static char macscsi_read (struct Scsi_Host *instance,int reg) -{ -int iobase = instance->io_port; -int i; -int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; - -CTRL (iobase,0 ); - i =in_8 (iobase + (reg<<4 )); -CTRL (iobase,0x40 ); - -return i; -} - -static void macscsi_write (struct Scsi_Host *instance,int reg,int value) -{ -int iobase = instance->io_port; -int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl; - -CTRL (iobase,0 ); -out_8 (iobase + (reg<<4 ), value); -CTRL (iobase,0x40 ); -} -#else - -/* Fast versions */ static __inline__char macscsi_read (struct Scsi_Host *instance,int reg) {return in_8 (instance->io_port + (reg<<4 ));
@@ -131,8 +102,6 @@ static __inline__ void macscsi_write(str {out_8 (instance->io_port + (reg<<4 ), value); } -#endif -/* * Function : mac_scsi_setup(char *str)
@@ -279,8 +248,6 @@ int __init macscsi_detect(struct scsi_ho instance->n_io_port =255 ; - ((struct NCR5380_hostdata *)instance->hostdata)->ctrl =0 ; -if (instance->irq !=SCSI_IRQ_NONE )if (request_irq (instance->irq, NCR5380_intr,0 ,"ncr5380" , instance)) { printk(KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n",
drivers/scsi/mac_scsi.h +1 -2
@@ -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
drivers/scsi/sun3_scsi.c +0 -2
@@ -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
drivers/scsi/sun3_scsi.h +1 -2
@@ -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
Re: [PATCH 02/29] ncr5380: Remove unused hostdata fields
Quoted 5 lines · Finn Thain
Remove unused fields from hostdata structs declared with the
NCR5380_implementation_fieldsmacro.Signed-off-by Finn Thain <[email protected]>
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 3/29 ncr5380: Fix compiler warnings and __setup options
In reply to Finn ThainSome __setup() options mentioned in Documentation/scsi don't work because a few lines of code went missing sometime since Linux 2.4. Fix the options and thus fix some compiler warnings for both the non-modular case,
CC drivers/scsi/dtc.odrivers/scsi/dtc.c:176:20: warning: 'dtc_setup' defined but not used [-Wunused-function]
and the modular case,
CC [M] drivers/scsi/pas16.odrivers/scsi/pas16.c:335:20: warning: 'pas16_setup' defined but not used [-Wunused-function]
CC [M] drivers/scsi/t128.o
drivers/scsi/t128.c:147:20: warning: 't128_setup' defined but not used [-Wunused-function]
--- drivers/scsi/dtc.c | 8 +++++++- drivers/scsi/pas16.c | 10 +++++++++- drivers/scsi/t128.c | 11 ++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-)
drivers/scsi/dtc.c +7 -1
@@ -173,10 +173,13 @@ static const struct signature {* */ -static void __init dtc_setup (char *str,int *ints) +static int __init dtc_setup (char *str) {static int commandline_current =0 ;int i; +int ints[10 ]; + +get_options (str,ARRAY_SIZE (ints), ints);if (ints[0 ] !=2 )printk ("dtc_setup: usage dtc=address,irq\n" );else if (commandline_current <NO_OVERRIDES ) {
@@ -189,7 +192,10 @@ static void __init dtc_setup(char *str, } ++commandline_current; } +return 1 ; } + +__setup ("dtc=" , dtc_setup);#endif /*
drivers/scsi/pas16.c +9 -1
@@ -337,6 +337,7 @@ static int __init } +#ifndef MODULE /* * Function : pas16_setup(char *str, int *ints) *
@@ -347,10 +348,13 @@ static int __init* */ -void __init pas16_setup (char *str,int *ints) +static int __init pas16_setup (char *str) {static int commandline_current =0 ;int i; +int ints[10 ]; + +get_options (str,ARRAY_SIZE (ints), ints);if (ints[0 ] !=2 )printk ("pas16_setup : usage pas16=io_port,irq\n" );else
@@ -364,8 +368,12 @@ void __init pas16_setup(char *str, int * } ++commandline_current; } +return 1 ; } +__setup ("pas16=" , pas16_setup); +#endif +/* * Function : int pas16_detect(struct scsi_host_template * tpnt) *
drivers/scsi/t128.c +10 -1
@@ -148,6 +148,7 @@ static struct signature {#define NO_SIGNATURES ARRAY_SIZE(signatures) +#ifndef MODULE /* * Function : t128_setup(char *str, int *ints) *
@@ -158,9 +159,13 @@ static struct signature {* */ -void __init t128_setup (char *str,int *ints){ +static int __init t128_setup (char *str) +{static int commandline_current =0 ;int i; +int ints[10 ]; + +get_options (str,ARRAY_SIZE (ints), ints);if (ints[0 ] !=2 )printk ("t128_setup : usage t128=address,irq\n" );else
@@ -174,8 +179,12 @@ void __init t128_setup(char *str, int *i } ++commandline_current; } +return 1 ; } +__setup ("t128=" , t128_setup); +#endif +/* * Function : int t128_detect(struct scsi_host_template * tpnt) *
Re: [PATCH 03/29] ncr5380: Fix compiler warnings and __setup options
Quoted 7 lines · Finn Thain
Some
__setup()options mentioned inDocumentation/scsidon't work because a few lines of code went missing sometime since Linux 2.4. Fix the options and thus fix some compiler warnings for both the non-modular case,CC
drivers/scsi/dtc.odrivers/scsi/dtc.c:176:20: warning: 'dtc_setup' defined but not used [-Wunused-function]
Quoted 9 lines
and the modular case,
CC [M]
drivers/scsi/pas16.odrivers/scsi/pas16.c:335:20: warning: 'pas16_setup' defined but not used [-Wunused-function]CC [M] drivers/scsi/t128.o
drivers/scsi/t128.c:147:20: warning: 't128_setup' defined but not used [-Wunused-function]Signed-off-by Finn Thain <[email protected]>
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH 4/29 ncr5380: Remove unused macros
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-unused-macros
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/52ba4ecb/attachment.ksh>
PATCH 4/29 ncr5380: Remove unused macros
Quoted 6 lines · Finn Thain
Some macros are never evaluated (i.e. FOO, USLEEP, SCSI2 and
USE_WRAPPER; and in some drivers,NCR5380_intrandNCR5380_proc_info).DRIVER_SETUPserves no purpose anymore. Remove these macro definitions.Signed-off-by Finn Thain <[email protected]>
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage hare at suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: J. Hawn, J. Guild, F. Imend?rffer, HRB 16746 (AG N?rnberg)
PATCH 5/29 ncr5380: Remove useless prototypes
In reply to Finn ThainAdd 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.
--- 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(-)
drivers/scsi/g_NCR5380.c +3 -3
@@ -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);
drivers/scsi/pas16.c +3 -3
@@ -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 ;
drivers/scsi/sun3_scsi.c +1 -3
@@ -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(structreturn 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);
drivers/scsi/t128.c +4 -3
@@ -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 ;
drivers/scsi/dtc.h +0 -7
@@ -32,13 +32,6 @@#define DTCDEBUG_INIT 0x1#define DTCDEBUG_TRANSFER 0x2 -static int dtc_abort (Scsi_Cmnd *); -static int dtc_biosparam (struct scsi_device *,struct block_device *, -sector_t ,int *); -static int dtc_detect (struct scsi_host_template *); -static int dtc_queue_command (struct Scsi_Host *,struct scsi_cmnd *); -static int dtc_bus_reset (Scsi_Cmnd *); -#ifndef CMD_PER_LUN #define CMD_PER_LUN 2#endif
drivers/scsi/g_NCR5380.h +0 -6
@@ -39,12 +39,6 @@#endif #ifndef ASM -static int generic_NCR5380_abort (Scsi_Cmnd *); -static int generic_NCR5380_detect (struct scsi_host_template *); -static int generic_NCR5380_release_resources (struct Scsi_Host *); -static int generic_NCR5380_queue_command (struct Scsi_Host *,struct scsi_cmnd *); -static int generic_NCR5380_bus_reset (Scsi_Cmnd *); -static const char *generic_NCR5380_info (struct Scsi_Host *);#ifndef CMD_PER_LUN #define CMD_PER_LUN 2
drivers/scsi/mac_scsi.c +0 -2
@@ -56,8 +56,6 @@#define RESET_BOOT -extern void via_scsi_clear (void ); -#ifdef RESET_BOOT static void mac_scsi_reset_boot (struct Scsi_Host *instance);#endif
drivers/scsi/pas16.h +0 -6
@@ -114,12 +114,6 @@#ifndef ASM -static int pas16_abort (Scsi_Cmnd *); -static int pas16_biosparam (struct scsi_device *,struct block_device *, -sector_t ,int *); -static int pas16_detect (struct scsi_host_template *); -static int pas16_queue_command (struct Scsi_Host *,struct scsi_cmnd *); -static int pas16_bus_reset (Scsi_Cmnd *);#ifndef CMD_PER_LUN #define CMD_PER_LUN 2
drivers/scsi/sun3_scsi.h +0 -7
@@ -43,13 +43,6 @@#define IOBASE_SUN3_VMESCSI 0xff200000 -static int sun3scsi_abort (struct scsi_cmnd *); -static int sun3scsi_detect (struct scsi_host_template *); -static const char *sun3scsi_info (struct Scsi_Host *); -static int sun3scsi_bus_reset (struct scsi_cmnd *); -static int sun3scsi_queue_command (struct Scsi_Host *,struct scsi_cmnd *); -static int sun3scsi_release (struct Scsi_Host *); -#ifndef CMD_PER_LUN #define CMD_PER_LUN 2#endif
drivers/scsi/t128.h +0 -6
@@ -88,12 +88,6 @@#define T_DATA_REG_OFFSET 0x1e00/* rw 512 bytes long */ #ifndef ASM -static int t128_abort (struct scsi_cmnd *); -static int t128_biosparam (struct scsi_device *,struct block_device *, -sector_t ,int *); -static int t128_detect (struct scsi_host_template *); -static int t128_queue_command (struct Scsi_Host *,struct scsi_cmnd *); -static int t128_bus_reset (struct scsi_cmnd *);#ifndef CMD_PER_LUN #define CMD_PER_LUN 2
drivers/scsi/atari_scsi.c +0 -5
@@ -181,12 +181,7 @@ static inline void DISABLE_IRQ(void)/***************************** Prototypes *****************************/ #ifdef REAL_DMA -static int scsi_dma_is_ignored_buserr (unsigned char dma_stat);static void atari_scsi_fetch_restbytes (void ); -static long atari_scsi_dma_residual (struct Scsi_Host *instance); -static int falcon_classify_cmd (Scsi_Cmnd *cmd); -static unsigned long atari_dma_xfer_len (unsigned long wanted_len, -Scsi_Cmnd *cmd,int write_flag);#endif static irqreturn_t scsi_tt_intr (int irq,void *dummy);static irqreturn_t scsi_falcon_intr (int irq,void *dummy);
PATCH 6/29 ncr5380: Remove more useless prototypes
In reply to Finn ThainMake 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
--- 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(-)
drivers/scsi/NCR5380.h +0 -8
@@ -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 )
drivers/scsi/dtc.c +3 -4
@@ -219,10 +219,6 @@ static int __init dtc_detect(struct scsivoid __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,
drivers/scsi/pas16.c +3 -4
@@ -390,10 +390,6 @@ static int __init pas16_detect(struct scunsigned short io_port;int count; - tpnt->proc_name ="pas16" ; - tpnt->show_info = pas16_show_info; - tpnt->write_info = pas16_write_info; -if (pas16_addr !=0 ) { overrides[0 ].io_port = pas16_addr;/*
@@ -622,6 +618,9 @@ static struct scsi_host_template driver_ .name = "Pro Audio Spectrum-16 SCSI", .detect = pas16_detect, .release = pas16_release, + .proc_name = "pas16", + .show_info = pas16_show_info, + .write_info = pas16_write_info, .queuecommand = pas16_queue_command, .eh_abort_handler = pas16_abort, .eh_bus_reset_handler = pas16_bus_reset,
drivers/scsi/t128.c +3 -4
@@ -201,10 +201,6 @@ static int __init t128_detect(struct scsvoid __iomem *p;int sig, count; - tpnt->proc_name ="t128" ; - tpnt->show_info = t128_show_info; - tpnt->write_info = t128_write_info; -for (count =0 ; current_override <NO_OVERRIDES ; ++current_override) { base =0 ; p =NULL ;
@@ -435,6 +431,9 @@ static struct scsi_host_template driver_ .name = "Trantor T128/T128F/T228", .detect = t128_detect, .release = t128_release, + .proc_name = "t128", + .show_info = t128_show_info, + .write_info = t128_write_info, .queuecommand = t128_queue_command, .eh_abort_handler = t128_abort, .eh_bus_reset_handler = t128_bus_reset,
drivers/scsi/atari_NCR5380.c +2 -1
@@ -769,7 +769,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cmseq_printf (m,"\n" ); } -static int NCR5380_show_info (struct seq_file *m,struct Scsi_Host *instance) +static int __maybe_unused NCR5380_show_info (struct seq_file *m, +struct Scsi_Host *instance) {struct NCR5380_hostdata *hostdata;Scsi_Cmnd *ptr;
drivers/scsi/sun3_NCR5380.c +2 -1
@@ -715,7 +715,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cmseq_printf (m,"\n" ); } -static int NCR5380_show_info (struct seq_file *m,struct Scsi_Host *instance) +static int __maybe_unused NCR5380_show_info (struct seq_file *m, +struct Scsi_Host *instance) {struct NCR5380_hostdata *hostdata;Scsi_Cmnd *ptr;
drivers/scsi/atari_scsi.c +37 -39
88 lines not on this page · raw message
PATCH 7/29 ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
In reply to Finn ThainBoth 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.
--- 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(-)
drivers/scsi/atari_NCR5380.c +5 -14
@@ -316,10 +316,6 @@ static struct scsi_host_template *the_te* important: the tag bit must be cleared before 'nr_allocated' is decreased. */ -/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */ -#undef TAG_NONE -#define TAG_NONE 0xff - typedef struct { DECLARE_BITMAP(allocated, MAX_TAGS); int nr_allocated;
@@ -1114,9 +1110,7 @@ static void NCR5380_main(struct work_str#ifdef SUPPORT_TAGS cmd_get_tag (tmp, tmp->cmnd[0 ] !=REQUEST_SENSE );#endif -if (!NCR5380_select (instance, tmp, - (tmp->cmnd[0 ] ==REQUEST_SENSE ) ?TAG_NONE : -TAG_NEXT )) { +if (!NCR5380_select (instance, tmp)) { falcon_dont_release--;/* release if target did not response! */ falcon_release_lock_if_possible (hostdata);
@@ -1347,17 +1341,14 @@ static void collect_stats(struct NCR5380#endif /* -* Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, -* int tag); +* Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd) * * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, * including ARBITRATION, SELECTION, and initial message out for * IDENTIFY and queue messages. * * Inputs : instance - instantiation of the 5380 driver on which this -* target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for -* new tag, TAG_NONE for untagged queueing, otherwise set to the tag for -* the command that is presently connected. +* target lives, cmd - SCSI command to execute. * * Returns : -1 if selection could not execute for some reason, * 0 if selection succeeded or failed because the target
@@ -1377,7 +1368,7 @@ static void collect_stats(struct NCR5380* cmd->result host byte set to DID_BAD_TARGET. */ -static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd *cmd,int tag) +static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd *cmd) {SETUP_HOSTDATA (instance);unsigned char tmp[3 ], phase;
@@ -2754,7 +2745,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd)local_irq_restore (flags);dprintk (NDEBUG_ABORT ,"scsi%d: aborting disconnected command.\n" ,HOSTNO ); -if (NCR5380_select (instance, cmd, (int )cmd->tag)) +if (NCR5380_select (instance, cmd))return FAILED ;dprintk (NDEBUG_ABORT ,"scsi%d: nexus reestablished.\n" ,HOSTNO );
drivers/scsi/sun3_NCR5380.c +5 -14
@@ -305,10 +305,6 @@ static struct scsi_host_template *the_te* important: the tag bit must be cleared before 'nr_allocated' is decreased. */ -/* -1 for TAG_NONE is not possible with unsigned char cmd->tag */ -#undef TAG_NONE -#define TAG_NONE 0xff -/* For the m68k, the number of bits in 'allocated' must be a multiple of 32! */ #if (MAX_TAGS %32 ) !=0 #error "MAX_TAGS must be a multiple of 32!"
@@ -1054,9 +1050,7 @@ static void NCR5380_main (struct work_st#ifdef SUPPORT_TAGS cmd_get_tag ( tmp, tmp->cmnd[0 ] !=REQUEST_SENSE );#endif -if (!NCR5380_select (instance, tmp, - (tmp->cmnd[0 ] ==REQUEST_SENSE ) ?TAG_NONE : -TAG_NEXT )) { +if (!NCR5380_select (instance, tmp)) {break ; }else {local_irq_disable ();
@@ -1289,16 +1283,14 @@ static void collect_stats(struct NCR5380/* * Function : int NCR5380_select(struct Scsi_Host *instance, -* struct scsi_cmnd *cmd, int tag); +* struct scsi_cmnd *cmd) * * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, * including ARBITRATION, SELECTION, and initial message out for * IDENTIFY and queue messages. * * Inputs : instance - instantiation of the 5380 driver on which this -* target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for -* new tag, TAG_NONE for untagged queueing, otherwise set to the tag for -* the command that is presently connected. +* target lives, cmd - SCSI command to execute. * * Returns : -1 if selection could not execute for some reason, * 0 if selection succeeded or failed because the target
@@ -1318,8 +1310,7 @@ static void collect_stats(struct NCR5380* cmd->result host byte set to DID_BAD_TARGET. */ -static int NCR5380_select (struct Scsi_Host *instance,struct scsi_cmnd *cmd, -int tag) +static int NCR5380_select (struct Scsi_Host *instance,struct scsi_cmnd *cmd) {SETUP_HOSTDATA (instance);unsigned char tmp[3 ], phase;
@@ -2733,7 +2724,7 @@ static int NCR5380_abort(struct scsi_cmnlocal_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 );
drivers/scsi/NCR5380.c +13 -16
@@ -1072,14 +1072,14 @@ static void NCR5380_main(struct work_str hostdata->selecting =NULL ;/* RvC: have to preset this to indicate a new command is being performed */ -if (!NCR5380_select (instance, tmp, -/* -* REQUEST SENSE commands are issued without tagged -* queueing, even on SCSI-II devices because the -* contingent allegiance condition exists for the -* entire unit. -*/ - (tmp->cmnd[0 ] ==REQUEST_SENSE ) ?TAG_NONE :TAG_NEXT )) { +/* +* REQUEST SENSE commands are issued without tagged +* queueing, even on SCSI-II devices because the +* contingent allegiance condition exists for the +* entire unit. +*/ + +if (!NCR5380_select (instance, tmp)) {break ; }else {LIST (tmp, hostdata->issue_queue);
@@ -1096,7 +1096,7 @@ static void NCR5380_main(struct work_strif (hostdata->selecting) { tmp = (Scsi_Cmnd *) hostdata->selecting;/* Selection will drop and retake the lock */ -if (!NCR5380_select (instance, tmp, (tmp->cmnd[0 ] ==REQUEST_SENSE ) ?TAG_NONE :TAG_NEXT )) { +if (!NCR5380_select (instance, tmp)) {/* Ok ?? */ }else {/* RvC: device failed, so we wait a long time
@@ -1245,17 +1245,14 @@ static void collect_stats(struct NCR5380/* -* Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd, -* int tag); +* Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd) * * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, * including ARBITRATION, SELECTION, and initial message out for * IDENTIFY and queue messages. * * Inputs : instance - instantiation of the 5380 driver on which this -* target lives, cmd - SCSI command to execute, tag - set to TAG_NEXT for -* new tag, TAG_NONE for untagged queueing, otherwise set to the tag for -* the command that is presently connected. +* target lives, cmd - SCSI command to execute. * * Returns : -1 if selection could not execute for some reason, * 0 if selection succeeded or failed because the target
@@ -1277,7 +1274,7 @@ static void collect_stats(struct NCR5380* Locks: caller holds hostdata lock in IRQ mode */ -static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd * cmd,int tag) +static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd *cmd) {NCR5380_local_declare ();struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata;
@@ -2773,7 +2770,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmdif (cmd == tmp) {dprintk (NDEBUG_ABORT ,"scsi%d : aborting disconnected command.\n" , instance->host_no); -if (NCR5380_select (instance, cmd, (int ) cmd->tag)) +if (NCR5380_select (instance, cmd))return FAILED ;dprintk (NDEBUG_ABORT ,"scsi%d : nexus reestablished.\n" , instance->host_no);
drivers/scsi/NCR5380.h +4 -7
@@ -224,14 +224,11 @@#define DISCONNECT_LONG 2/* -* These are "special" values for the tag parameter passed to NCR5380_select. +* "Special" value for the (unsigned char) command tag, to indicate +* I_T_L nexus instead of I_T_L_Q. */ -#define TAG_NEXT -1/* Use next free tag */ -#define TAG_NONE -2/* -* Establish I_T_L nexus instead of I_T_L_Q -* even on SCSI-II devices. -*/ +#define TAG_NONE 0xff/* * These are "special" values for the irq and dma_channel fields of the
@@ -323,7 +320,7 @@ static irqreturn_t NCR5380_intr(int irq,static void NCR5380_main (struct work_struct *work);static void __maybe_unused NCR5380_print_options (struct Scsi_Host *instance);static void NCR5380_reselect (struct Scsi_Host *instance); -static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd * cmd,int tag); +static int NCR5380_select (struct Scsi_Host *instance,Scsi_Cmnd *cmd);#if defined(PSEUDO_DMA ) || defined(REAL_DMA ) || defined(REAL_DMA_POLL )static int NCR5380_transfer_dma (struct Scsi_Host *instance,unsigned char *phase,int *count,unsigned char **data);#endif
Geert Uytterhoeven
maintainerRe: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 line 229
Quoted 10 lines · Finn Thain
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 renamed from drivers/scsi/NCR5380.h 2014-10-02 16:55:55.000000000 +1000 +2
-1@@ -224,14 +224,11 @@ #define DISCONNECT_LONG 2 /* - * These are "special" values for the tag parameter passed to NCR5380_select. + * "Special" value for the (unsigned char) command tag, to indicate + * I_T_L nexus instead of I_T_L_Q. */
I guess the above comment can just be removed instead of changed, as the I_T_L nexus definitions below are removed?
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 static irqreturn_t NCR5380_intr(int irq,
Quoted 10 lines
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 renamed from drivers/scsi/NCR5380.h 2014-10-02 16:55:55.000000000 +1000 +1
-5-#define TAG_NEXT -1 /* Use next free tag */ -#define TAG_NONE -2 /* - * Establish I_T_L nexus instead of I_T_L_Q - * even on SCSI-II devices. - */ +#define TAG_NONE 0xff /* * These are "special" values for the irq and dma_channel fields of the@@ -323,7 +320,7 @@ static irqreturn_t NCR5380_intr(int irq,
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
Quoted 6 lines · Geert Uytterhoeven
Quoted 5 lines · Finn Thain
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 renamed from drivers/scsi/NCR5380.h 2014-10-02 16:55:55.000000000 +1000 +0
-0@@ -224,14 +224,11 @@ #define DISCONNECT_LONG 2
Quoted 8 lines
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 line 229
Quoted 5 lines
drivers/scsi/NCR5380.h 2014-10-02 16:55:57.000000000 +1000 renamed from drivers/scsi/NCR5380.h 2014-10-02 16:55:55.000000000 +1000 +2
-1/* - * These are "special" values for the tag parameter passed to NCR5380_select. + * "Special" value for the (unsigned char) command tag, to indicate + * I_T_L nexus instead of I_T_L_Q. */I guess the above comment can just be removed instead of changed, as the
I_T_Lnexus definitions below are removed?
When I wrote this patch I didn't realize that the tag member in struct scsi_cmnd was going to be removed in favour of cmd->request.tag. I will rewrite this patch to remove all of the cmd->tag stuff.
When I sent this patch I knew I'd have to revise it, but I wanted to get the entire series out there anyway to avoid further duplication of effort.
Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
In reply to Finn ThainQuoted 10 lines · Finn Thain
Both
atari_NCR5380.candsun3_NCR5380.ccore drivers #undefTAG_NONEand then redefine it. But the original definition is unused becauseNCR5380.clacks support for tagged queueing. So just define it once.The
TAG_NEXTmacro only appears in the arguments toNCR5380_select()calls. But that routine doesn't use its tag argument as the tag was already assigned inNCR5380_main(). So remove the unused argument and the macro.Signed-off-by Finn Thain <[email protected]>
Why not use 'SCSI_NO_TAG' from include/scsi/scsi_tcq.h ?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH 07/29] ncr5380: Cleanup TAG_NEXT and TAG_NONE macros
Quoted 5 lines · Hannes Reinecke
Quoted 4 lines · Finn Thain
Both
atari_NCR5380.candsun3_NCR5380.ccore drivers #undefTAG_NONEand then redefine it. But the original definition is unused becauseNCR5380.clacks support for tagged queueing. So just define it once.
Quoted 8 lines
Quoted 7 lines
The
TAG_NEXTmacro only appears in the arguments toNCR5380_select()calls. But that routine doesn't use its tag argument as the tag was already assigned inNCR5380_main(). So remove the unused argument and the macro.Signed-off-by Finn Thain <[email protected]>Why not use '
SCSI_NO_TAG' frominclude/scsi/scsi_tcq.h?
I didn't use SCSI_NO_TAG because it seemed to relate to the int tag member in struct request and not the unsigned char tag member in struct scsi_cmnd.
In light of the plan to remove the tag member from struct scsi_cmnd, I don't know what to do with this patch. It doesn't really help with that plan so I figured it would be NAK'd.
I haven't given any thought to the problem of converting drivers to block layer tags (which might involve SCSI_NO_TAG, I guess). I have too much other work in progress. That's why I suggested commenting out #define SUPPORT_TAGS until they could be converted.
PATCH 8/29 ncr5380: Remove redundant AUTOSENSE macro
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-AUTOSENSE-macro
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/6cff966e/attachment.ksh>
PATCH 9/29 ncr5380: Remove duplicate comments
In reply to Finn ThainThe 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.
--- 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(-)
drivers/scsi/dtc.c +1 -16
@@ -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.
drivers/scsi/g_NCR5380.c +0 -16
@@ -20,18 +20,6 @@* Thomas Sailer, [email protected] * * 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.
drivers/scsi/pas16.c +0 -31
@@ -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
drivers/scsi/sun3_scsi.c +0 -21
@@ -22,27 +22,6 @@* Copyright 1995, Russell King * * ALPHA RELEASE 1. -* -* For more information, please consult -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 -*/ - - -/* -* This is from mac_scsi.h, but hey, maybe this is useful for Sun3 too! :) -* -* Options : -* -* PARITY - enable parity checking. Not supported. */ #include <linux/types.h>
drivers/scsi/t128.c +0 -23
@@ -23,32 +23,9 @@* 5415 Randall Place * Fremont, CA 94538 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910 -* -* and -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ /* -* Options : -* PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance -* increase compared to polled I/O. -* -* PARITY - enable parity checking. Not supported. -* -* UNSAFE - leave interrupts enabled during pseudo-DMA transfers. You -* only really want to use this if you're having a problem with -* dropped characters during high speed communications, and even -* then, you're going to be better off twiddling with transfersize. -* * The card is detected and initialized in one of several ways : * 1. Autoprobe (default) - since the board is memory mapped, * a BIOS signature is scanned for to locate the registers.
drivers/scsi/dtc.h +0 -16
@@ -7,22 +7,6 @@* +1 (303) 440-4894 * * DISTRIBUTION RELEASE 2. -* -* For more information, please consult -* -* -* -* and -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #ifndef DTC3280_H
drivers/scsi/g_NCR5380.h +0 -12
@@ -11,18 +11,6 @@* [email protected] * * ALPHA RELEASE 1. -* -* For more information, please consult -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #ifndef GENERIC_NCR5380_H
drivers/scsi/mac_scsi.c +0 -12
@@ -11,18 +11,6 @@* Copyright 1995, Russell King * * ALPHA RELEASE 1. -* -* For more information, please consult -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #include <linux/types.h>
drivers/scsi/mac_scsi.h +0 -12
@@ -8,18 +8,6 @@* +1 (303) 440-4894 * * ALPHA RELEASE 1. -* -* For more information, please consult -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #ifndef MAC_NCR5380_H
drivers/scsi/pas16.h +0 -12
@@ -18,18 +18,6 @@* Media Vision * (510) 770-8600 * (800) 348-7116 -* -* and -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */
drivers/scsi/sun3_scsi.h +0 -12
@@ -15,18 +15,6 @@* +1 (303) 440-4894 * * ALPHA RELEASE 1. -* -* For more information, please consult -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #ifndef SUN3_SCSI_H
drivers/scsi/t128.h +0 -12
@@ -20,18 +20,6 @@* 5415 Randall Place * Fremont, CA 94538 * 1+ (415) 770-1400, FAX 1+ (415) 770-9910 -* -* and -* -* NCR 5380 Family -* SCSI Protocol Controller -* Databook -* -* NCR Microelectronics -* 1635 Aeroplaza Drive -* Colorado Springs, CO 80916 -* 1+ (719) 578-3400 -* 1+ (800) 334-5454 */ #ifndef T128_H
PATCH 10/29 ncr5380: Fix SCSI_IRQ_NONE bugs
In reply to Finn ThainOak scsi doesn't use any IRQ, but it sets irq = IRQ_NONE rather than SCSI_IRQ_NONE. Problem is, the core NCR5380 driver expects SCSI_IRQ_NONE if it is to issue IDENTIFY commands that prevent target disconnection.
Other drivers, when they can't get an IRQ or can't use one, will set host->irq = SCSI_IRQ_NONE (that is, 255). But when they exit they will attempt to free IRQ 255 which was never requested.
Fix these bugs by using IRQ_NONE in place of SCSI_IRQ_NONE. This means IRQ 0 is no longer probed by ISA drivers but I don't think this matters.
Setting IRQ = 255 for these ISA drivers is understood to mean no IRQ. This remains supported so as to avoid breaking existing ISA setups (which can be difficult to get working) and because existing documentation (SANE, TLDP etc) describes this usage for the ISA NCR5380 driver options.
---
The are whitespace issues with this code; it will be cleaned up in a later patch.
--- drivers/scsi/NCR5380.c | 12 ++++++------ drivers/scsi/NCR5380.h | 1 - drivers/scsi/dmx3191d.c | 7 ++++--- drivers/scsi/dtc.c | 22 +++++++++++++--------- drivers/scsi/g_NCR5380.c | 18 +++++++++++------- drivers/scsi/mac_scsi.c | 8 ++++---- drivers/scsi/pas16.c | 20 +++++++++++--------- drivers/scsi/sun3_scsi.c | 6 +++--- drivers/scsi/t128.c | 14 +++++++++----- 9 files changed, 61 insertions(+), 47 deletions(-)
drivers/scsi/dtc.c +13 -9
@@ -254,31 +254,35 @@ found:else instance->irq =NCR5380_probe_irq (instance,DTC_IRQS ); +/* Compatibility with documented NCR5380 kernel parameters */ +if (instance->irq ==255 ) + instance->irq =IRQ_NONE ; +#ifndef DONT_USE_INTR /* With interrupts enabled, it will sometimes hang when doing heavy * reads. So better not enable them until I finger it out. */ -if (instance->irq !=SCSI_IRQ_NONE ) +if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, dtc_intr,0 ,"dtc" , instance)) {printk (KERN_ERR "scsi%d : IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ; } -if (instance->irq ==SCSI_IRQ_NONE ) { +if (instance->irq ==IRQ_NONE ) {printk (KERN_WARNING "scsi%d : interrupts not enabled. for better interactive performance,\n" , instance->host_no);printk (KERN_WARNING "scsi%d : please jumper the board for a free IRQ.\n" , instance->host_no); }#else -if (instance->irq !=SCSI_IRQ_NONE ) +if (instance->irq !=IRQ_NONE )printk (KERN_WARNING "scsi%d : interrupts not used. Might as well not jumper it.\n" , instance->host_no); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ;#endif #if defined(DTCDEBUG ) && (DTCDEBUG &DTCDEBUG_INIT )printk ("scsi%d : irq = %d\n" , instance->host_no, instance->irq);#endif printk (KERN_INFO "scsi%d : at 0x%05X" , instance->host_no, (int ) instance->base); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk (" interrupts disabled" );else printk (" irq %d" , instance->irq);
@@ -350,7 +354,7 @@ static inline int NCR5380_pread(struct S i =0 ;NCR5380_read (RESET_PARITY_INTERRUPT_REG );NCR5380_write (MODE_REG ,MR_ENABLE_EOP_INTR |MR_DMA_MODE ); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )NCR5380_write (DTC_CONTROL_REG ,CSR_DIR_READ );else NCR5380_write (DTC_CONTROL_REG ,CSR_DIR_READ |CSR_INT_BASE );
@@ -401,7 +405,7 @@ static inline int NCR5380_pwrite(structNCR5380_read (RESET_PARITY_INTERRUPT_REG );NCR5380_write (MODE_REG ,MR_ENABLE_EOP_INTR |MR_DMA_MODE );/* set direction (write) */ -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )NCR5380_write (DTC_CONTROL_REG ,0 );else NCR5380_write (DTC_CONTROL_REG ,CSR_5380_INTR );
@@ -440,7 +444,7 @@ static int dtc_release(struct Scsi_Host {NCR5380_local_declare ();NCR5380_setup (shost); -if (shost->irq) +if (shost->irq !=IRQ_NONE )free_irq (shost->irq, shost);NCR5380_exit (shost);if (shost->io_port && shost->n_io_port)
drivers/scsi/pas16.c +11 -9
@@ -62,13 +62,11 @@* If you have problems with your card not being recognized, use * the LILO command line override. Try to get it recognized without * interrupts. Ie, for a board at the default 0x388 base port, -* boot: linux pas16=0x388,255 +* boot: linux pas16=0x388,0 * -* SCSI_IRQ_NONE (255) should be specified for no interrupt, +* IRQ_NONE (0) should be specified for no interrupt, * IRQ_AUTO (254) to autoprobe for an IRQ line if overridden * on the command line. -* -* (IRQ_AUTO == 254, SCSI_IRQ_NONE == 255 in NCR5380.h) */ #include <linux/module.h>
@@ -416,15 +414,19 @@ static int __init pas16_detect(struct scelse instance->irq =NCR5380_probe_irq (instance,PAS16_IRQS ); -if (instance->irq !=SCSI_IRQ_NONE ) +/* Compatibility with documented NCR5380 kernel parameters */ +if (instance->irq ==255 ) + instance->irq =IRQ_NONE ; + +if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, pas16_intr,0 ,"pas16" , instance)) {printk ("scsi%d : IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ; } -if (instance->irq ==SCSI_IRQ_NONE ) { +if (instance->irq ==IRQ_NONE ) {printk ("scsi%d : interrupts not enabled. for better interactive performance,\n" , instance->host_no);printk ("scsi%d : please jumper the board for a free IRQ.\n" , instance->host_no);/* Disable 5380 interrupts, leave drive params the same */
@@ -438,7 +440,7 @@ static int __init pas16_detect(struct scprintk ("scsi%d : at 0x%04x" , instance->host_no, (int ) instance->io_port); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk (" interrupts disabled" );else printk (" irq %d" , instance->irq);
@@ -568,7 +570,7 @@ static inline int NCR5380_pwrite (structstatic int pas16_release (struct Scsi_Host *shost) { -if (shost->irq) +if (shost->irq !=IRQ_NONE )free_irq (shost->irq, shost);NCR5380_exit (shost);if (shost->dma_channel !=0xff )
drivers/scsi/t128.c +9 -5
@@ -228,15 +228,19 @@ found:else instance->irq =NCR5380_probe_irq (instance,T128_IRQS ); -if (instance->irq !=SCSI_IRQ_NONE ) +/* Compatibility with documented NCR5380 kernel parameters */ +if (instance->irq ==255 ) + instance->irq =IRQ_NONE ; + +if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, t128_intr,0 ,"t128" , instance)) {printk ("scsi%d : IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ; } -if (instance->irq ==SCSI_IRQ_NONE ) { +if (instance->irq ==IRQ_NONE ) {printk ("scsi%d : interrupts not enabled. for better interactive performance,\n" , instance->host_no);printk ("scsi%d : please jumper the board for a free IRQ.\n" , instance->host_no); }
@@ -246,7 +250,7 @@ found:#endif printk ("scsi%d : at 0x%08lx" , instance->host_no, instance->base); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk (" interrupts disabled" );else printk (" irq %d" , instance->irq);
@@ -265,7 +269,7 @@ static int t128_release(struct Scsi_Host {NCR5380_local_declare ();NCR5380_setup (shost); -if (shost->irq) +if (shost->irq !=IRQ_NONE )free_irq (shost->irq, shost);NCR5380_exit (shost);if (shost->io_port && shost->n_io_port)
drivers/scsi/NCR5380.c +6 -6
@@ -574,12 +574,12 @@ static int __init __maybe_unused NCR5380int trying_irqs, i, mask;NCR5380_setup (instance); -for (trying_irqs = i =0 , mask =1 ; i <16 ; ++i, mask <<=1 ) +for (trying_irqs =0 , i =1 , mask =2 ; i <16 ; ++i, mask <<=1 )if ((mask & possible) && (request_irq (i, &probe_intr,0 ,"NCR-probe" ,NULL ) ==0 )) trying_irqs |= mask; timeout = jiffies + (250 *HZ /1000 ); - probe_irq =SCSI_IRQ_NONE ; + probe_irq =IRQ_NONE ;/* * A interrupt is triggered whenever BSY = false, SEL = true
@@ -596,13 +596,13 @@ static int __init __maybe_unused NCR5380NCR5380_write (OUTPUT_DATA_REG , hostdata->id_mask);NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE |ICR_ASSERT_DATA |ICR_ASSERT_SEL ); -while (probe_irq ==SCSI_IRQ_NONE &&time_before (jiffies, timeout)) +while (probe_irq ==IRQ_NONE &&time_before (jiffies, timeout))schedule_timeout_uninterruptible (1 );NCR5380_write (SELECT_ENABLE_REG ,0 );NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); -for (i =0 , mask =1 ; i <16 ; ++i, mask <<=1 ) +for (i =1 , mask =2 ; i <16 ; ++i, mask <<=1 )if (trying_irqs & mask)free_irq (i,NULL );
@@ -730,7 +730,7 @@ static int __maybe_unused NCR5380_show_iSPRINTF ("\nBase Addr: 0x%05lX " , (long ) instance->base);SPRINTF ("io_port: %04x " , (int ) instance->io_port); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )SPRINTF ("IRQ: None.\n" );else SPRINTF ("IRQ: %d.\n" , instance->irq);
@@ -1500,7 +1500,7 @@ part2: }dprintk (NDEBUG_SELECTION ,"scsi%d : target %d selected, going into MESSAGE OUT phase.\n" , instance->host_no, cmd->device->id); - tmp[0 ] =IDENTIFY (((instance->irq ==SCSI_IRQ_NONE ) ?0 :1 ), cmd->device->lun); + tmp[0 ] =IDENTIFY (((instance->irq ==IRQ_NONE ) ?0 :1 ), cmd->device->lun); len =1 ; cmd->tag =0 ;
drivers/scsi/NCR5380.h +0 -1
@@ -232,7 +232,6 @@* Scsi_Host structure */ -#define SCSI_IRQ_NONE 255#define DMA_NONE 255#define IRQ_AUTO 254#define DMA_AUTO 254
drivers/scsi/dmx3191d.c +4 -3
@@ -100,7 +100,7 @@ static int dmx3191d_probe_one(struct pci*/ printk (KERN_WARNING "dmx3191: IRQ %d not available - " "switching to polled mode.\n" , pdev->irq); - shost->irq =SCSI_IRQ_NONE ; + shost->irq =IRQ_NONE ; }pci_set_drvdata (pdev, shost);
@@ -113,7 +113,8 @@ static int dmx3191d_probe_one(struct pcireturn 0 ; out_free_irq: -free_irq (shost->irq, shost); +if (shost->irq !=IRQ_NONE ) +free_irq (shost->irq, shost); out_release_region:release_region (io,DMX3191D_REGION_LEN ); out_disable_device:
@@ -130,7 +131,7 @@ static void dmx3191d_remove_one(struct pNCR5380_exit (shost); -if (shost->irq !=SCSI_IRQ_NONE ) +if (shost->irq !=IRQ_NONE )free_irq (shost->irq, shost);release_region (shost->io_port,DMX3191D_REGION_LEN );pci_disable_device (pdev);
drivers/scsi/g_NCR5380.c +11 -7
@@ -312,7 +312,7 @@ static int __init generic_NCR5380_detectif (pnp_irq_valid (dev,0 )) overrides[count].irq =pnp_irq (dev,0 );else - overrides[count].irq =SCSI_IRQ_NONE ; + overrides[count].irq =IRQ_NONE ;if (pnp_dma_valid (dev,0 )) overrides[count].dma =pnp_dma (dev,0 );else
@@ -432,20 +432,24 @@ static int __init generic_NCR5380_detectelse instance->irq =NCR5380_probe_irq (instance,0xffff ); -if (instance->irq !=SCSI_IRQ_NONE ) +/* Compatibility with documented NCR5380 kernel parameters */ +if (instance->irq ==255 ) + instance->irq =IRQ_NONE ; + +if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, generic_NCR5380_intr,0 ,"NCR5380" , instance)) {printk (KERN_WARNING "scsi%d : IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ; } -if (instance->irq ==SCSI_IRQ_NONE ) { +if (instance->irq ==IRQ_NONE ) {printk (KERN_INFO "scsi%d : interrupts not enabled. for better interactive performance,\n" , instance->host_no);printk (KERN_INFO "scsi%d : please jumper the board for a free IRQ.\n" , instance->host_no); } printk(KERN_INFO "scsi%d : at " STRVAL(NCR5380_map_name) " 0x%x", instance->host_no, (unsigned int) instance->NCR5380_instance_name); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk (" interrupts disabled" );else printk (" irq %d" , instance->irq);
@@ -486,7 +490,7 @@ static int generic_NCR5380_release_resouNCR5380_local_declare ();NCR5380_setup (instance); -if (instance->irq !=SCSI_IRQ_NONE ) +if (instance->irq !=IRQ_NONE )free_irq (instance->irq, instance);NCR5380_exit (instance);
@@ -796,7 +800,7 @@ static int generic_NCR5380_show_info(strPRINTP ("NO NCR53C400 driver extensions\n" );#endif PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name); -if (scsi_ptr->irq ==SCSI_IRQ_NONE ) +if (scsi_ptr->irq ==IRQ_NONE )PRINTP ("no interrupt\n" );else PRINTP ("on interrupt %d\n" ANDP scsi_ptr->irq);
drivers/scsi/mac_scsi.c +4 -4
@@ -229,15 +229,15 @@ int __init macscsi_detect(struct scsi_ho instance->n_io_port =255 ; -if (instance->irq !=SCSI_IRQ_NONE ) +if (instance->irq !=IRQ_NONE )if (request_irq (instance->irq, NCR5380_intr,0 ,"ncr5380" , instance)) {printk (KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ; }printk (KERN_INFO "scsi%d: generic 5380 at port %lX irq" , instance->host_no, instance->io_port); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk (KERN_INFO "s disabled" );else printk (KERN_INFO " %d" , instance->irq);
@@ -252,7 +252,7 @@ int __init macscsi_detect(struct scsi_hoint macscsi_release (struct Scsi_Host *shpnt) { -if (shpnt->irq !=SCSI_IRQ_NONE ) +if (shpnt->irq !=IRQ_NONE )free_irq (shpnt->irq, shpnt);NCR5380_exit (shpnt);
drivers/scsi/sun3_scsi.c +3 -3
@@ -278,7 +278,7 @@ static int __init sun3scsi_detect(struct#ifndef REAL_DMA printk ("scsi%d: IRQ%d not free, interrupts disabled\n" , instance->host_no, instance->irq); - instance->irq =SCSI_IRQ_NONE ; + instance->irq =IRQ_NONE ;#else printk ("scsi%d: IRQ%d not free, bailing out\n" , instance->host_no, instance->irq);
@@ -288,7 +288,7 @@ static int __init sun3scsi_detect(structpr_info ("scsi%d: %s at port %lX irq" , instance->host_no, tpnt->proc_name, instance->io_port); -if (instance->irq ==SCSI_IRQ_NONE ) +if (instance->irq ==IRQ_NONE )printk ("s disabled" );else printk (" %d" , instance->irq);
@@ -325,7 +325,7 @@ static int __init sun3scsi_detect(structstatic int sun3scsi_release (struct Scsi_Host *shpnt) { -if (shpnt->irq !=SCSI_IRQ_NONE ) +if (shpnt->irq !=IRQ_NONE )free_irq (shpnt->irq, shpnt);iounmap ((void *)sun3_scsi_regp);
Geert Uytterhoeven
maintainerRe: [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs
Quoted 10 lines · Finn Thain
Oak scsi doesn't use any IRQ, but it sets irq =
IRQ_NONErather thanSCSI_IRQ_NONE. Problem is, the core NCR5380 driver expectsSCSI_IRQ_NONEif it is to issue IDENTIFY commands that prevent target disconnection.Other drivers, when they can't get an IRQ or can't use one, will set
host->irq=SCSI_IRQ_NONE(that is, 255). But when they exit they will attempt to free IRQ 255 which was never requested.Fix these bugs by using
IRQ_NONEin place ofSCSI_IRQ_NONE. This means IRQ 0 is no longer probed by ISA drivers but I don't think this matters.
IRQ_NONE is part of enum irqreturn. I guess you meant NO_IRQ?
But NO_IRQ is deprecated, and not available on all architectures. The recommended way is to just use 0, like in "if (instance->irq) ...".
Note that some drivers do
#ifndef NO_IRQ
#define NO_IRQ (-1)
#endif
and others do
#ifndef NO_IRQ
#define NO_IRQ 0
#endif
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 10/29] ncr5380: Fix SCSI_IRQ_NONE bugs
Quoted 24 lines · Geert Uytterhoeven
Quoted 10 lines · Finn Thain
Oak scsi doesn't use any IRQ, but it sets irq =
IRQ_NONErather thanSCSI_IRQ_NONE. Problem is, the core NCR5380 driver expectsSCSI_IRQ_NONEif it is to issue IDENTIFY commands that prevent target disconnection.Other drivers, when they can't get an IRQ or can't use one, will set
host->irq=SCSI_IRQ_NONE(that is, 255). But when they exit they will attempt to free IRQ 255 which was never requested.Fix these bugs by using
IRQ_NONEin place ofSCSI_IRQ_NONE. This means IRQ 0 is no longer probed by ISA drivers but I don't think this matters.
IRQ_NONEis part of enum irqreturn. I guess you meantNO_IRQ?But
NO_IRQis deprecated, and not available on all architectures. The recommended way is to just use 0, like in "if (instance->irq) ...".Note that some drivers do
#ifndef
NO_IRQ
#defineNO_IRQ(-1)
#endif
Quoted 6 lines
and others do
#ifndef
NO_IRQ
#defineNO_IRQ0
#endif
Well, the question becomes, is it better to replace SCSI_IRQ_NONE with 0 or with NO_IRQ?
I guess drivers use #ifndef in case the architecture brings its own definition of NO_IRQ (presumably because it can't use 0).
Since NCR5380 drivers cover a variety of architectures (ARM, m68k, ISA, PCI...) it seems that the more prudent option is,
#ifndef NO_IRQ
#define NO_IRQ 0
#endif
PATCH 11/29 ncr5380: Remove NCR5380_STATS
In reply to Finn ThainThe 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.
--- 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(-)
drivers/scsi/NCR5380.c +0 -64
@@ -833,18 +833,6 @@ static int NCR5380_init(struct Scsi_HostINIT_DELAYED_WORK (&hostdata->coroutine, NCR5380_main); -#ifdef NCR5380_STATS -for (i =0 ; i <8 ; ++i) { - hostdata->time_read[i] =0 ; - hostdata->time_write[i] =0 ; - hostdata->bytes_read[i] =0 ; - hostdata->bytes_write[i] =0 ; - } - hostdata->timebase =0 ; - hostdata->pendingw =0 ; - hostdata->pendingr =0 ; -#endif -/* The CHECK code seems to break the 53C400. Will check it later maybe */ if (flags &FLAG_NCR53C400 ) hostdata->flags =FLAG_HAS_LAST_BYTE_SENT | flags;
@@ -943,25 +931,6 @@ static int NCR5380_queue_command_lck(Scs }#endif /* (NDEBUG & NDEBUG_NO_WRITE) */ -#ifdef NCR5380_STATS -switch (cmd->cmnd[0 ]) { -case WRITE : -case WRITE_6 : -case WRITE_10 : - hostdata->time_write[cmd->device->id] -= (jiffies - hostdata->timebase); - hostdata->bytes_write[cmd->device->id] +=scsi_bufflen (cmd); - hostdata->pendingw++; -break ; -case READ : -case READ_6 : -case READ_10 : - hostdata->time_read[cmd->device->id] -= (jiffies - hostdata->timebase); - hostdata->bytes_read[cmd->device->id] +=scsi_bufflen (cmd); - hostdata->pendingr++; -break ; - } -#endif -/* * We use the host_scribble field as a pointer to the next command * in a queue
@@ -1206,35 +1175,6 @@ static irqreturn_t NCR5380_intr(int dumm#endif -/** -* collect_stats - collect stats on a scsi command -* @hostdata: adapter -* @cmd: command being issued -* -* Update the statistical data by parsing the command in question -*/ - -static void collect_stats (struct NCR5380_hostdata *hostdata,Scsi_Cmnd * cmd) -{ -#ifdef NCR5380_STATS -switch (cmd->cmnd[0 ]) { -case WRITE : -case WRITE_6 : -case WRITE_10 : - hostdata->time_write[scmd_id (cmd)] += (jiffies - hostdata->timebase); - hostdata->pendingw--; -break ; -case READ : -case READ_6 : -case READ_10 : - hostdata->time_read[scmd_id (cmd)] += (jiffies - hostdata->timebase); - hostdata->pendingr--; -break ; - } -#endif -} - -/* * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd) *
@@ -1463,7 +1403,6 @@ part2:return -1 ; } cmd->result =DID_BAD_TARGET <<16 ; -collect_stats (hostdata, cmd); cmd->scsi_done (cmd);NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);dprintk (NDEBUG_SELECTION ,"scsi%d : target did not respond within 250ms\n" , instance->host_no);
@@ -2215,7 +2154,6 @@ static void NCR5380_information_transfer cmd->next_link->tag = cmd->tag; cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );dprintk (NDEBUG_LINKED ,"scsi%d : target %d lun %d linked request done, calling scsi_done().\n" , instance->host_no, cmd->device->id, cmd->device->lun); -collect_stats (hostdata, cmd); cmd->scsi_done (cmd); cmd = hostdata->connected;break ;
@@ -2267,7 +2205,6 @@ static void NCR5380_information_transfer hostdata->issue_queue = (Scsi_Cmnd *) cmd;dprintk (NDEBUG_QUEUES ,"scsi%d : REQUEST SENSE added to head of issue queue\n" , instance->host_no); }else { -collect_stats (hostdata, cmd); cmd->scsi_done (cmd); }
@@ -2414,7 +2351,6 @@ static void NCR5380_information_transfer hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun); hostdata->connected =NULL ; cmd->result =DID_ERROR <<16 ; -collect_stats (hostdata, cmd); cmd->scsi_done (cmd);NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);return ;
drivers/scsi/NCR5380.h +0 -9
@@ -268,15 +268,6 @@ struct NCR5380_hostdata {int select_time;/* timer in select for target response */ volatile Scsi_Cmnd *selecting;struct delayed_work coroutine;/* our co-routine */ -#ifdef NCR5380_STATS -unsigned timebase;/* Base for time calcs */ -long time_read[8 ];/* time to do reads */ -long time_write[8 ];/* time to do writes */ -unsigned long bytes_read[8 ];/* bytes read */ -unsigned long bytes_write[8 ];/* bytes written */ -unsigned pendingr; -unsigned pendingw; -#endif struct scsi_eh_save ses; };
drivers/scsi/atari_NCR5380.c +0 -65
101 lines not on this page · raw message
drivers/scsi/g_NCR5380.c +0 -45
63 lines not on this page · raw message
drivers/scsi/sun3_NCR5380.c +0 -69
105 lines not on this page · raw message
PATCH 12/29 ncr5380: Cleanup host info() methods
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-info-methods
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/51209ff3/attachment.ksh>
Geert Uytterhoeven
maintainerPATCH 12/29 ncr5380: Cleanup host info() methods
Quoted 5 lines · Finn Thain
(quoted diff) +5
-0+static void prepare_info(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + snprintf(hostdata->info, sizeof(hostdata->info),
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+ ""); + hostdata->info[sizeof(hostdata->info) - 1] = '\0';
snprintf() will make sure the string is zero-terminated, so doing this manually is not needed.
This applies to all three occurrences.
Quoted 1 line
}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 13/29 ncr5380: Move static PDMA spin counters to host data
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-move-pdma-spin-counters
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/b6a4c33e/attachment.ksh>
PATCH 14/29 ncr5380: Remove pointless compiler command line override macros
In reply to Finn ThainCompile-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.
--- 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(-)
drivers/scsi/mac_scsi.c +9 -10
@@ -177,13 +177,12 @@ int __init macscsi_detect(struct scsi_hoif (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 };
drivers/scsi/mac_scsi.h +0 -16
@@ -17,22 +17,6 @@#ifndef ASM -#ifndef CMD_PER_LUN -#define CMD_PER_LUN 2 -#endif - -#ifndef CAN_QUEUE -#define CAN_QUEUE 16 -#endif - -#ifndef SG_TABLESIZE -#define SG_TABLESIZE SG_NONE -#endif - -#ifndef USE_TAGGED_QUEUING -#define USE_TAGGED_QUEUING 0 -#endif -#include <scsi/scsicam.h> #define NCR5380_implementation_fields/* none */
drivers/scsi/sun3_scsi.c +10 -10
@@ -198,12 +198,12 @@ static int __init sun3scsi_detect(struct#endif /* setup variables */ - tpnt->can_queue = - (setup_can_queue >0 ) ? setup_can_queue :CAN_QUEUE ; - tpnt->cmd_per_lun = - (setup_cmd_per_lun >0 ) ? setup_cmd_per_lun :CMD_PER_LUN ; - tpnt->sg_tablesize = - (setup_sg_tablesize >=0 ) ? setup_sg_tablesize :SG_TABLESIZE ; +if (setup_can_queue >0 ) + tpnt->can_queue = setup_can_queue; +if (setup_cmd_per_lun >0 ) + tpnt->cmd_per_lun = setup_cmd_per_lun; +if (setup_sg_tablesize >=0 ) + tpnt->sg_tablesize = setup_sg_tablesize;if (setup_hostid >=0 ) tpnt->this_id = setup_hostid;
@@ -257,7 +257,7 @@ static int __init sun3scsi_detect(struct#endif #ifdef SUPPORT_TAGS if (setup_use_tagged_queuing <0 ) - setup_use_tagged_queuing =USE_TAGGED_QUEUING ; + setup_use_tagged_queuing =1 ;#endif instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata ));
@@ -683,10 +683,10 @@ static struct scsi_host_template driver_ .queuecommand = sun3scsi_queue_command, .eh_abort_handler = sun3scsi_abort, .eh_bus_reset_handler = sun3scsi_bus_reset, - .can_queue = CAN_QUEUE, + .can_queue = 16, .this_id = 7, - .sg_tablesize = SG_TABLESIZE, - .cmd_per_lun = CMD_PER_LUN, + .sg_tablesize = SG_NONE, + .cmd_per_lun = 2, .use_clustering = DISABLE_CLUSTERING };
drivers/scsi/sun3_scsi.h +0 -18
@@ -31,25 +31,7 @@#define IOBASE_SUN3_VMESCSI 0xff200000 -#ifndef CMD_PER_LUN -#define CMD_PER_LUN 2 -#endif - -#ifndef CAN_QUEUE -#define CAN_QUEUE 16 -#endif - -#ifndef SG_TABLESIZE -#define SG_TABLESIZE SG_NONE -#endif - -#ifndef MAX_TAGS #define MAX_TAGS 32 -#endif - -#ifndef USE_TAGGED_QUEUING -#define USE_TAGGED_QUEUING 1 -#endif #include <scsi/scsicam.h>
drivers/scsi/atari_scsi.c +1 -1
@@ -611,7 +611,7 @@ static int __init atari_scsi_detect(stru#ifdef SUPPORT_TAGS if (setup_use_tagged_queuing <0 ) - setup_use_tagged_queuing =DEFAULT_USE_TAGGED_QUEUING ; + setup_use_tagged_queuing =0 ;#endif #ifdef REAL_DMA /* If running on a Falcon and if there's TT-Ram (i.e., more than one
drivers/scsi/atari_scsi.h +0 -3
@@ -36,9 +36,6 @@#define ATARI_FALCON_CMD_PER_LUN 1#define ATARI_FALCON_SG_TABLESIZE SG_NONE -#define DEFAULT_USE_TAGGED_QUEUING 0 - -#define NCR5380_implementation_fields/* none */ #define NCR5380_read (reg) atari_scsi_reg_read( reg )
PATCH 15/29 ncr5380: Remove *_RELEASE macros
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-remove-RELEASE-macros
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/473c1b6a/attachment.ksh>
PATCH 16/29 ncr5380: Drop legacy scsi.h include
In reply to Finn ThainAn embedded and charset-unspecified text was scrubbed...
Name: ncr5380-drop-legacy-scsi-h-include
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/af42c230/attachment.ksh>
PATCH 17/29 dmx3191d: Use IRQ_NONE
In reply to Finn ThainTesting shows that the Domex 3191D card never asserts its IRQ. Hence it is non-functional with Linux (worse, the EH bugs in the core driver are fatal but that's a problem for another patch). Perhaps the DT-536 chip needs special setup? I can't find documentation for it. The NetBSD driver uses polling apparently because of this issue.
Set host->irq = IRQ_NONE so the core driver will prevent targets from disconnecting. Don't request the irq.
--- drivers/scsi/dmx3191d.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/scsi/dmx3191d.c +8 -17
@@ -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 pciif (!shost) goto out_release_region; shost->io_port = io; - shost->irq = pdev->irq; -NCR5380_init (shost,FLAG_NO_PSEUDO_DMA |FLAG_DTC3181E ); +/* This card does not seem to raise an interrupt on pdev->irq. +* Steam-powered SCSI controllers run without an IRQ anyway. +*/ + shost->irq =IRQ_NONE ; -if (request_irq (pdev->irq, NCR5380_intr,IRQF_SHARED , -DMX3191D_DRIVER_NAME , shost)) { -/* -* Steam powered scsi controllers run without an IRQ anyway -*/ -printk (KERN_WARNING "dmx3191: IRQ %d not available - " -"switching to polled mode.\n" , pdev->irq); - shost->irq =IRQ_NONE ; - } +NCR5380_init (shost,FLAG_NO_PSEUDO_DMA |FLAG_DTC3181E );pci_set_drvdata (pdev, shost); error =scsi_add_host (shost, &pdev->dev);if (error) - goto out_free_irq; + goto out_release_region;scsi_scan_host (shost);return 0 ; - out_free_irq: -if (shost->irq !=IRQ_NONE ) -free_irq (shost->irq, shost); out_release_region:release_region (io,DMX3191D_REGION_LEN ); out_disable_device:
@@ -131,8 +124,6 @@ static void dmx3191d_remove_one(struct pNCR5380_exit (shost); -if (shost->irq !=IRQ_NONE ) -free_irq (shost->irq, shost);release_region (shost->io_port,DMX3191D_REGION_LEN );pci_disable_device (pdev);
Geert Uytterhoeven
maintainerRe: [PATCH 17/29] dmx3191d: Use IRQ_NONE
Quoted 8 lines · 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=IRQ_NONEso the core driver will prevent targets from disconnecting. Don't request the irq.
Please use plain 0 instead of IRQ_NONE (which is related to irqreturn_t).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 18/29 mac_scsi: Remove header
In reply to Finn ThainThe #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.
--- drivers/scsi/mac_scsi.c | 21 ++++++++++++++++++++- drivers/scsi/mac_scsi.h | 42 ------------------------------------------ 2 files changed, 20 insertions(+), 43 deletions(-)
drivers/scsi/mac_scsi.c +20 -1
@@ -31,10 +31,29 @@#include <asm/mac_via.h> #include <scsi/scsi_host.h> -#include "mac_scsi.h" + +/* Definitions for the core NCR5380 driver. */ #define PSEUDO_DMA +#define NCR5380_implementation_fields/* none */ +#define NCR5380_local_declare () struct Scsi_Host *_instance +#define NCR5380_setup (instance) _instance = instance + +#define NCR5380_read (reg) macscsi_read(_instance, reg) +#define NCR5380_write (reg, value) macscsi_write(_instance, reg, value) + +#define NCR5380_pread macscsi_pread +#define NCR5380_pwrite macscsi_pwrite + +#define NCR5380_intr macscsi_intr +#define NCR5380_queue_command macscsi_queue_command +#define NCR5380_abort macscsi_abort +#define NCR5380_bus_reset macscsi_bus_reset +#define NCR5380_info macscsi_info +#define NCR5380_show_info macscsi_show_info +#define NCR5380_write_info macscsi_write_info +#include "NCR5380.h" #define RESET_BOOT
drivers/scsi/mac_scsi.h deleted +0 -42
42 lines not on this page · raw message
PATCH 19/29 mac_scsi: Add module option to Kconfig
In reply to Finn ThainAllow mac_scsi to be built as a module. Replace the old validation of __setup options with code that validates both module and __setup options.
--- drivers/scsi/Kconfig | 2 drivers/scsi/mac_scsi.c | 112 +++++++++++++++--------------------------------- 2 files changed, 38 insertions(+), 76 deletions(-)
drivers/scsi/Kconfig +1 -1
@@ -1644,7 +1644,7 @@ config ATARI_SCSI_RESET_BOOT that leave the devices with SCSI operations partway completed. config MAC_SCSI - bool "Macintosh NCR5380 SCSI" + tristate "Macintosh NCR5380 SCSI" depends on MAC && SCSI=y select SCSI_SPI_ATTRS help
drivers/scsi/mac_scsi.c +37 -75
155 lines not on this page · raw message
Geert Uytterhoeven
maintainerRe: [PATCH 19/29] mac_scsi: Add module option to Kconfig
Quoted 18 lines · Finn Thain
Allow
mac_scsito be built as a module. Replace the old validation of__setupoptions with code that validates both module and__setupoptions.drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +3
-3@@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho return 0; if (macintosh_config->ident == MAC_MODEL_IIFX) { - mac_scsi_regp = via1+0x8000; - mac_scsi_drq = via1+0xE000; - mac_scsi_nodrq = via1+0xC000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x8000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0xE000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000; /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ flags = FLAG_NO_PSEUDO_DMA;
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 int __init macscsi_detect(struct scsi_ho · line 193
Quoted 10 lines
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +3
-3} else { - mac_scsi_regp = via1+0x10000; - mac_scsi_drq = via1+0x6000; - mac_scsi_nodrq = via1+0x12000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x10000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0x6000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000; } if (! setup_use_pdma)
I don't think the above chunk belongs in this patch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 19/29] mac_scsi: Add module option to Kconfig
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Finn Thain
Allow
mac_scsito be built as a module. Replace the old validation of__setupoptions with code that validates both module and__setupoptions.drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +6
-6@@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho return 0; if (macintosh_config->ident == MAC_MODEL_IIFX) { - mac_scsi_regp = via1+0x8000; - mac_scsi_drq = via1+0xE000; - mac_scsi_nodrq = via1+0xC000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x8000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0xE000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000; /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ flags = FLAG_NO_PSEUDO_DMA; } else { - mac_scsi_regp = via1+0x10000; - mac_scsi_drq = via1+0x6000; - mac_scsi_nodrq = via1+0x12000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x10000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0x6000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000; }
Quoted 4 lines
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 int __init macscsi_detect(struct scsi_ho · line 193
Quoted 1 line
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +0
-0if (! setup_use_pdma)I don't think the above chunk belongs in this patch.
via1 is not an exported symbol, so this allows mac_scsi to be linked as a module.
Geert Uytterhoeven
maintainerRe: [PATCH 19/29] mac_scsi: Add module option to Kconfig
Quoted 29 lines · Finn Thain
Quoted 28 lines · Geert Uytterhoeven
Quoted 27 lines · Finn Thain
Allow
mac_scsito be built as a module. Replace the old validation of__setupoptions with code that validates both module and__setupoptions.drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +6
-6@@ -219,15 +179,15 @@ int __init macscsi_detect(struct scsi_ho return 0; if (macintosh_config->ident == MAC_MODEL_IIFX) { - mac_scsi_regp = via1+0x8000; - mac_scsi_drq = via1+0xE000; - mac_scsi_nodrq = via1+0xC000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x8000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0xE000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0xC000; /* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ flags = FLAG_NO_PSEUDO_DMA; } else { - mac_scsi_regp = via1+0x10000; - mac_scsi_drq = via1+0x6000; - mac_scsi_nodrq = via1+0x12000; + mac_scsi_regp = (unsigned char *) VIA1_BASE + 0x10000; + mac_scsi_drq = (unsigned char *) VIA1_BASE + 0x6000; + mac_scsi_nodrq = (unsigned char *) VIA1_BASE + 0x12000; }
Quoted 6 lines
Quoted 3 lines
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 int __init macscsi_detect(struct scsi_ho · line 193
Quoted 1 line
drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:17.000000000 +1000 +0
-0if (! setup_use_pdma)I don't think the above chunk belongs in this patch.
via1 is not an exported symbol, so this allows
mac_scsito be linked as a module.
OK.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 20/29 mac_scsi: Cleanup PDMA code
In reply to Finn ThainFix whitespace, remove pointless volatile qualifiers and improve code style by use of INPUT_DATA_REG and OUTPUT_DATA_REG macros.
--- drivers/scsi/mac_scsi.c | 122 ++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 60 deletions(-)
drivers/scsi/mac_scsi.c +62 -60
@@ -86,9 +86,9 @@ module_param(setup_hostid, int, 0);#define AFTER_RESET_DELAY (HZ/2)#endif -static volatile unsigned char *mac_scsi_regp =NULL ; -static volatile unsigned char *mac_scsi_drq =NULL ; -static volatile unsigned char *mac_scsi_nodrq =NULL ; +static unsigned char *mac_scsi_regp; +static unsigned char *mac_scsi_drq; +static unsigned char *mac_scsi_nodrq;/*
@@ -262,6 +262,7 @@ static void mac_scsi_reset_boot(struct S }#endif +#ifdef PSEUDO_DMA /* Pseudo-DMA: (Ove Edlund) The code attempts to catch bus errors that occur if one for example
@@ -331,38 +332,38 @@ __asm__ __volatile__ \ : "0"(s), "1"(d), "2"(len) \ : "d0") - -static int macscsi_pread (struct Scsi_Host *instance, -unsigned char *dst,int len) +static int macscsi_pread (struct Scsi_Host *instance, +unsigned char *dst,int len) { -unsigned char *d; -volatile unsigned char *s; +unsigned char *d; +unsigned char *s; + +NCR5380_local_declare (); +NCR5380_setup (instance); + + s = mac_scsi_drq + (INPUT_DATA_REG <<4 ); + d = dst; -NCR5380_local_declare (); -NCR5380_setup (instance); +/* These conditions are derived from MacOS */ - s = mac_scsi_drq+0x60 ; - d = dst; +while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && + !(NCR5380_read (STATUS_REG ) &SR_REQ )) + ; + +if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && + (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) { +pr_err ("Error in macscsi_pread\n" ); +return -1 ; + } -/* These conditions are derived from MacOS */ - -while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) - && !(NCR5380_read (STATUS_REG ) &SR_REQ )) - ; -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) - && (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) { -printk (KERN_ERR "Error in macscsi_pread\n" ); -return -1 ; - } - -CP_IO_TO_MEM (s, d, len); - -if (len !=0 ) { -printk (KERN_NOTICE "Bus error in macscsi_pread\n" ); -return -1 ; - } - -return 0 ; +CP_IO_TO_MEM (s, d, len); + +if (len !=0 ) { +pr_notice ("Bus error in macscsi_pread\n" ); +return -1 ; + } + +return 0 ; }
@@ -424,39 +425,40 @@ __asm__ __volatile__ \ : "0"(s), "1"(d), "2"(len) \ : "d0") -static int macscsi_pwrite (struct Scsi_Host *instance, -unsigned char *src,int len) +static int macscsi_pwrite (struct Scsi_Host *instance, +unsigned char *src,int len) { -unsigned char *s; -volatile unsigned char *d; +unsigned char *s; +unsigned char *d; + +NCR5380_local_declare (); +NCR5380_setup (instance); -NCR5380_local_declare (); -NCR5380_setup (instance); + s = src; + d = mac_scsi_drq + (OUTPUT_DATA_REG <<4 ); - s = src; - d = mac_scsi_drq; - -/* These conditions are derived from MacOS */ - -while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) - && (!(NCR5380_read (STATUS_REG ) &SR_REQ ) - || (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH ))) - ; -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ )) { -printk (KERN_ERR "Error in macscsi_pwrite\n" ); -return -1 ; - } - -CP_MEM_TO_IO (s, d, len); - -if (len !=0 ) { -printk (KERN_NOTICE "Bus error in macscsi_pwrite\n" ); -return -1 ; - } - -return 0 ; -} +/* These conditions are derived from MacOS */ + +while (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ ) && + (!(NCR5380_read (STATUS_REG ) &SR_REQ ) || + (NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH ))) + ; + +if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_DRQ )) { +pr_err ("Error in macscsi_pwrite\n" ); +return -1 ; + } + +CP_MEM_TO_IO (s, d, len); +if (len !=0 ) { +pr_notice ("Bus error in macscsi_pwrite\n" ); +return -1 ; + } + +return 0 ; +} +#endif #include "NCR5380.c"
PATCH 21/29 mac_scsi: Convert to platform device
In reply to Finn ThainConvert 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).
---
The new hwreg_present() call is not protected by local_irq_save/restore. This assumes Geert's patch, "Disable/restore interrupts in hwreg_present()/hwreg_write()":
http://marc.info/?l=linux-kernel&m=141189640826704&w=2
--- arch/m68k/include/asm/macintosh.h | 3 arch/m68k/mac/config.c | 101 +++++++++++++-- drivers/scsi/mac_scsi.c | 248 +++++++++++++++++++------------------- 3 files changed, 221 insertions(+), 131 deletions(-)
drivers/scsi/mac_scsi.c +129 -119
@@ -12,23 +12,18 @@*/ #include <linux/types.h> -#include <linux/stddef.h> -#include <linux/ctype.h> #include <linux/delay.h> -#include <linux/module.h> -#include <linux/signal.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/blkdev.h> #include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <asm/hwtest.h> #include <asm/io.h> -#include <asm/irq.h> - -#include <asm/macintosh.h> #include <asm/macints.h> -#include <asm/mac_via.h> +#include <asm/setup.h> #include <scsi/scsi_host.h>
@@ -36,7 +31,7 @@#define PSEUDO_DMA -#define NCR5380_implementation_fields/* none */ +#define NCR5380_implementation_fields unsigned char *pdma_base#define NCR5380_local_declare () struct Scsi_Host *_instance#define NCR5380_setup (instance) _instance = instance
@@ -58,10 +53,6 @@#define RESET_BOOT -#ifdef RESET_BOOT -static void mac_scsi_reset_boot (struct Scsi_Host *instance); -#endif -static int setup_can_queue =-1 ;module_param (setup_can_queue, int,0 );static int setup_cmd_per_lun =-1 ;
@@ -86,23 +77,18 @@ module_param(setup_hostid, int, 0);#define AFTER_RESET_DELAY (HZ/2)#endif -static unsigned char *mac_scsi_regp; -static unsigned char *mac_scsi_drq; -static unsigned char *mac_scsi_nodrq; - -/* * NCR 5380 register access functions */ -static __inline__char macscsi_read (struct Scsi_Host *instance,int reg) +static inline char macscsi_read (struct Scsi_Host *instance,int reg) { -return in_8 (instance->io_port + (reg<<4 )); +return in_8 (instance->base + (reg <<4 )); } -static __inline__void macscsi_write (struct Scsi_Host *instance,int reg,int value) +static inline void macscsi_write (struct Scsi_Host *instance,int reg,int value) { -out_8 (instance->io_port + (reg<<4 ), value); +out_8 (instance->base + (reg <<4 ), value); }#ifndef MODULE
@@ -134,96 +120,6 @@ static int __init mac_scsi_setup(char *s__setup ("mac5380=" , mac_scsi_setup);#endif /* !MODULE */ -/* -* Function : int macscsi_detect(struct scsi_host_template * tpnt) -* -* Purpose : initializes mac NCR5380 driver based on the -* command line / compile time port and irq definitions. -* -* Inputs : tpnt - template for this SCSI adapter. -* -* Returns : 1 if a host adapter was found, 0 if not. -* -*/ - -int __init macscsi_detect (struct scsi_host_template * tpnt) -{ -static int called =0 ; -int flags =0 ; -struct Scsi_Host *instance; - -if (!MACH_IS_MAC || called) -return (0 ); - -if (macintosh_config->scsi_type !=MAC_SCSI_OLD ) -return (0 ); - -if (setup_can_queue >0 ) - tpnt->can_queue = setup_can_queue; -if (setup_cmd_per_lun >0 ) - tpnt->cmd_per_lun = setup_cmd_per_lun; -if (setup_sg_tablesize >=0 ) - tpnt->sg_tablesize = setup_sg_tablesize; -if (setup_hostid >=0 ) - tpnt->this_id = setup_hostid &7 ; - -#ifdef SUPPORT_TAGS -if (setup_use_tagged_queuing <0 ) - setup_use_tagged_queuing =0 ; -#endif - -/* Once we support multiple 5380s (e.g. DuoDock) we'll do -something different here */ - instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); -if (instance ==NULL ) -return 0 ; - -if (macintosh_config->ident ==MAC_MODEL_IIFX ) { - mac_scsi_regp = (unsigned char *)VIA1_BASE +0x8000 ; - mac_scsi_drq = (unsigned char *)VIA1_BASE +0xE000 ; - mac_scsi_nodrq = (unsigned char *)VIA1_BASE +0xC000 ; -/* The IIFX should be able to do true DMA, but pseudo-dma doesn't work */ - flags =FLAG_NO_PSEUDO_DMA ; - }else { - mac_scsi_regp = (unsigned char *)VIA1_BASE +0x10000 ; - mac_scsi_drq = (unsigned char *)VIA1_BASE +0x6000 ; - mac_scsi_nodrq = (unsigned char *)VIA1_BASE +0x12000 ; - } - -if (! setup_use_pdma) - flags =FLAG_NO_PSEUDO_DMA ; - - instance->io_port = (unsigned long ) mac_scsi_regp; - instance->irq =IRQ_MAC_SCSI ; - -#ifdef RESET_BOOT -mac_scsi_reset_boot (instance); -#endif - -NCR5380_init (instance, flags); - - instance->n_io_port =255 ; - -if (instance->irq !=IRQ_NONE ) -if (request_irq (instance->irq, NCR5380_intr,0 ,"ncr5380" , instance)) { -printk (KERN_WARNING "scsi%d: IRQ%d not free, interrupts disabled\n" , - instance->host_no, instance->irq); - instance->irq =IRQ_NONE ; - } - - called =1 ; -return 1 ; -} - -int macscsi_release (struct Scsi_Host *shpnt) -{ -if (shpnt->irq !=IRQ_NONE ) -free_irq (shpnt->irq, shpnt); -NCR5380_exit (shpnt); - -return 0 ; -} -#ifdef RESET_BOOT /* * Our 'bus reset on boot' function
@@ -335,13 +231,14 @@ __asm__ __volatile__ \static int macscsi_pread (struct Scsi_Host *instance,unsigned char *dst,int len) { +struct NCR5380_hostdata *hostdata =shost_priv (instance);unsigned char *d;unsigned char *s;NCR5380_local_declare ();NCR5380_setup (instance); - s = mac_scsi_drq + (INPUT_DATA_REG <<4 ); + s = hostdata->pdma_base + (INPUT_DATA_REG <<4 ); d = dst;/* These conditions are derived from MacOS */
@@ -428,6 +325,7 @@ __asm__ __volatile__ \static int macscsi_pwrite (struct Scsi_Host *instance,unsigned char *src,int len) { +struct NCR5380_hostdata *hostdata =shost_priv (instance);unsigned char *s;unsigned char *d;
@@ -435,7 +333,7 @@ static int macscsi_pwrite(struct Scsi_HoNCR5380_setup (instance); s = src; - d = mac_scsi_drq + (OUTPUT_DATA_REG <<4 ); + d = hostdata->pdma_base + (OUTPUT_DATA_REG <<4 );/* These conditions are derived from MacOS */
@@ -462,13 +360,15 @@ static int macscsi_pwrite(struct Scsi_Ho#include "NCR5380.c" -static struct scsi_host_template driver_template = { - .proc_name ="Mac5380" , +#define DRV_MODULE_NAME "mac_scsi" +#define PFX DRV_MODULE_NAME ": " + +static struct scsi_host_template mac_scsi_template = { + .module =THIS_MODULE , + .proc_name =DRV_MODULE_NAME , .show_info = macscsi_show_info, .write_info = macscsi_write_info, .name ="Macintosh NCR5380 SCSI" , - .detect = macscsi_detect, - .release = macscsi_release, .info = macscsi_info, .queuecommand = macscsi_queue_command, .eh_abort_handler = macscsi_abort,
@@ -480,7 +380,117 @@ static struct scsi_host_template driver_ .use_clustering = DISABLE_CLUSTERING }; +static int __init mac_scsi_probe (struct platform_device *pdev) +{ +struct Scsi_Host *instance; +int error; +int host_flags =0 ; +struct resource *irq, *pio_mem, *pdma_mem =NULL ; + +if (!MACH_IS_MAC ) +return -ENODEV ; + + pio_mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!pio_mem) +return -ENODEV ; + +#ifdef PSEUDO_DMA + pdma_mem =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); +#endif + + irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); + +if (!hwreg_present ((unsigned char *)pio_mem->start + + (STATUS_REG <<4 ))) { +pr_info (PFX "no device detected at %pap\n" , &pio_mem->start); +return -ENODEV ; + } + +if (setup_can_queue >0 ) + mac_scsi_template.can_queue = setup_can_queue; +if (setup_cmd_per_lun >0 ) + mac_scsi_template.cmd_per_lun = setup_cmd_per_lun; +if (setup_sg_tablesize >=0 ) + mac_scsi_template.sg_tablesize = setup_sg_tablesize; +if (setup_hostid >=0 ) + mac_scsi_template.this_id = setup_hostid &7 ; +#ifdef SUPPORT_TAGS +if (setup_use_tagged_queuing <0 ) + setup_use_tagged_queuing =0 ; +#endif +if (setup_use_pdma <0 ) + setup_use_pdma =0 ; + + instance =scsi_host_alloc (&mac_scsi_template, +sizeof (struct NCR5380_hostdata )); +if (!instance) +return -ENOMEM ; + + instance->base = pio_mem->start; +if (irq) + instance->irq = irq->start; +else + instance->irq =IRQ_NONE ; + +if (pdma_mem && setup_use_pdma) { +struct NCR5380_hostdata *hostdata =shost_priv (instance); + + hostdata->pdma_base = (unsigned char *)pdma_mem->start; + }else + host_flags |=FLAG_NO_PSEUDO_DMA ; + +#ifdef RESET_BOOT +mac_scsi_reset_boot (instance); +#endif + +NCR5380_init (instance, host_flags); + +if (instance->irq !=IRQ_NONE ) { + error =request_irq (instance->irq, macscsi_intr,0 , +"NCR5380" , instance); +if (error) + goto fail_irq; + } + + error =scsi_add_host (instance,NULL ); +if (error) + goto fail_host; + +platform_set_drvdata (pdev, instance); + +scsi_scan_host (instance); +return 0 ; + +fail_host: +if (instance->irq !=IRQ_NONE ) +free_irq (instance->irq, instance); +fail_irq: +NCR5380_exit (instance); +scsi_host_put (instance); +return error; +} + +static int __exit mac_scsi_remove(struct platform_device *pdev) +{ +struct Scsi_Host *instance =platform_get_drvdata (pdev); + +scsi_remove_host (instance); +if (instance->irq !=IRQ_NONE ) +free_irq (instance->irq, instance); +NCR5380_exit (instance); +scsi_host_put (instance); +return 0 ; +} + +static struct platform_driver mac_scsi_driver = { + .remove =__exit_p (mac_scsi_remove), + .driver = { + .name =DRV_MODULE_NAME , + .owner =THIS_MODULE , + }, +}; -#include "scsi_module.c" +module_platform_driver_probe (mac_scsi_driver, mac_scsi_probe); +MODULE_ALIAS ("platform:" DRV_MODULE_NAME );MODULE_LICENSE ("GPL" );
arch/m68k/mac/config.c +89 -12
185 lines not on this page · raw message
arch/m68k/include/asm/macintosh.h +3 -0
@@ -53,6 +53,9 @@ struct mac_model#define MAC_SCSI_QUADRA 2#define MAC_SCSI_QUADRA2 3#define MAC_SCSI_QUADRA3 4 +#define MAC_SCSI_IIFX 5 +#define MAC_SCSI_DUO 6 +#define MAC_SCSI_CCL 7#define MAC_IDE_NONE 0#define MAC_IDE_QUADRA 1
Geert Uytterhoeven
maintainerRe: [PATCH 21/29] mac_scsi: Convert to platform device
Quoted 5 lines · Finn Thain
Convert
mac_scsito platform device and eliminatescsi_register().Platform resources for chip registers now follow the documentation. This should fix issues with the Mac IIci (and possibly other models too).
Quoted 8 lines
Signed-off-by Finn Thain <[email protected]>---
The new
hwreg_present()call is not protected by local_irq_save/restore. This assumes Geert's patch, "Disable/restore interrupts in hwreg_present()/hwreg_write()":
http://marc.info/?l=linux-kernel&m=141189640826704&w=2
OK, so this cannot go in before v3.18-rc1.
Quoted 6 lines
drivers/scsi/mac_scsi.c 2014-10-02 16:56:19.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:18.000000000 +1000 +0
-0@@ -480,7 +380,117 @@ static struct scsi_host_template driver_ .use_clustering = DISABLE_CLUSTERING };
drivers/scsi/mac_scsi.c 2014-10-02 16:56:19.000000000 +1000 static struct scsi_host_template driver_ · line 391
Quoted 10 lines
drivers/scsi/mac_scsi.c 2014-10-02 16:56:19.000000000 +1000 renamed from drivers/scsi/mac_scsi.c 2014-10-02 16:56:18.000000000 +1000 +9
-0+static int __init mac_scsi_probe(struct platform_device *pdev) +{ + struct Scsi_Host *instance; + int error; + int host_flags = 0; + struct resource *irq, *pio_mem, *pdma_mem = NULL; + + if (!MACH_IS_MAC) + return -ENODEV;
This check is not needed, asuming you'll only instantiate the platform device when running on a Mac.
Quoted 45 lines
arch/m68k/mac/config.c 2014-10-02 16:56:19.000000000 +1000 renamed from arch/m68k/mac/config.c 2014-10-02 16:55:28.000000000 +1000 +31
-0@@ -929,6 +929,36 @@ static struct platform_device swim_pdev .resource = &swim_rsrc, }; +static struct resource mac_scsi_0_rsrc[] = { + { + .flags = IORESOURCE_IRQ, + .start = IRQ_MAC_SCSI, + .end = IRQ_MAC_SCSI, + }, + { .flags = IORESOURCE_MEM }, + { .flags = IORESOURCE_MEM }, +}; + +static struct resource mac_scsi_1_rsrc[] = { + /* IRQ_NUBUS_E maybe? */ + { .flags = IORESOURCE_MEM }, + { .flags = IORESOURCE_MEM }, +}; + +static struct platform_device mac_scsi_0_pdev = { + .name = "mac_scsi", + .id = 0, + .resource = mac_scsi_0_rsrc, + .num_resources = ARRAY_SIZE(mac_scsi_0_rsrc), +}; + +static struct platform_device mac_scsi_1_pdev = { + .name = "mac_scsi", + .id = 1, + .resource = mac_scsi_1_rsrc, + .num_resources = ARRAY_SIZE(mac_scsi_1_rsrc), +}; + static struct platform_device esp_0_pdev = { .name = "mac_esp", .id = 0,@@ -1000,6 +1030,53 @@ int __init mac_platform_init(void) (macintosh_config->ident == MAC_MODEL_Q950)) platform_device_register(&esp_1_pdev); break; + case MAC_SCSI_IIFX:
arch/m68k/mac/config.c 2014-10-02 16:56:19.000000000 +1000 int __init mac_platform_init(void) · line 1043
Quoted 10 lines
arch/m68k/mac/config.c 2014-10-02 16:56:19.000000000 +1000 renamed from arch/m68k/mac/config.c 2014-10-02 16:55:28.000000000 +1000 +10
-0+ /* Addresses from The Guide to Mac Family Hardware. */ + mac_scsi_0_rsrc[1].start = 0x50008000; /* SCSI DMA */ + mac_scsi_0_rsrc[1].end = mac_scsi_0_rsrc[1].start + 0x1FFF; + /* $5000 E000 - $5000 FFFF: Alternate SCSI (Hsk) */ + /* $5000 C000 - $5000 DFFF: Alternate SCSI (DMA) */ + /* The SCSI DMA custom IC embeds the 53C80 core. mac_scsi does + * not make use of its DMA or hardware handshaking logic. + */ + mac_scsi_0_pdev.num_resources--; + platform_device_register(&mac_scsi_0_pdev);
What about removing the static mac_scsi_0_pdev and mac_scsi_1_pdev, and calling platform_device_register_simple() instead? That way you
(a) don't have to fiddle with mac_scsi_0_pdev.num_resources, and
(b) the resources can become const and __initconst, as a copy will be allocated dynamically.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 22/29 atari_scsi: Fix atari_scsi deadlocks on Falcon
In reply to Finn ThainDon't disable irqs when waiting for the ST DMA lock; its release may require an interrupt.
Introduce stdma_try_lock() for use in soft irq context. atari_scsi now tells the SCSI mid-layer to defer queueing a command if the ST DMA "lock" is not available, as per Michael's patch:
http://marc.info/?l=linux-m68k&m=139095335824863&w=2
The falcon_got_lock variable is race prone: we can't disable IRQs while waiting to acquire the lock so after acquiring it there has to be some interval during which falcon_got_lock remains false. Introduce stdma_is_locked_by() to replace falcon_got_lock.
The falcon_got_lock tests in EH handlers are not correct these days. It can happen that an EH handler is called after a command completes normally. Remove these checks along with falcon_got_lock.
Also remove the complicated and racy fairness wait queues. If fairness is an issue (when SCSI competes with IDE for the ST DMA interrupt), the solution is likely to be a lower value for host->can_queue.
--- arch/m68k/atari/stdma.c | 62 +++++++++++++++++++---------- arch/m68k/include/asm/atari_stdma.h | 4 - drivers/scsi/atari_NCR5380.c | 35 +++++----------- drivers/scsi/atari_scsi.c | 76 +++++++----------------------------- 4 files changed, 70 insertions(+), 107 deletions(-)
arch/m68k/atari/stdma.c +41 -21
@@ -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, vvoid stdma_lock (irq_handler_t handler,void *data) { -unsigned long flags; - -local_irq_save (flags);/* protect lock */ -/* Since the DMA is used for file system purposes, we have to sleep uninterruptible (there may be locked buffers) */ -wait_event (stdma_wait, !stdma_locked); - - stdma_locked =1 ; - stdma_isr = handler; - stdma_isr_data = data; -local_irq_restore (flags); +wait_event (stdma_wait,stdma_try_lock (handler, data)); }EXPORT_SYMBOL (stdma_lock);
@@ -122,22 +138,26 @@ void stdma_release(void)EXPORT_SYMBOL (stdma_release); -/* -* Function: int stdma_others_waiting( void ) -* -* Purpose: Check if someone waits for the ST-DMA lock. -* -* Inputs: none -* -* Returns: 0 if no one is waiting, != 0 otherwise +/** +* stdma_is_locked_by - allow lock holder to check whether it needs to release. +* @handler: interrupt handler previously used to acquire lock. * +* Returns !0 if locked for the given handler; 0 otherwise. */ -int stdma_others_waiting (void ) +int stdma_is_locked_by (irq_handler_t handler) { -return waitqueue_active (&stdma_wait); +unsigned long flags; + +local_irq_save (flags); +if (stdma_locked && (stdma_isr == handler)) { +local_irq_restore (flags); +return 1 ; + } +local_irq_restore (flags); +return 0 ; } -EXPORT_SYMBOL (stdma_others_waiting); +EXPORT_SYMBOL (stdma_is_locked_by);/*
arch/m68k/include/asm/atari_stdma.h +2 -2
@@ -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 **************************/
drivers/scsi/atari_NCR5380.c +12 -23
@@ -877,10 +877,10 @@ static void NCR5380_exit(struct Scsi_Hos* */ -static int NCR5380_queue_command_lck (struct scsi_cmnd *cmd, -void (*done)(struct scsi_cmnd *)) +static int NCR5380_queue_command (struct Scsi_Host *instance, +struct scsi_cmnd *cmd) { -SETUP_HOSTDATA (cmd->device->host); +struct NCR5380_hostdata *hostdata =shost_priv (instance);struct scsi_cmnd *tmp;unsigned long flags;
@@ -891,7 +891,7 @@ static int NCR5380_queue_command_lck(strprintk (KERN_NOTICE "scsi%d: WRITE attempted with NO_WRITE debugging flag set\n" ,H_NO (cmd)); cmd->result = (DID_ERROR <<16 ); -done (cmd); + cmd->scsi_done (cmd); return 0; }#endif /* (NDEBUG & NDEBUG_NO_WRITE) */
@@ -902,8 +902,6 @@ static int NCR5380_queue_command_lck(str*/ SET_NEXT (cmd,NULL ); - cmd->scsi_done = done; - cmd->result =0 ;/*
@@ -913,7 +911,6 @@ static int NCR5380_queue_command_lck(str* sense data is only guaranteed to be valid while the condition exists. */ -local_irq_save (flags);/* ++guenther: now that the issue queue is being set up, we can lock ST-DMA. * Otherwise a running NCR5380_main may steal the lock. * Lock before actually inserting due to fairness reasons explained in
@@ -926,11 +923,13 @@ static int NCR5380_queue_command_lck(str* because also a timer int can trigger an abort or reset, which would * alter queues and touch the lock. */ -if (!IS_A_TT ()) { -/* perhaps stop command timer here */ -falcon_get_lock (); -/* perhaps restart command timer here */ - } +/* perhaps stop command timer here */ +if (!falcon_get_lock ()) +return SCSI_MLQUEUE_HOST_BUSY ; +/* perhaps restart command timer here */ + +local_irq_save (flags); +if (!(hostdata->issue_queue) || (cmd->cmnd[0 ] ==REQUEST_SENSE )) {LIST (cmd, hostdata->issue_queue);SET_NEXT (cmd, hostdata->issue_queue);
@@ -954,15 +953,13 @@ static int NCR5380_queue_command_lck(str* If we're not in an interrupt, we can call NCR5380_main() * unconditionally, because it cannot be already running. */ -if (in_interrupt () || ((flags >>8 ) &7 ) >=6 ) +if (in_interrupt () ||irqs_disabled ())queue_main ();else NCR5380_main (NULL );return 0 ; } -static DEF_SCSI_QCMD (NCR5380_queue_command) -/* * Function : NCR5380_main (void) *
@@ -2552,10 +2549,6 @@ int NCR5380_abort(struct scsi_cmnd *cmd)local_irq_save (flags); -if (!IS_A_TT () && !falcon_got_lock) -printk (KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_abort\n" , -HOSTNO ); -dprintk (NDEBUG_ABORT ,"scsi%d: abort called basr 0x%02x, sr 0x%02x\n" ,HOSTNO ,NCR5380_read (BUS_AND_STATUS_REG ),NCR5380_read (STATUS_REG ));
@@ -2754,10 +2747,6 @@ static int NCR5380_bus_reset(struct scsistruct scsi_cmnd *connected, *disconnected_queue;#endif -if (!IS_A_TT () && !falcon_got_lock) -printk (KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n" , -H_NO (cmd)); -NCR5380_print_status (cmd->device->host);/* get in phase */
drivers/scsi/atari_scsi.c +15 -61
110 lines not on this page · raw message
Geert Uytterhoeven
maintainerRe: [PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon
Quoted 7 lines · Finn Thain
arch/m68k/atari/stdma.c 2014-10-02 16:56:20.000000000 +1000 renamed from arch/m68k/atari/stdma.c 2014-10-02 16:55:28.000000000 +1000 +1
-2-int stdma_others_waiting(void) +int stdma_is_locked_by(irq_handler_t handler) { - return waitqueue_active(&stdma_wait);
arch/m68k/atari/stdma.c 2014-10-02 16:56:20.000000000 +1000
Quoted 10 lines
arch/m68k/atari/stdma.c 2014-10-02 16:56:20.000000000 +1000 renamed from arch/m68k/atari/stdma.c 2014-10-02 16:55:28.000000000 +1000 +9
-0+ unsigned long flags; + + local_irq_save(flags); + if (stdma_locked && (stdma_isr == handler)) { + local_irq_restore(flags); + return 1; + } + local_irq_restore(flags); + return 0; }
This can be written shorter:
int stdma_is_locked_by(irq_handler_t handler)
{
unsigned long flags;
int res;
local_irq_save(flags);
res = stdma_locked && (stdma_isr == handler);
local_irq_restore(flags);
return res;
}Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 23/29 atari_scsi: Convert to platform device
In reply to Finn ThainConvert 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).
--- arch/m68k/atari/config.c | 5 drivers/scsi/atari_scsi.c | 426 ++++++++++++++++++++++------------------------ drivers/scsi/atari_scsi.h | 17 - 3 files changed, 217 insertions(+), 231 deletions(-)
arch/m68k/atari/config.c +5 -0
@@ -892,6 +892,11 @@ int __init atari_platform_init(void) }#endif +#ifdef CONFIG_ATARI_SCSI +if (ATARIHW_PRESENT (ST_SCSI ) ||ATARIHW_PRESENT (TT_SCSI )) +platform_device_register_simple ("atari_scsi" ,-1 ,NULL ,0 ); +#endif +return rv; }
drivers/scsi/atari_scsi.c +212 -214
489 lines not on this page · raw message
drivers/scsi/atari_scsi.h +0 -17
@@ -18,23 +18,6 @@/* (I_HAVE_OVERRUNS stuff removed) */ #ifndef ASM -/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher -* values should work, too; try it! (but cmd_per_lun costs memory!) */ - -/* But there seems to be a bug somewhere that requires CAN_QUEUE to be -* 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since -* changed CMD_PER_LUN... */ - -/* Note: The Falcon currently uses 8/1 setting due to unsolved problems with -* cmd_per_lun != 1 */ - -#define ATARI_TT_CAN_QUEUE 16 -#define ATARI_TT_CMD_PER_LUN 8 -#define ATARI_TT_SG_TABLESIZE SG_ALL - -#define ATARI_FALCON_CAN_QUEUE 8 -#define ATARI_FALCON_CMD_PER_LUN 1 -#define ATARI_FALCON_SG_TABLESIZE SG_NONE#define NCR5380_implementation_fields/* none */
Geert Uytterhoeven
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 10 lines · Finn Thain
Convert
atari_scsito platform device and eliminatescsi_register().Validate
__setupoptions 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).
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 8 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +7
-0+static int __init atari_scsi_probe(struct platform_device *pdev) +{ + struct Scsi_Host *instance; + int error; + + if (!MACH_IS_ATARI) + return -ENODEV;
This test is not needed.
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 6 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +6
-0+ if (ATARIHW_PRESENT(TT_SCSI)) { + atari_scsi_reg_read = atari_scsi_tt_reg_read; + atari_scsi_reg_write = atari_scsi_tt_reg_write; + } else if (ATARIHW_PRESENT(ST_SCSI)) { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write;
Can these be handled through the platform_device's resources?
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 2 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +2
-0+ } else + return -ENODEV;
This branch should not be there.
Quoted 10 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +10
-0+ /* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. + * Higher values should work, too; try it! + * (But cmd_per_lun costs memory!) + * + * But there seems to be a bug somewhere that requires CAN_QUEUE to be + * 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since + * changed CMD_PER_LUN... + * + * Note: The Falcon currently uses 8/1 setting due to unsolved problems + * with cmd_per_lun != 1
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 10 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +10
-0+ */ + if (IS_A_TT()) { + atari_scsi_template.can_queue = 16; + atari_scsi_template.cmd_per_lun = 8; + atari_scsi_template.sg_tablesize = SG_ALL; + } else { + atari_scsi_template.can_queue = 8; + atari_scsi_template.cmd_per_lun = 1; + atari_scsi_template.sg_tablesize = SG_NONE; + }
Shouldn't this be in platform data?
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 3 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +3
-0+ /* Leave sg_tablesize at 0 on a Falcon! */ + if (IS_A_TT() && setup_sg_tablesize >= 0) + atari_scsi_template.sg_tablesize = setup_sg_tablesize;
I think the IS_A_TT() check can just be removed.
Quoted 7 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +7
-0+#ifdef REAL_DMA + /* If running on a Falcon and if there's TT-Ram (i.e., more than one + * memory block, since there's always ST-Ram in a Falcon), then + * allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers + * from/to alternative Ram. + */ + if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 10 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +10
-0+ m68k_num_memory > 1) { + atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE, "SCSI"); + if (!atari_dma_buffer) { + pr_err(PFX "can't allocate ST-RAM double buffer\n"); + return -ENOMEM; + } + atari_dma_phys_buffer = atari_stram_to_phys(atari_dma_buffer); + atari_dma_orig_addr = 0; + } +#endif
More platform data?
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 4 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +4
-0+ if (IS_A_TT()) + instance->irq = IRQ_TT_MFP_SCSI; + else + instance->irq = IRQ_NONE;
platform_device resource?
(and IRQ_NONE is wrong, you should use 0)
Quoted 1 line
+ if (
IS_A_TT()) {
Check for instance->irq instead?
Quoted 28 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +28
-0+ error = request_irq(instance->irq, scsi_tt_intr, 0, + "NCR5380", instance); + if (error) { + pr_err(PFX "request irq %d failed, aborting\n", + instance->irq); + goto fail_irq; + } + tt_mfp.active_edge |= 0x80; /* SCSI int on L->H */ +#ifdef REAL_DMA + tt_scsi_dma.dma_ctrl = 0; + atari_dma_residual = 0; + + /* While the read overruns (described by Drew Eckhardt in + * NCR5380.c) never happened on TTs, they do in fact on the + * Medusa (This was the cause why SCSI didn't work right for + * so long there.) Since handling the overruns slows down + * a bit, I turned the #ifdef's into a runtime condition. + * + * In principle it should be sufficient to do max. 1 byte with + * PIO, but there is another problem on the Medusa with the DMA + * rest data register. So 'atari_read_overruns' is currently set + * to 4 to avoid having transfers that aren't a multiple of 4. + * If the rest data bug is fixed, this can be lowered to 1. + */ + if (MACH_IS_MEDUSA) + atari_read_overruns = 4; +#endif + } else {
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000
Quoted 10 lines
drivers/scsi/atari_scsi.c 2014-10-02 16:56:21.000000000 +1000 renamed from drivers/scsi/atari_scsi.c 2014-10-02 16:56:20.000000000 +1000 +10
-0+ /* Nothing to do for the interrupt: the ST-DMA is initialized + * already. + */ +#ifdef REAL_DMA + atari_dma_residual = 0; + atari_dma_active = 0; + atari_dma_stram_mask = (ATARIHW_PRESENT(EXTD_DMA) ? 0x00000000 + : 0xff000000); +#endif + }
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 9 lines · Geert Uytterhoeven
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 862
Quoted 6 lines
drivers/scsi/atari_scsi.c +6
-0+if (ATARIHW_PRESENT (TT_SCSI )) { + atari_scsi_reg_read = atari_scsi_tt_reg_read; + atari_scsi_reg_write = atari_scsi_tt_reg_write; + }else if (ATARIHW_PRESENT (ST_SCSI )) { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write;Can these be handled through the platform_device's resources?
I don't know.
Quoted 21 lines
Quoted 10 lines
drivers/scsi/atari_scsi.c +10
-0+/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. +* Higher values should work, too; try it! +* (But cmd_per_lun costs memory!) +* +* But there seems to be a bug somewhere that requires CAN_QUEUE to be +* 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since +* changed CMD_PER_LUN... +* +* Note: The Falcon currently uses 8/1 setting due to unsolved problems +* with cmd_per_lun != 1 drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 885
Quoted 10 lines
drivers/scsi/atari_scsi.c +10
-0+*/ +if (IS_A_TT ()) { + atari_scsi_template.can_queue =16 ; + atari_scsi_template.cmd_per_lun =8 ; + atari_scsi_template.sg_tablesize =SG_ALL ; + }else { + atari_scsi_template.can_queue =8 ; + atari_scsi_template.cmd_per_lun =1 ; + atari_scsi_template.sg_tablesize =SG_NONE ; + }
Quoted 7 lines
Shouldn't this be in platform data?
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 895
Quoted 3 lines
drivers/scsi/atari_scsi.c +3
-0+/* Leave sg_tablesize at 0 on a Falcon! */ +if (IS_A_TT () && setup_sg_tablesize >=0 ) + atari_scsi_template.sg_tablesize = setup_sg_tablesize;I think the
IS_A_TT()check can just be removed.
Well, ST DMA will break if scatter/gather is enabled by the user.
Quoted 21 lines
Quoted 8 lines
drivers/scsi/atari_scsi.c +7
-0+#ifdef REAL_DMA +/* If running on a Falcon and if there's TT-Ram (i.e., more than one +* memory block, since there's always ST-Ram in a Falcon), then +* allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers +* from/to alternative Ram. +*/ + if (ATARIHW_PRESENT(ST_SCSI) && !ATARIHW_PRESENT(EXTD_DMA) &&drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 933
Quoted 10 lines
drivers/scsi/atari_scsi.c +10
-0+ m68k_num_memory > 1) { + atari_dma_buffer =atari_stram_alloc (STRAM_BUFFER_SIZE ,"SCSI" ); +if (!atari_dma_buffer) { +pr_err (PFX "can't allocate ST-RAM double buffer\n" ); +return -ENOMEM ; + } + atari_dma_phys_buffer =atari_stram_to_phys (atari_dma_buffer); + atari_dma_orig_addr =0 ; + } +#endif More platform data?
Quoted 6 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 950
Quoted 4 lines
drivers/scsi/atari_scsi.c +4
-0+if (IS_A_TT ()) + instance->irq =IRQ_TT_MFP_SCSI ; +else + instance->irq =IRQ_NONE ;
platform_deviceresource?
If I thought it possible to parameterize the driver such that it never had to test IS_A_TT(), I'd probably agree that this would be more elegant.
Otherwise I'd prefer not to have parts of the logic separated off into the platform resources while the remaining logic remains in the driver itself.
While I don't think platform resources are desirable in this driver, I would like to hear Michael's views.
Aside from TT and ST, is there a third configuration that might benefit from a more data driven configuration?
Quoted 6 lines
(and
IRQ_NONEis wrong, you should use 0)Quoted 1 line
+ if (
IS_A_TT()) {Check for
instance->irqinstead?
Yes, you'd think so, but a later patch (not in this set) would have to change it back to IS_A_TT().
Further patches align atari_NCR5380.c with NCR5380.c, such that the core driver then checks host->irq to find out whether an IRQ is in use. For Atari ST, request_irq() is not called even though the ST DMA irq is in use.
Michael Schmitz
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
Finn,
Quoted 10 lines · Geert Uytterhoeven
Quoted 9 lines
Quoted 9 lines
drivers/scsi/atari_scsi.c +6
-0+if (ATARIHW_PRESENT (TT_SCSI )) { + atari_scsi_reg_read = atari_scsi_tt_reg_read; + atari_scsi_reg_write = atari_scsi_tt_reg_write; + }else if (ATARIHW_PRESENT (ST_SCSI )) { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write;
Quoted 6 lines
Quoted 3 lines
Can these be handled through the platform_device's resources?
I don't know.
Should be possible - I've seen that used in the ISP116x HCD driver (arch-dependent post-register access delay function passed via platform data).
Quoted 10 lines
Quoted 7 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 895
Quoted 5 lines
drivers/scsi/atari_scsi.c +3
-0+/* Leave sg_tablesize at 0 on a Falcon! */ +if (IS_A_TT () && setup_sg_tablesize >=0 ) + atari_scsi_template.sg_tablesize = setup_sg_tablesize;I think the
IS_A_TT()check can just be removed.Well, ST DMA will break if scatter/gather is enabled by the user.
Concur - we'd have to make certain the SG buffers are contiguous in physical memory before allowing SG on Falcon.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/scsi/atari_scsi.c +12
-0+#ifdef REAL_DMA +/* If running on a Falcon and if there's TT-Ram (i.e., more than one +* memory block, since there's always ST-Ram in a Falcon), then +* allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers +* from/to alternative Ram. +*/ +if (ATARIHW_PRESENT (ST_SCSI ) && !ATARIHW_PRESENT (EXTD_DMA ) && + m68k_num_memory >1 ) { + atari_dma_buffer =atari_stram_alloc (STRAM_BUFFER_SIZE ,"SCSI" ); +if (!atari_dma_buffer) { +pr_err (PFX "can't allocate ST-RAM double buffer\n" ); +return -ENOMEM ;
Quoted 8 lines
Quoted 8 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 933
Quoted 6 lines
drivers/scsi/atari_scsi.c +5
-0+ } + atari_dma_phys_buffer =atari_stram_to_phys (atari_dma_buffer); + atari_dma_orig_addr =0 ; + } +#endif More platform data?
Perhaps.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/scsi/atari_scsi.c +4
-0+if (IS_A_TT ()) + instance->irq =IRQ_TT_MFP_SCSI ; +else + instance->irq =IRQ_NONE ;
Quoted 9 lines
Quoted 2 lines
platform_deviceresource?If I thought it possible to parameterize the driver such that it never had to test
IS_A_TT(), I'd probably agree that this would be more elegant.Otherwise I'd prefer not to have parts of the logic separated off into the platform resources while the remaining logic remains in the driver itself.
While I don't think platform resources are desirable in this driver, I would like to hear Michael's views.
The IRQ is a good candidate to be passed via platform data. Register access primitives can be done via platform data as well. Likewise, the ST-DMA locking primitives. That still leaves the DMA setup and completion code - Falcon and TT differ here in that they require a different order of DMA setup and NCR setup (the Falcon SCSI chip is hooked up via the ST-DMA, the TT one memory mapped so DMA setup must come last on Falcon, and DMA completion check first. TT has that reversed. That's a bit more hassle and might require lib_NCR5380 approach similar to the ESP SCSI driver.
Quoted 2 lines
Aside from TT and ST, is there a third configuration that might benefit from a more data driven configuration?
TT and Falcon, not sure any of the ST/STE series ever had a SCSI adapter. Medusa is TT compatible
Quoted 12 lines
Quoted 7 lines
(and
IRQ_NONEis wrong, you should use 0)Quoted 2 lines
+ if (
IS_A_TT()) {Check for
instance->irqinstead?Yes, you'd think so, but a later patch (not in this set) would have to change it back to
IS_A_TT().Further patches align
atari_NCR5380.cwithNCR5380.c, such that the core driver then checkshost->irqto find out whether an IRQ is in use. For Atari ST,request_irq()is not called even though the ST DMA irq is in use.
That's why the IRQ is set to 0, I guess? Works for me. The old code states that setting instance->irq = 0 keeps the midlevel from tampering with the SCSI IRQ during queuecmd which would interfere with IDE and floppy. I guess this is still relevant - I would not have seen the ST-DMA locked by IDE during SCSI queuecmd otherwise.
Won't be able to test any of this for a while, sorry.
Cheers,
Michael
Re: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 14 lines · Michael Schmitz
Quoted 14 lines · Geert Uytterhoeven
Quoted 12 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 862
Quoted 9 lines
drivers/scsi/atari_scsi.c +6
-0+if (ATARIHW_PRESENT (TT_SCSI )) { + atari_scsi_reg_read = atari_scsi_tt_reg_read; + atari_scsi_reg_write = atari_scsi_tt_reg_write; + }else if (ATARIHW_PRESENT (ST_SCSI )) { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write;Can these be handled through the platform_device's resources?
Quoted 6 lines
Quoted 2 lines
I don't know.
Should be possible - I've seen that used in the ISP116x HCD driver (arch-dependent post-register access delay function passed via platform data).
Yes, possible, but is it desirable?
Quoted 46 lines
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
(quoted diff) +2
-0+#ifdef REAL_DMA + /* If running on a Falcon and if there's TT-Ram (i.e., more thanone
(quoted diff) +2
-0+ * memory block, since there's always ST-Ram in a Falcon), then + * allocate a STRAM_BUFFER_SIZE byte dribble buffer fortransfers
drivers/scsi/atari_scsi.c +5
-0+* from/to alternative Ram. +*/ +if (ATARIHW_PRESENT (ST_SCSI ) && !ATARIHW_PRESENT (EXTD_DMA ) && + m68k_num_memory >1 ) { + atari_dma_buffer = atari_stram_alloc(STRAM_BUFFER_SIZE,"SCSI");
(quoted diff) +2
-0+ if (!atari_dma_buffer) { + pr_err(PFX "can't allocate ST-RAM doublebuffer\n");
(quoted diff) +2
-0+ return -ENOMEM; + }Quoted 8 lines
Quoted 8 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 933
Quoted 6 lines
+
atari_dma_phys_buffer=atari_stram_to_phys(atari_dma_buffer);drivers/scsi/atari_scsi.c +3
-0+ atari_dma_orig_addr = 0; + } +#endif More platform data?
Perhaps.
Quoted 17 lines
Quoted 8 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 950
Quoted 6 lines
drivers/scsi/atari_scsi.c +4
-0+if (IS_A_TT ()) + instance->irq =IRQ_TT_MFP_SCSI ; +else + instance->irq =IRQ_NONE ;
platform_deviceresource?If I thought it possible to parameterize the driver such that it never had to test
IS_A_TT(), I'd probably agree that this would be more elegant.Otherwise I'd prefer not to have parts of the logic separated off into the platform resources while the remaining logic remains in the driver itself.
Quoted 5 lines
Quoted 3 lines
While I don't think platform resources are desirable in this driver, I would like to hear Michael's views.
The IRQ is a good candidate to be passed via platform data.
Geert didn't say so, but after thinking about his review comments I imagine that he wants all the Atari IRQ numbers kept in one place and all the Mac IRQ numbers in a different place, and so on. Makes sense.
Quoted 9 lines
Register access primitives can be done via platform data as well. Likewise, the ST-DMA locking primitives. That still leaves the DMA setup and completion code - Falcon and TT differ here in that they require a different order of DMA setup and NCR setup (the Falcon SCSI chip is hooked up via the ST-DMA, the TT one memory mapped so DMA setup must come last on Falcon, and DMA completion check first. TT has that reversed. That's a bit more hassle and might require
lib_NCR5380approach similar to the ESP SCSI driver.
Quoted 6 lines
Quoted 3 lines
Aside from TT and ST, is there a third configuration that might benefit from a more data driven configuration?
TT and Falcon, not sure any of the ST/STE series ever had a SCSI adapter. Medusa is TT compatible
If there's no third configuration then I see little to be gained from completely parameterizing the driver using a bunch of resources.
What am I missing? Why would it be desirable to have bits of driver code in arch/m68k/ and other bits of the same driver kept elsewhere in the tree (in drivers/)?
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
(and
IRQ_NONEis wrong, you should use 0)Quoted 2 lines
+ if (
IS_A_TT()) {Check for
instance->irqinstead?Yes, you'd think so, but a later patch (not in this set) would have to change it back to
IS_A_TT().
Quoted 6 lines
Quoted 5 lines
Further patches align
atari_NCR5380.cwithNCR5380.c, such that the core driver then checkshost->irqto find out whether an IRQ is in use. For Atari ST,request_irq()is not called even though the ST DMA irq is in use.That's why the IRQ is set to 0, I guess? Works for me.
My patch tests for IS_A_TT not 0 because 0 has a different meaning depending on which core driver you use. I don't want to support three forks of NCR5380.c. One of the objectives of this patch series is to try to move toward convergence on a common core driver.
Quoted 3 lines
The old code states that setting
instance->irq= 0 keeps the midlevel from tampering with the SCSI IRQ during queuecmd which would interfere with IDE and floppy.
I don't know what you mean. AFAIK, the SCSI mid layer doesn't care about instance->irq.
Quoted 2 lines
I guess this is still relevant - I would not have seen the ST-DMA locked by IDE during SCSI queuecmd otherwise.
Lock-ups were due to disabling local IRQs. Please see,
[PATCH 22/29] atari_scsi: Fix atari_scsi deadlocks on Falcon
in this series and (from our personal correspondence) the patch called ncr5380-atari_scsi-stdma_try_lock
Michael Schmitz
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
Hi Finn,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Can these be handled through the platform_device's resources?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I don't know.
Should be possible - I've seen that used in the ISP116x HCD driver (arch-dependent post-register access delay function passed via platform data).
Yes, possible, but is it desirable?
Only long term, i.e. if we can find a way to fold all the separate *_NCR5380 drivers into a core one.
Quoted 6 lines
If there's no third configuration then I see little to be gained from completely parameterizing the driver using a bunch of resources.
What am I missing? Why would it be desirable to have bits of driver code in
arch/m68k/and other bits of the same driver kept elsewhere in the tree (indrivers/)?
Again, only makes sense if the goal is to reduce the driver to a core driver with implementation bits separate.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 10 lines
(and
IRQ_NONEis wrong, you should use 0)Quoted 3 lines
+ if (
IS_A_TT()) {Check for
instance->irqinstead?Yes, you'd think so, but a later patch (not in this set) would have to change it back to
IS_A_TT().
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Further patches align
atari_NCR5380.cwithNCR5380.c, such that the core driver then checkshost->irqto find out whether an IRQ is in use. For Atari ST,request_irq()is not called even though the ST DMA irq is in use.That's why the IRQ is set to 0, I guess? Works for me.
My patch tests for
IS_A_TTnot 0 because 0 has a different meaning depending on which core driver you use. I don't want to support three forks ofNCR5380.c. One of the objectives of this patch series is to try to move toward convergence on a common core driver.
I wasn't talking about the use of IS_A_TT() here, rather about what host->irq = 0 achieves. Anyway, in the context of atari_scsi.c, host->irq == 0 is synonymous with !IS_A_TT(). If host->irq == 0 is problematic with the long term goal of a singe 5380 core driver, we'll just have to pick a value which means 'driver uses IRQ but you're not to fiddle with it'.
Quoted 5 lines
Quoted 2 lines
The old code states that setting
instance->irq= 0 keeps the midlevel from tampering with the SCSI IRQ during queuecmd which would interfere with IDE and floppy.I don't know what you mean. AFAIK, the SCSI mid layer doesn't care about
instance->irq.
You're right - that's another obsolete comment then. The midlevel uses spinlocks now for ages, this means we can set instance->irq to the actual IRQ used.
Quoted 5 lines
Quoted 2 lines
I guess this is still relevant - I would not have seen the ST-DMA locked by IDE during SCSI queuecmd otherwise.
Lock-ups were due to disabling local IRQs. Please see,
Absolutely right, but that's not what I meant. I assumed the midlevel disabled interrupts during queuecommand - it does not, so the point is moot. If using the actual IRQ for instance->irq helps at all, no objection to that.
SCSI commands can still be queued while IDE IO is in flight - that is what the 'ST-DMA locked by IDE' above refers to.
Cheers,
Michael
Re: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 4 lines · Michael Schmitz
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line
Can these be handled through the platform_device's resources?
I don't know.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Should be possible - I've seen that used in the ISP116x HCD driver (arch-dependent post-register access delay function passed via platform data).
Yes, possible, but is it desirable?
Only long term, i.e. if we can find a way to fold all the separate
*_NCR5380drivers into a core one.
But would it improve the ISA drivers to paramaterize the core driver using platform data? I don't know the answer, so I tend to think of code duplication as a separate issue.
Quoted 11 lines
Quoted 7 lines
If there's no third configuration then I see little to be gained from completely parameterizing the driver using a bunch of resources.
What am I missing? Why would it be desirable to have bits of driver code in
arch/m68k/and other bits of the same driver kept elsewhere in the tree (indrivers/)?Again, only makes sense if the goal is to reduce the driver to a core driver with implementation bits separate.
I think it makes sense if it completely eliminates modules like {atari,mac,sun3}_scsi and replaces them with a generic ncr5380 platform driver entirely parameterized by mac/atari/sun3 platform data.
Or maybe that would only amount to a complicated renaming, as the {atari,mac,sun3}_scsi driver logic would presumably just move from drivers/scsi to arch/m68k.
Anyway, that's a long way off. To begin with, it would require the elimination of all the macros (e.g. SUN3_SCSI_VME, REAL_DMA etc, and NCR5380_{read,write,dma_read_setup,etc}) and all the static variables (setup_use_tagged_queuing, atari_read_overruns etc).
I have written patches that eliminate static variables because that enables atari_NCR5380.c to support multiple chips, and it helps fix a compiler warning, and also helps cleanup the *RELEASE macros.
Replacing all the macros with flags and an ops struct/plataform data is not too difficult for atari_NCR5380.c at present but will be more difficult after sun3_NCR5380.c is merged into it.
The same goes for NCR5380.c and the ISA drivers.
I don't yet see a good way to merge all three core drivers, and if I did, I wouldn't be able to test the results. Hence I've taken a more gradual approach. This patch set eliminates scsi_register() from {atari,mac,sun3}_scsi at least.
Geert Uytterhoeven
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
In reply to Finn ThainQuoted 20 lines · Finn Thain
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
drivers/scsi/atari_scsi.c static int atari_scsi_bus_reset(struct s · line 950
Quoted 5 lines
drivers/scsi/atari_scsi.c +4
-0+if (IS_A_TT ()) + instance->irq =IRQ_TT_MFP_SCSI ; +else + instance->irq =IRQ_NONE ;
platform_deviceresource?If I thought it possible to parameterize the driver such that it never had to test
IS_A_TT(), I'd probably agree that this would be more elegant.Otherwise I'd prefer not to have parts of the logic separated off into the platform resources while the remaining logic remains in the driver itself.
While I don't think platform resources are desirable in this driver, I would like to hear Michael's views.
Quoted 5 lines
Quoted 1 line
The IRQ is a good candidate to be passed via platform data.
Geert didn't say so, but after thinking about his review comments I imagine that he wants all the Atari IRQ numbers kept in one place and all the Mac IRQ numbers in a different place, and so on. Makes sense.
In the end, it's the same SCSI chip.
The "only" differences are resources, interrupts, DMA, and glue logic.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Michael Schmitz
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
In reply to Finn ThainHi Finn,
not certain it is related to this exact patch - the driver crashes pretty much on the spot when selecting the first target on the bus.
Panic log:
Atari SCSI: resetting the SCSI bus... done
scsi host0: Atari native SCSI, io_port 0x0, n_io_port 0, base 0x0, irq 0, can_queue 8, cmd_per_lun 1, sg_tablesize 0, this_id 7, options { REAL_DMA SUPPORT_TAGS }blk_queue_max_segments: set to minimum 1blk_queue_max_segments: set to minimum 1blk_queue_max_segments: set to minimum 1
Unable to handle kernel NULL pointer dereference at virtual address 00000158
Oops: 00000000
Modules linked in:
PC: [<000cd87e>] do_coredump+0x3a/0xbe4
SR: 2204 SP: 20803c8c a2: 00a70000
d0: 00000000 d1: 003c0000 d2: 00000006 d3: 20803dbc
d4: 00025930 d5: 20802000 a0: 00b59c70 a1: 20802000
Process kworker/0:1 (pid: 69, task=00a70000)
Frame format=4 fault addr=00000158 fslw=01050200
Stack from 20803cc8:
00000006 20803dbc 00025930 20802000 0002b9be 0000001f 20803dd0
0002aa56
00a3c540 00b59c70 0008d3e0 00a07cc0 003a8074 00c75000 0002a664
00000007
00a7035c 20803dd0 20803e80 00000000 00000000 00000000 00000000
00000000
00a70374 0002a9d0 00c75000 00002200 20803dd0 00a70000 00000007
00a7035c
0002a5fe 00a70000 0002aa82 00002200 20803dbc 20803dd0 0002aa56
00a3c540
0002c5da 00b59c70 0002c6c4 20803dd0 00002200 20803f06 20803f00
00000000
Call Trace: [<00025930>] do_group_exit+0x0/0x9e
[<0002b9be>] do_signal_stop+0x0/0x186
[<0002aa56>] dequeue_signal+0x0/0x118
[<0008d3e0>] kmem_cache_free+0x10a/0x128
[<0002a664>] __sigqueue_free+0x32/0x3a
[<0002a9d0>] __dequeue_signal+0xaa/0x130
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0002a5fe>] recalc_sigpending+0x6/0x1e
[<0002aa82>] dequeue_signal+0x2c/0x118
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0002aa56>] dequeue_signal+0x0/0x118
[<0002c5da>] get_signal+0x7e/0x4aa
[<0002c6c4>] get_signal+0x168/0x4aa
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
[<000308b6>] move_linked_works+0x0/0x9c
[<0000428c>] do_signal+0x1a/0x1d8
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019d390>] NCR5380_main+0x9c6/0xd98
[<00046030>] handle_simple_irq+0x36/0x56
[<00002c36>] do_IRQ+0x26/0x32
[<00002200>] do_one_initcall+0x18c/0x1d4
[<00002b1c>] auto_irqhandler_fixup+0x4/0xc
[<00002200>] do_one_initcall+0x18c/0x1d4
[<00004a1a>] do_notify_resume+0x3a/0x44
[<00002ac8>] do_signal_return+0x10/0x1a
[<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
[<000308b6>] move_linked_works+0x0/0x9c
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019d390>] NCR5380_main+0x9c6/0xd98
[<00030a2a>] worker_enter_idle+0x0/0x146
[<00032a08>] process_one_work+0x0/0x2a8
[<00032cb0>] process_scheduled_works+0x0/0x30
[<000308b6>] move_linked_works+0x0/0x9c
[<00032cb0>] process_scheduled_works+0x0/0x30
[<000308b6>] move_linked_works+0x0/0x9c
[<00081c00>] change_protection_range+0x150/0x1cc
[<00032b14>] process_one_work+0x10c/0x2a8
[<002254bc>] schedule+0x0/0x58
[<00032dea>] worker_thread+0x10a/0x4d0
[<0003ee30>] __init_waitqueue_head+0x0/0xc
[<00032ce0>] worker_thread+0x0/0x4d0
[<0003ee30>] __init_waitqueue_head+0x0/0xc
[<00036ee0>] kthread+0xa4/0xc0
[<00036e3c>] kthread+0x0/0xc0
[<0000299c>] ret_from_kernel_thread+0xc/0x14
Code: 026c ffa4 206a 0354 2028 0170 2d40 ffac <202b> 0158 2d40 ffb0 286b 014c 4a8c 670c 4aac 0014 6706 e8c0 0782 660a 4cee 38fcDisabling lock debugging due to kernel taint
Unable to handle kernel NULL pointer dereference at virtual address 00000158
Oops: 00000000
Modules linked in:
PC: [<000372c2>] kthread_data+0x8/0x10
SR: 2700 SP: 20803af0 a2: 00a70000
d0: 00000003 d1: faf65c54 d2: 00a70000 d3: 00a701e8
d4: 00025930 d5: 20802000 a0: 00000000 a1: 00a90474
Process kworker/0:1 (pid: 69, task=00a70000)
Frame format=4 fault addr=fffffff0 fslw=01050020
Stack from 20803b2c:
00033976 00a70000 002252a6 00a70000 00000000 00000001 20803b98
00025930
20802000 00a70164 0000001f 00a70000 20803b98 00a6fff8 000255b8
00a90000
00025526 01050200 20803dbc 00025930 20802000 0002b9be 0000001f
20803c8c
00223674 20803dd0 20803d6c 20803b98 20803b98 00a701ac 0000581c
0000000b
00000007 00000001 00274ae2 0026dce5 0026e477 00000000 20803c8c
00006806
0026e477 20803c8c 00000000 0026e45f 00000158 20803c8c 0002aa56
00000007
Call Trace: [<00033976>] wq_worker_sleeping+0xa/0x82
[<002252a6>] __schedule+0x21e/0x394
[<00025930>] do_group_exit+0x0/0x9e
[<000255b8>] do_exit+0x550/0x846
[<00025526>] do_exit+0x4be/0x846
[<00025930>] do_group_exit+0x0/0x9e
[<0002b9be>] do_signal_stop+0x0/0x186
[<00223674>] printk+0x0/0x24
[<0000581c>] bad_super_trap+0x0/0xb2
[<00006806>] send_fault_sig+0xaa/0xea
[<0002aa56>] dequeue_signal+0x0/0x118
[<00005e5e>] buserr_c+0x254/0x390
[<0002aa56>] dequeue_signal+0x0/0x118
[<00002950>] buserr+0x20/0x28
[<00025930>] do_group_exit+0x0/0x9e
[<00025930>] do_group_exit+0x0/0x9e
[<0002b9be>] do_signal_stop+0x0/0x186
[<0002aa56>] dequeue_signal+0x0/0x118
[<0008d3e0>] kmem_cache_free+0x10a/0x128
[<0002a664>] __sigqueue_free+0x32/0x3a
[<0002a9d0>] __dequeue_signal+0xaa/0x130
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0002a5fe>] recalc_sigpending+0x6/0x1e
[<0002aa82>] dequeue_signal+0x2c/0x118
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0002aa56>] dequeue_signal+0x0/0x118
[<0002c5da>] get_signal+0x7e/0x4aa
[<0002c6c4>] get_signal+0x168/0x4aa
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
[<000308b6>] move_linked_works+0x0/0x9c
[<0000428c>] do_signal+0x1a/0x1d8
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019d390>] NCR5380_main+0x9c6/0xd98
[<00046030>] handle_simple_irq+0x36/0x56
[<00002c36>] do_IRQ+0x26/0x32
[<00002200>] do_one_initcall+0x18c/0x1d4
[<00002b1c>] auto_irqhandler_fixup+0x4/0xc
[<00002200>] do_one_initcall+0x18c/0x1d4
[<00004a1a>] do_notify_resume+0x3a/0x44
[<00002ac8>] do_signal_return+0x10/0x1a
[<0019bc12>] NCR5380_transfer_pio.isra.6+0x0/0x1da
[<000308b6>] move_linked_works+0x0/0x9c
[<00002200>] do_one_initcall+0x18c/0x1d4
[<0019d390>] NCR5380_main+0x9c6/0xd98
[<00030a2a>] worker_enter_idle+0x0/0x146
[<00032a08>] process_one_work+0x0/0x2a8
[<00032cb0>] process_scheduled_works+0x0/0x30
[<000308b6>] move_linked_works+0x0/0x9c
[<00032cb0>] process_scheduled_works+0x0/0x30
[<000308b6>] move_linked_works+0x0/0x9c
[<00081c00>] change_protection_range+0x150/0x1cc
[<00032b14>] process_one_work+0x10c/0x2a8
[<002254bc>] schedule+0x0/0x58
[<00032dea>] worker_thread+0x10a/0x4d0
[<0003ee30>] __init_waitqueue_head+0x0/0xc
[<00032ce0>] worker_thread+0x0/0x4d0
[<0003ee30>] __init_waitqueue_head+0x0/0xc
[<00036ee0>] kthread+0xa4/0xc0
[<00036e3c>] kthread+0x0/0xc0
[<0000299c>] ret_from_kernel_thread+0xc/0x14
Code: e9e8 0141 ffeb 4e75 206f 0004 2068 01bc <2068> fff0 2008 4e75 598f 2f0e 206f 000c 2068 01bc 4def 0008 42a6 4878 0004 4868Fixing recursive fault but reboot is needed!
(loops until reset)
Same kernel version (Geert's m68k tree as of yesterday) with your earlier patch series applied runs OK.
Cheers,
Michael
Quoted 565 lines
Convert
atari_scsito platform device and eliminatescsi_register().Validate
__setupoptions 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 <[email protected]>--- arch/m68k/atari/config.c | 5 drivers/scsi/atari_scsi.c | 426 ++++++++++++++++++++++------------------------ drivers/scsi/atari_scsi.h | 17 - 3 files changed, 217 insertions(+), 231 deletions(-)Index:
linux/arch/m68k/atari/config.c
===================================================================arch/m68k/atari/config.c +5
-0@@ -892,6 +892,11 @@ int __init atari_platform_init(void) }#endif +#ifdef CONFIG_ATARI_SCSI +if (ATARIHW_PRESENT (ST_SCSI ) ||ATARIHW_PRESENT (TT_SCSI )) +platform_device_register_simple ("atari_scsi" ,-1 ,NULL ,0 ); +#endif +return rv; }Index:
linux/drivers/scsi/atari_scsi.c
===================================================================drivers/scsi/atari_scsi.c +212
-214@@ -74,33 +74,26 @@#define MAX_TAGS 32#include <linux/types.h> -#include <linux/stddef.h> -#include <linux/ctype.h> #include <linux/delay.h> -#include <linux/mm.h> #include <linux/blkdev.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/nvram.h> #include <linux/bitops.h> #include <linux/wait.h> +#include <linux/platform_device.h> #include <asm/setup.h> #include <asm/atarihw.h> #include <asm/atariints.h> -#include <asm/page.h> -#include <asm/pgtable.h> -#include <asm/irq.h> -#include <asm/traps.h> - -#include <scsi/scsi_host.h> -#include "atari_scsi.h" -#include "NCR5380.h" #include <asm/atari_stdma.h> #include <asm/atari_stram.h> #include <asm/io.h> -#include <linux/stat.h> +#include <scsi/scsi_host.h> + +#include "atari_scsi.h" +#include "NCR5380.h" #define IS_A_TT () ATARIHW_PRESENT(TT_SCSI)@@ -176,25 +169,9 @@ static inline void DISABLE_IRQ(void)#define AFTER_RESET_DELAY (5*HZ/2)#endif -/***************************** Prototypes *****************************/ -#ifdef REAL_DMA static void atari_scsi_fetch_restbytes (void );#endif -static irqreturn_t scsi_tt_intr (int irq,void *dummy); -static irqreturn_t scsi_falcon_intr (int irq,void *dummy); -static void falcon_release_lock_if_possible (struct NCR5380_hostdata *hostdata); -static int falcon_get_lock (void ); -#ifdef CONFIG_ATARI_SCSI_RESET_BOOT -static void atari_scsi_reset_boot (void ); -#endif -static unsigned char atari_scsi_tt_reg_read (unsigned char reg); -static void atari_scsi_tt_reg_write (unsigned char reg,unsigned char value); -static unsigned char atari_scsi_falcon_reg_read (unsigned char reg); -static void atari_scsi_falcon_reg_write (unsigned char reg,unsigned char value); - -/************************* End of Prototypes **************************/ -static struct Scsi_Host *atari_scsi_host;static unsigned char (*atari_scsi_reg_read)(unsigned char reg);@@ -518,160 +495,12 @@ static int falcon_get_lock(void) } } - -static int __init atari_scsi_detect (struct scsi_host_template *host) -{ -static int called =0 ; -struct Scsi_Host *instance; - -if (!MACH_IS_ATARI || - (!ATARIHW_PRESENT (ST_SCSI ) && !ATARIHW_PRESENT (TT_SCSI )) || - called) -return 0 ; - - host->proc_name ="Atari" ; - - atari_scsi_reg_read =IS_A_TT () ? atari_scsi_tt_reg_read : - atari_scsi_falcon_reg_read; - atari_scsi_reg_write =IS_A_TT () ? atari_scsi_tt_reg_write : - atari_scsi_falcon_reg_write; - -/* setup variables */ - host->can_queue = - (setup_can_queue >0 ) ? setup_can_queue : -IS_A_TT () ?ATARI_TT_CAN_QUEUE :ATARI_FALCON_CAN_QUEUE ; - host->cmd_per_lun = - (setup_cmd_per_lun >0 ) ? setup_cmd_per_lun : -IS_A_TT () ?ATARI_TT_CMD_PER_LUN :ATARI_FALCON_CMD_PER_LUN ; -/* Force sg_tablesize to 0 on a Falcon! */ - host->sg_tablesize = - !IS_A_TT () ?ATARI_FALCON_SG_TABLESIZE : - (setup_sg_tablesize >=0 ) ? setup_sg_tablesize :ATARI_TT_SG_TABLESIZE ; - -if (setup_hostid >=0 ) - host->this_id = setup_hostid; -else { -/* use 7 as default */ - host->this_id =7 ; -/* Test if a host id is set in the NVRam */ -if (ATARIHW_PRESENT (TT_CLK ) &&nvram_check_checksum ()) { -unsigned char b =nvram_read_byte (14 ); -/* Arbitration enabled? (for TOS) If yes, use configured host ID */ -if (b &0x80 ) - host->this_id = b &7 ; - } - } - -#ifdef SUPPORT_TAGS -if (setup_use_tagged_queuing <0 ) - setup_use_tagged_queuing =0 ; -#endif -#ifdef REAL_DMA -/* If running on a Falcon and if there's TT-Ram (i.e., more than one -* memory block, since there's always ST-Ram in a Falcon), then allocate a -* STRAM_BUFFER_SIZE byte dribble buffer for transfers from/to alternative -* Ram. -*/ -if (MACH_IS_ATARI &&ATARIHW_PRESENT (ST_SCSI ) && - !ATARIHW_PRESENT (EXTD_DMA ) && m68k_num_memory >1 ) { - atari_dma_buffer =atari_stram_alloc (STRAM_BUFFER_SIZE ,"SCSI" ); -if (!atari_dma_buffer) { -printk (KERN_ERR "atari_scsi_detect: can't allocate ST-RAM " -"double buffer\n" ); -return 0 ; - } - atari_dma_phys_buffer =atari_stram_to_phys (atari_dma_buffer); - atari_dma_orig_addr =0 ; - } -#endif - instance =scsi_register (host,sizeof (struct NCR5380_hostdata )); -if (instance ==NULL ) { -atari_stram_free (atari_dma_buffer); - atari_dma_buffer =0 ; -return 0 ; - } - atari_scsi_host = instance; -/* -* Set irq to 0, to avoid that the mid-level code disables our interrupt -* during queue_command calls. This is completely unnecessary, and even -* worse causes bad problems on the Falcon, where the int is shared with -* IDE and floppy! -*/ - instance->irq =0 ; - -#ifdef CONFIG_ATARI_SCSI_RESET_BOOT -atari_scsi_reset_boot (); -#endif -NCR5380_init (instance,0 ); - -if (IS_A_TT ()) { - -/* This int is actually "pseudo-slow", i.e. it acts like a slow -* interrupt after having cleared the pending flag for the DMA -* interrupt. */ -if (request_irq (IRQ_TT_MFP_SCSI , scsi_tt_intr,IRQ_TYPE_SLOW , -"SCSI NCR5380" , instance)) { -printk (KERN_ERR "atari_scsi_detect: cannot allocate irq %d, aborting" ,IRQ_TT_MFP_SCSI ); -scsi_unregister (atari_scsi_host); -atari_stram_free (atari_dma_buffer); - atari_dma_buffer =0 ; -return 0 ; - } - tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ -#ifdef REAL_DMA - tt_scsi_dma.dma_ctrl =0 ; - atari_dma_residual =0 ; - -if (MACH_IS_MEDUSA ) { -/* While the read overruns (described by Drew Eckhardt in -* NCR5380.c) never happened on TTs, they do in fact on the Medusa -* (This was the cause why SCSI didn't work right for so long -* there.) Since handling the overruns slows down a bit, I turned -* the #ifdef's into a runtime condition. -* -* In principle it should be sufficient to do max. 1 byte with -* PIO, but there is another problem on the Medusa with the DMA -* rest data register. So 'atari_read_overruns' is currently set -* to 4 to avoid having transfers that aren't a multiple of 4. If -* the rest data bug is fixed, this can be lowered to 1. -*/ - atari_read_overruns =4 ; - } -#endif /*REAL_DMA*/ - }else {/* ! IS_A_TT */ - -/* Nothing to do for the interrupt: the ST-DMA is initialized -* already by atari_init_INTS() -*/ - -#ifdef REAL_DMA - atari_dma_residual =0 ; - atari_dma_active =0 ; - atari_dma_stram_mask = (ATARIHW_PRESENT (EXTD_DMA ) ?0x00000000 - :0xff000000 ); -#endif - } - - called =1 ; -return 1 ; -} - -static int atari_scsi_release (struct Scsi_Host *sh) -{ -if (IS_A_TT ()) -free_irq (IRQ_TT_MFP_SCSI , sh); -if (atari_dma_buffer) -atari_stram_free (atari_dma_buffer); -NCR5380_exit (sh); -return 1 ; -} -#ifndef MODULE static int __init atari_scsi_setup (char *str) {/* Format of atascsi parameter is: * atascsi=<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> -* Defaults depend on TT or Falcon, hostid determined at run time. +* Defaults depend on TT or Falcon, determined at run time. * Negative values mean don't change. */ int ints[6 ];@@ -682,36 +511,17 @@ static int __init atari_scsi_setup(charprintk ("atari_scsi_setup: no arguments!\n" );return 0 ; } - -if (ints[0 ] >=1 ) { -if (ints[1 ] >0 ) -/* no limits on this, just > 0 */ - setup_can_queue = ints[1 ]; - } -if (ints[0 ] >=2 ) { -if (ints[2 ] >0 ) - setup_cmd_per_lun = ints[2 ]; - } -if (ints[0 ] >=3 ) { -if (ints[3 ] >=0 ) { - setup_sg_tablesize = ints[3 ]; -/* Must be <= SG_ALL (255) */ -if (setup_sg_tablesize >SG_ALL ) - setup_sg_tablesize =SG_ALL ; - } - } -if (ints[0 ] >=4 ) { -/* Must be between 0 and 7 */ -if (ints[4 ] >=0 && ints[4 ] <=7 ) - setup_hostid = ints[4 ]; -else if (ints[4 ] >7 ) -printk ("atari_scsi_setup: invalid host ID %d !\n" , ints[4 ]); - } +if (ints[0 ] >=1 ) + setup_can_queue = ints[1 ]; +if (ints[0 ] >=2 ) + setup_cmd_per_lun = ints[2 ]; +if (ints[0 ] >=3 ) + setup_sg_tablesize = ints[3 ]; +if (ints[0 ] >=4 ) + setup_hostid = ints[4 ];#ifdef SUPPORT_TAGS -if (ints[0 ] >=5 ) { -if (ints[5 ] >=0 ) - setup_use_tagged_queuing = !!ints[5 ]; - } +if (ints[0 ] >=5 ) + setup_use_tagged_queuing = ints[5 ];#endif return 1 ;@@ -1020,23 +830,211 @@ static int atari_scsi_bus_reset(struct sreturn rv; } -static struct scsi_host_template driver_template = { +#define DRV_MODULE_NAME "atari_scsi" +#define PFX DRV_MODULE_NAME ": " + +static struct scsi_host_template atari_scsi_template = { + .module =THIS_MODULE , + .proc_name =DRV_MODULE_NAME , .show_info = atari_scsi_show_info, .name ="Atari native SCSI" , - .detect = atari_scsi_detect, - .release = atari_scsi_release, .info = atari_scsi_info, .queuecommand = atari_scsi_queue_command, .eh_abort_handler = atari_scsi_abort, .eh_bus_reset_handler = atari_scsi_bus_reset, - .can_queue =0 ,/* initialized at run-time */ - .this_id =0 ,/* initialized at run-time */ - .sg_tablesize =0 ,/* initialized at run-time */ - .cmd_per_lun =0 ,/* initialized at run-time */ + .this_id =7 , .use_clustering =DISABLE_CLUSTERING }; +static int __init atari_scsi_probe (struct platform_device *pdev) +{ +struct Scsi_Host *instance; +int error; + +if (!MACH_IS_ATARI ) +return -ENODEV ; + +if (ATARIHW_PRESENT (TT_SCSI )) { + atari_scsi_reg_read = atari_scsi_tt_reg_read; + atari_scsi_reg_write = atari_scsi_tt_reg_write; + }else if (ATARIHW_PRESENT (ST_SCSI )) { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write; + }else +return -ENODEV ; + +/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. +* Higher values should work, too; try it! +* (But cmd_per_lun costs memory!) +* +* But there seems to be a bug somewhere that requires CAN_QUEUE to be +* 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since +* changed CMD_PER_LUN... +* +* Note: The Falcon currently uses 8/1 setting due to unsolved problems +* with cmd_per_lun != 1 +*/ +if (IS_A_TT ()) { + atari_scsi_template.can_queue =16 ; + atari_scsi_template.cmd_per_lun =8 ; + atari_scsi_template.sg_tablesize =SG_ALL ; + }else { + atari_scsi_template.can_queue =8 ; + atari_scsi_template.cmd_per_lun =1 ; + atari_scsi_template.sg_tablesize =SG_NONE ; + } + +if (setup_can_queue >0 ) + atari_scsi_template.can_queue = setup_can_queue; + +if (setup_cmd_per_lun >0 ) + atari_scsi_template.cmd_per_lun = setup_cmd_per_lun; + +/* Leave sg_tablesize at 0 on a Falcon! */ +if (IS_A_TT () && setup_sg_tablesize >=0 ) + atari_scsi_template.sg_tablesize = setup_sg_tablesize; + +if (setup_hostid >=0 ) { + atari_scsi_template.this_id = setup_hostid &7 ; + }else { +/* Test if a host id is set in the NVRam */ +if (ATARIHW_PRESENT (TT_CLK ) &&nvram_check_checksum ()) { +unsigned char b =nvram_read_byte (14 ); + +/* Arbitration enabled? (for TOS) +* If yes, use configured host ID +*/ +if (b &0x80 ) + atari_scsi_template.this_id = b &7 ; + } + } + +#ifdef SUPPORT_TAGS +if (setup_use_tagged_queuing <0 ) + setup_use_tagged_queuing =0 ; +#endif + +#ifdef REAL_DMA +/* If running on a Falcon and if there's TT-Ram (i.e., more than one +* memory block, since there's always ST-Ram in a Falcon), then +* allocate a STRAM_BUFFER_SIZE byte dribble buffer for transfers +* from/to alternative Ram. +*/ +if (ATARIHW_PRESENT (ST_SCSI ) && !ATARIHW_PRESENT (EXTD_DMA ) && + m68k_num_memory >1 ) { + atari_dma_buffer =atari_stram_alloc (STRAM_BUFFER_SIZE ,"SCSI" ); +if (!atari_dma_buffer) { +pr_err (PFX "can't allocate ST-RAM double buffer\n" ); +return -ENOMEM ; + } + atari_dma_phys_buffer =atari_stram_to_phys (atari_dma_buffer); + atari_dma_orig_addr =0 ; + } +#endif + + instance =scsi_host_alloc (&atari_scsi_template, +sizeof (struct NCR5380_hostdata )); +if (!instance) { + error = -ENOMEM ; + goto fail_alloc; + } + atari_scsi_host = instance; + +#ifdef CONFIG_ATARI_SCSI_RESET_BOOT +atari_scsi_reset_boot (); +#endif + +if (IS_A_TT ()) + instance->irq =IRQ_TT_MFP_SCSI ; +else + instance->irq =IRQ_NONE ; + +NCR5380_init (instance,0 ); + +if (IS_A_TT ()) { + error =request_irq (instance->irq, scsi_tt_intr,0 , +"NCR5380" , instance); +if (error) { +pr_err (PFX "request irq %d failed, aborting\n" , + instance->irq); + goto fail_irq; + } + tt_mfp.active_edge |=0x80 ;/* SCSI int on L->H */ +#ifdef REAL_DMA + tt_scsi_dma.dma_ctrl =0 ; + atari_dma_residual =0 ; + +/* While the read overruns (described by Drew Eckhardt in +* NCR5380.c) never happened on TTs, they do in fact on the +* Medusa (This was the cause why SCSI didn't work right for +* so long there.) Since handling the overruns slows down +* a bit, I turned the #ifdef's into a runtime condition. +* +* In principle it should be sufficient to do max. 1 byte with +* PIO, but there is another problem on the Medusa with the DMA +* rest data register. So 'atari_read_overruns' is currently set +* to 4 to avoid having transfers that aren't a multiple of 4. +* If the rest data bug is fixed, this can be lowered to 1. +*/ +if (MACH_IS_MEDUSA ) + atari_read_overruns =4 ; +#endif + }else { +/* Nothing to do for the interrupt: the ST-DMA is initialized +* already. +*/ +#ifdef REAL_DMA + atari_dma_residual =0 ; + atari_dma_active =0 ; + atari_dma_stram_mask = (ATARIHW_PRESENT (EXTD_DMA ) ?0x00000000 + :0xff000000 ); +#endif + } + + error =scsi_add_host (instance,NULL ); +if (error) + goto fail_host; + +platform_set_drvdata (pdev, instance); + +scsi_scan_host (instance); +return 0 ; + +fail_host: +if (instance->irq !=IRQ_NONE ) +free_irq (instance->irq, instance); +fail_irq: +NCR5380_exit (instance); +scsi_host_put (instance); +fail_alloc: +if (atari_dma_buffer) +atari_stram_free (atari_dma_buffer); +return error; +} + +static int __exit atari_scsi_remove(struct platform_device *pdev) +{ +struct Scsi_Host *instance =platform_get_drvdata (pdev); + +scsi_remove_host (instance); +if (instance->irq !=IRQ_NONE ) +free_irq (instance->irq, instance); +NCR5380_exit (instance); +scsi_host_put (instance); +if (atari_dma_buffer) +atari_stram_free (atari_dma_buffer); +return 0 ; +} + +static struct platform_driver atari_scsi_driver = { + .remove =__exit_p (atari_scsi_remove), + .driver = { + .name =DRV_MODULE_NAME , + .owner =THIS_MODULE , + }, +}; -#include "scsi_module.c" +module_platform_driver_probe (atari_scsi_driver, atari_scsi_probe); +MODULE_ALIAS ("platform:" DRV_MODULE_NAME );MODULE_LICENSE ("GPL" );Index:
linux/drivers/scsi/atari_scsi.h
===================================================================drivers/scsi/atari_scsi.h +0
-18@@ -18,23 +18,6 @@/* (I_HAVE_OVERRUNS stuff removed) */ #ifndef ASM -/* The values for CMD_PER_LUN and CAN_QUEUE are somehow arbitrary. Higher -* values should work, too; try it! (but cmd_per_lun costs memory!) */ - -/* But there seems to be a bug somewhere that requires CAN_QUEUE to be -* 2*CMD_PER_LUN. At least on a TT, no spurious timeouts seen since -* changed CMD_PER_LUN... */ - -/* Note: The Falcon currently uses 8/1 setting due to unsolved problems with -* cmd_per_lun != 1 */ - -#define ATARI_TT_CAN_QUEUE 16 -#define ATARI_TT_CMD_PER_LUN 8 -#define ATARI_TT_SG_TABLESIZE SG_ALL - -#define ATARI_FALCON_CAN_QUEUE 8 -#define ATARI_FALCON_CMD_PER_LUN 1 -#define ATARI_FALCON_SG_TABLESIZE SG_NONE#define NCR5380_implementation_fields/* none */ --To unsubscribe from this list: send the line "unsubscribe linux-m68k" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 4 lines · Michael Schmitz
Hi Finn,
not certain it is related to this exact patch - the driver crashes pretty much on the spot when selecting the first target on the bus.
If it isn't that exact patch then it will probably be one of the other atari_scsi patches. Most of the other relevant stuff was covered by my own testing.
Anyway, thanks for testing and for sending the backtrace. I'll figure out what went wrong and fix it before I send a new patch set.
Michael Schmitz
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
Hi Finn,
Quoted 9 lines
Quoted 2 lines
not certain it is related to this exact patch - the driver crashes pretty much on the spot when selecting the first target on the bus.
If it isn't that exact patch then it will probably be one of the other
atari_scsipatches. Most of the other relevant stuff was covered by my own testing.Anyway, thanks for testing and for sending the backtrace. I'll figure out what went wrong and fix it before I send a new patch set.
Let me know what I can do to help - e.g. can the platform device patch be backed out without upsetting the rest of the series?
Cheers,
Michael
Michael Schmitz
maintainerRe: [PATCH 23/29] atari_scsi: Convert to platform device
In reply to Finn ThainFinn,
Quoted 13 lines · Michael Schmitz
Quoted 6 lines
Hi Finn,
not certain it is related to this exact patch - the driver crashes pretty much on the spot when selecting the first target on the bus.
If it isn't that exact patch then it will probably be one of the other
atari_scsipatches. Most of the other relevant stuff was covered by my own testing.Anyway, thanks for testing and for sending the backtrace. I'll figure out what went wrong and fix it before I send a new patch set.
Turns out I missed a reject in patch 29 of the series (hunk #4) which caused a local_irq_save(flags) to go AWOL. Both commenting out the resulting lone local_irq_restore(flags), as well as fixing the reject properly makes the driver behave as it should.
No locking races, and no more warnings about bytes stuck in the DMA fifo. We might be on to a winner here :-)
Cheers,
Michael
Re: [PATCH 23/29] atari_scsi: Convert to platform device
Quoted 7 lines · Michael Schmitz
Quoted 6 lines · Michael Schmitz
Quoted 4 lines
not certain it is related to this exact patch - the driver crashes pretty much on the spot when selecting the first target on the bus.
...
Quoted 7 lines
Turns out I missed a reject in patch 29 of the series (hunk #4) which caused a
local_irq_save(flags)to go AWOL. Both commenting out the resulting lonelocal_irq_restore(flags), as well as fixing the reject properly makes the driver behave as it should.No locking races, and no more warnings about bytes stuck in the DMA fifo. We might be on to a winner here :-)
That's good to hear. Thanks for testing v1. I'll send v2 when I'm done testing it.
PATCH 24/29 atari_scsi: Remove header
In reply to Finn ThainThe #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.
--- drivers/scsi/atari_scsi.c | 35 ++++++++++++++++++++++++++--------- drivers/scsi/atari_scsi.h | 40 ---------------------------------------- 2 files changed, 26 insertions(+), 49 deletions(-)
drivers/scsi/atari_scsi.c +26 -9
@@ -64,15 +64,7 @@/**************************************************************************/ -#include <linux/module.h> - -/* For the Atari version, use only polled IO or REAL_DMA */ -#define REAL_DMA -/* Support tagged queuing? (on devices that are able to... :-) */ -#define SUPPORT_TAGS -#define MAX_TAGS 32 -#include <linux/types.h> #include <linux/delay.h> #include <linux/blkdev.h>
@@ -92,9 +84,34 @@#include <scsi/scsi_host.h> -#include "atari_scsi.h" +/* Definitions for the core NCR5380 driver. */ + +#define REAL_DMA +#define SUPPORT_TAGS +#define MAX_TAGS 32 + +#define NCR5380_implementation_fields/* none */ + +#define NCR5380_read (reg) atari_scsi_reg_read(reg) +#define NCR5380_write (reg, value) atari_scsi_reg_write(reg, value) + +#define NCR5380_queue_command atari_scsi_queue_command +#define NCR5380_abort atari_scsi_abort +#define NCR5380_show_info atari_scsi_show_info +#define NCR5380_info atari_scsi_info + +#define NCR5380_dma_read_setup (instance, data, count) \ + atari_scsi_dma_setup(instance, data, count, 0) +#define NCR5380_dma_write_setup (instance, data, count) \ + atari_scsi_dma_setup(instance, data, count, 1) +#define NCR5380_dma_residual (instance) \ + atari_scsi_dma_residual(instance) +#define NCR5380_dma_xfer_len (instance, cmd, phase) \ + atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) +#include "NCR5380.h" +#define IS_A_TT () ATARIHW_PRESENT(TT_SCSI)#define SCSI_DMA_WRITE_P (elt,val) \
drivers/scsi/atari_scsi.h deleted +0 -40
@@ -1,40 +0,0 @@ -/* -* atari_scsi.h -- Header file for the Atari native SCSI driver -* -* Copyright 1994 Roman Hodek <[email protected]> -* -* (Loosely based on the work of Robert De Vries' team) -* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file COPYING in the main directory of this archive -* for more details. -* -*/ - - -#ifndef ATARI_SCSI_H -#define ATARI_SCSI_H - -/* (I_HAVE_OVERRUNS stuff removed) */ - -#ifndef ASM - -#define NCR5380_implementation_fields/* none */ - -#define NCR5380_read (reg) atari_scsi_reg_read( reg ) -#define NCR5380_write (reg, value) atari_scsi_reg_write( reg, value ) - -#define NCR5380_queue_command atari_scsi_queue_command -#define NCR5380_abort atari_scsi_abort -#define NCR5380_show_info atari_scsi_show_info -#define NCR5380_info atari_scsi_info -#define NCR5380_dma_read_setup (inst,d,c) atari_scsi_dma_setup (inst, d, c, 0) -#define NCR5380_dma_write_setup (inst,d,c) atari_scsi_dma_setup (inst, d, c, 1) -#define NCR5380_dma_residual (inst) atari_scsi_dma_residual( inst ) -#define NCR5380_dma_xfer_len (i,cmd,phase) \ - atari_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1) - -#endif /* ndef ASM */ -#endif /* ATARI_SCSI_H */ - -
PATCH 25/29 sun3_scsi: Convert to platform device
In reply to Finn ThainConvert sun3_scsi to platform device and eliminate scsi_register().
--- arch/m68k/sun3/config.c | 11 + drivers/scsi/sun3_scsi.c | 405 +++++++++++++++++++++++------------------------ drivers/scsi/sun3_scsi.h | 8 3 files changed, 214 insertions(+), 210 deletions(-)
arch/m68k/sun3/config.c +11 -0
@@ -16,6 +16,7 @@#include <linux/console.h> #include <linux/init.h> #include <linux/bootmem.h> +#include <linux/platform_device.h> #include <asm/oplib.h> #include <asm/setup.h>
@@ -169,3 +170,13 @@ static void __init sun3_sched_init(irq_hintersil_clear (); } +#ifdef CONFIG_SUN3_SCSI +int __init sun3_platform_init (void ) +{ +platform_device_register_simple ("sun3_scsi" ,-1 ,NULL ,0 ); +platform_device_register_simple ("sun3_scsi_vme" ,-1 ,NULL ,0 ); +return 0 ; +} + +arch_initcall (sun3_platform_init); +#endif
drivers/scsi/sun3_scsi.c +203 -202
466 lines not on this page · raw message
drivers/scsi/sun3_scsi.h +0 -8
@@ -29,14 +29,6 @@#define MAX_TAGS 32 -#include <scsi/scsicam.h> - -#ifdef SUN3_SCSI_VME -#define SUN3_SCSI_NAME "Sun3 NCR5380 VME SCSI" -#else -#define SUN3_SCSI_NAME "Sun3 NCR5380 SCSI" -#endif -#define NCR5380_implementation_fields/* none */ #define NCR5380_local_declare () \
PATCH 26/29 sun3_scsi: Move macro definitions
In reply to Finn ThainThe #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.
--- drivers/scsi/sun3_scsi.c | 45 ++++++++++++++++++++++++++++++++------------- drivers/scsi/sun3_scsi.h | 25 ------------------------- 2 files changed, 32 insertions(+), 38 deletions(-)
drivers/scsi/sun3_scsi.c +32 -13
@@ -36,18 +36,42 @@#include <asm/idprom.h> #include <asm/machines.h> -/* dma on! */ -#define REAL_DMA -#include <scsi/scsi_host.h> #include "sun3_scsi.h" -#include "NCR5380.h" -extern int sun3_map_test (unsigned long ,char *); +/* Definitions for the core NCR5380 driver. */ -/*#define RESET_BOOT */ +#define REAL_DMA +#define RESET_RUN_DONE /* #define SUPPORT_TAGS */ +/* #define MAX_TAGS 32 */ + +#define NCR5380_implementation_fields/* none */ + +#define NCR5380_read (reg) sun3scsi_read(reg) +#define NCR5380_write (reg, value) sun3scsi_write(reg, value) + +#define NCR5380_queue_command sun3scsi_queue_command +#define NCR5380_bus_reset sun3scsi_bus_reset +#define NCR5380_abort sun3scsi_abort +#define NCR5380_show_info sun3scsi_show_info +#define NCR5380_info sun3scsi_info + +#define NCR5380_dma_read_setup (instance, data, count) \ + sun3scsi_dma_setup(data, count, 0) +#define NCR5380_dma_write_setup (instance, data, count) \ + sun3scsi_dma_setup(data, count, 1) +#define NCR5380_dma_residual (instance) \ + sun3scsi_dma_residual(instance) +#define NCR5380_dma_xfer_len (instance, cmd, phase) \ + sun3scsi_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) + +#include "NCR5380.h" + + +extern int sun3_map_test (unsigned long ,char *); +#ifdef SUN3_SCSI_VME #define ENABLE_IRQ ()#else
@@ -68,9 +92,7 @@ module_param(setup_use_tagged_queuing, istatic int setup_hostid =-1 ;module_param (setup_hostid, int,0 ); -static struct scsi_cmnd *sun3_dma_setup_done =NULL ; - -#define RESET_RUN_DONE +/* #define RESET_BOOT */ #define AFTER_RESET_DELAY (HZ/2)
@@ -83,6 +105,7 @@ static struct scsi_cmnd *sun3_dma_setup_/* minimum number of bytes to do dma on */ #define SUN3_DMA_MINSIZE 128 +static struct scsi_cmnd *sun3_dma_setup_done;static unsigned char *sun3_scsi_regp;static volatile struct sun3_dma_regs *dregs;static struct sun3_udc_regs *udc_regs;
@@ -134,9 +157,6 @@ static inline void sun3_udc_write(unsignstatic void sun3_scsi_reset_boot (struct Scsi_Host *instance) {unsigned long end; - -NCR5380_local_declare (); -NCR5380_setup (instance);/* * Do a SCSI reset to clean up the bus during initialization. No
@@ -213,7 +233,6 @@ static irqreturn_t scsi_sun3_intr(int irvoid sun3_sun3_debug (void ) {unsigned long flags; -NCR5380_local_declare ();if (default_instance) {local_irq_save (flags);
drivers/scsi/sun3_scsi.h +0 -25
@@ -27,31 +27,6 @@#define IOBASE_SUN3_VMESCSI 0xff200000 -#define MAX_TAGS 32 - -#define NCR5380_implementation_fields/* none */ - -#define NCR5380_local_declare () \ - struct Scsi_Host *_instance - -#define NCR5380_setup (instance) \ - _instance = instance - -#define NCR5380_read (reg) sun3scsi_read(reg) -#define NCR5380_write (reg, value) sun3scsi_write(reg, value) - -#define NCR5380_queue_command sun3scsi_queue_command -#define NCR5380_bus_reset sun3scsi_bus_reset -#define NCR5380_abort sun3scsi_abort -#define NCR5380_show_info sun3scsi_show_info -#define NCR5380_info sun3scsi_info -#define NCR5380_dma_xfer_len (i, cmd, phase) \ - sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1) - -#define NCR5380_dma_write_setup (instance, data, count) sun3scsi_dma_setup(data, count, 1) -#define NCR5380_dma_read_setup (instance, data, count) sun3scsi_dma_setup(data, count, 0) -#define NCR5380_dma_residual sun3scsi_dma_residual -/* additional registers - mainly DMA control regs */ /* these start at regbase + 8 -- directly after the NCR regs */ struct sun3_dma_regs {
PATCH 27/29 ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros
In reply to Finn Thainatari_NCR5380.c enables its IRQ when it is already enabled. Sun3 doesn't use the ENABLE_IRQ/DISABLE_IRQ cruft. Remove it.
--- 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(-)
drivers/scsi/atari_NCR5380.c +0 -2
@@ -1226,7 +1226,6 @@ static irqreturn_t NCR5380_intr(int irq,NCR5380_dprint (NDEBUG_INTR , instance);if ((NCR5380_read (STATUS_REG ) & (SR_SEL |SR_IO )) == (SR_SEL |SR_IO )) { done =0 ; -ENABLE_IRQ ();dprintk (NDEBUG_INTR ,"scsi%d: SEL interrupt\n" ,HOSTNO );NCR5380_reselect (instance); (void )NCR5380_read (RESET_PARITY_INTERRUPT_REG );
@@ -1256,7 +1255,6 @@ static irqreturn_t NCR5380_intr(int irq,dprintk (NDEBUG_INTR ,"scsi%d: PHASE MISM or EOP interrupt\n" ,HOSTNO );NCR5380_dma_complete ( instance ); done =0 ; -ENABLE_IRQ (); } else#endif /* REAL_DMA */ {
drivers/scsi/atari_scsi.c +0 -21
@@ -157,23 +157,6 @@ static inline unsigned long SCSI_DMA_GETreturn 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 ; }
drivers/scsi/sun3_NCR5380.c +0 -2
@@ -1153,7 +1153,6 @@ static irqreturn_t NCR5380_intr (int irqNCR5380_dprint (NDEBUG_INTR , instance);if ((NCR5380_read (STATUS_REG ) & (SR_SEL |SR_IO )) == (SR_SEL |SR_IO )) { done =0 ; -// ENABLE_IRQ(); dprintk (NDEBUG_INTR ,"scsi%d: SEL interrupt\n" ,HOSTNO );NCR5380_reselect (instance); (void )NCR5380_read (RESET_PARITY_INTERRUPT_REG );
@@ -1186,7 +1185,6 @@ static irqreturn_t NCR5380_intr (int irqdprintk (NDEBUG_INTR ,"scsi%d: PHASE MISM or EOP interrupt\n" ,HOSTNO );NCR5380_dma_complete ( instance ); done =0 ; -// ENABLE_IRQ(); } else#endif /* REAL_DMA */ {
drivers/scsi/sun3_scsi.c +0 -7
@@ -72,13 +72,6 @@extern int sun3_map_test (unsigned long ,char *); -#ifdef SUN3_SCSI_VME -#define ENABLE_IRQ () -#else -#define ENABLE_IRQ () enable_irq( IRQ_SUN3_SCSI ); -#endif - -static int setup_can_queue =-1 ;module_param (setup_can_queue, int,0 );static int setup_cmd_per_lun =-1 ;
PATCH 28/29 atari_NCR5380: Refactor Falcon special cases
In reply to Finn ThainMake 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.
--- drivers/scsi/NCR5380.h | 4 ++++ drivers/scsi/atari_NCR5380.c | 30 +++++++++++++++--------------- drivers/scsi/atari_scsi.c | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 24 deletions(-)
drivers/scsi/atari_scsi.c +12 -9
@@ -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_possiif (!hostdata->disconnected_queue && !hostdata->issue_queue && !hostdata->connected && - !falcon_dont_release && + !hostdata->retain_dma_intr &&stdma_is_locked_by (scsi_falcon_intr))stdma_release ();
@@ -846,6 +842,7 @@ static int __init atari_scsi_probe(struc {struct Scsi_Host *instance;int error; +int host_flags =0 ;if (!MACH_IS_ATARI )return -ENODEV ;
@@ -945,7 +942,9 @@ static int __init atari_scsi_probe(strucelse instance->irq =IRQ_NONE ; -NCR5380_init (instance,0 ); + host_flags |=IS_A_TT () ?0 :FLAG_LATE_DMA_SETUP ; + +NCR5380_init (instance, host_flags);if (IS_A_TT ()) { error = request_irq(instance->irq, scsi_tt_intr, 0,
@@ -968,12 +967,16 @@ static int __init atari_scsi_probe(struc* * In principle it should be sufficient to do max. 1 byte with * PIO, but there is another problem on the Medusa with the DMA -* rest data register. So 'atari_read_overruns' is currently set +* rest data register. So read_overruns is currently set * to 4 to avoid having transfers that aren't a multiple of 4. * If the rest data bug is fixed, this can be lowered to 1. */ -if (MACH_IS_MEDUSA ) - atari_read_overruns =4 ; +if (MACH_IS_MEDUSA ) { +struct NCR5380_hostdata *hostdata = +shost_priv (instance); + + hostdata->read_overruns =4 ; + }#endif }else {/* Nothing to do for the interrupt: the ST-DMA is initialized
drivers/scsi/NCR5380.h +4 -0
@@ -237,6 +237,7 @@#define FLAG_NCR53C400 4/* NCR53c400 */ #define FLAG_NO_PSEUDO_DMA 8/* Inhibit DMA */ #define FLAG_DTC3181E 16/* DTC3181E */ +#define FLAG_LATE_DMA_SETUP 32/* Setup NCR before DMA H/W */ #ifndef ASM struct NCR5380_hostdata {
@@ -265,6 +266,9 @@ struct NCR5380_hostdata {struct delayed_work coroutine;/* our co-routine */ struct scsi_eh_save ses;char info[256 ]; +int read_overruns;/* number of bytes to cut from a +* transfer to handle chip overruns */ +int retain_dma_intr;#ifdef PSEUDO_DMA unsigned spin_max_r;unsigned spin_max_w;
drivers/scsi/atari_NCR5380.c +15 -15
@@ -837,7 +837,7 @@ static int __init NCR5380_init(struct Sc hostdata->connected =NULL ; hostdata->issue_queue =NULL ; hostdata->disconnected_queue =NULL ; - hostdata->flags =FLAG_CHECK_LAST_BYTE_SENT ; + hostdata->flags = flags;if (!the_template) { the_template = instance->hostt;
@@ -1053,7 +1053,7 @@ static void NCR5380_main(struct work_str hostdata->issue_queue =NEXT (tmp); }SET_NEXT (tmp,NULL ); - falcon_dont_release++; + hostdata->retain_dma_intr++;/* reenable interrupts after finding one */ local_irq_restore (flags);
@@ -1081,7 +1081,7 @@ static void NCR5380_main(struct work_strcmd_get_tag (tmp, tmp->cmnd[0 ] !=REQUEST_SENSE );#endif if (!NCR5380_select (instance, tmp)) { - falcon_dont_release--; + hostdata->retain_dma_intr--;/* release if target did not response! */ falcon_release_lock_if_possible (hostdata);break ;
@@ -1093,7 +1093,7 @@ static void NCR5380_main(struct work_str#ifdef SUPPORT_TAGS cmd_free_tag (tmp);#endif - falcon_dont_release--; + hostdata->retain_dma_intr--;local_irq_restore (flags);dprintk (NDEBUG_MAIN ,"scsi%d: main(): select() failed, " "returned to issue_queue\n" ,HOSTNO );
@@ -1150,7 +1150,7 @@ static void NCR5380_dma_complete(structreturn ; } -if (atari_read_overruns) { +if (hostdata->read_overruns) { p = hostdata->connected->SCp.phase;if (p &SR_IO ) {udelay (10 );
@@ -1180,9 +1180,9 @@ static void NCR5380_dma_complete(struct *data += transfered; *count -= transfered; -if (atari_read_overruns) { +if (hostdata->read_overruns) {if ((NCR5380_read (STATUS_REG ) &PHASE_MASK ) == p && (p &SR_IO )) { - cnt = toPIO = atari_read_overruns; + cnt = toPIO = hostdata->read_overruns;if (overrun) {dprintk (NDEBUG_DMA ,"Got an input overrun, using saved byte\n" ); *(*data)++ = saved_data;
@@ -1837,8 +1837,8 @@ static int NCR5380_transfer_dma(struct Sreturn -1 ; } -if (atari_read_overruns && (p &SR_IO )) - c -= atari_read_overruns; +if (hostdata->read_overruns && (p &SR_IO )) + c -= hostdata->read_overruns; dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n", HOSTNO, (p & SR_IO) ? "reading" : "writing",
@@ -1850,7 +1850,7 @@ static int NCR5380_transfer_dma(struct SNCR5380_write (MODE_REG ,MR_BASE |MR_DMA_MODE |MR_ENABLE_EOP_INTR |MR_MONITOR_BSY );#endif /* def REAL_DMA */ -if (IS_A_TT ()) { +if (!(hostdata->flags &FLAG_LATE_DMA_SETUP )) {/* On the Medusa, it is a must to initialize the DMA before * starting the NCR. This is also the cleaner way for the TT. */
@@ -1868,7 +1868,7 @@ static int NCR5380_transfer_dma(struct SNCR5380_write (START_DMA_SEND_REG ,0 ); } -if (!IS_A_TT ()) { +if (hostdata->flags &FLAG_LATE_DMA_SETUP ) {/* On the Falcon, the DMA setup must be done after the last */ /* NCR access, else the DMA setup gets trashed! */
@@ -2083,7 +2083,7 @@ static void NCR5380_information_transfer/* Accept message by clearing ACK */ NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE );/* ++guenther: possible race with Falcon locking */ - falcon_dont_release++; + hostdata->retain_dma_intr++; hostdata->connected =NULL ;dprintk (NDEBUG_QUEUES ,"scsi%d: command for target %d, lun %d " "completed\n" ,HOSTNO , cmd->device->id, cmd->device->lun);
@@ -2166,7 +2166,7 @@ static void NCR5380_information_transferwhile ((NCR5380_read (STATUS_REG ) &SR_BSY ) && !hostdata->connected)barrier (); - falcon_dont_release--; + hostdata->retain_dma_intr--;/* ++roman: For Falcon SCSI, release the lock on the * ST-DMA here if no other commands are waiting on the * disconnected queue.
@@ -2473,7 +2473,7 @@ static void NCR5380_reselect(struct Scsi#endif ) {/* ++guenther: prevent race with falcon_release_lock */ - falcon_dont_release++; + hostdata->retain_dma_intr++;if (prev) {REMOVE (prev,NEXT (prev), tmp,NEXT (tmp));SET_NEXT (prev,NEXT (tmp));
@@ -2511,7 +2511,7 @@ static void NCR5380_reselect(struct Scsi hostdata->connected = tmp;dprintk (NDEBUG_RESELECTION ,"scsi%d: nexus established, target = %d, lun = %d, tag = %d\n" ,HOSTNO , tmp->device->id, tmp->device->lun, tmp->tag); - falcon_dont_release--; + hostdata->retain_dma_intr--; }
Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
Quoted 6 lines · Finn Thain
Make the
atari_NCR5380.ccore driver usable bysun3_scsi,mac_scsiand others by moving some of the Falcon-specific code out of the core driver: !IS_A_TT,atari_read_overrunsandfalcon_dont_release. Replace these with hostdata variables and flags.FLAG_CHECK_LAST_BYTE_SENTis unused inatari_NCR5380.cso don't set it.
Hmm. Shouldn't there be some more patches for sun3_scsi and mac_scsi to actually make use of this?
I'd _love_ to get rid of all of this NCR5380 code duplication ...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
Quoted 9 lines · Hannes Reinecke
Quoted 6 lines · Finn Thain
Make the
atari_NCR5380.ccore driver usable bysun3_scsi,mac_scsiand others by moving some of the Falcon-specific code out of the core
driver: !IS_A_TT,atari_read_overrunsandfalcon_dont_release. Replace these with hostdata variables and flags.FLAG_CHECK_LAST_BYTE_SENTis unused inatari_NCR5380.cso don't set it.Hmm. Shouldn't there be some more patches for
sun3_scsiandmac_scsito actually make use of this?
Yes, I think you are right, some of those patches should be included.
I've done some testing of mac_scsi and dmx3191d using the atari_NCR5380.c core driver but this isn't working adequately yet. It's not yet a proof of concept.
To convert sun3_scsi to use the atari_NCR5380 core driver is easier.
If I had atari and sun3 hardware to test on, everything would be done in one patch set and I could test the end result rather than asking others to test it in stages on the appropriate hardware.
Anyway, I will include more patches when I re-submit: not just the sun3_NCR5380.c removal (which is ugly but hopefully Sam can simplify it) but also some more work on atari_NCR5380.c (to minimise testing effort).
Quoted 2 lines
I'd _love_ to get rid of all of this NCR5380 code duplication ...
My reading is that if mac_scsi can work with atari_NCR5380 then the same is very likely true for the ARM drivers (oak, cumana_1) and also dmx3191d.
To merge atari_NCR5380.c with NCR5380.c would be much more difficult. If someone who has the hardware were to take an interest in the remaining drivers (just the ISA card drivers, dtc, pas16, g_NCR5380, t128), perhaps it would be feasible.
Quoted 5 lines
Cheers,
Hannes
Re: [PATCH 28/29] atari_NCR5380: Refactor Falcon special cases
Quoted 29 lines · Finn Thain
Quoted 9 lines · Hannes Reinecke
Quoted 5 lines · Finn Thain
Make the
atari_NCR5380.ccore driver usable bysun3_scsi,mac_scsiand others by moving some of the Falcon-specific code out of the core
driver: !IS_A_TT,atari_read_overrunsandfalcon_dont_release. Replace these with hostdata variables and flags.FLAG_CHECK_LAST_BYTE_SENTis unused inatari_NCR5380.cso don't set it.Hmm. Shouldn't there be some more patches for
sun3_scsiandmac_scsito actually make use of this?Yes, I think you are right, some of those patches should be included.
I've done some testing of
mac_scsiand dmx3191d using theatari_NCR5380.ccore driver but this isn't working adequately yet. It's not yet a proof of concept.To convert
sun3_scsito use theatari_NCR5380core driver is easier.If I had atari and sun3 hardware to test on, everything would be done in one patch set and I could test the end result rather than asking others to test it in stages on the appropriate hardware.
Anyway, I will include more patches when I re-submit: not just the
sun3_NCR5380.cremoval (which is ugly but hopefully Sam can simplify it) but also some more work onatari_NCR5380.c(to minimise testing effort).Quoted 1 line
I'd _love_ to get rid of all of this NCR5380 code duplication ...
Quoted 7 lines
My reading is that if
mac_scsican work withatari_NCR5380then the same is very likely true for the ARM drivers (oak,cumana_1) and also dmx3191d.To merge
atari_NCR5380.cwithNCR5380.cwould be much more difficult. If someone who has the hardware were to take an interest in the remaining drivers (just the ISA card drivers, dtc, pas16,g_NCR5380, t128), perhaps it would be feasible.
I have some NCR5380 ISA cards and did some fixes to the driver a couple of years ago.
Signature · 1 line
Ondrej Zary
PATCH 29/29 atari_NCR5380: Refactor Falcon locking
In reply to Finn ThainSimplify 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.
--- drivers/scsi/atari_NCR5380.c | 72 ++++++++++++++++++++++++++----------------- drivers/scsi/atari_scsi.c | 47 ++++++++++------------------ 2 files changed, 62 insertions(+), 57 deletions(-)
drivers/scsi/atari_NCR5380.c +45 -27
@@ -924,7 +924,7 @@ static int NCR5380_queue_command(struct* alter queues and touch the lock. */ /* perhaps stop command timer here */ -if (!falcon_get_lock ()) +if (!NCR5380_acquire_dma_irq (instance))return SCSI_MLQUEUE_HOST_BUSY ;/* perhaps restart command timer here */
@@ -960,6 +960,18 @@ static int NCR5380_queue_command(structreturn 0 ; } +static inline void maybe_release_dma_irq (struct Scsi_Host *instance) +{ +struct NCR5380_hostdata *hostdata =shost_priv (instance); + +/* Caller does the locking needed to set & test these data atomically */ +if (!hostdata->disconnected_queue && + !hostdata->issue_queue && + !hostdata->connected && + !hostdata->retain_dma_intr) +NCR5380_release_dma_irq (instance); +} +/* * Function : NCR5380_main (void) *
@@ -1081,9 +1093,11 @@ static void NCR5380_main(struct work_strcmd_get_tag (tmp, tmp->cmnd[0 ] !=REQUEST_SENSE );#endif if (!NCR5380_select (instance, tmp)) { +local_irq_disable (); hostdata->retain_dma_intr--;/* release if target did not response! */ -falcon_release_lock_if_possible (hostdata); +maybe_release_dma_irq (instance); +local_irq_restore (flags);break ; }else {local_irq_disable ();
@@ -2082,11 +2096,12 @@ static void NCR5380_information_transfercase COMMAND_COMPLETE :/* Accept message by clearing ACK */ NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); -/* ++guenther: possible race with Falcon locking */ - hostdata->retain_dma_intr++; - hostdata->connected =NULL ;dprintk (NDEBUG_QUEUES ,"scsi%d: command for target %d, lun %d " "completed\n" ,HOSTNO , cmd->device->id, cmd->device->lun); + +local_irq_save (flags); + hostdata->retain_dma_intr++; + hostdata->connected =NULL ;#ifdef SUPPORT_TAGS cmd_free_tag (cmd);if (status_byte (cmd->SCp.Status) ==QUEUE_FULL ) {
@@ -2145,17 +2160,17 @@ static void NCR5380_information_transferdprintk (NDEBUG_AUTOSENSE ,"scsi%d: performing request sense\n" ,HOSTNO ); -local_irq_save (flags);LIST (cmd,hostdata->issue_queue);SET_NEXT (cmd, hostdata->issue_queue); hostdata->issue_queue = (struct scsi_cmnd *) cmd; -local_irq_restore (flags);dprintk (NDEBUG_QUEUES ,"scsi%d: REQUEST SENSE added to head of " "issue queue\n" ,H_NO (cmd)); }else { cmd->scsi_done (cmd); } +local_irq_restore (flags); +NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);/* * Restore phase bits to 0 so an interrupted selection,
@@ -2166,12 +2181,14 @@ static void NCR5380_information_transferwhile ((NCR5380_read (STATUS_REG ) &SR_BSY ) && !hostdata->connected)barrier (); +local_irq_save (flags); hostdata->retain_dma_intr--;/* ++roman: For Falcon SCSI, release the lock on the * ST-DMA here if no other commands are waiting on the * disconnected queue. */ -falcon_release_lock_if_possible (hostdata); +maybe_release_dma_irq (instance); +local_irq_restore (flags);return ;case MESSAGE_REJECT :/* Accept message by clearing ACK */
@@ -2330,6 +2347,7 @@ static void NCR5380_information_transfer hostdata->last_message = msgout;NCR5380_transfer_pio (instance, &phase, &len, &data);if (msgout ==ABORT ) { +local_irq_save (flags);#ifdef SUPPORT_TAGS cmd_free_tag (cmd);#else
@@ -2337,9 +2355,10 @@ static void NCR5380_information_transfer#endif hostdata->connected =NULL ; cmd->result =DID_ERROR <<16 ; - cmd->scsi_done (cmd);NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask); -falcon_release_lock_if_possible (hostdata); +maybe_release_dma_irq (instance); +local_irq_restore (flags); + cmd->scsi_done (cmd);return ; } msgout =NOP ;
@@ -2392,7 +2411,6 @@ static void NCR5380_reselect(struct Scsiunsigned char msg[3 ];unsigned char *data;struct scsi_cmnd *tmp =NULL , *prev; -/* unsigned long flags; */ /* * Disable arbitration, etc. since the host adapter obviously
@@ -2472,8 +2490,6 @@ static void NCR5380_reselect(struct Scsi && (tag == tmp->tag) #endif ) { -/* ++guenther: prevent race with falcon_release_lock */ - hostdata->retain_dma_intr++;if (prev) {REMOVE (prev,NEXT (prev), tmp,NEXT (tmp));SET_NEXT (prev,NEXT (tmp));
@@ -2511,7 +2527,6 @@ static void NCR5380_reselect(struct Scsi hostdata->connected = tmp;dprintk (NDEBUG_RESELECTION ,"scsi%d: nexus established, target = %d, lun = %d, tag = %d\n" ,HOSTNO , tmp->device->id, tmp->device->lun, tmp->tag); - hostdata->retain_dma_intr--; }
@@ -2587,12 +2602,12 @@ int NCR5380_abort(struct scsi_cmnd *cmd)#else hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);#endif +maybe_release_dma_irq (instance);local_irq_restore (flags); cmd->scsi_done (cmd); -falcon_release_lock_if_possible (hostdata);return SUCCESS ; }else { -/* local_irq_restore(flags); */ +local_irq_restore (flags);printk ("scsi%d: abort of connected command failed!\n" ,HOSTNO );return FAILED ; }
@@ -2611,13 +2626,13 @@ int NCR5380_abort(struct scsi_cmnd *cmd) (*prev) =NEXT (tmp);SET_NEXT (tmp,NULL ); tmp->result =DID_ABORT <<16 ; +maybe_release_dma_irq (instance);local_irq_restore (flags);dprintk (NDEBUG_ABORT ,"scsi%d: abort removed command from issue queue.\n" ,HOSTNO );/* Tagged queuing note: no tag to free here, hasn't been assigned * yet... */ tmp->scsi_done (tmp); -falcon_release_lock_if_possible (hostdata);return SUCCESS ; } }
@@ -2695,15 +2710,22 @@ int NCR5380_abort(struct scsi_cmnd *cmd)#else hostdata->busy[cmd->device->id] &= ~(1 << cmd->device->lun);#endif +maybe_release_dma_irq (instance);local_irq_restore (flags); tmp->scsi_done (tmp); -falcon_release_lock_if_possible (hostdata);return SUCCESS ; } } } } +/* Maybe it is sufficient just to release the ST-DMA lock... (if +* possible at all) At least, we should check if the lock could be +* released after the abort, in case it is kept due to some bug. +*/ +maybe_release_dma_irq (instance); +local_irq_restore (flags); +/* * Case 5 : If we reached this point, the command was not found in any of * the queues.
@@ -2714,15 +2736,8 @@ int NCR5380_abort(struct scsi_cmnd *cmd)* broke. */ -local_irq_restore (flags);printk (KERN_INFO "scsi%d: warning : SCSI command probably completed successfully before abortion\n" ,HOSTNO ); -/* Maybe it is sufficient just to release the ST-DMA lock... (if -* possible at all) At least, we should check if the lock could be -* released after the abort, in case it is kept due to some bug. -*/ -falcon_release_lock_if_possible (hostdata); -return FAILED ; }
@@ -2738,14 +2753,15 @@ int NCR5380_abort(struct scsi_cmnd *cmd)static int NCR5380_bus_reset (struct scsi_cmnd *cmd) { -SETUP_HOSTDATA (cmd->device->host); +struct Scsi_Host *instance = cmd->device->host; +struct NCR5380_hostdata *hostdata =shost_priv (instance);int i;unsigned long flags;#if defined(RESET_RUN_DONE )struct scsi_cmnd *connected, *disconnected_queue;#endif -NCR5380_print_status (cmd->device->host); +NCR5380_print_status (instance);/* get in phase */ NCR5380_write(TARGET_COMMAND_REG,
@@ -2870,6 +2886,8 @@ static int NCR5380_bus_reset(struct scsi#ifdef REAL_DMA hostdata->dma_len =0 ;#endif + +maybe_release_dma_irq (instance);local_irq_restore (flags);/* we did no complete reset of all commands, so a wakeup is required */
drivers/scsi/atari_scsi.c +17 -30
82 lines not on this page · raw message