[PATCH] drivers: scsi: megaraid: Add megaraid_sas_internal.h for internal shared functions using
For shared inline functions acrossed source files, better to let it as static inline in a header file. For extern functions, better to declare them in header file. For the latest upstream gcc/binutiles (gcc 5 with ld 2.25.51), it will cause building break (although it might be the gcc's or ld's issue), the related error (with allmodconfig under tile): MODPOST 4002 modules ERROR: megasas_return_cmd [drivers/scsi/megaraid/megaraid_sas.ko] undefined! ERROR: megasas_is_ldio [drivers/scsi/megaraid/megaraid_sas.ko] undefined! Signed-off-by: Chen Gang gang.chen.5...@gmail.com --- drivers/scsi/megaraid/megaraid_sas_base.c | 65 + drivers/scsi/megaraid/megaraid_sas_fusion.c | 38 +- drivers/scsi/megaraid/megaraid_sas_internal.h | 100 ++ 3 files changed, 102 insertions(+), 101 deletions(-) create mode 100644 drivers/scsi/megaraid/megaraid_sas_internal.h diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index f6a69a3..4a71c04 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -57,6 +57,7 @@ #include scsi/scsi_tcq.h #include megaraid_sas_fusion.h #include megaraid_sas.h +#include megaraid_sas_internal.h /* * Number of sectors per IO command @@ -98,7 +99,6 @@ MODULE_VERSION(MEGASAS_VERSION); MODULE_AUTHOR(megaraidli...@lsi.com); MODULE_DESCRIPTION(LSI MegaRAID SAS Driver); -int megasas_transition_to_ready(struct megasas_instance *instance, int ocr); static int megasas_get_pd_list(struct megasas_instance *instance); static int megasas_ld_list_query(struct megasas_instance *instance, u8 query_type); @@ -155,9 +155,6 @@ static u32 support_device_change; /* define lock for aen poll */ spinlock_t poll_aen_lock; -void -megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, -u8 alt_status); static u32 megasas_read_fw_status_reg_gen2(struct megasas_register_set __iomem *regs); static int @@ -170,26 +167,8 @@ u32 megasas_build_and_issue_cmd(struct megasas_instance *instance, struct scsi_cmnd *scmd); static void megasas_complete_cmd_dpc(unsigned long instance_addr); -void -megasas_release_fusion(struct megasas_instance *instance); -int -megasas_ioc_init_fusion(struct megasas_instance *instance); -void -megasas_free_cmds_fusion(struct megasas_instance *instance); -u8 -megasas_get_map_info(struct megasas_instance *instance); -int -megasas_sync_map_info(struct megasas_instance *instance); -int -wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, - int seconds); -void megasas_reset_reply_desc(struct megasas_instance *instance); -int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout); -void megasas_fusion_ocr_wq(struct work_struct *work); static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, int initial); -int megasas_check_mpio_paths(struct megasas_instance *instance, -struct scsi_cmnd *scmd); void megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd) @@ -258,22 +237,6 @@ __megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) } /** - * megasas_return_cmd -Return a cmd to free command pool - * @instance: Adapter soft state - * @cmd: Command packet to be returned to free command pool - */ -inline void -megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) -{ - unsigned long flags; - - spin_lock_irqsave(instance-mfi_pool_lock, flags); - __megasas_return_cmd(instance, cmd); - spin_unlock_irqrestore(instance-mfi_pool_lock, flags); -} - - -/** * The following functions are defined for xscale * (deviceid : 1064R, PERC5) controllers */ @@ -1417,32 +1380,6 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, return cmd-frame_count; } -/** - * megasas_is_ldio - Checks if the cmd is for logical drive - * @scmd: SCSI command - * - * Called by megasas_queue_command to find out if the command to be queued - * is a logical drive command - */ -inline int megasas_is_ldio(struct scsi_cmnd *cmd) -{ - if (!MEGASAS_IS_LOGICAL(cmd)) - return 0; - switch (cmd-cmnd[0]) { - case READ_10: - case WRITE_10: - case READ_12: - case WRITE_12: - case READ_6: - case WRITE_6: - case READ_16: - case WRITE_16: - return 1; - default: - return 0; - } -} - /** * megasas_dump_pending_frames - Dumps the frame address of all pending cmds * in FW diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index
[PATCH] drivers: scsi: megaraid: Add megaraid_sas_internal.h for internal shared functions using
For shared inline functions crossed source files, better to let it as static inline in a header file. For extern functions, better to declare them in header file. For the latest upstream gcc/binutiles (gcc 5 with ld 2.25.51), it will cause building break (although it might be the gcc's or ld's issue), the related error (with allmodconfig under tile): MODPOST 4002 modules ERROR: megasas_return_cmd [drivers/scsi/megaraid/megaraid_sas.ko] undefined! ERROR: megasas_is_ldio [drivers/scsi/megaraid/megaraid_sas.ko] undefined! Signed-off-by: Chen Gang gang.chen.5...@gmail.com --- drivers/scsi/megaraid/megaraid_sas_base.c | 65 + drivers/scsi/megaraid/megaraid_sas_fusion.c | 38 +- drivers/scsi/megaraid/megaraid_sas_internal.h | 100 ++ 3 files changed, 102 insertions(+), 101 deletions(-) create mode 100644 drivers/scsi/megaraid/megaraid_sas_internal.h diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index f6a69a3..4a71c04 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -57,6 +57,7 @@ #include scsi/scsi_tcq.h #include megaraid_sas_fusion.h #include megaraid_sas.h +#include megaraid_sas_internal.h /* * Number of sectors per IO command @@ -98,7 +99,6 @@ MODULE_VERSION(MEGASAS_VERSION); MODULE_AUTHOR(megaraidli...@lsi.com); MODULE_DESCRIPTION(LSI MegaRAID SAS Driver); -int megasas_transition_to_ready(struct megasas_instance *instance, int ocr); static int megasas_get_pd_list(struct megasas_instance *instance); static int megasas_ld_list_query(struct megasas_instance *instance, u8 query_type); @@ -155,9 +155,6 @@ static u32 support_device_change; /* define lock for aen poll */ spinlock_t poll_aen_lock; -void -megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, -u8 alt_status); static u32 megasas_read_fw_status_reg_gen2(struct megasas_register_set __iomem *regs); static int @@ -170,26 +167,8 @@ u32 megasas_build_and_issue_cmd(struct megasas_instance *instance, struct scsi_cmnd *scmd); static void megasas_complete_cmd_dpc(unsigned long instance_addr); -void -megasas_release_fusion(struct megasas_instance *instance); -int -megasas_ioc_init_fusion(struct megasas_instance *instance); -void -megasas_free_cmds_fusion(struct megasas_instance *instance); -u8 -megasas_get_map_info(struct megasas_instance *instance); -int -megasas_sync_map_info(struct megasas_instance *instance); -int -wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, - int seconds); -void megasas_reset_reply_desc(struct megasas_instance *instance); -int megasas_reset_fusion(struct Scsi_Host *shost, int iotimeout); -void megasas_fusion_ocr_wq(struct work_struct *work); static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, int initial); -int megasas_check_mpio_paths(struct megasas_instance *instance, -struct scsi_cmnd *scmd); void megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd) @@ -258,22 +237,6 @@ __megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) } /** - * megasas_return_cmd -Return a cmd to free command pool - * @instance: Adapter soft state - * @cmd: Command packet to be returned to free command pool - */ -inline void -megasas_return_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd) -{ - unsigned long flags; - - spin_lock_irqsave(instance-mfi_pool_lock, flags); - __megasas_return_cmd(instance, cmd); - spin_unlock_irqrestore(instance-mfi_pool_lock, flags); -} - - -/** * The following functions are defined for xscale * (deviceid : 1064R, PERC5) controllers */ @@ -1417,32 +1380,6 @@ megasas_build_ldio(struct megasas_instance *instance, struct scsi_cmnd *scp, return cmd-frame_count; } -/** - * megasas_is_ldio - Checks if the cmd is for logical drive - * @scmd: SCSI command - * - * Called by megasas_queue_command to find out if the command to be queued - * is a logical drive command - */ -inline int megasas_is_ldio(struct scsi_cmnd *cmd) -{ - if (!MEGASAS_IS_LOGICAL(cmd)) - return 0; - switch (cmd-cmnd[0]) { - case READ_10: - case WRITE_10: - case READ_12: - case WRITE_12: - case READ_6: - case WRITE_6: - case READ_16: - case WRITE_16: - return 1; - default: - return 0; - } -} - /** * megasas_dump_pending_frames - Dumps the frame address of all pending cmds * in FW diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index
Re: [PATCH v2 25/36] sun3_scsi: Convert to platform device
On Mon, Oct 27, 2014 at 6:26 AM, Finn Thain fth...@telegraphics.com.au wrote: --- linux.orig/arch/m68k/sun3/config.c 2014-10-27 16:17:59.0 +1100 +++ linux/arch/m68k/sun3/config.c 2014-10-27 16:25:50.0 +1100 @@ -169,3 +171,61 @@ static void __init sun3_sched_init(irq_h intersil_clear(); } +#ifdef CONFIG_SUN3_SCSI + +static const struct resource sun3_scsi_vme_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI0, + .end = SUN3_VEC_VMESCSI0, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff20, + .end = 0xff20 + PAGE_SIZE - 1, PAGE_SIZE is a software kernel configuration option, not a hardware property. It makes sense to use it in an ioremap() call, but not in a platform device's resource, which describes the hardware. + }, { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI1, + .end = SUN3_VEC_VMESCSI1, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff204000, + .end = 0xff204000 + PAGE_SIZE - 1, Likewise + }, +}; + +/* + * Int: level 2 autovector + * IO: type 1, base 0x0014, 5 bits phys space: A4..0 + */ +static const struct resource sun3_scsi_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = 2, + .end = 2, + }, { + .flags = IORESOURCE_MEM, + .start = 0x0014, + .end = 0x0014 + PAGE_SIZE - 1, Likewise According to the Sun-3 Architecture Manual v2.0 (May 1985), end should be 0x0014001f. I guess the resource length is 0x20 for VME SCSI, too? + }, Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 00/36] Fixes, cleanups and modernization for NCR5380 drivers
Hi Finn, On Fri, Nov 7, 2014 at 3:34 AM, Finn Thain fth...@telegraphics.com.au wrote: it's probably not Geert but James who needs to give the go-ahead. Given Geert's objections to the changes under arch/m68k in v1, I'm hoping for an acked-by from Geert for v2... I'm happy with the arch/m68k changes in v2 (modulo the PAGE_SIZE comment on Sun-3), so please add my Acked-by: Geert Uytterhoeven ge...@linux-m68k.org after fixing that one. As I'm not afraid of merge conflicts, I think this can go in through the SCSI tree? James? Note that there's still room for improvement in the individual drivers, using more modern infrastructure (e.g. using devm_*() calls, and getting rid of the multiple ATARIHW_PRESENT() checks using e.g. platform_data or regmap). But this is already a giant step forward. Thanks a lot for doing this cleanup! Removing ca. 3700 LoC deserves you a spot in the LoC removal Hall of Fame! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 25/36] sun3_scsi: Convert to platform device
On Sun, 9 Nov 2014, Geert Uytterhoeven wrote: On Mon, Oct 27, 2014 at 6:26 AM, Finn Thain fth...@telegraphics.com.au wrote: --- linux.orig/arch/m68k/sun3/config.c 2014-10-27 16:17:59.0 +1100 +++ linux/arch/m68k/sun3/config.c 2014-10-27 16:25:50.0 +1100 @@ -169,3 +171,61 @@ static void __init sun3_sched_init(irq_h intersil_clear(); } +#ifdef CONFIG_SUN3_SCSI + +static const struct resource sun3_scsi_vme_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI0, + .end = SUN3_VEC_VMESCSI0, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff20, + .end = 0xff20 + PAGE_SIZE - 1, PAGE_SIZE is a software kernel configuration option, not a hardware property. It makes sense to use it in an ioremap() call, but not in a platform device's resource, which describes the hardware. + }, { + .flags = IORESOURCE_IRQ, + .start = SUN3_VEC_VMESCSI1, + .end = SUN3_VEC_VMESCSI1, + }, { + .flags = IORESOURCE_MEM, + .start = 0xff204000, + .end = 0xff204000 + PAGE_SIZE - 1, Likewise + }, +}; + +/* + * Int: level 2 autovector + * IO: type 1, base 0x0014, 5 bits phys space: A4..0 + */ +static const struct resource sun3_scsi_rsrc[] __initconst = { + { + .flags = IORESOURCE_IRQ, + .start = 2, + .end = 2, + }, { + .flags = IORESOURCE_MEM, + .start = 0x0014, + .end = 0x0014 + PAGE_SIZE - 1, Likewise According to the Sun-3 Architecture Manual v2.0 (May 1985), end should be 0x0014001f. OK. Where did you find that, BTW? I guess the resource length is 0x20 for VME SCSI, too? For VME SCSI it would need to be 8 + sizeof(struct sun3_dma_regs) which I think equals 0x22: struct sun3_dma_regs { unsigned short dma_addr_hi; /* vme only */ unsigned short dma_addr_lo; /* vme only */ unsigned short dma_count_hi; /* vme only */ unsigned short dma_count_lo; /* vme only */ unsigned short udc_data; /* udc dma data reg (obio only) */ unsigned short udc_addr; /* uda dma addr reg (obio only) */ unsigned short fifo_data; /* fifo data reg, holds extra byte on odd dma reads */ unsigned short fifo_count; unsigned short csr; /* control/status reg */ unsigned short bpack_hi; /* vme only */ unsigned short bpack_lo; /* vme only */ unsigned short ivect; /* vme only */ unsigned short fifo_count_hi; /* vme only */ }; I'll make these changes and re-spin the patch series once Hannes' questions have been resolved. Thanks for reviewing. -- -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 19/36] mac_scsi: Add module option to Kconfig
On Fri, 31 Oct 2014, Hannes Reinecke wrote: On 10/31/2014 08:17 AM, Finn Thain wrote: On Thu, 30 Oct 2014, Hannes Reinecke wrote: On 10/27/2014 06:26 AM, Finn Thain wrote: Allow mac_scsi to be built as a module. Replace the old validation of __setup options with code that validates both module and __setup options. Signed-off-by: Finn Thain fth...@telegraphics.com.au --- drivers/scsi/Kconfig|2 drivers/scsi/mac_scsi.c | 112 +++- 2 files changed, 38 insertions(+), 76 deletions(-) Index: linux/drivers/scsi/Kconfig === --- linux.orig/drivers/scsi/Kconfig 2014-10-27 16:17:59.0 +1100 +++ linux/drivers/scsi/Kconfig2014-10-27 16:25:42.0 +1100 @@ -1595,7 +1595,7 @@ config ATARI_SCSI_RESET_BOOT that leave the devices with SCSI operations partway completed. config MAC_SCSI - bool Macintosh NCR5380 SCSI + tristate Macintosh NCR5380 SCSI depends on MAC SCSI=y select SCSI_SPI_ATTRS help Index: linux/drivers/scsi/mac_scsi.c === --- linux.orig/drivers/scsi/mac_scsi.c2014-10-27 16:25:40.0 +1100 +++ linux/drivers/scsi/mac_scsi.c 2014-10-27 16:25:42.0 +1100 @@ -62,15 +62,18 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance); #endif -static int setup_called = 0; static int setup_can_queue = -1; +module_param(setup_can_queue, int, 0); static int setup_cmd_per_lun = -1; +module_param(setup_cmd_per_lun, int, 0); static int setup_sg_tablesize = -1; +module_param(setup_sg_tablesize, int, 0); static int setup_use_pdma = -1; -#ifdef SUPPORT_TAGS +module_param(setup_use_pdma, int, 0); static int setup_use_tagged_queuing = -1; -#endif +module_param(setup_use_tagged_queuing, int, 0); static int setup_hostid = -1; +module_param(setup_hostid, int, 0); /* Time (in jiffies) to wait after a reset; the SCSI standard calls for 250ms, * we usually do 0.5s to be on the safe side. But Toshiba CD-ROMs once more @@ -102,72 +105,34 @@ static __inline__ void macscsi_write(str out_8(instance-io_port + (reg4), value); } -/* - * Function : mac_scsi_setup(char *str) - * - * Purpose : booter command line initialization of the overrides array, - * - * Inputs : str - comma delimited list of options - * - */ - -static int __init mac_scsi_setup(char *str) { +#ifndef MODULE +static int __init mac_scsi_setup(char *str) +{ int ints[7]; - - (void)get_options( str, ARRAY_SIZE(ints), ints); - - if (setup_called++ || ints[0] 1 || ints[0] 6) { - printk(KERN_WARNING scsi: mac5380 - Usage: mac5380=can_queue[,cmd_per_lun,sg_tablesize,hostid,use_tags,use_pdma]\n); - printk(KERN_ALERT scsi: mac5380 Bad Penguin parameters?\n); - return 0; - } - - if (ints[0] = 1) { - if (ints[1] 0) - /* no limits on this, just 0 */ - setup_can_queue = ints[1]; - } - if (ints[0] = 2) { - if (ints[2] 0) - setup_cmd_per_lun = ints[2]; - } - if (ints[0] = 3) { - if (ints[3] = 0) { - setup_sg_tablesize = ints[3]; - /* Must be = SG_ALL (255) */ - if (setup_sg_tablesize SG_ALL) - setup_sg_tablesize = SG_ALL; - } - } - if (ints[0] = 4) { - /* Must be between 0 and 7 */ - if (ints[4] = 0 ints[4] = 7) - setup_hostid = ints[4]; - else if (ints[4] 7) - printk(KERN_WARNING mac_scsi_setup: invalid host ID %d !\n, ints[4] ); - } -#ifdef SUPPORT_TAGS - if (ints[0] = 5) { - if (ints[5] = 0) - setup_use_tagged_queuing = !!ints[5]; + + (void)get_options(str, ARRAY_SIZE(ints), ints); + + if (ints[0] 1 || ints[0] 6) { + pr_err(Usage: mac5380=can_queue[,cmd_per_lun[,sg_tablesize[,hostid[,use_tags[,use_pdma]\n); + return 0; } - - if (ints[0] == 6) { - if (ints[6] = 0) + if (ints[0] = 1) + setup_can_queue = ints[1]; + if (ints[0] = 2) + setup_cmd_per_lun = ints[2]; + if (ints[0] = 3) + setup_sg_tablesize = ints[3]; + if (ints[0] = 4) + setup_hostid = ints[4]; + if (ints[0] = 5) + setup_use_tagged_queuing = ints[5]; + if (ints[0] = 6) setup_use_pdma = ints[6]; - } -#else - if (ints[0] == 5) { - if (ints[5] = 0) - setup_use_pdma = ints[5]; - } -#endif /* SUPPORT_TAGS */ - return 1; } __setup(mac5380=, mac_scsi_setup); +#endif /* !MODULE */ /* * Function : int macscsi_detect(struct scsi_host_template * tpnt) @@ -199,13 +164,8 @@ int __init
Re: [PATCH v2 25/36] sun3_scsi: Convert to platform device
On Sun, Nov 9, 2014 at 1:12 PM, Finn Thain fth...@telegraphics.com.au wrote: According to the Sun-3 Architecture Manual v2.0 (May 1985), end should be 0x0014001f. OK. Where did you find that, BTW? In my local collection of hardware docs I downloaded eons ago ;-) Fortunately it hasn't disappeared from the Internet, unlike many others docs I've collected over the years: https://www.google.be/search?q=Sun-3_Architecture_Manual_Ver_2.0_May85.pdf I guess the resource length is 0x20 for VME SCSI, too? For VME SCSI it would need to be 8 + sizeof(struct sun3_dma_regs) which I think equals 0x22: IC. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say programmer or something like that. -- Linus Torvalds -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 29/36] atari_NCR5380: Refactor Falcon locking
Ping... On Fri, 31 Oct 2014, Finn Thain wrote: On Thu, 30 Oct 2014, Hannes Reinecke wrote: On 10/27/2014 06:26 AM, Finn Thain wrote: Simplify falcon_release_lock_if_possible() by making callers responsible for disabling local IRQ's, which they must do anyway to correctly synchronize the ST DMA lock with core driver data structures. Move this synchronization logic to the core driver with which it is tightly coupled. Other LLD's like sun3_scsi and mac_scsi that can make use of this core driver can just stub out the NCR5380_acquire_dma_irq() and NCR5380_release_dma_irq() calls so the compiler will eliminate the ST DMA code. Remove a redundant local_irq_save/restore pair (irq's are disabled for interrupt handlers these days). Revise the locking for atari_scsi_bus_reset(): use local_irq_save/restore() instead of atari_turnoff/turnon_irq(). There is no guarantee that atari_scsi still holds the ST DMA lock during EH, so atari_turnoff/turnon_irq() could end up dropping an IDE or floppy interrupt. Signed-off-by: Finn Thain fth...@telegraphics.com.au --- drivers/scsi/atari_NCR5380.c | 72 ++- drivers/scsi/atari_scsi.c| 47 ++-- 2 files changed, 62 insertions(+), 57 deletions(-) Index: linux/drivers/scsi/atari_NCR5380.c === --- linux.orig/drivers/scsi/atari_NCR5380.c 2014-10-27 16:25:54.0 +1100 +++ linux/drivers/scsi/atari_NCR5380.c2014-10-27 16:25:55.0 +1100 @@ -926,7 +926,7 @@ static int NCR5380_queue_command(struct * alter queues and touch the lock. */ /* perhaps stop command timer here */ - if (!falcon_get_lock()) + if (!NCR5380_acquire_dma_irq(instance)) return SCSI_MLQUEUE_HOST_BUSY; /* perhaps restart command timer here */ @@ -962,6 +962,18 @@ static int NCR5380_queue_command(struct return 0; } +static inline void maybe_release_dma_irq(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + /* Caller does the locking needed to set test these data atomically */ + if (!hostdata-disconnected_queue + !hostdata-issue_queue + !hostdata-connected + !hostdata-retain_dma_intr) + NCR5380_release_dma_irq(instance); +} + /* * Function : NCR5380_main (void) * @@ -1084,9 +1096,11 @@ static void NCR5380_main(struct work_str cmd_get_tag(tmp, tmp-cmnd[0] != REQUEST_SENSE); #endif if (!NCR5380_select(instance, tmp)) { + local_irq_disable(); hostdata-retain_dma_intr--; /* release if target did not response! */ - falcon_release_lock_if_possible(hostdata); + maybe_release_dma_irq(instance); + local_irq_restore(flags); break; } else { local_irq_disable(); @@ -2085,11 +2099,12 @@ static void NCR5380_information_transfer case COMMAND_COMPLETE: /* Accept message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - /* ++guenther: possible race with Falcon locking */ - hostdata-retain_dma_intr++; - hostdata-connected = NULL; dprintk(NDEBUG_QUEUES, scsi%d: command for target %d, lun %llu completed\n, HOSTNO, cmd-device-id, cmd-device-lun); + + local_irq_save(flags); + hostdata-retain_dma_intr++; + hostdata-connected = NULL; #ifdef SUPPORT_TAGS cmd_free_tag(cmd); if (status_byte(cmd-SCp.Status) == QUEUE_FULL) { @@ -2148,17 +2163,17 @@ static void NCR5380_information_transfer dprintk(NDEBUG_AUTOSENSE, scsi%d: performing request sense\n, HOSTNO); - local_irq_save(flags); LIST(cmd,hostdata-issue_queue); SET_NEXT(cmd, hostdata-issue_queue); hostdata-issue_queue =
Re: [PATCH v2 06/36] ncr5380: Remove more useless prototypes
Ping... On Wed, 29 Oct 2014, Hannes Reinecke wrote: On 10/27/2014 06:26 AM, Finn Thain wrote: Make use of the host template static initializer instead of assigning handlers at run-time. Move __maybe_unused qualifiers from declarations to definitions. Move the atari_scsi_bus_reset() wrapper after the definition of NCR5380_bus_reset(). All of the host template handler prototypes are now redundant so remove them. The write_info() handler is only relevant to drivers using PSEUDO_DMA so this patch fixes the compiler warning in atari_NCR5380.c and sun3_NCR5380.c: CC drivers/scsi/atari_scsi.o drivers/scsi/NCR5380.h:329: warning: 'NCR5380_write_info' declared 'static' but never defined Signed-off-by: Finn Thain fth...@telegraphics.com.au --- drivers/scsi/NCR5380.h |8 drivers/scsi/atari_NCR5380.c |3 + drivers/scsi/atari_scsi.c| 76 --- drivers/scsi/dtc.c |7 +-- drivers/scsi/pas16.c |7 +-- drivers/scsi/sun3_NCR5380.c |3 + drivers/scsi/t128.c |7 +-- 7 files changed, 50 insertions(+), 61 deletions(-) Index: linux/drivers/scsi/NCR5380.h === --- linux.orig/drivers/scsi/NCR5380.h 2014-10-27 16:25:06.0 +1100 +++ linux/drivers/scsi/NCR5380.h2014-10-27 16:25:14.0 +1100 @@ -322,14 +322,6 @@ static irqreturn_t NCR5380_intr(int irq, #endif static void NCR5380_main(struct work_struct *work); static void __maybe_unused NCR5380_print_options(struct Scsi_Host *instance); -static int NCR5380_abort(Scsi_Cmnd * cmd); -static int NCR5380_bus_reset(Scsi_Cmnd * cmd); -static int NCR5380_queue_command(struct Scsi_Host *, struct scsi_cmnd *); -static int __maybe_unused NCR5380_show_info(struct seq_file *, - struct Scsi_Host *); -static int __maybe_unused NCR5380_write_info(struct Scsi_Host *instance, - char *buffer, int length); - static void NCR5380_reselect(struct Scsi_Host *instance); static int NCR5380_select(struct Scsi_Host *instance, Scsi_Cmnd * cmd, int tag); #if defined(PSEUDO_DMA) || defined(REAL_DMA) || defined(REAL_DMA_POLL) Index: linux/drivers/scsi/dtc.c === --- linux.orig/drivers/scsi/dtc.c 2014-10-27 16:25:08.0 +1100 +++ linux/drivers/scsi/dtc.c2014-10-27 16:25:14.0 +1100 @@ -219,10 +219,6 @@ static int __init dtc_detect(struct scsi void __iomem *base; int sig, count; - tpnt-proc_name = dtc3x80; - tpnt-show_info = dtc_show_info; - tpnt-write_info = dtc_write_info; - for (count = 0; current_override NO_OVERRIDES; ++current_override) { addr = 0; base = NULL; @@ -477,6 +473,9 @@ static struct scsi_host_template driver_ .name = DTC 3180/3280 , .detect = dtc_detect, .release= dtc_release, + .proc_name = dtc3x80, + .show_info = dtc_show_info, + .write_info = dtc_write_info, .queuecommand = dtc_queue_command, .eh_abort_handler = dtc_abort, .eh_bus_reset_handler = dtc_bus_reset, What is the current consensus on using '.proc_name' ? At one point is was claimed to be deprecated, yet the only driver actually following this seems to be lpfc. (_And_ we have a patch in our tree to hook that back in). Can't we just get it back for the time being and decide upon a proper solution later? Cheers, Hannes -- -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] scsi: introduce force_blk_mq
From scsi driver view, it is a bit troublesome to support both blk-mq and non-blk-mq at the same time, especially when drivers start to support multi hw-queue. This patch introduces 'force_blk_mq' to scsi_host_template so that drivers can provide blk-mq only support, and avoid to consider legacy support. Signed-off-by: Ming Lei ming@canonical.com --- drivers/scsi/hosts.c |3 ++- include/scsi/scsi_host.h |3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index 06030e1..d2b83f8 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -459,7 +459,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) else shost-dma_boundary = 0x; - shost-use_blk_mq = scsi_use_blk_mq !shost-hostt-disable_blk_mq; + shost-use_blk_mq = (scsi_use_blk_mq !shost-hostt-disable_blk_mq) + || shost-hostt-force_blk_mq; device_initialize(shost-shost_gendev); dev_set_name(shost-shost_gendev, host%d, shost-host_no); diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 537c431..75c1468 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -514,6 +514,9 @@ struct scsi_host_template { /* temporary flag to disable blk-mq I/O path */ bool disable_blk_mq; + + /* tell scsi core we only support blk-mq */ + bool force_blk_mq; }; /* -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] virtio_scsi: support multi hw queue of blk-mq
Since virtio_scsi has supported multi virtqueue already, it is natural to map virtque to hw-queue of blk-mq. Cc: Paolo Bonzini pbonz...@redhat.com Signed-off-by: Ming Lei ming@canonical.com --- drivers/scsi/virtio_scsi.c | 154 1 file changed, 14 insertions(+), 140 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index b83846f..719adb2 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -65,36 +65,6 @@ struct virtio_scsi_vq { struct virtqueue *vq; }; -/* - * Per-target queue state. - * - * This struct holds the data needed by the queue steering policy. When a - * target is sent multiple requests, we need to drive them to the same queue so - * that FIFO processing order is kept. However, if a target was idle, we can - * choose a queue arbitrarily. In this case the queue is chosen according to - * the current VCPU, so the driver expects the number of request queues to be - * equal to the number of VCPUs. This makes it easy and fast to select the - * queue, and also lets the driver optimize the IRQ affinity for the virtqueues - * (each virtqueue's affinity is set to the CPU that owns the queue). - * - * tgt_seq is held to serialize reading and writing req_vq. - * - * Decrements of reqs are never concurrent with writes of req_vq: before the - * decrement reqs will be != 0; after the decrement the virtqueue completion - * routine will not use the req_vq so it can be changed by a new request. - * Thus they can happen outside the tgt_seq, provided of course we make reqs - * an atomic_t. - */ -struct virtio_scsi_target_state { - seqcount_t tgt_seq; - - /* Count of outstanding requests. */ - atomic_t reqs; - - /* Currently active virtqueue for requests sent to this target. */ - struct virtio_scsi_vq *req_vq; -}; - /* Driver instance state */ struct virtio_scsi { struct virtio_device *vdev; @@ -150,8 +120,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) struct virtio_scsi_cmd *cmd = buf; struct scsi_cmnd *sc = cmd-sc; struct virtio_scsi_cmd_resp *resp = cmd-resp.cmd; - struct virtio_scsi_target_state *tgt = - scsi_target(sc-device)-hostdata; dev_dbg(sc-device-sdev_gendev, cmd %p response %u status %#02x sense_len %u\n, @@ -205,8 +173,6 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) } sc-scsi_done(sc); - - atomic_dec(tgt-reqs); } static void virtscsi_vq_done(struct virtio_scsi *vscsi, @@ -514,9 +480,9 @@ static void virtio_scsi_init_hdr_pi(struct virtio_scsi_cmd_req_pi *cmd_pi, cmd_pi-pi_bytesin = blk_rq_sectors(rq) * bi-tuple_size; } -static int virtscsi_queuecommand(struct virtio_scsi *vscsi, -struct virtio_scsi_vq *req_vq, -struct scsi_cmnd *sc) +static int __virtscsi_queuecommand(struct virtio_scsi *vscsi, + struct virtio_scsi_vq *req_vq, + struct scsi_cmnd *sc) { struct Scsi_Host *shost = virtio_scsi_host(vscsi-vdev); struct virtio_scsi_cmd *cmd = scsi_cmd_priv(sc); @@ -550,63 +516,15 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi, return 0; } -static int virtscsi_queuecommand_single(struct Scsi_Host *sh, - struct scsi_cmnd *sc) -{ - struct virtio_scsi *vscsi = shost_priv(sh); - struct virtio_scsi_target_state *tgt = - scsi_target(sc-device)-hostdata; - - atomic_inc(tgt-reqs); - return virtscsi_queuecommand(vscsi, vscsi-req_vqs[0], sc); -} - -static struct virtio_scsi_vq *virtscsi_pick_vq(struct virtio_scsi *vscsi, - struct virtio_scsi_target_state *tgt) -{ - struct virtio_scsi_vq *vq; - unsigned long flags; - u32 queue_num; - - local_irq_save(flags); - if (atomic_inc_return(tgt-reqs) 1) { - unsigned long seq; - - do { - seq = read_seqcount_begin(tgt-tgt_seq); - vq = tgt-req_vq; - } while (read_seqcount_retry(tgt-tgt_seq, seq)); - } else { - /* no writes can be concurrent because of atomic_t */ - write_seqcount_begin(tgt-tgt_seq); - - /* keep previous req_vq if a reader just arrived */ - if (unlikely(atomic_read(tgt-reqs) 1)) { - vq = tgt-req_vq; - goto unlock; - } - - queue_num = smp_processor_id(); - while (unlikely(queue_num = vscsi-num_queues)) - queue_num -= vscsi-num_queues; - tgt-req_vq = vq = vscsi-req_vqs[queue_num]; - unlock: -
[PATCH 0/2] virtio_scsi: support multi hw queue of blk-mq
Hi, The 1st patch introduces 'force_blk_mq' so that one driver can claim that it only supports blk-mq. The 2nd patch implements multi hw queue support for virtio_scsi, since it is very natural to map virtqueue to hw queue of blk-mq. Thanks, Ming Lei -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] st: call scsi_set_medium_removal directly
On 7.11.2014, at 1.54, Elliott, Robert (Server Storage) elli...@hp.com wrote: ... 3. Reviewing the callers, st_release has an initialized result variable but does nothing else with it but return it: int result = 0; ... return result; It ignores the do_door_lock - scsi_set_medium_removal result (like many others). The return code for automatic door locking/unlocking has been ignored on purpose. It is returned to caller for explicit door locking/unlocking. One can, of course, revise this decision. The return value of release() is ignored by VFS. The proper fix would probably be to define release() void. Thanks, Kai -- To unsubscribe from this list: send the line unsubscribe linux-scsi in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 19/36] mac_scsi: Add module option to Kconfig
On 11/09/2014 01:17 PM, Finn Thain wrote: On Fri, 31 Oct 2014, Hannes Reinecke wrote: On 10/31/2014 08:17 AM, Finn Thain wrote: On Thu, 30 Oct 2014, Hannes Reinecke wrote: On 10/27/2014 06:26 AM, Finn Thain wrote: Allow mac_scsi to be built as a module. Replace the old validation of __setup options with code that validates both module and __setup options. Signed-off-by: Finn Thain fth...@telegraphics.com.au --- drivers/scsi/Kconfig|2 drivers/scsi/mac_scsi.c | 112 +++- 2 files changed, 38 insertions(+), 76 deletions(-) Index: linux/drivers/scsi/Kconfig === --- linux.orig/drivers/scsi/Kconfig 2014-10-27 16:17:59.0 +1100 +++ linux/drivers/scsi/Kconfig2014-10-27 16:25:42.0 +1100 @@ -1595,7 +1595,7 @@ config ATARI_SCSI_RESET_BOOT that leave the devices with SCSI operations partway completed. config MAC_SCSI - bool Macintosh NCR5380 SCSI + tristate Macintosh NCR5380 SCSI depends on MAC SCSI=y select SCSI_SPI_ATTRS help Index: linux/drivers/scsi/mac_scsi.c === --- linux.orig/drivers/scsi/mac_scsi.c2014-10-27 16:25:40.0 +1100 +++ linux/drivers/scsi/mac_scsi.c 2014-10-27 16:25:42.0 +1100 @@ -62,15 +62,18 @@ static void mac_scsi_reset_boot(struct Scsi_Host *instance); #endif -static int setup_called = 0; static int setup_can_queue = -1; +module_param(setup_can_queue, int, 0); static int setup_cmd_per_lun = -1; +module_param(setup_cmd_per_lun, int, 0); static int setup_sg_tablesize = -1; +module_param(setup_sg_tablesize, int, 0); static int setup_use_pdma = -1; -#ifdef SUPPORT_TAGS +module_param(setup_use_pdma, int, 0); static int setup_use_tagged_queuing = -1; -#endif +module_param(setup_use_tagged_queuing, int, 0); static int setup_hostid = -1; +module_param(setup_hostid, int, 0); /* Time (in jiffies) to wait after a reset; the SCSI standard calls for 250ms, * we usually do 0.5s to be on the safe side. But Toshiba CD-ROMs once more @@ -102,72 +105,34 @@ static __inline__ void macscsi_write(str out_8(instance-io_port + (reg4), value); } -/* - * Function : mac_scsi_setup(char *str) - * - * Purpose : booter command line initialization of the overrides array, - * - * Inputs : str - comma delimited list of options - * - */ - -static int __init mac_scsi_setup(char *str) { +#ifndef MODULE +static int __init mac_scsi_setup(char *str) +{ int ints[7]; - - (void)get_options( str, ARRAY_SIZE(ints), ints); - - if (setup_called++ || ints[0] 1 || ints[0] 6) { - printk(KERN_WARNING scsi: mac5380 - Usage: mac5380=can_queue[,cmd_per_lun,sg_tablesize,hostid,use_tags,use_pdma]\n); - printk(KERN_ALERT scsi: mac5380 Bad Penguin parameters?\n); - return 0; - } - - if (ints[0] = 1) { - if (ints[1] 0) - /* no limits on this, just 0 */ - setup_can_queue = ints[1]; - } - if (ints[0] = 2) { - if (ints[2] 0) - setup_cmd_per_lun = ints[2]; - } - if (ints[0] = 3) { - if (ints[3] = 0) { - setup_sg_tablesize = ints[3]; - /* Must be = SG_ALL (255) */ - if (setup_sg_tablesize SG_ALL) - setup_sg_tablesize = SG_ALL; - } - } - if (ints[0] = 4) { - /* Must be between 0 and 7 */ - if (ints[4] = 0 ints[4] = 7) - setup_hostid = ints[4]; - else if (ints[4] 7) - printk(KERN_WARNING mac_scsi_setup: invalid host ID %d !\n, ints[4] ); - } -#ifdef SUPPORT_TAGS - if (ints[0] = 5) { - if (ints[5] = 0) - setup_use_tagged_queuing = !!ints[5]; + + (void)get_options(str, ARRAY_SIZE(ints), ints); + + if (ints[0] 1 || ints[0] 6) { + pr_err(Usage: mac5380=can_queue[,cmd_per_lun[,sg_tablesize[,hostid[,use_tags[,use_pdma]\n); + return 0; } - - if (ints[0] == 6) { - if (ints[6] = 0) + if (ints[0] = 1) + setup_can_queue = ints[1]; + if (ints[0] = 2) + setup_cmd_per_lun = ints[2]; + if (ints[0] = 3) + setup_sg_tablesize = ints[3]; + if (ints[0] = 4) + setup_hostid = ints[4]; + if (ints[0] = 5) + setup_use_tagged_queuing = ints[5]; + if (ints[0] = 6) setup_use_pdma = ints[6]; - } -#else - if (ints[0] == 5) { - if (ints[5] = 0) - setup_use_pdma = ints[5]; - } -#endif /* SUPPORT_TAGS */ - return 1; } __setup(mac5380=, mac_scsi_setup); +#endif /* !MODULE */ /* * Function : int macscsi_detect(struct scsi_host_template * tpnt) @@ -199,13 +164,8 @@ int __init macscsi_detect(struct scsi_ho tpnt-cmd_per_lun = setup_cmd_per_lun; if (setup_sg_tablesize = 0)
Re: [PATCH v2 29/36] atari_NCR5380: Refactor Falcon locking
On 11/09/2014 01:18 PM, Finn Thain wrote: Ping... On Fri, 31 Oct 2014, Finn Thain wrote: On Thu, 30 Oct 2014, Hannes Reinecke wrote: On 10/27/2014 06:26 AM, Finn Thain wrote: Simplify falcon_release_lock_if_possible() by making callers responsible for disabling local IRQ's, which they must do anyway to correctly synchronize the ST DMA lock with core driver data structures. Move this synchronization logic to the core driver with which it is tightly coupled. Other LLD's like sun3_scsi and mac_scsi that can make use of this core driver can just stub out the NCR5380_acquire_dma_irq() and NCR5380_release_dma_irq() calls so the compiler will eliminate the ST DMA code. Remove a redundant local_irq_save/restore pair (irq's are disabled for interrupt handlers these days). Revise the locking for atari_scsi_bus_reset(): use local_irq_save/restore() instead of atari_turnoff/turnon_irq(). There is no guarantee that atari_scsi still holds the ST DMA lock during EH, so atari_turnoff/turnon_irq() could end up dropping an IDE or floppy interrupt. Signed-off-by: Finn Thain fth...@telegraphics.com.au --- drivers/scsi/atari_NCR5380.c | 72 ++- drivers/scsi/atari_scsi.c| 47 ++-- 2 files changed, 62 insertions(+), 57 deletions(-) Index: linux/drivers/scsi/atari_NCR5380.c === --- linux.orig/drivers/scsi/atari_NCR5380.c2014-10-27 16:25:54.0 +1100 +++ linux/drivers/scsi/atari_NCR5380.c 2014-10-27 16:25:55.0 +1100 @@ -926,7 +926,7 @@ static int NCR5380_queue_command(struct * alter queues and touch the lock. */ /* perhaps stop command timer here */ - if (!falcon_get_lock()) + if (!NCR5380_acquire_dma_irq(instance)) return SCSI_MLQUEUE_HOST_BUSY; /* perhaps restart command timer here */ @@ -962,6 +962,18 @@ static int NCR5380_queue_command(struct return 0; } +static inline void maybe_release_dma_irq(struct Scsi_Host *instance) +{ + struct NCR5380_hostdata *hostdata = shost_priv(instance); + + /* Caller does the locking needed to set test these data atomically */ + if (!hostdata-disconnected_queue + !hostdata-issue_queue + !hostdata-connected + !hostdata-retain_dma_intr) + NCR5380_release_dma_irq(instance); +} + /* * Function : NCR5380_main (void) * @@ -1084,9 +1096,11 @@ static void NCR5380_main(struct work_str cmd_get_tag(tmp, tmp-cmnd[0] != REQUEST_SENSE); #endif if (!NCR5380_select(instance, tmp)) { + local_irq_disable(); hostdata-retain_dma_intr--; /* release if target did not response! */ - falcon_release_lock_if_possible(hostdata); + maybe_release_dma_irq(instance); + local_irq_restore(flags); break; } else { local_irq_disable(); @@ -2085,11 +2099,12 @@ static void NCR5380_information_transfer case COMMAND_COMPLETE: /* Accept message by clearing ACK */ NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE); - /* ++guenther: possible race with Falcon locking */ - hostdata-retain_dma_intr++; - hostdata-connected = NULL; dprintk(NDEBUG_QUEUES, scsi%d: command for target %d, lun %llu completed\n, HOSTNO, cmd-device-id, cmd-device-lun); + + local_irq_save(flags); + hostdata-retain_dma_intr++; + hostdata-connected = NULL; #ifdef SUPPORT_TAGS cmd_free_tag(cmd); if (status_byte(cmd-SCp.Status) == QUEUE_FULL) { @@ -2148,17 +2163,17 @@ static void NCR5380_information_transfer dprintk(NDEBUG_AUTOSENSE, scsi%d: performing request sense\n, HOSTNO); - local_irq_save(flags); LIST(cmd,hostdata-issue_queue); SET_NEXT(cmd, hostdata-issue_queue); hostdata-issue_queue = (struct scsi_cmnd *) cmd; - local_irq_restore(flags);