From ed8b9e7f1827ebae902e868866438d1bcdbef0a2 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:51 +1100 Subject: ncr5380: Remove useless prototypes Add missing static qualifiers and remove the now pointless prototypes. The NCR5380_* prototypes are all declared in NCR5380.h and renamed using macros. Further declarations are redundant (some are completely unused). Remove them. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/atari_scsi.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index b522134528d6..151beea19b9a 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -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); -- cgit v1.2.3 From 4d3d2a54f731aa25f66adcf934ba9a55ca8204d4 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:52 +1100 Subject: ncr5380: Remove more useless prototypes Make use of the host template static initializer instead of assigning handlers at run-time. Move __maybe_unused qualifiers from declarations to definitions. Move the atari_scsi_bus_reset() wrapper after the definition of NCR5380_bus_reset(). All of the host template handler prototypes are now redundant so remove them. The write_info() handler is only relevant to drivers using PSEUDO_DMA so this patch fixes the compiler warning in atari_NCR5380.c and sun3_NCR5380.c: CC drivers/scsi/atari_scsi.o drivers/scsi/NCR5380.h:329: warning: 'NCR5380_write_info' declared 'static' but never defined Signed-off-by: Finn Thain Tested-by: Michael Schmitz Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- 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(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 8b96b687885b..b1ed20aaf10e 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -322,14 +322,6 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id); #endif static void NCR5380_main(struct work_struct *work); static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance); -static 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) diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 11e93025b87a..339f238598b1 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -772,7 +772,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) seq_printf(m, "\n"); } -static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) +static int __maybe_unused NCR5380_show_info(struct seq_file *m, + struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; Scsi_Cmnd *ptr; diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 151beea19b9a..a68d6257bc68 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -783,45 +783,6 @@ static int __init atari_scsi_setup(char *str) __setup("atascsi=", atari_scsi_setup); #endif /* !MODULE */ -static int atari_scsi_bus_reset(Scsi_Cmnd *cmd) -{ - int rv; - struct NCR5380_hostdata *hostdata = - (struct NCR5380_hostdata *)cmd->device->host->hostdata; - - /* For doing the reset, SCSI interrupts must be disabled first, - * since the 5380 raises its IRQ line while _RST is active and we - * can't disable interrupts completely, since we need the timer. - */ - /* And abort a maybe active DMA transfer */ - if (IS_A_TT()) { - atari_turnoff_irq(IRQ_TT_MFP_SCSI); -#ifdef REAL_DMA - tt_scsi_dma.dma_ctrl = 0; -#endif /* REAL_DMA */ - } else { - atari_turnoff_irq(IRQ_MFP_FSCSI); -#ifdef REAL_DMA - st_dma.dma_mode_status = 0x90; - atari_dma_active = 0; - atari_dma_orig_addr = NULL; -#endif /* REAL_DMA */ - } - - rv = NCR5380_bus_reset(cmd); - - /* Re-enable ints */ - if (IS_A_TT()) { - atari_turnon_irq(IRQ_TT_MFP_SCSI); - } else { - atari_turnon_irq(IRQ_MFP_FSCSI); - } - if (rv == SUCCESS) - falcon_release_lock_if_possible(hostdata); - - return rv; -} - #ifdef CONFIG_ATARI_SCSI_RESET_BOOT static void __init atari_scsi_reset_boot(void) @@ -1094,6 +1055,43 @@ static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value) #include "atari_NCR5380.c" +static int atari_scsi_bus_reset(struct scsi_cmnd *cmd) +{ + int rv; + struct NCR5380_hostdata *hostdata = shost_priv(cmd->device->host); + + /* For doing the reset, SCSI interrupts must be disabled first, + * since the 5380 raises its IRQ line while _RST is active and we + * can't disable interrupts completely, since we need the timer. + */ + /* And abort a maybe active DMA transfer */ + if (IS_A_TT()) { + atari_turnoff_irq(IRQ_TT_MFP_SCSI); +#ifdef REAL_DMA + tt_scsi_dma.dma_ctrl = 0; +#endif + } else { + atari_turnoff_irq(IRQ_MFP_FSCSI); +#ifdef REAL_DMA + st_dma.dma_mode_status = 0x90; + atari_dma_active = 0; + atari_dma_orig_addr = NULL; +#endif + } + + rv = NCR5380_bus_reset(cmd); + + if (IS_A_TT()) + atari_turnon_irq(IRQ_TT_MFP_SCSI); + else + atari_turnon_irq(IRQ_MFP_FSCSI); + + if (rv == SUCCESS) + falcon_release_lock_if_possible(hostdata); + + return rv; +} + static struct scsi_host_template driver_template = { .show_info = atari_scsi_show_info, .name = "Atari native SCSI", diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index f271fc5f6b82..e890b08efbd8 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c @@ -219,10 +219,6 @@ static int __init dtc_detect(struct scsi_host_template * tpnt) void __iomem *base; int sig, count; - tpnt->proc_name = "dtc3x80"; - tpnt->show_info = dtc_show_info; - tpnt->write_info = dtc_write_info; - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { addr = 0; base = NULL; @@ -477,6 +473,9 @@ static struct scsi_host_template driver_template = { .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, diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index 736540e789ed..ffa399e7860a 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c @@ -390,10 +390,6 @@ static int __init pas16_detect(struct scsi_host_template *tpnt) unsigned short io_port; int count; - tpnt->proc_name = "pas16"; - tpnt->show_info = pas16_show_info; - tpnt->write_info = pas16_write_info; - if (pas16_addr != 0) { overrides[0].io_port = pas16_addr; /* @@ -620,6 +616,9 @@ static struct scsi_host_template driver_template = { .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, diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 835bd8dafe0a..24e90c9776a6 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -718,7 +718,8 @@ static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) seq_printf(m, "\n"); } -static int NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) +static int __maybe_unused NCR5380_show_info(struct seq_file *m, + struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; Scsi_Cmnd *ptr; diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index ccfdc427c4c7..f06ad91d737d 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c @@ -201,10 +201,6 @@ static int __init t128_detect(struct scsi_host_template *tpnt) void __iomem *p; int sig, count; - tpnt->proc_name = "t128"; - tpnt->show_info = t128_show_info; - tpnt->write_info = t128_write_info; - for (count = 0; current_override < NO_OVERRIDES; ++current_override) { base = 0; p = NULL; @@ -435,6 +431,9 @@ static struct scsi_host_template driver_template = { .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, -- cgit v1.2.3 From 997acab7d593913eaa0606ff257079efcfcb146d Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:54 +1100 Subject: ncr5380: Remove redundant AUTOSENSE macro Every NCR5380 driver sets AUTOSENSE so it need not be optional (and the mid-layer expects it). Remove this redundant macro to improve readability. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.c | 14 +------------- drivers/scsi/NCR5380.h | 5 ----- drivers/scsi/arm/cumana_1.c | 1 - drivers/scsi/arm/oak.c | 1 - drivers/scsi/atari_NCR5380.c | 15 +-------------- drivers/scsi/atari_scsi.c | 1 - drivers/scsi/dmx3191d.c | 1 - drivers/scsi/dtc.c | 4 ---- drivers/scsi/g_NCR5380.c | 2 -- drivers/scsi/mac_scsi.c | 2 -- drivers/scsi/pas16.c | 4 ---- drivers/scsi/sun3_NCR5380.c | 16 +--------------- drivers/scsi/sun3_scsi.c | 2 -- drivers/scsi/t128.c | 4 ---- 14 files changed, 3 insertions(+), 69 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 0a8786acddc3..e17e64e3e0d9 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -627,9 +627,6 @@ NCR5380_print_options(struct Scsi_Host *instance) #ifdef AUTOPROBE_IRQ " AUTOPROBE_IRQ" #endif -#ifdef AUTOSENSE - " AUTOSENSE" -#endif #ifdef DIFFERENTIAL " DIFFERENTIAL" #endif @@ -857,12 +854,6 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) hostdata->host = instance; hostdata->time_expires = 0; -#ifndef AUTOSENSE - if ((instance->cmd_per_lun > 1) || instance->can_queue > 1) - printk(KERN_WARNING "scsi%d : WARNING : support for multiple outstanding commands enabled\n" " without AUTOSENSE option, contingent allegiance conditions may\n" - " be incorrectly cleared.\n", instance->host_no); -#endif /* def AUTOSENSE */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); @@ -2260,7 +2251,6 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { else if (status_byte(cmd->SCp.Status) != GOOD) cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); -#ifdef AUTOSENSE if ((cmd->cmnd[0] == REQUEST_SENSE) && hostdata->ses.cmd_len) { scsi_eh_restore_cmnd(cmd, &hostdata->ses); @@ -2277,9 +2267,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { hostdata->issue_queue; hostdata->issue_queue = (Scsi_Cmnd *) cmd; dprintk(NDEBUG_QUEUES, "scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no); - } else -#endif /* def AUTOSENSE */ - { + } else { collect_stats(hostdata, cmd); cmd->scsi_done(cmd); } diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index b36e3b4a9d43..f09d560fb6b2 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -25,10 +25,7 @@ #define NCR5380_H #include - -#ifdef AUTOSENSE #include -#endif #define NCR5380_PUBLIC_RELEASE 7 #define NCR53C400_PUBLIC_RELEASE 2 @@ -281,9 +278,7 @@ struct NCR5380_hostdata { unsigned pendingr; unsigned pendingw; #endif -#ifdef AUTOSENSE struct scsi_eh_save ses; -#endif }; #ifdef __KERNEL__ diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 8ef810a4476e..8266039b60ee 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c @@ -18,7 +18,6 @@ #include -#define AUTOSENSE #define PSEUDO_DMA #define CUMANASCSI_PUBLIC_RELEASE 1 diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index 5ba3db605000..f62cc904a47b 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c @@ -17,7 +17,6 @@ #include "../scsi.h" #include -#define AUTOSENSE /*#define PSEUDO_DMA*/ #define OAKSCSI_PUBLIC_RELEASE 1 diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 3cfd39c583ad..f69d36327a7d 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -683,9 +683,6 @@ static inline void NCR5380_all_init(void) static void __init NCR5380_print_options(struct Scsi_Host *instance) { printk(" generic options" -#ifdef AUTOSENSE - " AUTOSENSE" -#endif #ifdef REAL_DMA " REAL DMA" #endif @@ -842,13 +839,6 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) first_instance = instance; } -#ifndef AUTOSENSE - if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1)) - printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n" - " without AUTOSENSE option, contingent allegiance conditions may\n" - " be incorrectly cleared.\n", HOSTNO); -#endif /* def AUTOSENSE */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); @@ -2199,7 +2189,6 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) else if (status_byte(cmd->SCp.Status) != GOOD) cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); -#ifdef AUTOSENSE if ((cmd->cmnd[0] == REQUEST_SENSE) && hostdata->ses.cmd_len) { scsi_eh_restore_cmnd(cmd, &hostdata->ses); @@ -2219,9 +2208,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) local_irq_restore(flags); dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of " "issue queue\n", H_NO(cmd)); - } else -#endif /* def AUTOSENSE */ - { + } else { #ifdef NCR5380_STATS collect_stats(hostdata, cmd); #endif diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index a68d6257bc68..9f4d58ca3647 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -67,7 +67,6 @@ #include -#define AUTOSENSE /* For the Atari version, use only polled IO or REAL_DMA */ #define REAL_DMA /* Support tagged queuing? (on devices that are able to... :-) */ diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index 6d534b9ffc91..5101328656b8 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c @@ -33,7 +33,6 @@ /* * Definitions for the generic 5380 driver. */ -#define AUTOSENSE #define NCR5380_read(reg) inb(port + reg) #define NCR5380_write(reg, value) outb(value, port + reg) diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index e890b08efbd8..975abbfe0bba 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c @@ -1,5 +1,4 @@ -#define AUTOSENSE #define PSEUDO_DMA #define DONT_USE_INTR #define UNSAFE /* Leave interrupts enabled during pseudo-dma I/O */ @@ -30,9 +29,6 @@ /* * Options : - * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically - * for commands that return with a CHECK CONDITION status. - * * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance * increase compared to polled I/O. * diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index c10466939a52..eda978f29d9d 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -80,8 +80,6 @@ #define USLEEP_WAITLONG 500 #define AUTOPROBE_IRQ -#define AUTOSENSE - #ifdef CONFIG_SCSI_GENERIC_NCR53C400 #define NCR53C400_PSEUDO_DMA 1 diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index aa372ec38507..3f125838a29d 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -48,8 +48,6 @@ #include #include "mac_scsi.h" -/* These control the behaviour of the generic 5380 core */ -#define AUTOSENSE #define PSEUDO_DMA #include "NCR5380.h" diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index ffa399e7860a..7621205e4aa0 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c @@ -1,4 +1,3 @@ -#define AUTOSENSE #define PSEUDO_DMA #define UNSAFE /* Not unsafe for PAS16 -- use it */ #define PDEBUG 0 @@ -39,9 +38,6 @@ /* * Options : - * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically - * for commands that return with a CHECK CONDITION status. - * * LIMIT_TRANSFERSIZE - if defined, limit the pseudo-dma transfers to 512 * bytes at a time. Since interrupts are disabled by default during * these transfers, we might need this to give reasonable interrupt diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 3586fecdc8bb..f52bda71dfb9 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -629,9 +629,6 @@ static inline void NCR5380_all_init (void) static void __init NCR5380_print_options (struct Scsi_Host *instance) { printk(" generic options" -#ifdef AUTOSENSE - " AUTOSENSE" -#endif #ifdef REAL_DMA " REAL DMA" #endif @@ -788,14 +785,6 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) first_instance = instance; } - -#ifndef AUTOSENSE - if ((instance->cmd_per_lun > 1) || (instance->can_queue > 1)) - printk("scsi%d: WARNING : support for multiple outstanding commands enabled\n" - " without AUTOSENSE option, contingent allegiance conditions may\n" - " be incorrectly cleared.\n", HOSTNO); -#endif /* def AUTOSENSE */ - NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); @@ -2161,7 +2150,6 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) else if (status_byte(cmd->SCp.Status) != GOOD) cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16); -#ifdef AUTOSENSE if ((cmd->cmnd[0] == REQUEST_SENSE) && hostdata->ses.cmd_len) { scsi_eh_restore_cmnd(cmd, &hostdata->ses); @@ -2185,9 +2173,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance) local_irq_restore(flags); dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of " "issue queue\n", H_NO(cmd)); - } else -#endif /* def AUTOSENSE */ - { + } else { #ifdef NCR5380_STATS collect_stats(hostdata, cmd); #endif diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 30353f6b599c..a5e58a7373be 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -45,8 +45,6 @@ * PARITY - enable parity checking. Not supported. */ -#define AUTOSENSE - #include #include #include diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index f06ad91d737d..4253fe97c210 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c @@ -1,4 +1,3 @@ -#define AUTOSENSE #define PSEUDO_DMA /* @@ -40,9 +39,6 @@ /* * Options : - * AUTOSENSE - if defined, REQUEST SENSE will be performed automatically - * for commands that return with a CHECK CONDITION status. - * * PSEUDO_DMA - enables PSEUDO-DMA hardware, should give a 3-4X performance * increase compared to polled I/O. * -- cgit v1.2.3 From 8c32513bd395dc5d382e4883097482567cf8bbc5 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:11:58 +1100 Subject: ncr5380: Cleanup host info() methods If the host->info() method is not set, then host->name is used by default. For atari_scsi, that is exactly the same text. So remove the redundant info() method. Keep sun3_scsi.c in line with atari_scsi. Some NCR5380 drivers return an empty string from the info() method (arm/cumana_1.c arm/oak.c mac_scsi.c) while other drivers use the default (dmx3191d dtc.c g_NCR5380.c pas16.c t128.c). Implement a common info() method to replace a lot of duplicated code which the various drivers use to announce the same information. This replaces most of the (deprecated) show_info() output and all of the NCR5380_print_info() output. This also eliminates a bunch of code in g_NCR5380 which just duplicates functionality in the core driver. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.c | 74 +++++++++++++++--------- drivers/scsi/NCR5380.h | 3 +- drivers/scsi/arm/cumana_1.c | 14 +---- drivers/scsi/arm/oak.c | 14 +---- drivers/scsi/atari_NCR5380.c | 57 +++++++++++------- drivers/scsi/atari_scsi.c | 24 -------- drivers/scsi/atari_scsi.h | 1 + drivers/scsi/dmx3191d.c | 1 + drivers/scsi/dtc.c | 10 +--- drivers/scsi/dtc.h | 1 + drivers/scsi/g_NCR5380.c | 135 +------------------------------------------ drivers/scsi/g_NCR5380.h | 2 + drivers/scsi/mac_scsi.c | 14 ----- drivers/scsi/mac_scsi.h | 1 + drivers/scsi/pas16.c | 12 +--- drivers/scsi/pas16.h | 1 + drivers/scsi/sun3_NCR5380.c | 59 +++++++++++-------- drivers/scsi/sun3_scsi.c | 18 ------ drivers/scsi/sun3_scsi.h | 1 + drivers/scsi/t128.c | 11 +--- drivers/scsi/t128.h | 1 + 21 files changed, 134 insertions(+), 320 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 2bb4df0e5551..f1792bb80e70 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -610,47 +610,70 @@ static int __init __maybe_unused NCR5380_probe_irq(struct Scsi_Host *instance, } /** - * NCR58380_print_options - show options - * @instance: unused for now + * NCR58380_info - report driver and host information + * @instance: relevant scsi host instance * - * Called by probe code indicating the NCR5380 driver options that - * were selected. At some point this will switch to runtime options - * read from the adapter in question + * For use as the host template info() handler. * * Locks: none */ -static void __init __maybe_unused -NCR5380_print_options(struct Scsi_Host *instance) +static const char *NCR5380_info(struct Scsi_Host *instance) { - printk(" generic options" + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + return hostdata->info; +} + +static void prepare_info(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + snprintf(hostdata->info, sizeof(hostdata->info), + "%s, io_port 0x%lx, n_io_port %d, " + "base 0x%lx, irq %d, " + "can_queue %d, cmd_per_lun %d, " + "sg_tablesize %d, this_id %d, " + "flags { %s%s%s}, " +#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG) + "USLEEP_POLL %d, USLEEP_WAITLONG %d, " +#endif + "options { %s} ", + instance->hostt->name, instance->io_port, instance->n_io_port, + instance->base, instance->irq, + instance->can_queue, instance->cmd_per_lun, + instance->sg_tablesize, instance->this_id, + hostdata->flags & FLAG_NCR53C400 ? "NCR53C400 " : "", + hostdata->flags & FLAG_DTC3181E ? "DTC3181E " : "", + hostdata->flags & FLAG_NO_PSEUDO_DMA ? "NO_PSEUDO_DMA " : "", +#if defined(USLEEP_POLL) && defined(USLEEP_WAITLONG) + USLEEP_POLL, USLEEP_WAITLONG, +#endif #ifdef AUTOPROBE_IRQ - " AUTOPROBE_IRQ" + "AUTOPROBE_IRQ " #endif #ifdef DIFFERENTIAL - " DIFFERENTIAL" + "DIFFERENTIAL " #endif #ifdef REAL_DMA - " REAL DMA" + "REAL_DMA " #endif #ifdef REAL_DMA_POLL - " REAL DMA POLL" + "REAL_DMA_POLL " #endif #ifdef PARITY - " PARITY" + "PARITY " #endif #ifdef PSEUDO_DMA - " PSEUDO DMA" + "PSEUDO_DMA " #endif #ifdef UNSAFE - " UNSAFE " + "UNSAFE " #endif - ); - printk(" USLEEP_POLL=%d USLEEP_SLEEP=%d", USLEEP_POLL, USLEEP_SLEEP); - printk(" generic release=%d", NCR5380_PUBLIC_RELEASE); - if (((struct NCR5380_hostdata *) instance->hostdata)->flags & FLAG_NCR53C400) { - printk(" ncr53c400 release=%d", NCR53C400_PUBLIC_RELEASE); - } +#ifdef NCR53C400 + "NCR53C400 " +#endif + ""); } /** @@ -728,13 +751,6 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, SPRINTF("PAS16 release=%d", PAS16_PUBLIC_RELEASE); #endif - SPRINTF("\nBase Addr: 0x%05lX ", (long) instance->base); - SPRINTF("io_port: %04x ", (int) instance->io_port); - if (instance->irq == NO_IRQ) - SPRINTF("IRQ: None.\n"); - else - SPRINTF("IRQ: %d.\n", instance->irq); - #ifdef DTC_PUBLIC_RELEASE SPRINTF("Highwater I/O busy_spin_counts -- write: %d read: %d\n", dtc_wmaxi, dtc_maxi); #endif @@ -842,6 +858,8 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) hostdata->host = instance; hostdata->time_expires = 0; + prepare_info(instance); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index d811775ffd9d..dc37da49656b 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -273,6 +273,7 @@ struct NCR5380_hostdata { volatile Scsi_Cmnd *selecting; struct delayed_work coroutine; /* our co-routine */ struct scsi_eh_save ses; + char info[256]; }; #ifdef __KERNEL__ @@ -307,7 +308,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance); static irqreturn_t NCR5380_intr(int irq, void *dev_id); #endif static void NCR5380_main(struct work_struct *work); -static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance); +static const char *NCR5380_info(struct Scsi_Host *instance); static void NCR5380_reselect(struct Scsi_Host *instance); static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd); #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL) diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 8266039b60ee..d3b96af3aa5c 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c @@ -29,6 +29,7 @@ #define NCR5380_write(reg, value) cumanascsi_write(_instance, reg, value) #define NCR5380_intr cumanascsi_intr #define NCR5380_queue_command cumanascsi_queue_command +#define NCR5380_info cumanascsi_info #define NCR5380_implementation_fields \ unsigned ctrl; \ @@ -41,11 +42,6 @@ void cumanascsi_setup(char *str, int *ints) { } -const char *cumanascsi_info(struct Scsi_Host *spnt) -{ - return ""; -} - #define CTRL 0x16fc #define STAT 0x2004 #define L(v) (((v)<<16)|((v) & 0x0000ffff)) @@ -266,14 +262,6 @@ static int cumanascsi1_probe(struct expansion_card *ec, goto out_unmap; } - printk("scsi%d: at port 0x%08lx irq %d", - host->host_no, host->io_port, host->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - host->can_queue, host->cmd_per_lun, CUMANASCSI_PUBLIC_RELEASE); - printk("\nscsi%d:", host->host_no); - NCR5380_print_options(host); - printk("\n"); - ret = scsi_add_host(host, &ec->dev); if (ret) goto out_free_irq; diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index 13d5995531fc..a5ef3f79a2fd 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c @@ -29,6 +29,7 @@ #define NCR5380_read(reg) readb(_base + ((reg) << 2)) #define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2)) #define NCR5380_queue_command oakscsi_queue_command +#define NCR5380_info oakscsi_info #define NCR5380_show_info oakscsi_show_info #define NCR5380_write_info oakscsi_write_info @@ -40,11 +41,6 @@ #undef START_DMA_INITIATOR_RECEIVE_REG #define START_DMA_INITIATOR_RECEIVE_REG (128 + 7) -const char * oakscsi_info (struct Scsi_Host *spnt) -{ - return ""; -} - #define STAT ((128 + 16) << 2) #define DATA ((128 + 8) << 2) @@ -153,14 +149,6 @@ static int oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id) NCR5380_init(host, 0); - printk("scsi%d: at port 0x%08lx irqs disabled", - host->host_no, host->io_port); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - host->can_queue, host->cmd_per_lun, OAKSCSI_PUBLIC_RELEASE); - printk("\nscsi%d:", host->host_no); - NCR5380_print_options(host); - printk("\n"); - ret = scsi_add_host(host, &ec->dev); if (ret) goto out_unmap; diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 6177830ef0d9..4d903b86adda 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -144,12 +144,6 @@ * be able to coexist with appropriate changes to the high level * SCSI code. * - * A NCR5380_PUBLIC_REVISION macro is provided, with the release - * number (updated for each public release) printed by the - * NCR5380_print_options command, which should be called from the - * wrapper detect function, so that I know what release of the driver - * users are using. - * * Issues specific to the NCR5380 : * * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead @@ -247,7 +241,6 @@ * NCR5380_queue_command * NCR5380_reset * NCR5380_abort - * NCR5380_proc_info * * to be the global entry points into the specific driver, ie * #define NCR5380_queue_command t128_queue_command. @@ -259,8 +252,7 @@ * The generic driver is initialized by calling NCR5380_init(instance), * after setting the appropriate host specific fields and ID. If the * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance, - * possible) function may be used. Before the specific driver initialization - * code finishes, NCR5380_print_options should be called. + * possible) function may be used. */ static struct Scsi_Host *first_instance = NULL; @@ -670,30 +662,49 @@ static inline void NCR5380_all_init(void) } } - -/* - * Function : void NCR58380_print_options (struct Scsi_Host *instance) +/** + * NCR58380_info - report driver and host information + * @instance: relevant scsi host instance * - * Purpose : called by probe code indicating the NCR5380 driver - * options that were selected. + * For use as the host template info() handler. * - * Inputs : instance, pointer to this instance. Unused. + * Locks: none */ -static void __init NCR5380_print_options(struct Scsi_Host *instance) +static const char *NCR5380_info(struct Scsi_Host *instance) { - printk(" generic options" + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + return hostdata->info; +} + +static void prepare_info(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + snprintf(hostdata->info, sizeof(hostdata->info), + "%s, io_port 0x%lx, n_io_port %d, " + "base 0x%lx, irq %d, " + "can_queue %d, cmd_per_lun %d, " + "sg_tablesize %d, this_id %d, " + "options { %s} ", + instance->hostt->name, instance->io_port, instance->n_io_port, + instance->base, instance->irq, + instance->can_queue, instance->cmd_per_lun, + instance->sg_tablesize, instance->this_id, +#ifdef DIFFERENTIAL + "DIFFERENTIAL " +#endif #ifdef REAL_DMA - " REAL DMA" + "REAL_DMA " #endif #ifdef PARITY - " PARITY" + "PARITY " #endif #ifdef SUPPORT_TAGS - " SCSI-2 TAGGED QUEUING" + "SUPPORT_TAGS " #endif - ); - printk(" generic release=%d", NCR5380_PUBLIC_RELEASE); + ""); } /* @@ -839,6 +850,8 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) first_instance = instance; } + prepare_info(instance); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 9f4d58ca3647..1022a391c82a 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -699,21 +699,6 @@ static int __init atari_scsi_detect(struct scsi_host_template *host) #endif } - printk(KERN_INFO "scsi%d: options CAN_QUEUE=%d CMD_PER_LUN=%d SCAT-GAT=%d " -#ifdef SUPPORT_TAGS - "TAGGED-QUEUING=%s " -#endif - "HOSTID=%d", - instance->host_no, instance->hostt->can_queue, - instance->hostt->cmd_per_lun, - instance->hostt->sg_tablesize, -#ifdef SUPPORT_TAGS - setup_use_tagged_queuing ? "yes" : "no", -#endif - instance->hostt->this_id ); - NCR5380_print_options(instance); - printk("\n"); - called = 1; return 1; } @@ -815,15 +800,6 @@ static void __init atari_scsi_reset_boot(void) } #endif - -static const char *atari_scsi_info(struct Scsi_Host *host) -{ - /* atari_scsi_detect() is verbose enough... */ - static const char string[] = "Atari native SCSI"; - return string; -} - - #if defined(REAL_DMA) static unsigned long atari_scsi_dma_setup(struct Scsi_Host *instance, diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h index 58cc32f79b86..24e854590dc4 100644 --- a/drivers/scsi/atari_scsi.h +++ b/drivers/scsi/atari_scsi.h @@ -47,6 +47,7 @@ #define NCR5380_queue_command atari_scsi_queue_command #define NCR5380_abort atari_scsi_abort #define NCR5380_show_info atari_scsi_show_info +#define NCR5380_info atari_scsi_info #define NCR5380_dma_read_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 0) #define NCR5380_dma_write_setup(inst,d,c) atari_scsi_dma_setup (inst, d, c, 1) #define NCR5380_dma_residual(inst) atari_scsi_dma_residual( inst ) diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index 6e1960a88270..feaba705a369 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c @@ -57,6 +57,7 @@ static struct scsi_host_template dmx3191d_driver_template = { .proc_name = DMX3191D_DRIVER_NAME, .name = "Domex DMX3191D", + .info = NCR5380_info, .queuecommand = NCR5380_queue_command, .eh_abort_handler = NCR5380_abort, .eh_bus_reset_handler = NCR5380_bus_reset, diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index 2971c7f0e898..2dacf2833b64 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c @@ -281,15 +281,6 @@ found: printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); #endif - printk(KERN_INFO "scsi%d : at 0x%05X", instance->host_no, (int) instance->base); - if (instance->irq == NO_IRQ) - printk(" interrupts disabled"); - else - printk(" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, DTC_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - ++current_override; ++count; } @@ -461,6 +452,7 @@ static struct scsi_host_template driver_template = { .proc_name = "dtc3x80", .show_info = dtc_show_info, .write_info = dtc_write_info, + .info = dtc_info, .queuecommand = dtc_queue_command, .eh_abort_handler = dtc_abort, .eh_bus_reset_handler = dtc_bus_reset, diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h index 46ad3403bda7..48e2c399ace6 100644 --- a/drivers/scsi/dtc.h +++ b/drivers/scsi/dtc.h @@ -65,6 +65,7 @@ #define NCR5380_queue_command dtc_queue_command #define NCR5380_abort dtc_abort #define NCR5380_bus_reset dtc_bus_reset +#define NCR5380_info dtc_info #define NCR5380_show_info dtc_show_info #define NCR5380_write_info dtc_write_info diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index 9040023ed1c0..2b8155f1bf94 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -446,34 +446,12 @@ static int __init generic_NCR5380_detect(struct scsi_host_template *tpnt) 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 == NO_IRQ) - printk(" interrupts disabled"); - else - printk(" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", CAN_QUEUE, CMD_PER_LUN, GENERIC_NCR5380_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - ++current_override; ++count; } return count; } -/** - * generic_NCR5380_info - reporting string - * @host: NCR5380 to report on - * - * Report driver information for the NCR5380 - */ - -static const char *generic_NCR5380_info(struct Scsi_Host *host) -{ - static const char string[] = "Generic NCR5380/53C400 Driver"; - return string; -} - /** * generic_NCR5380_release_resources - free resources * @instance: host adapter to clean up @@ -720,120 +698,9 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src, #include "NCR5380.c" -#define PRINTP(x) seq_printf(m, x) -#define ANDP , - -static void sprint_opcode(struct seq_file *m, int opcode) -{ - PRINTP("0x%02x " ANDP opcode); -} - -static void sprint_command(struct seq_file *m, unsigned char *command) -{ - int i, s; - sprint_opcode(m, command[0]); - for (i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) - PRINTP("%02x " ANDP command[i]); - PRINTP("\n"); -} - -/** - * sprintf_Scsi_Cmnd - print a scsi command - * @m: seq_fil to print into - * @cmd: SCSI command block - * - * Print out the target and command data in hex - */ - -static void sprint_Scsi_Cmnd(struct seq_file *m, Scsi_Cmnd * cmd) -{ - PRINTP("host number %d destination target %d, lun %llu\n" ANDP cmd->device->host->host_no ANDP cmd->device->id ANDP cmd->device->lun); - PRINTP(" command = "); - sprint_command(m, cmd->cmnd); -} - -/** - * generic_NCR5380_proc_info - /proc for NCR5380 driver - * @buffer: buffer to print into - * @start: start position - * @offset: offset into buffer - * @len: length - * @hostno: instance to affect - * @inout: read/write - * - * Provide the procfs information for the 5380 controller. We fill - * this with useful debugging information including the commands - * being executed, disconnected command queue and the statistical - * data - * - * Locks: global cli/lock for queue walk - */ - -static int generic_NCR5380_show_info(struct seq_file *m, struct Scsi_Host *scsi_ptr) -{ - NCR5380_local_declare(); - unsigned long flags; - unsigned char status; - int i; - Scsi_Cmnd *ptr; - struct NCR5380_hostdata *hostdata; - - NCR5380_setup(scsi_ptr); - hostdata = (struct NCR5380_hostdata *) scsi_ptr->hostdata; - - spin_lock_irqsave(scsi_ptr->host_lock, flags); - PRINTP("SCSI host number %d : %s\n" ANDP scsi_ptr->host_no ANDP scsi_ptr->hostt->name); - PRINTP("Generic NCR5380 driver version %d\n" ANDP GENERIC_NCR5380_PUBLIC_RELEASE); - PRINTP("NCR5380 core version %d\n" ANDP NCR5380_PUBLIC_RELEASE); -#ifdef NCR53C400 - PRINTP("NCR53C400 extension version %d\n" ANDP NCR53C400_PUBLIC_RELEASE); - PRINTP("NCR53C400 card%s detected\n" ANDP(((struct NCR5380_hostdata *) scsi_ptr->hostdata)->flags & FLAG_NCR53C400) ? "" : " not"); -# if NCR53C400_PSEUDO_DMA - PRINTP("NCR53C400 pseudo DMA used\n"); -# endif -#else - PRINTP("NO NCR53C400 driver extensions\n"); -#endif - PRINTP("Using %s mapping at %s 0x%lx, " ANDP STRVAL(NCR5380_map_config) ANDP STRVAL(NCR5380_map_name) ANDP scsi_ptr->NCR5380_instance_name); - if (scsi_ptr->irq == NO_IRQ) - PRINTP("no interrupt\n"); - else - PRINTP("on interrupt %d\n" ANDP scsi_ptr->irq); - - status = NCR5380_read(STATUS_REG); - if (!(status & SR_REQ)) - PRINTP("REQ not asserted, phase unknown.\n"); - else { - for (i = 0; (phases[i].value != PHASE_UNKNOWN) && (phases[i].value != (status & PHASE_MASK)); ++i); - PRINTP("Phase %s\n" ANDP phases[i].name); - } - - if (!hostdata->connected) { - PRINTP("No currently connected command\n"); - } else { - sprint_Scsi_Cmnd(m, (Scsi_Cmnd *) hostdata->connected); - } - - PRINTP("issue_queue\n"); - - for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - sprint_Scsi_Cmnd(m, ptr); - - PRINTP("disconnected_queue\n"); - - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) - sprint_Scsi_Cmnd(m, ptr); - - spin_unlock_irqrestore(scsi_ptr->host_lock, flags); - return 0; -} - -#undef PRINTP -#undef ANDP - static struct scsi_host_template driver_template = { .show_info = generic_NCR5380_show_info, - .name = "Generic NCR5380/NCR53C400 Scsi Driver", + .name = "Generic NCR5380/NCR53C400 SCSI", .detect = generic_NCR5380_detect, .release = generic_NCR5380_release_resources, .info = generic_NCR5380_info, diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h index e15b95c37860..b1c7ae1204d8 100644 --- a/drivers/scsi/g_NCR5380.h +++ b/drivers/scsi/g_NCR5380.h @@ -100,6 +100,8 @@ #define NCR5380_bus_reset generic_NCR5380_bus_reset #define NCR5380_pread generic_NCR5380_pread #define NCR5380_pwrite generic_NCR5380_pwrite +#define NCR5380_info generic_NCR5380_info +#define NCR5380_show_info generic_NCR5380_show_info #define BOARD_NCR5380 0 #define BOARD_NCR53C400 1 diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 5d8d75c619cd..a27216d534ed 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -236,16 +236,6 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) instance->irq = NO_IRQ; } - printk(KERN_INFO "scsi%d: generic 5380 at port %lX irq", instance->host_no, instance->io_port); - if (instance->irq == NO_IRQ) - printk (KERN_INFO "s disabled"); - else - printk (KERN_INFO " %d", instance->irq); - printk(KERN_INFO " options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - instance->can_queue, instance->cmd_per_lun, MACSCSI_PUBLIC_RELEASE); - printk(KERN_INFO "\nscsi%d:", instance->host_no); - NCR5380_print_options(instance); - printk("\n"); called = 1; return 1; } @@ -297,10 +287,6 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance) } #endif -const char * macscsi_info (struct Scsi_Host *spnt) { - return ""; -} - /* Pseudo-DMA: (Ove Edlund) The code attempts to catch bus errors that occur if one for example diff --git a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h index 0b123fe9c248..66b34dbdc0d0 100644 --- a/drivers/scsi/mac_scsi.h +++ b/drivers/scsi/mac_scsi.h @@ -53,6 +53,7 @@ #define NCR5380_queue_command macscsi_queue_command #define NCR5380_abort macscsi_abort #define NCR5380_bus_reset macscsi_bus_reset +#define NCR5380_info macscsi_info #define NCR5380_show_info macscsi_show_info #define NCR5380_write_info macscsi_write_info diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index 3782091f82cb..51766895e90e 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c @@ -438,17 +438,6 @@ static int __init pas16_detect(struct scsi_host_template *tpnt) printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); #endif - printk("scsi%d : at 0x%04x", instance->host_no, (int) - instance->io_port); - if (instance->irq == NO_IRQ) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, PAS16_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - ++current_override; ++count; } @@ -586,6 +575,7 @@ static struct scsi_host_template driver_template = { .proc_name = "pas16", .show_info = pas16_show_info, .write_info = pas16_write_info, + .info = pas16_info, .queuecommand = pas16_queue_command, .eh_abort_handler = pas16_abort, .eh_bus_reset_handler = pas16_bus_reset, diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h index 489acb5bf299..bf589850e8ca 100644 --- a/drivers/scsi/pas16.h +++ b/drivers/scsi/pas16.h @@ -143,6 +143,7 @@ #define NCR5380_queue_command pas16_queue_command #define NCR5380_abort pas16_abort #define NCR5380_bus_reset pas16_bus_reset +#define NCR5380_info pas16_info #define NCR5380_show_info pas16_show_info #define NCR5380_write_info pas16_write_info diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index b00d97557cff..97cd0071c9aa 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -131,12 +131,6 @@ * be able to coexist with appropriate changes to the high level * SCSI code. * - * A NCR5380_PUBLIC_REVISION macro is provided, with the release - * number (updated for each public release) printed by the - * NCR5380_print_options command, which should be called from the - * wrapper detect function, so that I know what release of the driver - * users are using. - * * Issues specific to the NCR5380 : * * When used in a PIO or pseudo-dma mode, the NCR5380 is a braindead @@ -234,7 +228,6 @@ * NCR5380_queue_command * NCR5380_reset * NCR5380_abort - * NCR5380_proc_info * * to be the global entry points into the specific driver, ie * #define NCR5380_queue_command t128_queue_command. @@ -246,8 +239,7 @@ * The generic driver is initialized by calling NCR5380_init(instance), * after setting the appropriate host specific fields and ID. If the * driver wishes to autoprobe for an IRQ line, the NCR5380_probe_irq(instance, - * possible) function may be used. Before the specific driver initialization - * code finishes, NCR5380_print_options should be called. + * possible) function may be used. */ static struct Scsi_Host *first_instance = NULL; @@ -616,30 +608,49 @@ static inline void NCR5380_all_init (void) } } - -/* - * Function : void NCR58380_print_options (struct Scsi_Host *instance) +/** + * NCR58380_info - report driver and host information + * @instance: relevant scsi host instance * - * Purpose : called by probe code indicating the NCR5380 driver - * options that were selected. + * For use as the host template info() handler. * - * Inputs : instance, pointer to this instance. Unused. + * Locks: none */ -static void __init NCR5380_print_options (struct Scsi_Host *instance) +static const char *NCR5380_info(struct Scsi_Host *instance) { - printk(" generic options" + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + return hostdata->info; +} + +static void prepare_info(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + snprintf(hostdata->info, sizeof(hostdata->info), + "%s, io_port 0x%lx, n_io_port %d, " + "base 0x%lx, irq %d, " + "can_queue %d, cmd_per_lun %d, " + "sg_tablesize %d, this_id %d, " + "options { %s} ", + instance->hostt->name, instance->io_port, instance->n_io_port, + instance->base, instance->irq, + instance->can_queue, instance->cmd_per_lun, + instance->sg_tablesize, instance->this_id, +#ifdef DIFFERENTIAL + "DIFFERENTIAL " +#endif #ifdef REAL_DMA - " REAL DMA" + "REAL_DMA " #endif #ifdef PARITY - " PARITY" + "PARITY " #endif #ifdef SUPPORT_TAGS - " SCSI-2 TAGGED QUEUING" + "SUPPORT_TAGS " #endif - ); - printk(" generic release=%d", NCR5380_PUBLIC_RELEASE); + ""); } /* @@ -784,7 +795,9 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) the_template = instance->hostt; first_instance = instance; } - + + prepare_info(instance); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(TARGET_COMMAND_REG, 0); diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 3e6386252953..9bae5f6122a7 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -286,19 +286,6 @@ static int __init sun3scsi_detect(struct scsi_host_template *tpnt) #endif } - pr_info("scsi%d: %s at port %lX irq", instance->host_no, - tpnt->proc_name, instance->io_port); - if (instance->irq == NO_IRQ) - printk ("s disabled"); - else - printk (" %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - instance->can_queue, instance->cmd_per_lun, - SUN3SCSI_PUBLIC_RELEASE); - printk("\nscsi%d:", instance->host_no); - NCR5380_print_options(instance); - printk("\n"); - dregs->csr = 0; udelay(SUN3_DMA_DELAY); dregs->csr = CSR_SCSI | CSR_FIFO | CSR_INTR; @@ -380,11 +367,6 @@ static void sun3_scsi_reset_boot(struct Scsi_Host *instance) } #endif -static const char *sun3scsi_info(struct Scsi_Host *spnt) -{ - return ""; -} - // safe bits for the CSR #define CSR_GOOD 0x060f diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h index cb9d2a488404..3b8a05ca3625 100644 --- a/drivers/scsi/sun3_scsi.h +++ b/drivers/scsi/sun3_scsi.h @@ -74,6 +74,7 @@ #define NCR5380_bus_reset sun3scsi_bus_reset #define NCR5380_abort sun3scsi_abort #define NCR5380_show_info sun3scsi_show_info +#define NCR5380_info sun3scsi_info #define NCR5380_dma_xfer_len(i, cmd, phase) \ sun3scsi_dma_xfer_len(cmd->SCp.this_residual,cmd,((phase) & SR_IO) ? 0 : 1) diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index ad833689b311..60aff4ed4cbf 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c @@ -249,16 +249,6 @@ found: printk("scsi%d : irq = %d\n", instance->host_no, instance->irq); #endif - printk("scsi%d : at 0x%08lx", instance->host_no, instance->base); - if (instance->irq == NO_IRQ) - printk (" interrupts disabled"); - else - printk (" irq %d", instance->irq); - printk(" options CAN_QUEUE=%d CMD_PER_LUN=%d release=%d", - CAN_QUEUE, CMD_PER_LUN, T128_PUBLIC_RELEASE); - NCR5380_print_options(instance); - printk("\n"); - ++current_override; ++count; } @@ -411,6 +401,7 @@ static struct scsi_host_template driver_template = { .proc_name = "t128", .show_info = t128_show_info, .write_info = t128_write_info, + .info = t128_info, .queuecommand = t128_queue_command, .eh_abort_handler = t128_abort, .eh_bus_reset_handler = t128_bus_reset, diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h index 9f06c1851069..806dda75820a 100644 --- a/drivers/scsi/t128.h +++ b/drivers/scsi/t128.h @@ -116,6 +116,7 @@ #define NCR5380_queue_command t128_queue_command #define NCR5380_abort t128_abort #define NCR5380_bus_reset t128_bus_reset +#define NCR5380_info t128_info #define NCR5380_show_info t128_show_info #define NCR5380_write_info t128_write_info -- cgit v1.2.3 From d572f65fdf78a6dcb55b86ad8684f88830bf2e08 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:00 +1100 Subject: ncr5380: Remove pointless compiler command line override macros Compile-time override of scsi host defaults is pointless for drivers that provide module parameters and __setup options for that. Too many macros make the code hard to read so remove them. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- 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(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 1022a391c82a..0e3a9cc40c94 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -611,7 +611,7 @@ static int __init atari_scsi_detect(struct scsi_host_template *host) #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 diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h index 24e854590dc4..41b7cd7d36b8 100644 --- a/drivers/scsi/atari_scsi.h +++ b/drivers/scsi/atari_scsi.h @@ -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 ) diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index a27216d534ed..f00c987478ec 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -177,13 +177,12 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) if (macintosh_config->scsi_type != MAC_SCSI_OLD) return( 0 ); - /* setup variables */ - tpnt->can_queue = - (setup_can_queue > 0) ? setup_can_queue : CAN_QUEUE; - tpnt->cmd_per_lun = - (setup_cmd_per_lun > 0) ? setup_cmd_per_lun : CMD_PER_LUN; - tpnt->sg_tablesize = - (setup_sg_tablesize >= 0) ? setup_sg_tablesize : SG_TABLESIZE; + if (setup_can_queue > 0) + tpnt->can_queue = setup_can_queue; + if (setup_cmd_per_lun > 0) + tpnt->cmd_per_lun = setup_cmd_per_lun; + if (setup_sg_tablesize >= 0) + tpnt->sg_tablesize = setup_sg_tablesize; if (setup_hostid >= 0) tpnt->this_id = setup_hostid; @@ -194,7 +193,7 @@ int __init macscsi_detect(struct scsi_host_template * tpnt) #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_template = { .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 }; diff --git a/drivers/scsi/mac_scsi.h b/drivers/scsi/mac_scsi.h index 66b34dbdc0d0..4eed4a75160b 100644 --- a/drivers/scsi/mac_scsi.h +++ b/drivers/scsi/mac_scsi.h @@ -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 #define NCR5380_implementation_fields /* none */ diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 9bae5f6122a7..12a991b19e58 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -198,12 +198,12 @@ static int __init sun3scsi_detect(struct scsi_host_template *tpnt) #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 scsi_host_template *tpnt) #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_template = { .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 }; diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h index 3b8a05ca3625..d616c9539cec 100644 --- a/drivers/scsi/sun3_scsi.h +++ b/drivers/scsi/sun3_scsi.h @@ -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 -- cgit v1.2.3 From 710ddd0d50d22b40e3b644ea35966489ad178978 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:02 +1100 Subject: ncr5380: Drop legacy scsi.h include Convert Scsi_Cmnd to struct scsi_cmnd and drop the #include "scsi.h". The sun3_NCR5380.c core driver already uses struct scsi_cmnd so converting the other core drivers reduces the diff which makes them easier to unify. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.c | 70 ++++++++++++++--------------- drivers/scsi/NCR5380.h | 10 ++--- drivers/scsi/arm/cumana_1.c | 1 - drivers/scsi/arm/oak.c | 1 - drivers/scsi/atari_NCR5380.c | 102 ++++++++++++++++++++++--------------------- drivers/scsi/atari_scsi.c | 5 +-- drivers/scsi/dmx3191d.c | 1 - drivers/scsi/dtc.c | 1 - drivers/scsi/g_NCR5380.c | 1 - drivers/scsi/mac_scsi.c | 1 - drivers/scsi/pas16.c | 1 - drivers/scsi/sun3_NCR5380.c | 20 ++++----- drivers/scsi/sun3_scsi.c | 1 - drivers/scsi/t128.c | 1 - 14 files changed, 105 insertions(+), 111 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index 12334a08b701..36244d63def2 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -277,7 +277,7 @@ static void do_reset(struct Scsi_Host *host); * Set up the internal fields in the SCSI command. */ -static __inline__ void initialize_SCp(Scsi_Cmnd * cmd) +static inline void initialize_SCp(struct scsi_cmnd *cmd) { /* * Initialize the Scsi Pointer field so that all of the commands in the @@ -719,7 +719,7 @@ static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance, #undef SPRINTF #define SPRINTF(args...) seq_printf(m, ## args) static -void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m); +void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m); static void lprint_command(unsigned char *cmd, struct seq_file *m); static @@ -729,7 +729,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; - Scsi_Cmnd *ptr; + struct scsi_cmnd *ptr; hostdata = (struct NCR5380_hostdata *) instance->hostdata; @@ -741,19 +741,19 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, if (!hostdata->connected) SPRINTF("scsi%d: no currently connected command\n", instance->host_no); else - lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); + lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m); SPRINTF("scsi%d: issue_queue\n", instance->host_no); - for (ptr = (Scsi_Cmnd *) hostdata->issue_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) + for (ptr = (struct scsi_cmnd *) hostdata->issue_queue; ptr; ptr = (struct scsi_cmnd *) ptr->host_scribble) lprint_Scsi_Cmnd(ptr, m); SPRINTF("scsi%d: disconnected_queue\n", instance->host_no); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; ptr = (Scsi_Cmnd *) ptr->host_scribble) + for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = (struct scsi_cmnd *) ptr->host_scribble) lprint_Scsi_Cmnd(ptr, m); spin_unlock_irq(instance->host_lock); return 0; } -static void lprint_Scsi_Cmnd(Scsi_Cmnd * cmd, struct seq_file *m) +static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m) { SPRINTF("scsi%d : destination target %d, lun %llu\n", cmd->device->host->host_no, cmd->device->id, cmd->device->lun); SPRINTF(" command = "); @@ -912,11 +912,11 @@ static void NCR5380_exit(struct Scsi_Host *instance) * Locks: host lock taken by caller */ -static int NCR5380_queue_command_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *)) +static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, void (*done) (struct scsi_cmnd *)) { struct Scsi_Host *instance = cmd->device->host; struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; - Scsi_Cmnd *tmp; + struct scsi_cmnd *tmp; #if (NDEBUG & NDEBUG_NO_WRITE) switch (cmd->cmnd[0]) { @@ -950,7 +950,7 @@ static int NCR5380_queue_command_lck(Scsi_Cmnd * cmd, void (*done) (Scsi_Cmnd *) cmd->host_scribble = (unsigned char *) hostdata->issue_queue; hostdata->issue_queue = cmd; } else { - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (Scsi_Cmnd *) tmp->host_scribble); + for (tmp = (struct scsi_cmnd *) hostdata->issue_queue; tmp->host_scribble; tmp = (struct scsi_cmnd *) tmp->host_scribble); LIST(cmd, tmp); tmp->host_scribble = (unsigned char *) cmd; } @@ -981,7 +981,7 @@ static void NCR5380_main(struct work_struct *work) struct NCR5380_hostdata *hostdata = container_of(work, struct NCR5380_hostdata, coroutine.work); struct Scsi_Host *instance = hostdata->host; - Scsi_Cmnd *tmp, *prev; + struct scsi_cmnd *tmp, *prev; int done; spin_lock_irq(instance->host_lock); @@ -994,7 +994,7 @@ static void NCR5380_main(struct work_struct *work) * Search through the issue_queue for a command destined * for a target that's not busy. */ - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = (struct scsi_cmnd *) tmp->host_scribble) { if (prev != tmp) dprintk(NDEBUG_LISTS, "MAIN tmp=%p target=%d busy=%d lun=%llu\n", tmp, tmp->device->id, hostdata->busy[tmp->device->id], tmp->device->lun); @@ -1006,7 +1006,7 @@ static void NCR5380_main(struct work_struct *work) prev->host_scribble = tmp->host_scribble; } else { REMOVE(-1, hostdata->issue_queue, tmp, tmp->host_scribble); - hostdata->issue_queue = (Scsi_Cmnd *) tmp->host_scribble; + hostdata->issue_queue = (struct scsi_cmnd *) tmp->host_scribble; } tmp->host_scribble = NULL; @@ -1053,7 +1053,7 @@ static void NCR5380_main(struct work_struct *work) /* exited locked */ } /* if (!hostdata->connected) */ if (hostdata->selecting) { - tmp = (Scsi_Cmnd *) hostdata->selecting; + tmp = (struct scsi_cmnd *) hostdata->selecting; /* Selection will drop and retake the lock */ if (!NCR5380_select(instance, tmp)) { /* Ok ?? */ @@ -1175,7 +1175,8 @@ static irqreturn_t NCR5380_intr(int dummy, void *dev_id) #endif /* - * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd) + * Function : int NCR5380_select(struct Scsi_Host *instance, + * struct scsi_cmnd *cmd) * * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, * including ARBITRATION, SELECTION, and initial message out for @@ -1204,7 +1205,7 @@ static irqreturn_t NCR5380_intr(int dummy, void *dev_id) * Locks: caller holds hostdata lock in IRQ mode */ -static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd) +static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd) { NCR5380_local_declare(); struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; @@ -2011,7 +2012,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { #endif unsigned char *data; unsigned char phase, tmp, extended_msg[10], old_phase = 0xff; - Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; + struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected; /* RvC: we need to set the end of the polling time */ unsigned long poll_time = jiffies + USLEEP_POLL; @@ -2201,7 +2202,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { LIST(cmd, hostdata->issue_queue); cmd->host_scribble = (unsigned char *) hostdata->issue_queue; - hostdata->issue_queue = (Scsi_Cmnd *) cmd; + hostdata->issue_queue = (struct scsi_cmnd *) cmd; dprintk(NDEBUG_QUEUES, "scsi%d : REQUEST SENSE added to head of issue queue\n", instance->host_no); } else { cmd->scsi_done(cmd); @@ -2398,7 +2399,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) { * Function : void NCR5380_reselect (struct Scsi_Host *instance) * * Purpose : does reselection, initializing the instance->connected - * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q + * field to point to the scsi_cmnd for which the I_T_L or I_T_L_Q * nexus has been reestablished, * * Inputs : instance - this instance of the NCR5380. @@ -2415,7 +2416,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { int len; unsigned char msg[3]; unsigned char *data; - Scsi_Cmnd *tmp = NULL, *prev; + struct scsi_cmnd *tmp = NULL, *prev; int abort = 0; NCR5380_setup(instance); @@ -2481,7 +2482,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = (struct scsi_cmnd *) tmp->host_scribble) if ((target_mask == (1 << tmp->device->id)) && (lun == (u8)tmp->device->lun) ) { if (prev) { @@ -2489,7 +2490,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { prev->host_scribble = tmp->host_scribble; } else { REMOVE(-1, hostdata->disconnected_queue, tmp, tmp->host_scribble); - hostdata->disconnected_queue = (Scsi_Cmnd *) tmp->host_scribble; + hostdata->disconnected_queue = (struct scsi_cmnd *) tmp->host_scribble; } tmp->host_scribble = NULL; break; @@ -2520,7 +2521,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) { * * Inputs : instance - this instance of the NCR5380. * - * Returns : pointer to the Scsi_Cmnd structure for which the I_T_L + * Returns : pointer to the scsi_cmnd structure for which the I_T_L * nexus has been reestablished, on failure NULL is returned. */ @@ -2562,11 +2563,11 @@ static void NCR5380_dma_complete(NCR5380_instance * instance) { #endif /* def REAL_DMA */ /* - * Function : int NCR5380_abort (Scsi_Cmnd *cmd) + * Function : int NCR5380_abort (struct scsi_cmnd *cmd) * * Purpose : abort a command * - * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the + * Inputs : cmd - the scsi_cmnd to abort, code - code to set the * host byte of the result field to, if zero DID_ABORTED is * used. * @@ -2580,11 +2581,12 @@ static void NCR5380_dma_complete(NCR5380_instance * instance) { * Locks: host lock taken by caller */ -static int NCR5380_abort(Scsi_Cmnd * cmd) { +static int NCR5380_abort(struct scsi_cmnd *cmd) +{ NCR5380_local_declare(); struct Scsi_Host *instance = cmd->device->host; struct NCR5380_hostdata *hostdata = (struct NCR5380_hostdata *) instance->hostdata; - Scsi_Cmnd *tmp, **prev; + struct scsi_cmnd *tmp, **prev; scmd_printk(KERN_WARNING, cmd, "aborting command\n"); @@ -2632,10 +2634,10 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { */ dprintk(NDEBUG_ABORT, "scsi%d : abort going into loop.\n", instance->host_no); - for (prev = (Scsi_Cmnd **) & (hostdata->issue_queue), tmp = (Scsi_Cmnd *) hostdata->issue_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (prev = (struct scsi_cmnd **) &(hostdata->issue_queue), tmp = (struct scsi_cmnd *) hostdata->issue_queue; tmp; prev = (struct scsi_cmnd **) &(tmp->host_scribble), tmp = (struct scsi_cmnd *) tmp->host_scribble) if (cmd == tmp) { REMOVE(5, *prev, tmp, tmp->host_scribble); - (*prev) = (Scsi_Cmnd *) tmp->host_scribble; + (*prev) = (struct scsi_cmnd *) tmp->host_scribble; tmp->host_scribble = NULL; tmp->result = DID_ABORT << 16; dprintk(NDEBUG_ABORT, "scsi%d : abort removed command from issue queue.\n", instance->host_no); @@ -2688,7 +2690,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { * it from the disconnected queue. */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp; tmp = (struct scsi_cmnd *) tmp->host_scribble) if (cmd == tmp) { dprintk(NDEBUG_ABORT, "scsi%d : aborting disconnected command.\n", instance->host_no); @@ -2698,10 +2700,10 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { do_abort(instance); - for (prev = (Scsi_Cmnd **) & (hostdata->disconnected_queue), tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; prev = (Scsi_Cmnd **) & (tmp->host_scribble), tmp = (Scsi_Cmnd *) tmp->host_scribble) + for (prev = (struct scsi_cmnd **) &(hostdata->disconnected_queue), tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp; prev = (struct scsi_cmnd **) &(tmp->host_scribble), tmp = (struct scsi_cmnd *) tmp->host_scribble) if (cmd == tmp) { REMOVE(5, *prev, tmp, tmp->host_scribble); - *prev = (Scsi_Cmnd *) tmp->host_scribble; + *prev = (struct scsi_cmnd *) tmp->host_scribble; tmp->host_scribble = NULL; tmp->result = DID_ABORT << 16; tmp->scsi_done(tmp); @@ -2724,7 +2726,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { /* - * Function : int NCR5380_bus_reset (Scsi_Cmnd *cmd) + * Function : int NCR5380_bus_reset (struct scsi_cmnd *cmd) * * Purpose : reset the SCSI bus. * @@ -2733,7 +2735,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) { * Locks: host lock taken by caller */ -static int NCR5380_bus_reset(Scsi_Cmnd * cmd) +static int NCR5380_bus_reset(struct scsi_cmnd *cmd) { struct Scsi_Host *instance = cmd->device->host; diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 81e9c26184c0..11257784b2d7 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -255,9 +255,9 @@ struct NCR5380_hostdata { volatile int dma_len; /* requested length of DMA */ #endif volatile unsigned char last_message; /* last message OUT */ - volatile Scsi_Cmnd *connected; /* currently connected command */ - volatile Scsi_Cmnd *issue_queue; /* waiting to be issued */ - volatile Scsi_Cmnd *disconnected_queue; /* waiting for reconnect */ + volatile struct scsi_cmnd *connected; /* currently connected command */ + volatile struct scsi_cmnd *issue_queue; /* waiting to be issued */ + volatile struct scsi_cmnd *disconnected_queue; /* waiting for reconnect */ volatile int restart_select; /* we have disconnected, used to restart NCR5380_select() */ @@ -265,7 +265,7 @@ struct NCR5380_hostdata { int flags; unsigned long time_expires; /* in jiffies, set prior to sleeping */ int select_time; /* timer in select for target response */ - volatile Scsi_Cmnd *selecting; + volatile struct scsi_cmnd *selecting; struct delayed_work coroutine; /* our co-routine */ struct scsi_eh_save ses; char info[256]; @@ -309,7 +309,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id); static void NCR5380_main(struct work_struct *work); static const char *NCR5380_info(struct Scsi_Host *instance); static void NCR5380_reselect(struct Scsi_Host *instance); -static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd); +static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd); #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL) static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data); #endif diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c index 154c9fae255b..d28d6c0f18c0 100644 --- a/drivers/scsi/arm/cumana_1.c +++ b/drivers/scsi/arm/cumana_1.c @@ -13,7 +13,6 @@ #include #include -#include "../scsi.h" #include #include diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c index d1a0dc9c39ff..7c6fa1479c9c 100644 --- a/drivers/scsi/arm/oak.c +++ b/drivers/scsi/arm/oak.c @@ -14,7 +14,6 @@ #include #include -#include "../scsi.h" #include /*#define PSEUDO_DMA*/ diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 31bd81210fc4..4eeb9684977b 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -262,9 +262,9 @@ static struct scsi_host_template *the_template = NULL; (struct NCR5380_hostdata *)(in)->hostdata #define HOSTDATA(in) ((struct NCR5380_hostdata *)(in)->hostdata) -#define NEXT(cmd) ((Scsi_Cmnd *)(cmd)->host_scribble) +#define NEXT(cmd) ((struct scsi_cmnd *)(cmd)->host_scribble) #define SET_NEXT(cmd,next) ((cmd)->host_scribble = (void *)(next)) -#define NEXTADDR(cmd) ((Scsi_Cmnd **)&(cmd)->host_scribble) +#define NEXTADDR(cmd) ((struct scsi_cmnd **)&(cmd)->host_scribble) #define HOSTNO instance->host_no #define H_NO(cmd) (cmd)->device->host->host_no @@ -345,7 +345,7 @@ static void __init init_tags(void) * conditions. */ -static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged) +static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged) { u8 lun = cmd->device->lun; SETUP_HOSTDATA(cmd->device->host); @@ -370,7 +370,7 @@ static int is_lun_busy(Scsi_Cmnd *cmd, int should_be_tagged) * untagged. */ -static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged) +static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged) { u8 lun = cmd->device->lun; SETUP_HOSTDATA(cmd->device->host); @@ -402,7 +402,7 @@ static void cmd_get_tag(Scsi_Cmnd *cmd, int should_be_tagged) * unlock the LUN. */ -static void cmd_free_tag(Scsi_Cmnd *cmd) +static void cmd_free_tag(struct scsi_cmnd *cmd) { u8 lun = cmd->device->lun; SETUP_HOSTDATA(cmd->device->host); @@ -445,18 +445,18 @@ static void free_all_tags(void) /* - * Function: void merge_contiguous_buffers( Scsi_Cmnd *cmd ) + * Function: void merge_contiguous_buffers( struct scsi_cmnd *cmd ) * * Purpose: Try to merge several scatter-gather requests into one DMA * transfer. This is possible if the scatter buffers lie on * physical contiguous addresses. * - * Parameters: Scsi_Cmnd *cmd + * Parameters: struct scsi_cmnd *cmd * The command to work on. The first scatter buffer's data are * assumed to be already transferred into ptr/this_residual. */ -static void merge_contiguous_buffers(Scsi_Cmnd *cmd) +static void merge_contiguous_buffers(struct scsi_cmnd *cmd) { unsigned long endaddr; #if (NDEBUG & NDEBUG_MERGING) @@ -485,15 +485,15 @@ static void merge_contiguous_buffers(Scsi_Cmnd *cmd) } /* - * Function : void initialize_SCp(Scsi_Cmnd *cmd) + * Function : void initialize_SCp(struct scsi_cmnd *cmd) * * Purpose : initialize the saved data pointers for cmd to point to the * start of the buffer. * - * Inputs : cmd - Scsi_Cmnd structure to have pointers reset. + * Inputs : cmd - scsi_cmnd structure to have pointers reset. */ -static inline void initialize_SCp(Scsi_Cmnd *cmd) +static inline void initialize_SCp(struct scsi_cmnd *cmd) { /* * Initialize the Scsi Pointer field so that all of the commands in the @@ -714,7 +714,7 @@ static void prepare_info(struct Scsi_Host *instance) * Inputs : instance, pointer to this instance. */ -static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) +static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd) { int i, s; unsigned char *command; @@ -731,7 +731,7 @@ static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) static void NCR5380_print_status(struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; - Scsi_Cmnd *ptr; + struct scsi_cmnd *ptr; unsigned long flags; NCR5380_dprint(NDEBUG_ANY, instance); @@ -745,13 +745,13 @@ static void NCR5380_print_status(struct Scsi_Host *instance) if (!hostdata->connected) printk("scsi%d: no currently connected command\n", HOSTNO); else - lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); + lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected); printk("scsi%d: issue_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) lprint_Scsi_Cmnd(ptr); printk("scsi%d: disconnected_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = NEXT(ptr)) lprint_Scsi_Cmnd(ptr); @@ -759,7 +759,7 @@ static void NCR5380_print_status(struct Scsi_Host *instance) printk("\n"); } -static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) +static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m) { int i, s; unsigned char *command; @@ -777,7 +777,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; - Scsi_Cmnd *ptr; + struct scsi_cmnd *ptr; unsigned long flags; hostdata = (struct NCR5380_hostdata *)instance->hostdata; @@ -788,13 +788,13 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, if (!hostdata->connected) seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); else - show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); + show_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m); seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) show_Scsi_Cmnd(ptr, m); seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = NEXT(ptr)) show_Scsi_Cmnd(ptr, m); @@ -862,8 +862,8 @@ static void NCR5380_exit(struct Scsi_Host *instance) } /* - * Function : int NCR5380_queue_command (Scsi_Cmnd *cmd, - * void (*done)(Scsi_Cmnd *)) + * Function : int NCR5380_queue_command (struct scsi_cmnd *cmd, + * void (*done)(struct scsi_cmnd *)) * * Purpose : enqueues a SCSI command * @@ -879,10 +879,11 @@ static void NCR5380_exit(struct Scsi_Host *instance) * */ -static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) +static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, + void (*done)(struct scsi_cmnd *)) { SETUP_HOSTDATA(cmd->device->host); - Scsi_Cmnd *tmp; + struct scsi_cmnd *tmp; unsigned long flags; #if (NDEBUG & NDEBUG_NO_WRITE) @@ -937,7 +938,7 @@ static int NCR5380_queue_command_lck(Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *)) SET_NEXT(cmd, hostdata->issue_queue); hostdata->issue_queue = cmd; } else { - for (tmp = (Scsi_Cmnd *)hostdata->issue_queue; + for (tmp = (struct scsi_cmnd *)hostdata->issue_queue; NEXT(tmp); tmp = NEXT(tmp)) ; LIST(cmd, tmp); @@ -978,7 +979,7 @@ static DEF_SCSI_QCMD(NCR5380_queue_command) static void NCR5380_main(struct work_struct *work) { - Scsi_Cmnd *tmp, *prev; + struct scsi_cmnd *tmp, *prev; struct Scsi_Host *instance = first_instance; struct NCR5380_hostdata *hostdata = HOSTDATA(instance); int done; @@ -1021,7 +1022,7 @@ static void NCR5380_main(struct work_struct *work) * for a target that's not busy. */ #if (NDEBUG & NDEBUG_LISTS) - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, prev = NULL; + for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL; tmp && (tmp != prev); prev = tmp, tmp = NEXT(tmp)) ; /*printk("%p ", tmp);*/ @@ -1029,7 +1030,7 @@ static void NCR5380_main(struct work_struct *work) printk(" LOOP\n"); /* else printk("\n"); */ #endif - for (tmp = (Scsi_Cmnd *) hostdata->issue_queue, + for (tmp = (struct scsi_cmnd *) hostdata->issue_queue, prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) { u8 lun = tmp->device->lun; @@ -1291,7 +1292,8 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) } /* - * Function : int NCR5380_select (struct Scsi_Host *instance, Scsi_Cmnd *cmd) + * Function : int NCR5380_select(struct Scsi_Host *instance, + * struct scsi_cmnd *cmd) * * Purpose : establishes I_T_L or I_T_L_Q nexus for new or existing command, * including ARBITRATION, SELECTION, and initial message out for @@ -1318,7 +1320,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) * cmd->result host byte set to DID_BAD_TARGET. */ -static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd *cmd) +static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd) { SETUP_HOSTDATA(instance); unsigned char tmp[3], phase; @@ -1917,7 +1919,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) #endif unsigned char *data; unsigned char phase, tmp, extended_msg[10], old_phase = 0xff; - Scsi_Cmnd *cmd = (Scsi_Cmnd *) hostdata->connected; + struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected; while (1) { tmp = NCR5380_read(STATUS_REG); @@ -2154,7 +2156,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) local_irq_save(flags); LIST(cmd,hostdata->issue_queue); SET_NEXT(cmd, hostdata->issue_queue); - hostdata->issue_queue = (Scsi_Cmnd *) cmd; + hostdata->issue_queue = (struct scsi_cmnd *) cmd; local_irq_restore(flags); dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of " "issue queue\n", H_NO(cmd)); @@ -2378,7 +2380,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) * Function : void NCR5380_reselect (struct Scsi_Host *instance) * * Purpose : does reselection, initializing the instance->connected - * field to point to the Scsi_Cmnd for which the I_T_L or I_T_L_Q + * field to point to the scsi_cmnd for which the I_T_L or I_T_L_Q * nexus has been reestablished, * * Inputs : instance - this instance of the NCR5380. @@ -2397,7 +2399,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) #endif unsigned char msg[3]; unsigned char *data; - Scsi_Cmnd *tmp = NULL, *prev; + struct scsi_cmnd *tmp = NULL, *prev; /* unsigned long flags; */ /* @@ -2471,7 +2473,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) * just reestablished, and remove it from the disconnected queue. */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue, prev = NULL; + for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue, prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) { if ((target_mask == (1 << tmp->device->id)) && (lun == tmp->device->lun) #ifdef SUPPORT_TAGS @@ -2522,11 +2524,11 @@ static void NCR5380_reselect(struct Scsi_Host *instance) /* - * Function : int NCR5380_abort (Scsi_Cmnd *cmd) + * Function : int NCR5380_abort (struct scsi_cmnd *cmd) * * Purpose : abort a command * - * Inputs : cmd - the Scsi_Cmnd to abort, code - code to set the + * Inputs : cmd - the scsi_cmnd to abort, code - code to set the * host byte of the result field to, if zero DID_ABORTED is * used. * @@ -2539,11 +2541,11 @@ static void NCR5380_reselect(struct Scsi_Host *instance) */ static -int NCR5380_abort(Scsi_Cmnd *cmd) +int NCR5380_abort(struct scsi_cmnd *cmd) { struct Scsi_Host *instance = cmd->device->host; SETUP_HOSTDATA(instance); - Scsi_Cmnd *tmp, **prev; + struct scsi_cmnd *tmp, **prev; unsigned long flags; scmd_printk(KERN_NOTICE, cmd, "aborting command\n"); @@ -2612,8 +2614,8 @@ int NCR5380_abort(Scsi_Cmnd *cmd) * Case 2 : If the command hasn't been issued yet, we simply remove it * from the issue queue. */ - for (prev = (Scsi_Cmnd **)&(hostdata->issue_queue), - tmp = (Scsi_Cmnd *)hostdata->issue_queue; + for (prev = (struct scsi_cmnd **)&(hostdata->issue_queue), + tmp = (struct scsi_cmnd *)hostdata->issue_queue; tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) { if (cmd == tmp) { REMOVE(5, *prev, tmp, NEXT(tmp)); @@ -2673,7 +2675,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd) * it from the disconnected queue. */ - for (tmp = (Scsi_Cmnd *) hostdata->disconnected_queue; tmp; + for (tmp = (struct scsi_cmnd *) hostdata->disconnected_queue; tmp; tmp = NEXT(tmp)) { if (cmd == tmp) { local_irq_restore(flags); @@ -2687,8 +2689,8 @@ int NCR5380_abort(Scsi_Cmnd *cmd) do_abort(instance); local_irq_save(flags); - for (prev = (Scsi_Cmnd **)&(hostdata->disconnected_queue), - tmp = (Scsi_Cmnd *)hostdata->disconnected_queue; + for (prev = (struct scsi_cmnd **)&(hostdata->disconnected_queue), + tmp = (struct scsi_cmnd *)hostdata->disconnected_queue; tmp; prev = NEXTADDR(tmp), tmp = NEXT(tmp)) { if (cmd == tmp) { REMOVE(5, *prev, tmp, NEXT(tmp)); @@ -2737,7 +2739,7 @@ int NCR5380_abort(Scsi_Cmnd *cmd) /* - * Function : int NCR5380_reset (Scsi_Cmnd *cmd) + * Function : int NCR5380_reset (struct scsi_cmnd *cmd) * * Purpose : reset the SCSI bus. * @@ -2745,13 +2747,13 @@ int NCR5380_abort(Scsi_Cmnd *cmd) * */ -static int NCR5380_bus_reset(Scsi_Cmnd *cmd) +static int NCR5380_bus_reset(struct scsi_cmnd *cmd) { SETUP_HOSTDATA(cmd->device->host); int i; unsigned long flags; #if defined(RESET_RUN_DONE) - Scsi_Cmnd *connected, *disconnected_queue; + struct scsi_cmnd *connected, *disconnected_queue; #endif if (!IS_A_TT() && !falcon_got_lock) @@ -2793,9 +2795,9 @@ static int NCR5380_bus_reset(Scsi_Cmnd *cmd) * remembered in local variables first. */ local_irq_save(flags); - connected = (Scsi_Cmnd *)hostdata->connected; + connected = (struct scsi_cmnd *)hostdata->connected; hostdata->connected = NULL; - disconnected_queue = (Scsi_Cmnd *)hostdata->disconnected_queue; + disconnected_queue = (struct scsi_cmnd *)hostdata->disconnected_queue; hostdata->disconnected_queue = NULL; #ifdef SUPPORT_TAGS free_all_tags(); diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 0e3a9cc40c94..48fabebdbbb0 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -93,7 +93,6 @@ #include #include -#include "scsi.h" #include #include "atari_scsi.h" #include "NCR5380.h" @@ -880,7 +879,7 @@ static long atari_scsi_dma_residual(struct Scsi_Host *instance) #define CMD_SURELY_BYTE_MODE 1 #define CMD_MODE_UNKNOWN 2 -static int falcon_classify_cmd(Scsi_Cmnd *cmd) +static int falcon_classify_cmd(struct scsi_cmnd *cmd) { unsigned char opcode = cmd->cmnd[0]; @@ -912,7 +911,7 @@ static int falcon_classify_cmd(Scsi_Cmnd *cmd) */ static unsigned long atari_dma_xfer_len(unsigned long wanted_len, - Scsi_Cmnd *cmd, int write_flag) + struct scsi_cmnd *cmd, int write_flag) { unsigned long possible_len, limit; diff --git a/drivers/scsi/dmx3191d.c b/drivers/scsi/dmx3191d.c index feaba705a369..159434a5cfdb 100644 --- a/drivers/scsi/dmx3191d.c +++ b/drivers/scsi/dmx3191d.c @@ -45,7 +45,6 @@ * Includes needed for NCR5380.[ch] (XXX: Move them to NCR5380.h) */ #include -#include "scsi.h" #include "NCR5380.h" #include "NCR5380.c" diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c index 072ca426293d..4c74c7ba2dff 100644 --- a/drivers/scsi/dtc.c +++ b/drivers/scsi/dtc.c @@ -58,7 +58,6 @@ #include #include #include -#include "scsi.h" #include #include "dtc.h" #define AUTOPROBE_IRQ diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index c158104fd3aa..f35792f7051c 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -72,7 +72,6 @@ #include #include #include -#include "scsi.h" #include #include "g_NCR5380.h" #include "NCR5380.h" diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 54cb1ab2b676..40cb5f1e8bf9 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -30,7 +30,6 @@ #include #include -#include "scsi.h" #include #include "mac_scsi.h" diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c index 7994b5275431..e81eadd08afc 100644 --- a/drivers/scsi/pas16.c +++ b/drivers/scsi/pas16.c @@ -81,7 +81,6 @@ #include #include -#include "scsi.h" #include #include "pas16.h" #define AUTOPROBE_IRQ diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 1999c8e71d9f..963969f3f83f 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -660,7 +660,7 @@ static void prepare_info(struct Scsi_Host *instance) * Inputs : instance, pointer to this instance. */ -static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) +static void lprint_Scsi_Cmnd(struct scsi_cmnd *cmd) { int i, s; unsigned char *command; @@ -677,7 +677,7 @@ static void lprint_Scsi_Cmnd(Scsi_Cmnd *cmd) static void NCR5380_print_status(struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; - Scsi_Cmnd *ptr; + struct scsi_cmnd *ptr; unsigned long flags; NCR5380_dprint(NDEBUG_ANY, instance); @@ -691,13 +691,13 @@ static void NCR5380_print_status(struct Scsi_Host *instance) if (!hostdata->connected) printk("scsi%d: no currently connected command\n", HOSTNO); else - lprint_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected); + lprint_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected); printk("scsi%d: issue_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) lprint_Scsi_Cmnd(ptr); printk("scsi%d: disconnected_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = NEXT(ptr)) lprint_Scsi_Cmnd(ptr); @@ -705,7 +705,7 @@ static void NCR5380_print_status(struct Scsi_Host *instance) printk("\n"); } -static void show_Scsi_Cmnd(Scsi_Cmnd *cmd, struct seq_file *m) +static void show_Scsi_Cmnd(struct scsi_cmnd *cmd, struct seq_file *m) { int i, s; unsigned char *command; @@ -723,7 +723,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, struct Scsi_Host *instance) { struct NCR5380_hostdata *hostdata; - Scsi_Cmnd *ptr; + struct scsi_cmnd *ptr; unsigned long flags; hostdata = (struct NCR5380_hostdata *)instance->hostdata; @@ -734,13 +734,13 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, if (!hostdata->connected) seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); else - show_Scsi_Cmnd((Scsi_Cmnd *) hostdata->connected, m); + show_Scsi_Cmnd((struct scsi_cmnd *) hostdata->connected, m); seq_printf(m, "scsi%d: issue_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) + for (ptr = (struct scsi_cmnd *)hostdata->issue_queue; ptr; ptr = NEXT(ptr)) show_Scsi_Cmnd(ptr, m); seq_printf(m, "scsi%d: disconnected_queue\n", HOSTNO); - for (ptr = (Scsi_Cmnd *) hostdata->disconnected_queue; ptr; + for (ptr = (struct scsi_cmnd *) hostdata->disconnected_queue; ptr; ptr = NEXT(ptr)) show_Scsi_Cmnd(ptr, m); diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 19e9808be8d8..bb660fe4739d 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -43,7 +43,6 @@ /* dma on! */ #define REAL_DMA -#include "scsi.h" #include #include "sun3_scsi.h" #include "NCR5380.h" diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c index 69dac7776059..87828acbf7c6 100644 --- a/drivers/scsi/t128.c +++ b/drivers/scsi/t128.c @@ -77,7 +77,6 @@ #include #include -#include "scsi.h" #include #include "t128.h" #define AUTOPROBE_IRQ -- cgit v1.2.3 From 16b29e75a78ae03250233468b68f7ae467d3dc7a Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:08 +1100 Subject: atari_scsi: Fix atari_scsi deadlocks on Falcon Don't disable irqs when waiting for the ST DMA "lock"; its release may require an interrupt. Introduce stdma_try_lock() for use in soft irq context. atari_scsi now tells the SCSI mid-layer to defer queueing a command if the ST DMA lock is not available, as per Michael's patch: http://marc.info/?l=linux-m68k&m=139095335824863&w=2 The falcon_got_lock variable is race prone: we can't disable IRQs while waiting to acquire the lock, so after acquiring it there must be some interval during which falcon_got_lock remains false. Introduce stdma_is_locked_by() to replace falcon_got_lock. The falcon_got_lock tests in the EH handlers are incorrect these days. It can happen that an EH handler is called after a command completes normally. Remove these checks along with falcon_got_lock. Also remove the complicated and racy fairness wait queues. If fairness is an issue (when SCSI competes with IDE for the ST DMA interrupt), the solution is likely to be a lower value for host->can_queue. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Acked-by: Geert Uytterhoeven Signed-off-by: Christoph Hellwig --- arch/m68k/atari/stdma.c | 61 +++++++++++++++++++----------- arch/m68k/include/asm/atari_stdma.h | 4 +- drivers/scsi/atari_NCR5380.c | 33 +++++----------- drivers/scsi/atari_scsi.c | 75 +++++++------------------------------ 4 files changed, 66 insertions(+), 107 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/arch/m68k/atari/stdma.c b/arch/m68k/atari/stdma.c index ddbf43ca8858..e5a66596b116 100644 --- a/arch/m68k/atari/stdma.c +++ b/arch/m68k/atari/stdma.c @@ -59,6 +59,31 @@ static irqreturn_t stdma_int (int irq, void *dummy); /************************* 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, void *dummy); void stdma_lock(irq_handler_t handler, void *data) { - unsigned long flags; - - local_irq_save(flags); /* protect lock */ - /* Since the DMA is used for file system purposes, we have to sleep uninterruptible (there may be locked buffers) */ - wait_event(stdma_wait, !stdma_locked); - - stdma_locked = 1; - stdma_isr = handler; - stdma_isr_data = data; - local_irq_restore(flags); + wait_event(stdma_wait, stdma_try_lock(handler, data)); } EXPORT_SYMBOL(stdma_lock); @@ -122,22 +138,25 @@ void stdma_release(void) EXPORT_SYMBOL(stdma_release); -/* - * Function: int stdma_others_waiting( void ) - * - * Purpose: Check if someone waits for the ST-DMA lock. - * - * Inputs: none - * - * Returns: 0 if no one is waiting, != 0 otherwise +/** + * stdma_is_locked_by - allow lock holder to check whether it needs to release. + * @handler: interrupt handler previously used to acquire lock. * + * Returns !0 if locked for the given handler; 0 otherwise. */ -int stdma_others_waiting(void) +int stdma_is_locked_by(irq_handler_t handler) { - return waitqueue_active(&stdma_wait); + unsigned long flags; + int result; + + local_irq_save(flags); + result = stdma_locked && (stdma_isr == handler); + local_irq_restore(flags); + + return result; } -EXPORT_SYMBOL(stdma_others_waiting); +EXPORT_SYMBOL(stdma_is_locked_by); /* diff --git a/arch/m68k/include/asm/atari_stdma.h b/arch/m68k/include/asm/atari_stdma.h index 8e389b7fa70c..d24e34d870dc 100644 --- a/arch/m68k/include/asm/atari_stdma.h +++ b/arch/m68k/include/asm/atari_stdma.h @@ -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 **************************/ diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 4eeb9684977b..7a6f90ce0316 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -879,10 +879,10 @@ static void NCR5380_exit(struct Scsi_Host *instance) * */ -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; @@ -893,7 +893,7 @@ static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, printk(KERN_NOTICE "scsi%d: WRITE attempted with NO_WRITE debugging flag set\n", H_NO(cmd)); cmd->result = (DID_ERROR << 16); - done(cmd); + cmd->scsi_done(cmd); return 0; } #endif /* (NDEBUG & NDEBUG_NO_WRITE) */ @@ -904,8 +904,6 @@ static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, */ SET_NEXT(cmd, NULL); - cmd->scsi_done = done; - cmd->result = 0; /* @@ -915,7 +913,6 @@ static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, * 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 @@ -928,11 +925,11 @@ static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, * 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 */ - } + if (!falcon_get_lock()) + return SCSI_MLQUEUE_HOST_BUSY; + + local_irq_save(flags); + if (!(hostdata->issue_queue) || (cmd->cmnd[0] == REQUEST_SENSE)) { LIST(cmd, hostdata->issue_queue); SET_NEXT(cmd, hostdata->issue_queue); @@ -956,15 +953,13 @@ static int NCR5380_queue_command_lck(struct scsi_cmnd *cmd, * 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) * @@ -2554,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)); @@ -2756,10 +2747,6 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd) struct scsi_cmnd *connected, *disconnected_queue; #endif - if (!IS_A_TT() && !falcon_got_lock) - printk(KERN_ERR "scsi%d: !!BINGO!! Falcon has no lock in NCR5380_reset\n", - H_NO(cmd)); - NCR5380_print_status(cmd->device->host); /* get in phase */ diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 48fabebdbbb0..b2e86d0630ce 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -184,7 +184,7 @@ static void atari_scsi_fetch_restbytes(void); static irqreturn_t scsi_tt_intr(int irq, void *dummy); static irqreturn_t scsi_falcon_intr(int irq, void *dummy); static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata); -static void falcon_get_lock(void); +static int falcon_get_lock(void); #ifdef CONFIG_ATARI_SCSI_RESET_BOOT static void atari_scsi_reset_boot(void); #endif @@ -473,17 +473,10 @@ static void atari_scsi_fetch_restbytes(void) #endif /* REAL_DMA */ -static int falcon_got_lock = 0; -static DECLARE_WAIT_QUEUE_HEAD(falcon_fairness_wait); -static int falcon_trying_lock = 0; -static DECLARE_WAIT_QUEUE_HEAD(falcon_try_wait); static int falcon_dont_release = 0; /* This function releases the lock on the DMA chip if there is no - * connected command and the disconnected queue is empty. On - * releasing, instances of falcon_get_lock are awoken, that put - * themselves to sleep for fairness. They can now try to get the lock - * again (but others waiting longer more probably will win). + * connected command and the disconnected queue is empty. */ static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata) @@ -495,20 +488,12 @@ static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata) local_irq_save(flags); - if (falcon_got_lock && !hostdata->disconnected_queue && - !hostdata->issue_queue && !hostdata->connected) { - - if (falcon_dont_release) { -#if 0 - printk("WARNING: Lock release not allowed. Ignored\n"); -#endif - local_irq_restore(flags); - return; - } - falcon_got_lock = 0; + if (!hostdata->disconnected_queue && + !hostdata->issue_queue && + !hostdata->connected && + !falcon_dont_release && + stdma_is_locked_by(scsi_falcon_intr)) stdma_release(); - wake_up(&falcon_fairness_wait); - } local_irq_restore(flags); } @@ -517,51 +502,19 @@ static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata) * If the DMA isn't locked already for SCSI, it tries to lock it by * calling stdma_lock(). But if the DMA is locked by the SCSI code and * there are other drivers waiting for the chip, we do not issue the - * command immediately but wait on 'falcon_fairness_queue'. We will be - * waked up when the DMA is unlocked by some SCSI interrupt. After that - * we try to get the lock again. - * But we must be prepared that more than one instance of - * falcon_get_lock() is waiting on the fairness queue. They should not - * try all at once to call stdma_lock(), one is enough! For that, the - * first one sets 'falcon_trying_lock', others that see that variable - * set wait on the queue 'falcon_try_wait'. - * Complicated, complicated.... Sigh... + * command immediately but tell the SCSI mid-layer to defer. */ -static void falcon_get_lock(void) +static int falcon_get_lock(void) { - unsigned long flags; - if (IS_A_TT()) - return; + return 1; - local_irq_save(flags); + if (in_interrupt()) + return stdma_try_lock(scsi_falcon_intr, NULL); - wait_event_cmd(falcon_fairness_wait, - in_interrupt() || !falcon_got_lock || !stdma_others_waiting(), - local_irq_restore(flags), - local_irq_save(flags)); - - while (!falcon_got_lock) { - if (in_irq()) - panic("Falcon SCSI hasn't ST-DMA lock in interrupt"); - if (!falcon_trying_lock) { - falcon_trying_lock = 1; - stdma_lock(scsi_falcon_intr, NULL); - falcon_got_lock = 1; - falcon_trying_lock = 0; - wake_up(&falcon_try_wait); - } else { - wait_event_cmd(falcon_try_wait, - falcon_got_lock && !falcon_trying_lock, - local_irq_restore(flags), - local_irq_save(flags)); - } - } - - local_irq_restore(flags); - if (!falcon_got_lock) - panic("Falcon SCSI: someone stole the lock :-(\n"); + stdma_lock(scsi_falcon_intr, NULL); + return 1; } -- cgit v1.2.3 From 3ff228af84b57767645d81a89c166c777646ad61 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:09 +1100 Subject: atari_scsi: Convert to platform device Convert atari_scsi to platform device and eliminate scsi_register(). Validate __setup options later on so that module options are checked as well. Remove the comment about the scsi mid-layer disabling the host irq as it is no longer true (AFAICT). Also remove the obsolete slow interrupt stuff (IRQ_TYPE_SLOW == 0 anyway). Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Acked-by: Geert Uytterhoeven Signed-off-by: Christoph Hellwig --- arch/m68k/atari/config.c | 27 +++ drivers/scsi/atari_scsi.c | 424 +++++++++++++++++++++++----------------------- drivers/scsi/atari_scsi.h | 17 -- 3 files changed, 237 insertions(+), 231 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/arch/m68k/atari/config.c b/arch/m68k/atari/config.c index 01a62161b08a..192b00f098f4 100644 --- a/arch/m68k/atari/config.c +++ b/arch/m68k/atari/config.c @@ -858,6 +858,24 @@ static struct platform_device *atari_netusbee_devices[] __initdata = { }; #endif /* CONFIG_ATARI_ETHERNEC */ +#ifdef CONFIG_ATARI_SCSI +static const struct resource atari_scsi_st_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = IRQ_MFP_FSCSI, + .end = IRQ_MFP_FSCSI, + }, +}; + +static const struct resource atari_scsi_tt_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = IRQ_TT_MFP_SCSI, + .end = IRQ_TT_MFP_SCSI, + }, +}; +#endif + int __init atari_platform_init(void) { int rv = 0; @@ -892,6 +910,15 @@ int __init atari_platform_init(void) } #endif +#ifdef CONFIG_ATARI_SCSI + if (ATARIHW_PRESENT(ST_SCSI)) + platform_device_register_simple("atari_scsi", -1, + atari_scsi_st_rsrc, ARRAY_SIZE(atari_scsi_st_rsrc)); + else if (ATARIHW_PRESENT(TT_SCSI)) + platform_device_register_simple("atari_scsi", -1, + atari_scsi_tt_rsrc, ARRAY_SIZE(atari_scsi_tt_rsrc)); +#endif + return rv; } diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index b2e86d0630ce..b765e1c2277f 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -74,33 +74,26 @@ #define MAX_TAGS 32 #include -#include -#include #include -#include #include #include #include #include #include #include +#include #include #include #include -#include -#include -#include -#include - -#include -#include "atari_scsi.h" -#include "NCR5380.h" #include #include #include -#include +#include + +#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); @@ -517,160 +494,12 @@ static int falcon_get_lock(void) return 1; } - -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=,,,, - * 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]; @@ -681,36 +510,17 @@ static int __init atari_scsi_setup(char *str) printk("atari_scsi_setup: no arguments!\n"); return 0; } - - if (ints[0] >= 1) { - if (ints[1] > 0) - /* no limits on this, just > 0 */ - setup_can_queue = ints[1]; - } - if (ints[0] >= 2) { - if (ints[2] > 0) - setup_cmd_per_lun = ints[2]; - } - if (ints[0] >= 3) { - if (ints[3] >= 0) { - setup_sg_tablesize = ints[3]; - /* Must be <= SG_ALL (255) */ - if (setup_sg_tablesize > SG_ALL) - setup_sg_tablesize = SG_ALL; - } - } - if (ints[0] >= 4) { - /* Must be between 0 and 7 */ - if (ints[4] >= 0 && ints[4] <= 7) - setup_hostid = ints[4]; - else if (ints[4] > 7) - printk("atari_scsi_setup: invalid host ID %d !\n", ints[4]); - } + if (ints[0] >= 1) + setup_can_queue = ints[1]; + if (ints[0] >= 2) + setup_cmd_per_lun = ints[2]; + if (ints[0] >= 3) + setup_sg_tablesize = ints[3]; + if (ints[0] >= 4) + setup_hostid = ints[4]; #ifdef SUPPORT_TAGS - if (ints[0] >= 5) { - if (ints[5] >= 0) - setup_use_tagged_queuing = !!ints[5]; - } + if (ints[0] >= 5) + setup_use_tagged_queuing = ints[5]; #endif return 1; @@ -1019,23 +829,209 @@ static int atari_scsi_bus_reset(struct scsi_cmnd *cmd) return rv; } -static struct scsi_host_template driver_template = { +#define DRV_MODULE_NAME "atari_scsi" +#define PFX DRV_MODULE_NAME ": " + +static struct scsi_host_template atari_scsi_template = { + .module = THIS_MODULE, + .proc_name = DRV_MODULE_NAME, .show_info = atari_scsi_show_info, .name = "Atari native SCSI", - .detect = atari_scsi_detect, - .release = atari_scsi_release, .info = atari_scsi_info, .queuecommand = atari_scsi_queue_command, .eh_abort_handler = atari_scsi_abort, .eh_bus_reset_handler = atari_scsi_bus_reset, - .can_queue = 0, /* initialized at run-time */ - .this_id = 0, /* initialized at run-time */ - .sg_tablesize = 0, /* initialized at run-time */ - .cmd_per_lun = 0, /* initialized at run-time */ + .this_id = 7, .use_clustering = DISABLE_CLUSTERING }; +static int __init atari_scsi_probe(struct platform_device *pdev) +{ + struct Scsi_Host *instance; + int error; + struct resource *irq; + + irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); + if (!irq) + 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 { + atari_scsi_reg_read = atari_scsi_falcon_reg_read; + atari_scsi_reg_write = atari_scsi_falcon_reg_write; + } + + /* 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 (ATARIHW_PRESENT(TT_SCSI)) { + atari_scsi_template.can_queue = 16; + atari_scsi_template.cmd_per_lun = 8; + atari_scsi_template.sg_tablesize = SG_ALL; + } else { + atari_scsi_template.can_queue = 8; + atari_scsi_template.cmd_per_lun = 1; + atari_scsi_template.sg_tablesize = SG_NONE; + } + + 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 (ATARIHW_PRESENT(TT_SCSI) && 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 + + instance->irq = irq->start; + + 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 (IS_A_TT()) + 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 (IS_A_TT()) + 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"); diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h index 41b7cd7d36b8..ff329f9f1b98 100644 --- a/drivers/scsi/atari_scsi.h +++ b/drivers/scsi/atari_scsi.h @@ -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 */ -- cgit v1.2.3 From 4e705205252ffc6979b938ab10facf765692f5cf Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:10 +1100 Subject: atari_scsi: Remove header The #defines in atari_scsi.h are intended to influence subsequent #includes in atari_scsi.c. IMHO, that's too convoluted. Remove atari_scsi.h by moving those macro definitions to atari_scsi.c, consistent with other NCR5380 drivers. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/atari_scsi.c | 35 ++++++++++++++++++++++++++--------- drivers/scsi/atari_scsi.h | 40 ---------------------------------------- 2 files changed, 26 insertions(+), 49 deletions(-) delete mode 100644 drivers/scsi/atari_scsi.h (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index b765e1c2277f..e031f6dbcebc 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -64,15 +64,7 @@ /**************************************************************************/ - #include - -/* 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 #include #include @@ -92,9 +84,34 @@ #include -#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) \ diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h deleted file mode 100644 index ff329f9f1b98..000000000000 --- a/drivers/scsi/atari_scsi.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * atari_scsi.h -- Header file for the Atari native SCSI driver - * - * Copyright 1994 Roman Hodek - * - * (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 */ - - -- cgit v1.2.3 From f527590278f1b823ba979a234241d09ed2c436b4 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:13 +1100 Subject: ncr5380: Remove ENABLE_IRQ/DISABLE_IRQ macros atari_NCR5380.c enables its IRQ when it is already enabled. Sun3 doesn't use the ENABLE_IRQ/DISABLE_IRQ cruft. Remove it. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- 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(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 7a6f90ce0316..75d34031c280 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -1227,7 +1227,6 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) 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); @@ -1257,7 +1256,6 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO); NCR5380_dma_complete( instance ); done = 0; - ENABLE_IRQ(); } else #endif /* REAL_DMA */ { diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index e031f6dbcebc..78324e056d4c 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -157,23 +157,6 @@ static inline unsigned long SCSI_DMA_GETADR(void) return adr; } -static inline void ENABLE_IRQ(void) -{ - if (IS_A_TT()) - atari_enable_irq(IRQ_TT_MFP_SCSI); - else - atari_enable_irq(IRQ_MFP_FSCSI); -} - -static inline void DISABLE_IRQ(void) -{ - if (IS_A_TT()) - atari_disable_irq(IRQ_TT_MFP_SCSI); - else - atari_disable_irq(IRQ_MFP_FSCSI); -} - - #define HOSTDATA_DMALEN (((struct NCR5380_hostdata *) \ (atari_scsi_host->hostdata))->dma_len) @@ -373,10 +356,6 @@ static irqreturn_t scsi_tt_intr(int irq, void *dummy) 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; } diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c index 963969f3f83f..0cb25f6d58b2 100644 --- a/drivers/scsi/sun3_NCR5380.c +++ b/drivers/scsi/sun3_NCR5380.c @@ -1155,7 +1155,6 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id) NCR5380_dprint(NDEBUG_INTR, instance); if ((NCR5380_read(STATUS_REG) & (SR_SEL|SR_IO)) == (SR_SEL|SR_IO)) { done = 0; -// ENABLE_IRQ(); dprintk(NDEBUG_INTR, "scsi%d: SEL interrupt\n", HOSTNO); NCR5380_reselect(instance); (void) NCR5380_read(RESET_PARITY_INTERRUPT_REG); @@ -1188,7 +1187,6 @@ static irqreturn_t NCR5380_intr (int irq, void *dev_id) dprintk(NDEBUG_INTR, "scsi%d: PHASE MISM or EOP interrupt\n", HOSTNO); NCR5380_dma_complete( instance ); done = 0; -// ENABLE_IRQ(); } else #endif /* REAL_DMA */ { diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 6943dd6b9b56..446c8e58a8db 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -69,13 +69,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; -- cgit v1.2.3 From ef1081cbf05b22d3d0e05b267a5559a8cd8e8d4a Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:14 +1100 Subject: atari_NCR5380: Refactor Falcon special cases Make the atari_NCR5380.c core driver usable by sun3_scsi, mac_scsi and others by moving some of the Falcon-specific code out of the core driver: !IS_A_TT, atari_read_overruns and falcon_dont_release. Replace these with hostdata variables and flags. FLAG_CHECK_LAST_BYTE_SENT is unused in atari_NCR5380.c so don't set it. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.h | 4 ++++ drivers/scsi/atari_NCR5380.c | 30 +++++++++++++++--------------- drivers/scsi/atari_scsi.c | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 24 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 11257784b2d7..7b1a0913d94c 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -241,6 +241,7 @@ #define FLAG_NCR53C400 4 /* NCR53c400 */ #define FLAG_NO_PSEUDO_DMA 8 /* Inhibit DMA */ #define FLAG_DTC3181E 16 /* DTC3181E */ +#define FLAG_LATE_DMA_SETUP 32 /* Setup NCR before DMA H/W */ #ifndef ASM struct NCR5380_hostdata { @@ -269,6 +270,9 @@ struct NCR5380_hostdata { struct delayed_work coroutine; /* our co-routine */ struct scsi_eh_save ses; char info[256]; + int read_overruns; /* number of bytes to cut from a + * transfer to handle chip overruns */ + int retain_dma_intr; #ifdef PSEUDO_DMA unsigned spin_max_r; unsigned spin_max_w; diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 75d34031c280..371ca14f08ea 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -839,7 +839,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) 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; @@ -1054,7 +1054,7 @@ static void NCR5380_main(struct work_struct *work) 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); @@ -1082,7 +1082,7 @@ static void NCR5380_main(struct work_struct *work) cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE); #endif if (!NCR5380_select(instance, tmp)) { - falcon_dont_release--; + hostdata->retain_dma_intr--; /* release if target did not response! */ falcon_release_lock_if_possible(hostdata); break; @@ -1094,7 +1094,7 @@ static void NCR5380_main(struct work_struct *work) #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); @@ -1151,7 +1151,7 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) return; } - if (atari_read_overruns) { + if (hostdata->read_overruns) { p = hostdata->connected->SCp.phase; if (p & SR_IO) { udelay(10); @@ -1181,9 +1181,9 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) *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; @@ -1838,8 +1838,8 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, return -1; } - if (atari_read_overruns && (p & SR_IO)) - c -= atari_read_overruns; + if (hostdata->read_overruns && (p & SR_IO)) + c -= hostdata->read_overruns; dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n", HOSTNO, (p & SR_IO) ? "reading" : "writing", @@ -1851,7 +1851,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, NCR5380_write(MODE_REG, MR_BASE | MR_DMA_MODE | MR_ENABLE_EOP_INTR | MR_MONITOR_BSY); #endif /* def REAL_DMA */ - if (IS_A_TT()) { + if (!(hostdata->flags & FLAG_LATE_DMA_SETUP)) { /* On the Medusa, it is a must to initialize the DMA before * starting the NCR. This is also the cleaner way for the TT. */ @@ -1869,7 +1869,7 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, NCR5380_write(START_DMA_SEND_REG, 0); } - if (!IS_A_TT()) { + if (hostdata->flags & FLAG_LATE_DMA_SETUP) { /* On the Falcon, the DMA setup must be done after the last */ /* NCR access, else the DMA setup gets trashed! */ @@ -2084,7 +2084,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) /* 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 %llu " "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); @@ -2167,7 +2167,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) barrier(); - falcon_dont_release--; + hostdata->retain_dma_intr--; /* ++roman: For Falcon SCSI, release the lock on the * ST-DMA here if no other commands are waiting on the * disconnected queue. @@ -2474,7 +2474,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) #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)); @@ -2512,7 +2512,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) hostdata->connected = tmp; dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n", HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag); - falcon_dont_release--; + hostdata->retain_dma_intr--; } diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 78324e056d4c..70c662f9fee4 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -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(void) #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_possible(struct NCR5380_hostdata *hostdata) if (!hostdata->disconnected_queue && !hostdata->issue_queue && !hostdata->connected && - !falcon_dont_release && + !hostdata->retain_dma_intr && stdma_is_locked_by(scsi_falcon_intr)) stdma_release(); @@ -846,6 +842,7 @@ static int __init atari_scsi_probe(struct platform_device *pdev) struct Scsi_Host *instance; int error; struct resource *irq; + int host_flags = 0; irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!irq) @@ -942,7 +939,9 @@ static int __init atari_scsi_probe(struct platform_device *pdev) instance->irq = irq->start; - NCR5380_init(instance, 0); + host_flags |= IS_A_TT() ? 0 : FLAG_LATE_DMA_SETUP; + + NCR5380_init(instance, host_flags); if (IS_A_TT()) { error = request_irq(instance->irq, scsi_tt_intr, 0, @@ -965,12 +964,16 @@ static int __init atari_scsi_probe(struct platform_device *pdev) * * 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 -- cgit v1.2.3 From e3c3da67340ac7d1d2f630f319eb718474b0d9c3 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:15 +1100 Subject: atari_NCR5380: Refactor Falcon locking Simplify falcon_release_lock_if_possible() by making callers responsible for disabling local IRQ's, which they must do anyway to correctly synchronize the ST DMA "lock" with core driver data structures. Move this synchronization logic to the core driver with which it is tightly coupled. Other LLD's like sun3_scsi and mac_scsi that can make use of this core driver can just stub out the NCR5380_acquire_dma_irq() and NCR5380_release_dma_irq() calls so the compiler will eliminate the ST DMA code. Remove a redundant local_irq_save/restore pair (irq's are disabled for interrupt handlers these days). Revise the locking for atari_scsi_bus_reset(): use local_irq_save/restore() instead of atari_turnoff/turnon_irq(). There is no guarantee that atari_scsi still holds the ST DMA lock during EH, so atari_turnoff/turnon_irq() could end up dropping an IDE or floppy interrupt. Signed-off-by: Finn Thain Tested-by: Michael Schmitz Reviewed-by: Hannes Reinecke Signed-off-by: Christoph Hellwig --- drivers/scsi/atari_NCR5380.c | 72 +++++++++++++++++++++++++++----------------- drivers/scsi/atari_scsi.c | 47 +++++++++++------------------ 2 files changed, 62 insertions(+), 57 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 371ca14f08ea..795522192d36 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -925,7 +925,7 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, * because also a timer int can trigger an abort or reset, which would * alter queues and touch the lock. */ - if (!falcon_get_lock()) + if (!NCR5380_acquire_dma_irq(instance)) return SCSI_MLQUEUE_HOST_BUSY; local_irq_save(flags); @@ -960,6 +960,18 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, return 0; } +static inline void maybe_release_dma_irq(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + /* Caller does the locking needed to set & test these data atomically */ + if (!hostdata->disconnected_queue && + !hostdata->issue_queue && + !hostdata->connected && + !hostdata->retain_dma_intr) + NCR5380_release_dma_irq(instance); +} + /* * Function : NCR5380_main (void) * @@ -1082,9 +1094,11 @@ static void NCR5380_main(struct work_struct *work) cmd_get_tag(tmp, tmp->cmnd[0] != REQUEST_SENSE); #endif if (!NCR5380_select(instance, tmp)) { + local_irq_disable(); hostdata->retain_dma_intr--; /* release if target did not response! */ - falcon_release_lock_if_possible(hostdata); + maybe_release_dma_irq(instance); + local_irq_restore(flags); break; } else { local_irq_disable(); @@ -2083,11 +2097,12 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) case COMMAND_COMPLETE: /* Accept message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - /* ++guenther: possible race with Falcon locking */ - hostdata->retain_dma_intr++; - hostdata->connected = NULL; dprintk(NDEBUG_QUEUES, "scsi%d: command for target %d, lun %llu " "completed\n", HOSTNO, cmd->device->id, cmd->device->lun); + + local_irq_save(flags); + hostdata->retain_dma_intr++; + hostdata->connected = NULL; #ifdef SUPPORT_TAGS cmd_free_tag(cmd); if (status_byte(cmd->SCp.Status) == QUEUE_FULL) { @@ -2146,17 +2161,17 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) dprintk(NDEBUG_AUTOSENSE, "scsi%d: performing request sense\n", HOSTNO); - local_irq_save(flags); LIST(cmd,hostdata->issue_queue); SET_NEXT(cmd, hostdata->issue_queue); hostdata->issue_queue = (struct scsi_cmnd *) cmd; - local_irq_restore(flags); dprintk(NDEBUG_QUEUES, "scsi%d: REQUEST SENSE added to head of " "issue queue\n", H_NO(cmd)); } else { cmd->scsi_done(cmd); } + local_irq_restore(flags); + NCR5380_write(SELECT_ENABLE_REG, hostdata->id_mask); /* * Restore phase bits to 0 so an interrupted selection, @@ -2167,12 +2182,14 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) barrier(); + local_irq_save(flags); hostdata->retain_dma_intr--; /* ++roman: For Falcon SCSI, release the lock on the * ST-DMA here if no other commands are waiting on the * disconnected queue. */ - falcon_release_lock_if_possible(hostdata); + maybe_release_dma_irq(instance); + local_irq_restore(flags); return; case MESSAGE_REJECT: /* Accept message by clearing ACK */ @@ -2331,6 +2348,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) 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 @@ -2338,9 +2356,10 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) #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; @@ -2393,7 +2412,6 @@ static void NCR5380_reselect(struct Scsi_Host *instance) unsigned char msg[3]; unsigned char *data; struct scsi_cmnd *tmp = NULL, *prev; -/* unsigned long flags; */ /* * Disable arbitration, etc. since the host adapter obviously @@ -2473,8 +2491,6 @@ static void NCR5380_reselect(struct Scsi_Host *instance) && (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)); @@ -2512,7 +2528,6 @@ static void NCR5380_reselect(struct Scsi_Host *instance) hostdata->connected = tmp; dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, 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_cmnd *cmd) #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 */ diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 70c662f9fee4..045112186f84 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -109,6 +109,9 @@ #define NCR5380_dma_xfer_len(instance, cmd, phase) \ atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) +#define NCR5380_acquire_dma_irq(instance) falcon_get_lock() +#define NCR5380_release_dma_irq(instance) falcon_release_lock() + #include "NCR5380.h" @@ -448,23 +451,13 @@ static void atari_scsi_fetch_restbytes(void) * connected command and the disconnected queue is empty. */ -static void falcon_release_lock_if_possible(struct NCR5380_hostdata *hostdata) +static void falcon_release_lock(void) { - unsigned long flags; - if (IS_A_TT()) return; - local_irq_save(flags); - - if (!hostdata->disconnected_queue && - !hostdata->issue_queue && - !hostdata->connected && - !hostdata->retain_dma_intr && - stdma_is_locked_by(scsi_falcon_intr)) + if (stdma_is_locked_by(scsi_falcon_intr)) stdma_release(); - - local_irq_restore(flags); } /* This function manages the locking of the ST-DMA. @@ -787,36 +780,30 @@ static void atari_scsi_falcon_reg_write(unsigned char reg, unsigned char value) static int atari_scsi_bus_reset(struct scsi_cmnd *cmd) { int rv; - struct NCR5380_hostdata *hostdata = shost_priv(cmd->device->host); + unsigned long flags; + + local_irq_save(flags); - /* For doing the reset, SCSI interrupts must be disabled first, - * since the 5380 raises its IRQ line while _RST is active and we - * can't disable interrupts completely, since we need the timer. - */ - /* And abort a maybe active DMA transfer */ - if (IS_A_TT()) { - atari_turnoff_irq(IRQ_TT_MFP_SCSI); #ifdef REAL_DMA + /* Abort a maybe active DMA transfer */ + if (IS_A_TT()) { tt_scsi_dma.dma_ctrl = 0; -#endif } else { - atari_turnoff_irq(IRQ_MFP_FSCSI); -#ifdef REAL_DMA st_dma.dma_mode_status = 0x90; atari_dma_active = 0; atari_dma_orig_addr = NULL; -#endif } +#endif rv = NCR5380_bus_reset(cmd); - if (IS_A_TT()) - atari_turnon_irq(IRQ_TT_MFP_SCSI); - else - atari_turnon_irq(IRQ_MFP_FSCSI); + /* The 5380 raises its IRQ line while _RST is active but the ST DMA + * "lock" has been released so this interrupt may end up handled by + * floppy or IDE driver (if one of them holds the lock). The NCR5380 + * interrupt flag has been cleared already. + */ - if (rv == SUCCESS) - falcon_release_lock_if_possible(hostdata); + local_irq_restore(flags); return rv; } -- cgit v1.2.3 From e3f463b034bad82cd247d9a1b39209ba7152e545 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:16 +1100 Subject: atari_NCR5380: Merge from sun3_NCR5380.c There is very little difference between the sun3_NCR5380.c core driver and atari_NCR5380.c. The former is a fork of the latter. Merge the sun3_NCR5380.c core driver into atari_NCR5380.c so that sun3_scsi.c can adopt the latter and the former can be deleted. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/atari_NCR5380.c | 208 +++++++++++++++++++++++++++++++++++++++---- drivers/scsi/atari_scsi.c | 1 + 2 files changed, 193 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 795522192d36..1331b8cf5fe9 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -71,6 +71,9 @@ * 1. Test linked command handling code after Eric is ready with * the high level code. */ + +/* Adapted for the sun3 by Sam Creasey. */ + #include #include @@ -458,6 +461,7 @@ static void free_all_tags(void) static void merge_contiguous_buffers(struct scsi_cmnd *cmd) { +#if !defined(CONFIG_SUN3) unsigned long endaddr; #if (NDEBUG & NDEBUG_MERGING) unsigned long oldlen = cmd->SCp.this_residual; @@ -482,6 +486,7 @@ static void merge_contiguous_buffers(struct scsi_cmnd *cmd) dprintk(NDEBUG_MERGING, "merged %d buffers from %p, new length %08x\n", cnt, cmd->SCp.ptr, cmd->SCp.this_residual); #endif +#endif /* !defined(CONFIG_SUN3) */ } /* @@ -1041,12 +1046,10 @@ static void NCR5380_main(struct work_struct *work) prev = NULL; tmp; prev = tmp, tmp = NEXT(tmp)) { u8 lun = tmp->device->lun; -#if (NDEBUG & NDEBUG_LISTS) - if (prev != tmp) - printk("MAIN tmp=%p target=%d busy=%d lun=%llu\n", - tmp, tmp->device->id, hostdata->busy[tmp->device->id], - lun); -#endif + dprintk(NDEBUG_LISTS, + "MAIN tmp=%p target=%d busy=%d lun=%d\n", + tmp, scmd_id(tmp), hostdata->busy[scmd_id(tmp)], + lun); /* When we find one, remove it from the issue queue. */ /* ++guenther: possible race with Falcon locking */ if ( @@ -1155,9 +1158,11 @@ static void NCR5380_main(struct work_struct *work) static void NCR5380_dma_complete(struct Scsi_Host *instance) { SETUP_HOSTDATA(instance); - int transfered, saved_data = 0, overrun = 0, cnt, toPIO; - unsigned char **data, p; + int transfered; + unsigned char **data; volatile int *count; + int saved_data = 0, overrun = 0; + unsigned char p; if (!hostdata->connected) { printk(KERN_WARNING "scsi%d: received end of DMA interrupt with " @@ -1183,6 +1188,24 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) HOSTNO, NCR5380_read(BUS_AND_STATUS_REG), NCR5380_read(STATUS_REG)); +#if defined(CONFIG_SUN3) + if ((sun3scsi_dma_finish(rq_data_dir(hostdata->connected->request)))) { + pr_err("scsi%d: overrun in UDC counter -- not prepared to deal with this!\n", + instance->host_no); + BUG(); + } + + /* make sure we're not stuck in a data phase */ + if ((NCR5380_read(BUS_AND_STATUS_REG) & (BASR_PHASE_MATCH | BASR_ACK)) == + (BASR_PHASE_MATCH | BASR_ACK)) { + pr_err("scsi%d: BASR %02x\n", instance->host_no, + NCR5380_read(BUS_AND_STATUS_REG)); + pr_err("scsi%d: bus stuck in data phase -- probably a single byte overrun!\n", + instance->host_no); + BUG(); + } +#endif + (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG); NCR5380_write(MODE_REG, MR_BASE); NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); @@ -1196,6 +1219,8 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) *count -= transfered; if (hostdata->read_overruns) { + int cnt, toPIO; + if ((NCR5380_read(STATUS_REG) & PHASE_MASK) == p && (p & SR_IO)) { cnt = toPIO = hostdata->read_overruns; if (overrun) { @@ -1275,11 +1300,14 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) { /* MS: Ignore unknown phase mismatch interrupts (caused by EOP interrupt) */ if (basr & BASR_PHASE_MATCH) - printk(KERN_NOTICE "scsi%d: unknown interrupt, " + dprintk(NDEBUG_INTR, "scsi%d: unknown interrupt, " "BASR 0x%x, MR 0x%x, SR 0x%x\n", HOSTNO, basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG)); (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG); +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_DMA_ENABLE; +#endif } } /* if !(SELECTION || PARITY) */ handled = 1; @@ -1288,6 +1316,9 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) "BASR 0x%X, MR 0x%X, SR 0x%x\n", HOSTNO, basr, NCR5380_read(MODE_REG), NCR5380_read(STATUS_REG)); (void)NCR5380_read(RESET_PARITY_INTERRUPT_REG); +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_DMA_ENABLE; +#endif } if (!done) { @@ -1620,6 +1651,9 @@ static int NCR5380_select(struct Scsi_Host *instance, struct scsi_cmnd *cmd) #ifndef SUPPORT_TAGS hostdata->busy[cmd->device->id] |= (1 << cmd->device->lun); #endif +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_INTR; +#endif initialize_SCp(cmd); @@ -1843,9 +1877,54 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, SETUP_HOSTDATA(instance); register int c = *count; register unsigned char p = *phase; + unsigned long flags; + +#if defined(CONFIG_SUN3) + /* sanity check */ + if (!sun3_dma_setup_done) { + pr_err("scsi%d: transfer_dma without setup!\n", + instance->host_no); + BUG(); + } + hostdata->dma_len = c; + + dprintk(NDEBUG_DMA, "scsi%d: initializing DMA for %s, %d bytes %s %p\n", + instance->host_no, (p & SR_IO) ? "reading" : "writing", + c, (p & SR_IO) ? "to" : "from", *data); + + /* netbsd turns off ints here, why not be safe and do it too */ + local_irq_save(flags); + + /* send start chain */ + sun3scsi_dma_start(c, *data); + + if (p & SR_IO) { + NCR5380_write(TARGET_COMMAND_REG, 1); + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + NCR5380_write(INITIATOR_COMMAND_REG, 0); + NCR5380_write(MODE_REG, + (NCR5380_read(MODE_REG) | MR_DMA_MODE | MR_ENABLE_EOP_INTR)); + NCR5380_write(START_DMA_INITIATOR_RECEIVE_REG, 0); + } else { + NCR5380_write(TARGET_COMMAND_REG, 0); + NCR5380_read(RESET_PARITY_INTERRUPT_REG); + NCR5380_write(INITIATOR_COMMAND_REG, ICR_ASSERT_DATA); + NCR5380_write(MODE_REG, + (NCR5380_read(MODE_REG) | MR_DMA_MODE | MR_ENABLE_EOP_INTR)); + NCR5380_write(START_DMA_SEND_REG, 0); + } + +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_DMA_ENABLE; +#endif + + local_irq_restore(flags); + + sun3_dma_active = 1; + +#else /* !defined(CONFIG_SUN3) */ register unsigned char *d = *data; unsigned char tmp; - unsigned long flags; if ((tmp = (NCR5380_read(STATUS_REG) & PHASE_MASK)) != p) { *phase = tmp; @@ -1893,6 +1972,8 @@ static int NCR5380_transfer_dma(struct Scsi_Host *instance, NCR5380_dma_write_setup(instance, d, c); local_irq_restore(flags); } +#endif /* !defined(CONFIG_SUN3) */ + return 0; } #endif /* defined(REAL_DMA) */ @@ -1928,6 +2009,10 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) unsigned char phase, tmp, extended_msg[10], old_phase = 0xff; struct scsi_cmnd *cmd = (struct scsi_cmnd *) hostdata->connected; +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_INTR; +#endif + while (1) { tmp = NCR5380_read(STATUS_REG); /* We only have a valid SCSI phase when REQ is asserted */ @@ -1937,6 +2022,33 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) old_phase = phase; NCR5380_dprint_phase(NDEBUG_INFORMATION, instance); } +#if defined(CONFIG_SUN3) + if (phase == PHASE_CMDOUT) { +#if defined(REAL_DMA) + void *d; + unsigned long count; + + if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) { + count = cmd->SCp.buffer->length; + d = sg_virt(cmd->SCp.buffer); + } else { + count = cmd->SCp.this_residual; + d = cmd->SCp.ptr; + } + /* this command setup for dma yet? */ + if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != cmd)) { + if (cmd->request->cmd_type == REQ_TYPE_FS) { + sun3scsi_dma_setup(d, count, + rq_data_dir(cmd->request)); + sun3_dma_setup_done = cmd; + } + } +#endif +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_INTR; +#endif + } +#endif /* CONFIG_SUN3 */ if (sink && (phase != PHASE_MSGOUT)) { NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(tmp)); @@ -1998,8 +2110,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) */ #if defined(REAL_DMA) - if (!cmd->device->borken && - (transfersize = NCR5380_dma_xfer_len(instance,cmd,phase)) > 31) { + if ( +#if !defined(CONFIG_SUN3) + !cmd->device->borken && +#endif + (transfersize = NCR5380_dma_xfer_len(instance, cmd, phase)) >= DMA_MIN_SIZE) { len = transfersize; cmd->SCp.phase = phase; if (NCR5380_transfer_dma(instance, &phase, @@ -2036,6 +2151,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) NCR5380_transfer_pio(instance, &phase, (int *)&cmd->SCp.this_residual, (unsigned char **)&cmd->SCp.ptr); +#if defined(CONFIG_SUN3) && defined(REAL_DMA) + /* if we had intended to dma that command clear it */ + if (sun3_dma_setup_done == cmd) + sun3_dma_setup_done = NULL; +#endif break; case PHASE_MSGIN: len = 1; @@ -2241,6 +2361,9 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) /* Wait for bus free to avoid nasty timeouts */ while ((NCR5380_read(STATUS_REG) & SR_BSY) && !hostdata->connected) barrier(); +#ifdef SUN3_SCSI_VME + dregs->csr |= CSR_DMA_ENABLE; +#endif return; /* * The SCSI data pointer is *IMPLICITLY* saved on a disconnect @@ -2400,17 +2523,20 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) */ +/* it might eventually prove necessary to do a dma setup on + reselection, but it doesn't seem to be needed now -- sam */ + static void NCR5380_reselect(struct Scsi_Host *instance) { SETUP_HOSTDATA(instance); unsigned char target_mask; - unsigned char lun, phase; - int len; + unsigned char lun; #ifdef SUPPORT_TAGS unsigned char tag; #endif unsigned char msg[3]; - unsigned char *data; + int __maybe_unused len; + unsigned char __maybe_unused *data, __maybe_unused phase; struct scsi_cmnd *tmp = NULL, *prev; /* @@ -2447,10 +2573,18 @@ static void NCR5380_reselect(struct Scsi_Host *instance) while (!(NCR5380_read(STATUS_REG) & SR_REQ)) ; +#if defined(CONFIG_SUN3) && defined(REAL_DMA) + /* acknowledge toggle to MSGIN */ + NCR5380_write(TARGET_COMMAND_REG, PHASE_SR_TO_TCR(PHASE_MSGIN)); + + /* peek at the byte without really hitting the bus */ + msg[0] = NCR5380_read(CURRENT_SCSI_DATA_REG); +#else len = 1; data = msg; phase = PHASE_MSGIN; NCR5380_transfer_pio(instance, &phase, &len, &data); +#endif if (!(msg[0] & 0x80)) { printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); @@ -2460,7 +2594,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) } lun = (msg[0] & 0x07); -#ifdef SUPPORT_TAGS +#if defined(SUPPORT_TAGS) && !defined(CONFIG_SUN3) /* If the phase is still MSGIN, the target wants to send some more * messages. In case it supports tagged queuing, this is probably a * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus. @@ -2522,9 +2656,51 @@ static void NCR5380_reselect(struct Scsi_Host *instance) return; } +#if defined(CONFIG_SUN3) && defined(REAL_DMA) + /* engage dma setup for the command we just saw */ + { + void *d; + unsigned long count; + + if (!tmp->SCp.this_residual && tmp->SCp.buffers_residual) { + count = tmp->SCp.buffer->length; + d = sg_virt(tmp->SCp.buffer); + } else { + count = tmp->SCp.this_residual; + d = tmp->SCp.ptr; + } + /* setup this command for dma if not already */ + if ((count >= DMA_MIN_SIZE) && (sun3_dma_setup_done != tmp)) { + sun3scsi_dma_setup(d, count, rq_data_dir(tmp->request)); + sun3_dma_setup_done = tmp; + } + } + + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | ICR_ASSERT_ACK); +#endif + /* Accept message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); +#if defined(SUPPORT_TAGS) && defined(CONFIG_SUN3) + /* If the phase is still MSGIN, the target wants to send some more + * messages. In case it supports tagged queuing, this is probably a + * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus. + */ + tag = TAG_NONE; + if (phase == PHASE_MSGIN && setup_use_tagged_queuing) { + /* Accept previous IDENTIFY message by clearing ACK */ + NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); + len = 2; + data = msg + 1; + if (!NCR5380_transfer_pio(instance, &phase, &len, &data) && + msg[1] == SIMPLE_QUEUE_TAG) + tag = msg[2]; + dprintk(NDEBUG_TAGS, "scsi%d: target mask %02x, lun %d sent tag %d at reselection\n" + HOSTNO, target_mask, lun, tag); + } +#endif + hostdata->connected = tmp; dprintk(NDEBUG_RESELECTION, "scsi%d: nexus established, target = %d, lun = %llu, tag = %d\n", HOSTNO, tmp->device->id, tmp->device->lun, tmp->tag); diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index 045112186f84..f0da0c8cbb0d 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -89,6 +89,7 @@ #define REAL_DMA #define SUPPORT_TAGS #define MAX_TAGS 32 +#define DMA_MIN_SIZE 32 #define NCR5380_implementation_fields /* none */ -- cgit v1.2.3 From ca513fc948e66ecdd3c75cca9371762bb4c06776 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:19 +1100 Subject: atari_NCR5380: Introduce FLAG_TAGGED_QUEUING The static variable setup_use_tagged_queuing is declared in mac_scsi.c, sun3_scsi.c and atari_scsi.c and doesn't belong in the core driver. None of the other NCR5380 drivers suffer from this layering issue which makes merging the core drivers more difficult and will likely hinder plans for future use of platform data to configure the driver. Replace the static variable with a host flag. This way it can be reported along with the other flags. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.h | 1 + drivers/scsi/atari_NCR5380.c | 22 +++++++++++++--------- drivers/scsi/atari_scsi.c | 8 ++++---- drivers/scsi/mac_scsi.c | 8 ++++---- drivers/scsi/sun3_scsi.c | 12 ++++++------ 5 files changed, 28 insertions(+), 23 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 7b1a0913d94c..2fafe1d54fb8 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -242,6 +242,7 @@ #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 */ +#define FLAG_TAGGED_QUEUING 64 /* as X3T9.2 spelled it */ #ifndef ASM struct NCR5380_hostdata { diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 7bbfa1b777c3..74b7c538c394 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -283,12 +283,12 @@ typedef struct { static TAG_ALLOC TagAlloc[8][8]; /* 8 targets and 8 LUNs */ -static void __init init_tags(void) +static void __init init_tags(struct NCR5380_hostdata *hostdata) { int target, lun; TAG_ALLOC *ta; - if (!setup_use_tagged_queuing) + if (!(hostdata->flags & FLAG_TAGGED_QUEUING)) return; for (target = 0; target < 8; ++target) { @@ -321,7 +321,8 @@ static int is_lun_busy(struct scsi_cmnd *cmd, int should_be_tagged) if (hostdata->busy[cmd->device->id] & (1 << lun)) return 1; if (!should_be_tagged || - !setup_use_tagged_queuing || !cmd->device->tagged_supported) + !(hostdata->flags & FLAG_TAGGED_QUEUING) || + !cmd->device->tagged_supported) return 0; if (TagAlloc[cmd->device->id][lun].nr_allocated >= TagAlloc[cmd->device->id][lun].queue_size) { @@ -347,7 +348,8 @@ static void cmd_get_tag(struct scsi_cmnd *cmd, int should_be_tagged) * an untagged command. */ if (!should_be_tagged || - !setup_use_tagged_queuing || !cmd->device->tagged_supported) { + !(hostdata->flags & FLAG_TAGGED_QUEUING) || + !cmd->device->tagged_supported) { cmd->tag = TAG_NONE; hostdata->busy[cmd->device->id] |= (1 << lun); dprintk(NDEBUG_TAGS, "scsi%d: target %d lun %d now allocated by untagged " @@ -392,12 +394,12 @@ static void cmd_free_tag(struct scsi_cmnd *cmd) } -static void free_all_tags(void) +static void free_all_tags(struct NCR5380_hostdata *hostdata) { int target, lun; TAG_ALLOC *ta; - if (!setup_use_tagged_queuing) + if (!(hostdata->flags & FLAG_TAGGED_QUEUING)) return; for (target = 0; target < 8; ++target) { @@ -653,11 +655,13 @@ static void prepare_info(struct Scsi_Host *instance) "base 0x%lx, irq %d, " "can_queue %d, cmd_per_lun %d, " "sg_tablesize %d, this_id %d, " + "flags { %s}, " "options { %s} ", instance->hostt->name, instance->io_port, instance->n_io_port, instance->base, instance->irq, instance->can_queue, instance->cmd_per_lun, instance->sg_tablesize, instance->this_id, + hostdata->flags & FLAG_TAGGED_QUEUING ? "TAGGED_QUEUING " : "", #ifdef DIFFERENTIAL "DIFFERENTIAL " #endif @@ -799,7 +803,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) for (i = 0; i < 8; ++i) hostdata->busy[i] = 0; #ifdef SUPPORT_TAGS - init_tags(); + init_tags(hostdata); #endif #if defined (REAL_DMA) hostdata->dma_len = 0; @@ -2565,7 +2569,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) * SIMPLE_QUEUE_TAG for the I_T_L_Q nexus. */ tag = TAG_NONE; - if (phase == PHASE_MSGIN && setup_use_tagged_queuing) { + if (phase == PHASE_MSGIN && (hostdata->flags & FLAG_TAGGED_QUEUING)) { /* Accept previous IDENTIFY message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); len = 2; @@ -3020,7 +3024,7 @@ static int NCR5380_bus_reset(struct scsi_cmnd *cmd) hostdata->connected = NULL; hostdata->disconnected_queue = NULL; #ifdef SUPPORT_TAGS - free_all_tags(); + free_all_tags(hostdata); #endif for (i = 0; i < 8; ++i) hostdata->busy[i] = 0; diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index f0da0c8cbb0d..b69010604699 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -890,10 +890,6 @@ static int __init atari_scsi_probe(struct platform_device *pdev) } } -#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 @@ -929,6 +925,10 @@ static int __init atari_scsi_probe(struct platform_device *pdev) host_flags |= IS_A_TT() ? 0 : FLAG_LATE_DMA_SETUP; +#ifdef SUPPORT_TAGS + host_flags |= setup_use_tagged_queuing > 0 ? FLAG_TAGGED_QUEUING : 0; +#endif + NCR5380_init(instance, host_flags); if (IS_A_TT()) { diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c index 030f3b0bb53b..953fd9b953c7 100644 --- a/drivers/scsi/mac_scsi.c +++ b/drivers/scsi/mac_scsi.c @@ -411,10 +411,6 @@ static int __init mac_scsi_probe(struct platform_device *pdev) 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; @@ -440,6 +436,10 @@ static int __init mac_scsi_probe(struct platform_device *pdev) mac_scsi_reset_boot(instance); #endif +#ifdef SUPPORT_TAGS + host_flags |= setup_use_tagged_queuing > 0 ? FLAG_TAGGED_QUEUING : 0; +#endif + NCR5380_init(instance, host_flags); if (instance->irq != NO_IRQ) { diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c index 985a6b36756e..a98c7325f2dd 100644 --- a/drivers/scsi/sun3_scsi.c +++ b/drivers/scsi/sun3_scsi.c @@ -522,6 +522,7 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) int error; struct resource *irq, *mem; unsigned char *ioaddr; + int host_flags = 0; #ifdef SUN3_SCSI_VME int i; #endif @@ -535,11 +536,6 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) if (setup_hostid >= 0) sun3_scsi_template.this_id = setup_hostid & 7; -#ifdef SUPPORT_TAGS - if (setup_use_tagged_queuing < 0) - setup_use_tagged_queuing = 1; -#endif - #ifdef SUN3_SCSI_VME ioaddr = NULL; for (i = 0; i < 2; i++) { @@ -601,7 +597,11 @@ static int __init sun3_scsi_probe(struct platform_device *pdev) instance->io_port = (unsigned long)ioaddr; instance->irq = irq->start; - NCR5380_init(instance, 0); +#ifdef SUPPORT_TAGS + host_flags |= setup_use_tagged_queuing > 0 ? FLAG_TAGGED_QUEUING : 0; +#endif + + NCR5380_init(instance, host_flags); error = request_irq(instance->irq, scsi_sun3_intr, 0, "NCR5380", instance); -- cgit v1.2.3 From a53a21e4662fd2ed27863f511715898459312393 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Wed, 12 Nov 2014 16:12:21 +1100 Subject: atari_NCR5380: Move static co-routine variables to host data Unlike NCR5380.c, the atari_NCR5380.c core driver is limited to a single instance because co-routine state is stored globally. Fix this by removing the static scsi host pointer. For the co-routine, obtain this pointer from the work_struct pointer instead. For the interrupt handler, obtain it from the dev_id argument. Signed-off-by: Finn Thain Reviewed-by: Hannes Reinecke Tested-by: Michael Schmitz Signed-off-by: Christoph Hellwig --- drivers/scsi/NCR5380.h | 2 ++ drivers/scsi/atari_NCR5380.c | 61 ++++++++++++++++---------------------------- drivers/scsi/atari_scsi.c | 8 +++--- 3 files changed, 28 insertions(+), 43 deletions(-) (limited to 'drivers/scsi/atari_scsi.c') diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index a6946f2d1dc0..162112dd1bf8 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -283,6 +283,8 @@ struct NCR5380_hostdata { int read_overruns; /* number of bytes to cut from a * transfer to handle chip overruns */ int retain_dma_intr; + struct work_struct main_task; + volatile int main_running; #ifdef SUPPORT_TAGS struct tag_alloc TagAlloc[8][8]; /* 8 targets and 8 LUNs */ #endif diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c index 590035f194e3..f1f9f4794527 100644 --- a/drivers/scsi/atari_NCR5380.c +++ b/drivers/scsi/atari_NCR5380.c @@ -221,9 +221,6 @@ * possible) function may be used. */ -static struct Scsi_Host *first_instance = NULL; -static struct scsi_host_template *the_template = NULL; - /* Macros ease life... :-) */ #define SETUP_HOSTDATA(in) \ struct NCR5380_hostdata *hostdata = \ @@ -595,32 +592,19 @@ static void NCR5380_print_phase(struct Scsi_Host *instance) #include #include -static volatile int main_running; -static DECLARE_WORK(NCR5380_tqueue, NCR5380_main); - -static inline void queue_main(void) +static inline void queue_main(struct NCR5380_hostdata *hostdata) { - if (!main_running) { + if (!hostdata->main_running) { /* If in interrupt and NCR5380_main() not already running, queue it on the 'immediate' task queue, to be processed immediately after the current interrupt processing has finished. */ - schedule_work(&NCR5380_tqueue); + schedule_work(&hostdata->main_task); } /* else: nothing to do: the running NCR5380_main() will pick up any newly queued command. */ } - -static inline void NCR5380_all_init(void) -{ - static int done = 0; - if (!done) { - dprintk(NDEBUG_INIT, "scsi : NCR5380_all_init()\n"); - done = 1; - } -} - /** * NCR58380_info - report driver and host information * @instance: relevant scsi host instance @@ -703,7 +687,7 @@ static void NCR5380_print_status(struct Scsi_Host *instance) local_irq_save(flags); printk("NCR5380: coroutine is%s running.\n", - main_running ? "" : "n't"); + hostdata->main_running ? "" : "n't"); if (!hostdata->connected) printk("scsi%d: no currently connected command\n", HOSTNO); else @@ -746,7 +730,7 @@ static int __maybe_unused NCR5380_show_info(struct seq_file *m, local_irq_save(flags); seq_printf(m, "NCR5380: coroutine is%s running.\n", - main_running ? "" : "n't"); + hostdata->main_running ? "" : "n't"); if (!hostdata->connected) seq_printf(m, "scsi%d: no currently connected command\n", HOSTNO); else @@ -783,8 +767,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) int i; SETUP_HOSTDATA(instance); - NCR5380_all_init(); - + hostdata->host = instance; hostdata->aborted = 0; hostdata->id_mask = 1 << instance->this_id; hostdata->id_higher_mask = 0; @@ -805,10 +788,7 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) hostdata->disconnected_queue = NULL; hostdata->flags = flags; - if (!the_template) { - the_template = instance->hostt; - first_instance = instance; - } + INIT_WORK(&hostdata->main_task, NCR5380_main); prepare_info(instance); @@ -829,7 +809,9 @@ static int __init NCR5380_init(struct Scsi_Host *instance, int flags) static void NCR5380_exit(struct Scsi_Host *instance) { - cancel_work_sync(&NCR5380_tqueue); + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + cancel_work_sync(&hostdata->main_task); } /** @@ -924,9 +906,9 @@ static int NCR5380_queue_command(struct Scsi_Host *instance, * unconditionally, because it cannot be already running. */ if (in_interrupt() || irqs_disabled()) - queue_main(); + queue_main(hostdata); else - NCR5380_main(NULL); + NCR5380_main(&hostdata->main_task); return 0; } @@ -955,9 +937,10 @@ static inline void maybe_release_dma_irq(struct Scsi_Host *instance) static void NCR5380_main(struct work_struct *work) { + struct NCR5380_hostdata *hostdata = + container_of(work, struct NCR5380_hostdata, main_task); + struct Scsi_Host *instance = hostdata->host; struct scsi_cmnd *tmp, *prev; - struct Scsi_Host *instance = first_instance; - struct NCR5380_hostdata *hostdata = HOSTDATA(instance); int done; unsigned long flags; @@ -982,9 +965,9 @@ static void NCR5380_main(struct work_struct *work) 'main_running' is set here, and queues/executes main via the task queue, it doesn't do any harm, just this instance of main won't find any work left to do. */ - if (main_running) + if (hostdata->main_running) return; - main_running = 1; + hostdata->main_running = 1; local_save_flags(flags); do { @@ -1103,7 +1086,7 @@ static void NCR5380_main(struct work_struct *work) /* Better allow ints _after_ 'main_running' has been cleared, else an interrupt could believe we'll pick up the work it left for us, but we won't see it anymore here... */ - main_running = 0; + hostdata->main_running = 0; local_irq_restore(flags); } @@ -1215,7 +1198,7 @@ static void NCR5380_dma_complete(struct Scsi_Host *instance) static irqreturn_t NCR5380_intr(int irq, void *dev_id) { - struct Scsi_Host *instance = first_instance; + struct Scsi_Host *instance = dev_id; int done = 1, handled = 0; unsigned char basr; @@ -1287,7 +1270,7 @@ static irqreturn_t NCR5380_intr(int irq, void *dev_id) if (!done) { dprintk(NDEBUG_INTR, "scsi%d: in int routine, calling main\n", HOSTNO); /* Put a call to NCR5380_main() on the queue... */ - queue_main(); + queue_main(shost_priv(instance)); } return IRQ_RETVAL(handled); } @@ -1767,7 +1750,7 @@ static int NCR5380_transfer_pio(struct Scsi_Host *instance, * Returns : 0 on success, -1 on failure. */ -static int do_abort(struct Scsi_Host *host) +static int do_abort(struct Scsi_Host *instance) { unsigned char tmp, *msgptr, phase; int len; @@ -1802,7 +1785,7 @@ static int do_abort(struct Scsi_Host *host) msgptr = &tmp; len = 1; phase = PHASE_MSGOUT; - NCR5380_transfer_pio(host, &phase, &len, &msgptr); + NCR5380_transfer_pio(instance, &phase, &len, &msgptr); /* * If we got here, and the command completed successfully, diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c index b69010604699..d1c37a386947 100644 --- a/drivers/scsi/atari_scsi.c +++ b/drivers/scsi/atari_scsi.c @@ -110,7 +110,7 @@ #define NCR5380_dma_xfer_len(instance, cmd, phase) \ atari_dma_xfer_len(cmd->SCp.this_residual, cmd, !((phase) & SR_IO)) -#define NCR5380_acquire_dma_irq(instance) falcon_get_lock() +#define NCR5380_acquire_dma_irq(instance) falcon_get_lock(instance) #define NCR5380_release_dma_irq(instance) falcon_release_lock() #include "NCR5380.h" @@ -468,15 +468,15 @@ static void falcon_release_lock(void) * command immediately but tell the SCSI mid-layer to defer. */ -static int falcon_get_lock(void) +static int falcon_get_lock(struct Scsi_Host *instance) { if (IS_A_TT()) return 1; if (in_interrupt()) - return stdma_try_lock(scsi_falcon_intr, NULL); + return stdma_try_lock(scsi_falcon_intr, instance); - stdma_lock(scsi_falcon_intr, NULL); + stdma_lock(scsi_falcon_intr, instance); return 1; } -- cgit v1.2.3