Skip to contentSkip to conversation

SCSI bug fixes for 4.6

PATCH In review Arnd Bergmann 3 participants 10 messages Jan 27, 2016 – Feb 11, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover SCSI bug fixes for 4.6

Here are a bunch of fixes for harmless bugs I found during ARM randconfig testing. It would be nice to get them mered in 4.6, but there is no need to have them in 4.5 as no incorrect behavior results from the current code, and the warnings are all hard to trigger.

Arnd Bergmann (7):
scsi: fdomain: drop fdomain_pci_tbl when built-in
mptfusion: hide unused seq_mpt_print_ioc_summary function
scsi: acornscsi: mark calc_sync_xfer as __maybe_unused
scsi: fas216: avoid fas216_log_setup for loadable module
scsi: qla4xxx: shut up warning for rd_reg_indirect
scsi: aha1542: avoid uninitialized variable warnings
scsi_dh: force modular build if SCSI is a module

 drivers/message/fusion/mptbase.c    | 2 ++
 drivers/scsi/aha1542.c              | 3 +++
 drivers/scsi/arm/acornscsi.c        | 3 ++-
 drivers/scsi/arm/fas216.c           | 2 ++
 drivers/scsi/device_handler/Kconfig | 8 ++++----
 drivers/scsi/fdomain.c              | 2 +-
 drivers/scsi/qla4xxx/ql4_83xx.c     | 6 ++++--
 7 files changed, 18 insertions(+), 8 deletions(-)
Signature · 1 line
2.7.0
#1 lore raw

PATCH 1/7 scsi: fdomain: drop fdomain_pci_tbl when built-in

The fdomain SCSI host driver is one of the last remaining drivers that manually search the PCI bus using pci_get_device rather than registering a pci_driver instance.

This means the module device table is unused when the driver is built-in, and we get a warning about it:

drivers/scsi/fdomain.c:1773:29: warning: 'fdomain_pci_tbl' defined but not used [-Wunused-variable]

To avoid the warning, this adds another #ifdef around the table definition.

---
 drivers/scsi/fdomain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fdomain.c +1 -1
index eefe14d453db..b87ab38a4530 100644
@@ -1768,7 +1768,7 @@ struct scsi_host_template fdomain_driver_template = {
 };
 
 #ifndef PCMCIA
-#ifdef CONFIG_PCI
+#if defined(CONFIG_PCI) && defined(MODULE)
 
 static struct pci_device_id fdomain_pci_tbl[] = {
 	{ PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70,
Signature · 1 line
2.7.0
#2 lore raw

PATCH 2/7 mptfusion: hide unused seq_mpt_print_ioc_summary function

In reply to Arnd Bergmann

The seq_mpt_print_ioc_summary function is used for the /proc/mpt/iocN/summary implementation and never gets called when CONFIG_PROC_FS is disabled:

drivers/message/fusion/mptbase.c:6851:13: warning: 'seq_mpt_print_ioc_summary' defined but not used [-Wunused-function]
static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int showlan)

This adds an #ifdef to hide the function definition in that case and avoid the warning.

---
 drivers/message/fusion/mptbase.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/message/fusion/mptbase.c +2 -0
index 5dcc0313c38a..207370d68c17 100644
@@ -6848,6 +6848,7 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
 	*size = y;
 }
 
