mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 03:40:35 +09:00
FROMGIT: scsi: ufs: Fix race conditions related to driver data
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(). Link: https://lore.kernel.org/r/20211203231950.193369-7-bvanassche@acm.org Fixes:3b1d05807a("[SCSI] ufs: Segregate PCI Specific Code") Reported-by: Alexey Dobriyan <adobriyan@gmail.com> Tested-by: Bean Huo <beanhuo@micron.com> Reviewed-by: Bean Huo <beanhuo@micron.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit21ad0e4908git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Bug: 204438323 Change-Id: Id924038c13cab1e203bb650cc3939ebd5acf56fe Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
committed by
Bart Van Assche
parent
968af1dd93
commit
f531b624a6
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -9525,6 +9525,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");
|
||||
|
||||
Reference in New Issue
Block a user