From: Jeff Mahoney <jeffm@suse.com>
Subject: hpsa: handle unsupported devices more gracefully
Patch-mainline: Never, SUSE-specific
References: FATE#316683
The hpsa_allow_any parameter is used to allow the hpsa driver to claim
devices that aren't officially supported but identify as SmartArray devices.
Since SLES must ship with a supported configuration on the media, we can't
support these devices without explicit user action. This patch declines to
load the unsupported devices unless the hpsa_allow_any module parameter
is explicitly set. This is similar to how we already control access to
unsupported features in btrfs.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
drivers/scsi/hpsa.c | 43 ++++++++++++++++++++++++++++++++++++++++---
1 file changed, 40 insertions(+), 3 deletions(-)
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -72,10 +72,19 @@ MODULE_SUPPORTED_DEVICE("HP Smart Array
MODULE_VERSION(HPSA_DRIVER_VERSION);
MODULE_LICENSE("GPL");
-static int hpsa_allow_any;
-module_param(hpsa_allow_any, int, S_IRUGO|S_IWUSR);
+static bool hpsa_allow_any = false;
+static bool hpsa_claimed_unsupported = false;
+static int hpsa_set_hpsa_allow_any(const char *buffer,
+ const struct kernel_param *kp);
+static struct kernel_param_ops hpsa_allow_any_ops = {
+ .set = hpsa_set_hpsa_allow_any,
+ .get = param_get_bool,
+};
+
+module_param_cb(hpsa_allow_any, &hpsa_allow_any_ops, &hpsa_allow_any,
+ S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(hpsa_allow_any,
- "Allow hpsa driver to access unknown HP Smart Array hardware");
+ "Allow hpsa driver to access unsupported HP Smart Array hardware");
static int hpsa_simple_mode;
module_param(hpsa_simple_mode, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(hpsa_simple_mode,
@@ -6203,12 +6212,14 @@ static int hpsa_lookup_board_id(struct p
!hpsa_allow_any) {
dev_warn(&pdev->dev, "unrecognized board ID: "
"0x%08x, ignoring.\n", *board_id);
+ dev_warn(&pdev->dev, "This device may be enabled by loading the hpsa module with the hpsa_allow_any=1 option or by writing \"%s\" to /sys/bus/pci/drivers/hpsa/bind while the module is loaded. Please note that the driver is untested with this device and will result in an unsupported environment.\n", dev_name(&pdev->dev));
return -ENODEV;
}
#ifdef CONFIG_SUSE_KERNEL_SUPPORTED
add_taint(TAINT_NO_SUPPORT, LOCKDEP_STILL_OK);
#endif
dev_warn(&pdev->dev, "unsupported board ID: 0x%08x\n", *board_id);
+ hpsa_claimed_unsupported = true;
return ARRAY_SIZE(products) - 1; /* generic unknown smart array */
}
@@ -7642,5 +7653,31 @@ static void __attribute__((unused)) veri
#undef VERIFY_OFFSET
}
+static int hpsa_set_hpsa_allow_any(const char *buffer,
+ const struct kernel_param *kp)
+{
+ int ret;
+ struct kernel_param dummy_kp = *kp;
+ bool newval;
+
+ dummy_kp.arg = &newval;
+
+ ret = param_set_bool(buffer, &dummy_kp);
+ if (ret)
+ return ret;
+
+ if (hpsa_allow_any && !newval) {
+ if (hpsa_claimed_unsupported) {
+ pr_info("hpsa: can't disable hpsa_allow_any parameter. Devices already in use.\n");
+ return -EPERM;
+ } else
+ hpsa_allow_any = false;
+ } else if (!hpsa_allow_any && newval) {
+ pr_info("hpsa: allowing unsupported devices. If devices are claimed, this will result in an unsupported environment.\n");
+ hpsa_allow_any = true;
+ }
+ return 0;
+}
+
module_init(hpsa_init);
module_exit(hpsa_cleanup);