+#ifdef CONFIG_PROC_FS
 static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int showlan)
 {
 	char expVer[32];
@@ -6879,6 +6880,7 @@ static void seq_mpt_print_ioc_summary(MPT_ADAPTER *ioc, struct seq_file *m, int
 
 	seq_putc(m, '\n');
 }
+#endif
 
 /**
  *	mpt_set_taskmgmt_in_progress_flag - set flags associated with task management
Signature · 1 line
2.7.0
#3 lore raw

PATCH 3/7 scsi: acornscsi: mark calc_sync_xfer as __maybe_unused

In reply to Arnd Bergmann

The calc_sync_xfer function is only used if CONFIG_SCSI_ACORNSCSI_SYNC is set, otherwise we get a compiler warning:

scsi/arm/acornscsi.c:680:15: warning: 'calc_sync_xfer' defined but not used [-Wunused-function]
unsigned char calc_sync_xfer(unsigned int period, unsigned int offset)

This marks the function as __maybe_unused to shut up the warning and silently drop the function in the object code when there is no caller.

---
 drivers/scsi/arm/acornscsi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/arm/acornscsi.c +2 -1
index deaaf84989cd..12b88294d667 100644
@@ -677,7 +677,8 @@ int round_period(unsigned int period)
  * Copyright: Copyright (c) 1996 John Shifflett, GeoLog Consulting
  */
 static
-unsigned char calc_sync_xfer(unsigned int period, unsigned int offset)
+unsigned char __maybe_unused calc_sync_xfer(unsigned int period,
+					    unsigned int offset)
 {
     return sync_xfer_table[round_period(period)].reg_value |
 		((offset < SDTR_SIZE) ? offset : SDTR_SIZE);
Signature · 1 line
2.7.0
#4 lore raw

PATCH 4/7 scsi: fas216: avoid fas216_log_setup for loadable module

In reply to Arnd Bergmann

We get a warning for the fas216 driver when it is compiled as a loadable module, as the __setup() functions are never called then:

scsi/arm/fas216.c:101:19: warning: 'fas216_log_setup' defined but not used [-Wunused-function]
static int __init fas216_log_setup(char *str)

This adds an #ifndef MODULE around the definition to shut up the warning and clarify for the reader when it is used or not.

---
 drivers/scsi/arm/fas216.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/scsi/arm/fas216.c +2 -0
index decdc71b6b86..24388795ee9a 100644
@@ -98,6 +98,7 @@ static int level_mask = LOG_ERROR;
 
 module_param(level_mask, int, 0644);
 
+#ifndef MODULE
 static int __init fas216_log_setup(char *str)
 {
 	char *s;
@@ -138,6 +139,7 @@ static int __init fas216_log_setup(char *str)
 }
 
 __setup("fas216_logging=", fas216_log_setup);
+#endif
 
 static inline unsigned char fas216_readb(FAS216_Info *info, unsigned int reg)
 {
Signature · 1 line
2.7.0
#5 lore raw

PATCH 5/7 scsi: qla4xxx: shut up warning for rd_reg_indirect

In reply to Arnd Bergmann

The qla4_83xx_rd_reg_indirect() function can fail when it is unable to read a register, but not all callers check its return value before using the register data, and gcc correctly warns about this:

qla4xxx/ql4_83xx.c: In function 'qla4_83xx_process_reset_template':
qla4xxx/ql4_83xx.c:1073:36: warning: 'value' may be used uninitialized in this function

     ha->reset_tmplt.array[index++] = value;
                                    ^
qla4xxx/ql4_83xx.c:1050:11: note: 'value' was declared here
  uint32_t value;
           ^
qla4xxx/ql4_83xx.c:902:8: warning: 'value' may be used uninitialized in this function
  value &= p_rmw_hdr->test_mask;
        ^
qla4xxx/ql4_83xx.c:895:11: note: 'value' was declared here
  uint32_t value;
           ^
In file included from ../include/linux/io.h:25:0,
                 from ../include/linux/pci.h:31,
                 from ../drivers/scsi/qla4xxx/ql4_def.h:16,
                 from ../drivers/scsi/qla4xxx/ql4_83xx.c:10:

asm/io.h:101:2: warning: 'value' may be used uninitialized in this function
asm volatile("str %1, %0"
^
qla4xxx/ql4_83xx.c:874:11: note: 'value' was declared here

  uint32_t value;
           ^

Unfortunately, I don't see any helpful way to add proper error handling for this case, and the failure scenario for rd_reg seems rather obscure, so this bails out and makes the rd_reg accessor set the result to 0xffffffff so we at least get a predictable value.

---
 drivers/scsi/qla4xxx/ql4_83xx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla4xxx/ql4_83xx.c +4 -2
index 5d4f8e67fb25..638f72c5ab05 100644
@@ -46,11 +46,13 @@ int qla4_83xx_rd_reg_indirect(struct scsi_qla_host *ha, uint32_t addr,
 
 	ret_val = qla4_83xx_set_win_base(ha, addr);
 
-	if (ret_val == QLA_SUCCESS)
+	if (ret_val == QLA_SUCCESS) {
 		*data = qla4_83xx_rd_reg(ha, QLA83XX_WILDCARD);
-	else
+	} else {
+		*data = 0xffffffff;
 		ql4_printk(KERN_ERR, ha, "%s: failed read of addr 0x%x!\n",
 			   __func__, addr);
+	}
 
 	return ret_val;
 }
Signature · 1 line
2.7.0
Acked-by on v1 5/7
#6 lore raw

Re: [PATCH 5/7] scsi: qla4xxx: shut up warning for rd_reg_indirect

Quoted 63 lines · Arnd Bergmann

The qla4_83xx_rd_reg_indirect() function can fail when it is unable to read a register, but not all callers check its return value before using the register data, and gcc correctly warns about this:

qla4xxx/ql4_83xx.c: In function 'qla4_83xx_process_reset_template':
qla4xxx/ql4_83xx.c:1073:36: warning: 'value' may be used uninitialized in this function

    ha->reset_tmplt.array[index++] = value;
                                   ^
qla4xxx/ql4_83xx.c:1050:11: note: 'value' was declared here
 uint32_t value;
          ^
qla4xxx/ql4_83xx.c:902:8: warning: 'value' may be used uninitialized in
this function
 value &= p_rmw_hdr->test_mask;
       ^
qla4xxx/ql4_83xx.c:895:11: note: 'value' was declared here
 uint32_t value;
          ^
In file included from ../include/linux/io.h:25:0,
                from ../include/linux/pci.h:31,
                from ../drivers/scsi/qla4xxx/ql4_def.h:16,
                from ../drivers/scsi/qla4xxx/ql4_83xx.c:10:

asm/io.h:101:2: warning: 'value' may be used uninitialized in this function
asm volatile("str %1, %0"
^
qla4xxx/ql4_83xx.c:874:11: note: 'value' was declared here

 uint32_t value;
          ^

Unfortunately, I don't see any helpful way to add proper error handling for this case, and the failure scenario for rd_reg seems rather obscure, so this bails out and makes the rd_reg accessor set the result to 0xffffffff
so we at least get a predictable value.

---
drivers/scsi/qla4xxx/ql4_83xx.c | 6 ++++--

1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/qla4xxx/ql4_83xx.c +4 -2
index 5d4f8e67fb25..638f72c5ab05 100644
@@ -46,11 +46,13 @@ int qla4_83xx_rd_reg_indirect(struct scsi_qla_host
 *ha, uint32_t addr,
 
 	ret_val = qla4_83xx_set_win_base(ha, addr);
 
-	if (ret_val == QLA_SUCCESS)
+	if (ret_val == QLA_SUCCESS) {
 		*data = qla4_83xx_rd_reg(ha, QLA83XX_WILDCARD);
-	else
+	} else {
+		*data = 0xffffffff;
 		ql4_printk(KERN_ERR, ha, "%s: failed read of addr 0x%x!\n",
 			   __func__, addr);
+	}
 
 	return ret_val;
Quoted 4 lines

}

Signature · 1 line
2.7.0
#7 lore raw

PATCH 6/7 scsi: aha1542: avoid uninitialized variable warnings

In reply to Arnd Bergmann

Gcc incorrectly detects that two variables in aha1542_queuecommand might be used without an initialization:

scsi/aha1542.c: In function 'aha1542_queuecommand':
scsi/aha1542.c:382:16: error: 'cptr' may be used uninitialized in this function [-Werror=maybe-uninitialized] scsi/aha1542.c:379:11: error: 'sg_count' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The only user of these is doing the same check that the assigment has, so it is actually guaranteed to work. Adding an "else" clause with a fake initialization shuts up the warning.

---
 drivers/scsi/aha1542.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/scsi/aha1542.c +3 -0
index 5b8b2937a3fe..7db448ec8beb 100644
@@ -403,6 +403,9 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 		cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA);
 		if (!cptr)
 			return SCSI_MLQUEUE_HOST_BUSY;
+	} else {
+		sg_count = 0;
+		cptr = NULL;
 	}
 
 	/* Use the outgoing mailboxes in a round-robin fashion, because this
Signature · 1 line
2.7.0
#8 lore raw

PATCH 7/7 scsi_dh: force modular build if SCSI is a module

In reply to Arnd Bergmann

When the scsi_dh core was moved into the scsi core module, CONFIG_SCSI_DH became a 'bool' option, and now anything depending on it can be built-in even when CONFIG_SCSI=m. This of course cannot link successfully:

drivers/scsi/built-in.o: In function `rdac_init':
scsi_dh_alua.c:(.init.text+0x14): undefined reference to scsi_register_device_handler' scsi_dh_alua.c:(.init.text+0x64): undefined reference to scsi_unregister_device_handler' drivers/scsi/built-in.o: In function `alua_init':
scsi_dh_alua.c:(.init.text+0xb0): undefined reference to `scsi_register_device_handler'

As a workaround, this adds an extra dependency on CONFIG_SCSI, so Kconfig can figure out whether built-in is allowed or not.

Fixes 086b91d052eb ("scsi_dh: integrate into the core SCSI code")
---
 drivers/scsi/device_handler/Kconfig | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/scsi/device_handler/Kconfig +4 -4
index e5647d59224f..0b331c9c0a8f 100644
@@ -13,13 +13,13 @@ menuconfig SCSI_DH
 
 config SCSI_DH_RDAC
 	tristate "LSI RDAC Device Handler"
-	depends on SCSI_DH
+	depends on SCSI_DH && SCSI
 	help
 	If you have a LSI RDAC select y. Otherwise, say N.
 
 config SCSI_DH_HP_SW
 	tristate "HP/COMPAQ MSA Device Handler"
-	depends on SCSI_DH
+	depends on SCSI_DH && SCSI
 	help
 	If you have a HP/COMPAQ MSA device that requires START_STOP to
 	be sent to start it and cannot upgrade the firmware then select y.
@@ -27,13 +27,13 @@ config SCSI_DH_HP_SW
 
 config SCSI_DH_EMC
 	tristate "EMC CLARiiON Device Handler"
-	depends on SCSI_DH
+	depends on SCSI_DH && SCSI
 	help
 	If you have a EMC CLARiiON select y. Otherwise, say N.
 
 config SCSI_DH_ALUA
 	tristate "SPC-3 ALUA Device Handler"
-	depends on SCSI_DH
+	depends on SCSI_DH && SCSI
 	help
 	  SCSI Device handler for generic SPC-3 Asymmetric Logical Unit
 	  Access (ALUA).
Signature · 1 line
2.7.0
#9 lore raw

cover SCSI bug fixes for 4.6

In reply to Arnd Bergmann
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnd" == Arnd Bergmann <[email protected]> writes:

Arnd> Here are a bunch of fixes for harmless bugs I found during ARM Arnd> randconfig testing. It would be nice to get them mered in 4.6, but Arnd> there is no need to have them in 4.5 as no incorrect behavior Arnd> results from the current code, and the warnings are all hard to Arnd> trigger.

Applied to 4.6/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering