From: Bart Van Assche <bvanassche@acm.org>
To: "Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Bean Huo <beanhuo@micron.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
Avri Altman <avri.altman@wdc.com>,
Asutosh Das <asutoshd@codeaurora.org>,
Stanley Chu <stanley.chu@mediatek.com>,
Yue Hu <huyue2@yulong.com>,
Sergey Shtylyov <s.shtylyov@omprussia.ru>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Can Guo <cang@codeaurora.org>,
Vinayak Holikatti <vinholikatti@gmail.com>,
Santosh Yaraganavi <santoshsy@gmail.com>,
Namjae Jeon <linkinjeon@gmail.com>, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH v4 06/17] scsi: ufs: Fix race conditions related to driver data
Date: Fri, 3 Dec 2021 15:19:39 -0800 [thread overview]
Message-ID: <20211203231950.193369-7-bvanassche@acm.org> (raw)
In-Reply-To: <20211203231950.193369-1-bvanassche@acm.org>
The driver data pointer must be set before any callbacks are registered
that use that pointer. Hence move the initialization of that pointer
from after the ufshcd_init() call to inside ufshcd_init().
Fixes: 3b1d05807a9a ("[SCSI] ufs: Segregate PCI Specific Code")
Reviewed-by: Bean Huo <beanhuo@micron.com>
Tested-by: Bean Huo <beanhuo@micron.com>
Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/ufs/tc-dwc-g210-pci.c | 1 -
drivers/scsi/ufs/ufshcd-pci.c | 2 --
drivers/scsi/ufs/ufshcd-pltfrm.c | 2 --
drivers/scsi/ufs/ufshcd.c | 7 +++++++
4 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/ufs/tc-dwc-g210-pci.c b/drivers/scsi/ufs/tc-dwc-g210-pci.c
index 679289e1a78e..7b08e2e07cc5 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pci.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pci.c
@@ -110,7 +110,6 @@ tc_dwc_g210_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return err;
}
- pci_set_drvdata(pdev, hba);
pm_runtime_put_noidle(&pdev->dev);
pm_runtime_allow(&pdev->dev);
diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index 51424557810d..a673eedb2f05 100644
--- a/drivers/scsi/ufs/ufshcd-pci.c
+++ b/drivers/scsi/ufs/ufshcd-pci.c
@@ -522,8 +522,6 @@ ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return err;
}
- pci_set_drvdata(pdev, hba);
-
hba->vops = (struct ufs_hba_variant_ops *)id->driver_data;
err = ufshcd_init(hba, mmio_base, pdev->irq);
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index eaeae83b999f..8b16bbbcb806 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -361,8 +361,6 @@ int ufshcd_pltfrm_init(struct platform_device *pdev,
goto dealloc_host;
}
- platform_set_drvdata(pdev, hba);
-
pm_runtime_set_active(&pdev->dev);
pm_runtime_enable(&pdev->dev);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d4996ada55b6..04a19b826837 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9481,6 +9481,13 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
struct device *dev = hba->dev;
char eh_wq_name[sizeof("ufs_eh_wq_00")];
+ /*
+ * dev_set_drvdata() must be called before any callbacks are registered
+ * that use dev_get_drvdata() (frequency scaling, clock scaling, hwmon,
+ * sysfs).
+ */
+ dev_set_drvdata(dev, hba);
+
if (!mmio_base) {
dev_err(hba->dev,
"Invalid memory reference for mmio_base is NULL\n");
next prev parent reply other threads:[~2021-12-03 23:20 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-03 23:19 [PATCH v4 00/17] UFS patches for kernel v5.17 Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 01/17] scsi: core: Fix scsi_device_max_queue_depth() Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 02/17] scsi: ufs: Rename a function argument Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 03/17] scsi: ufs: Remove is_rpmb_wlun() Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 04/17] scsi: ufs: Remove the sdev_rpmb member Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 05/17] scsi: ufs: Remove dead code Bart Van Assche
2021-12-03 23:19 ` Bart Van Assche [this message]
2021-12-03 23:19 ` [PATCH v4 07/17] scsi: ufs: Remove ufshcd_any_tag_in_use() Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 08/17] scsi: ufs: Rework ufshcd_change_queue_depth() Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 09/17] scsi: ufs: Fix a deadlock in the error handler Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 10/17] scsi: ufs: Remove hba->cmd_queue Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 11/17] scsi: ufs: Remove the 'update_scaling' local variable Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 12/17] scsi: ufs: Introduce ufshcd_release_scsi_cmd() Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 13/17] scsi: ufs: Improve SCSI abort handling further Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 14/17] scsi: ufs: Fix a kernel crash during shutdown Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 15/17] scsi: ufs: Stop using the clock scaling lock in the error handler Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 16/17] scsi: ufs: Optimize the command queueing code Bart Van Assche
2021-12-06 22:41 ` Asutosh Das (asd)
2021-12-08 17:28 ` Asutosh Das (asd)
2021-12-08 17:53 ` Bart Van Assche
2021-12-14 4:04 ` Bjorn Andersson
2021-12-14 4:57 ` Bart Van Assche
2021-12-15 3:52 ` Bjorn Andersson
2021-12-15 18:44 ` Bart Van Assche
2021-12-03 23:19 ` [PATCH v4 17/17] scsi: ufs: Implement polling support Bart Van Assche
2021-12-07 3:31 ` [PATCH v4 00/17] UFS patches for kernel v5.17 Martin K. Petersen
2021-12-14 4:40 ` Martin K. Petersen
2021-12-14 7:14 ` Avri Altman
2021-12-14 7:18 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211203231950.193369-7-bvanassche@acm.org \
--to=bvanassche@acm.org \
--cc=adobriyan@gmail.com \
--cc=adrian.hunter@intel.com \
--cc=arnd@arndb.de \
--cc=asutoshd@codeaurora.org \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=cang@codeaurora.org \
--cc=huyue2@yulong.com \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linkinjeon@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=s.shtylyov@omprussia.ru \
--cc=santoshsy@gmail.com \
--cc=srinivas.kandagatla@linaro.org \
--cc=stanley.chu@mediatek.com \
--cc=vinholikatti@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox