
Starting with the v5.x kernels asynchronous device scanning is enabled by default to speed up the boot process. This results in device detection order and thus naming potentially changing from one boot to the next, affecting disk and USB storage device names. We revert two related patches, returning the kernel device naming convention of pre-v5.x kernels. Since we are slotting a 5.10 kernel into a fairly old userspace, this is preferred approach versus adapting the userspace to this new kernel behavior, at least at this time. NOTE: BIOS and other factors outside the kernel's control may still result in different device naming, users should be aware of this if performing firmware updates. In the long term different approaches will be required to determine which devices to use that don't rely on device names, allowing the original 5.10 kernel behavior to work as designed. Verification: Ran test 120 times with an unpatched 5.10.74 kernel, 120 times with an unpatched 5.10.74 kernel with "scsi_mod.scan=sync" and 220 times with a patched 5.10.74 kernel with the two commits reverted. Here are the results: 1. 5.10.74 unpatched without scsi_mod.scan=sync --14/120 instances of unexpected disk order. 2. 5.10.74 unpatched with scsi_mod.scan=sync --12/120 instances of unexpected disk order. 3. 5.10.74 patched without scsi_mod.scan=sync --220 instances of the same disk order. Closes-bug: #1953433 Closes-Bug: #1950163 [Submitted on behalf of Vefa Bicakci.] Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com> Signed-off-by: Jiping Ma <jiping.ma2@windriver.com> Change-Id: I4f508fce99a30deb4ab6688682a1057205013679
136 lines
4.3 KiB
Diff
136 lines
4.3 KiB
Diff
From b5dad6e67f9704968ca7d4daf1715667cddafa3d Mon Sep 17 00:00:00 2001
|
|
From: Jiping Ma <jiping.ma2@windriver.com>
|
|
Date: Wed, 8 Dec 2021 18:34:59 -0800
|
|
Subject: [PATCH 2/2] Revert commit f049cf1a7b
|
|
|
|
commit f049cf1a7b "scsi: sd: Rely on the driver core for asynchronous
|
|
probing"
|
|
|
|
This reverts commit f049cf1a7b6737c75884247c3f6383ef104d255a,
|
|
and it is a clean revert, there is not any conflict.
|
|
|
|
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
|
|
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
|
|
---
|
|
drivers/scsi/scsi.c | 12 +++++++++---
|
|
drivers/scsi/scsi_pm.c | 6 +++++-
|
|
drivers/scsi/scsi_priv.h | 1 +
|
|
drivers/scsi/sd.c | 12 +++++++++---
|
|
4 files changed, 24 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
|
|
index 24619c3bebd5..3080292a16cd 100644
|
|
--- a/drivers/scsi/scsi.c
|
|
+++ b/drivers/scsi/scsi.c
|
|
@@ -86,10 +86,15 @@ unsigned int scsi_logging_level;
|
|
EXPORT_SYMBOL(scsi_logging_level);
|
|
#endif
|
|
|
|
+/* sd, scsi core and power management need to coordinate flushing async actions */
|
|
+ASYNC_DOMAIN(scsi_sd_probe_domain);
|
|
+EXPORT_SYMBOL(scsi_sd_probe_domain);
|
|
+
|
|
/*
|
|
- * Domain for asynchronous system resume operations. It is marked 'exclusive'
|
|
- * to avoid being included in the async_synchronize_full() that is invoked by
|
|
- * dpm_resume().
|
|
+ * Separate domain (from scsi_sd_probe_domain) to maximize the benefit of
|
|
+ * asynchronous system resume operations. It is marked 'exclusive' to avoid
|
|
+ * being included in the async_synchronize_full() that is invoked by
|
|
+ * dpm_resume()
|
|
*/
|
|
ASYNC_DOMAIN_EXCLUSIVE(scsi_sd_pm_domain);
|
|
EXPORT_SYMBOL(scsi_sd_pm_domain);
|
|
@@ -799,6 +804,7 @@ static void __exit exit_scsi(void)
|
|
scsi_exit_devinfo();
|
|
scsi_exit_procfs();
|
|
scsi_exit_queue();
|
|
+ async_unregister_domain(&scsi_sd_probe_domain);
|
|
}
|
|
|
|
subsys_initcall(init_scsi);
|
|
diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
|
|
index 3717eea37ecb..b3d71b516213 100644
|
|
--- a/drivers/scsi/scsi_pm.c
|
|
+++ b/drivers/scsi/scsi_pm.c
|
|
@@ -175,7 +175,11 @@ static int scsi_bus_resume_common(struct device *dev,
|
|
|
|
static int scsi_bus_prepare(struct device *dev)
|
|
{
|
|
- if (scsi_is_host_device(dev)) {
|
|
+ if (scsi_is_sdev_device(dev)) {
|
|
+ /* sd probing uses async_schedule. Wait until it finishes. */
|
|
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
|
|
+
|
|
+ } else if (scsi_is_host_device(dev)) {
|
|
/* Wait until async scanning is finished */
|
|
scsi_complete_async_scans();
|
|
}
|
|
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
|
|
index 180636d54982..c43456f0870c 100644
|
|
--- a/drivers/scsi/scsi_priv.h
|
|
+++ b/drivers/scsi/scsi_priv.h
|
|
@@ -172,6 +172,7 @@ static inline void scsi_autopm_put_host(struct Scsi_Host *h) {}
|
|
#endif /* CONFIG_PM */
|
|
|
|
extern struct async_domain scsi_sd_pm_domain;
|
|
+extern struct async_domain scsi_sd_probe_domain;
|
|
|
|
/* scsi_dh.c */
|
|
#ifdef CONFIG_SCSI_DH
|
|
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
|
|
index 2e22ee4501e7..e6c70475f084 100644
|
|
--- a/drivers/scsi/sd.c
|
|
+++ b/drivers/scsi/sd.c
|
|
@@ -616,7 +616,6 @@ static struct scsi_driver sd_template = {
|
|
.name = "sd",
|
|
.owner = THIS_MODULE,
|
|
.probe = sd_probe,
|
|
- .probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
|
.remove = sd_remove,
|
|
.shutdown = sd_shutdown,
|
|
.pm = &sd_pm_ops,
|
|
@@ -3364,8 +3363,12 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
|
|
return 0;
|
|
}
|
|
|
|
-static void sd_probe_part2(struct scsi_disk *sdkp)
|
|
+/*
|
|
+ * The asynchronous part of sd_probe
|
|
+ */
|
|
+static void sd_probe_async(void *data, async_cookie_t cookie)
|
|
{
|
|
+ struct scsi_disk *sdkp = data;
|
|
struct scsi_device *sdp;
|
|
struct gendisk *gd;
|
|
u32 index;
|
|
@@ -3424,6 +3427,7 @@ static void sd_probe_part2(struct scsi_disk *sdkp)
|
|
sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
|
|
sdp->removable ? "removable " : "");
|
|
scsi_autopm_put_device(sdp);
|
|
+ put_device(&sdkp->dev);
|
|
}
|
|
|
|
/**
|
|
@@ -3517,7 +3521,8 @@ static int sd_probe(struct device *dev)
|
|
|
|
dev_set_drvdata(dev, sdkp);
|
|
|
|
- sd_probe_part2(sdkp);
|
|
+ get_device(&sdkp->dev); /* prevent release before async_schedule */
|
|
+ async_schedule_domain(sd_probe_async, sdkp, &scsi_sd_probe_domain);
|
|
|
|
return 0;
|
|
|
|
@@ -3554,6 +3559,7 @@ static int sd_remove(struct device *dev)
|
|
scsi_autopm_get_device(sdkp->device);
|
|
|
|
async_synchronize_full_domain(&scsi_sd_pm_domain);
|
|
+ async_synchronize_full_domain(&scsi_sd_probe_domain);
|
|
device_del(&sdkp->dev);
|
|
del_gendisk(sdkp->disk);
|
|
sd_shutdown(dev);
|
|
--
|
|
2.31.1
|
|
|