Skip to content

Commit 69f5eb7

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Move the ufshcd_device_init(hba, true) call
ufshcd_async_scan() is called (asynchronously) only by ufshcd_init(). Move the ufshcd_device_init(hba, true) call from ufshcd_async_scan() into ufshcd_init(). This patch prepares for moving both scsi_add_host() calls into ufshcd_add_scsi_host(). Calling ufshcd_device_init() from ufshcd_init() without holding hba->host_sem is safe. This is safe because hba->host_sem serializes core code and sysfs callbacks. The ufshcd_device_init() call is moved before the scsi_add_host() call and hence happens before any SCSI sysfs attributes are created. Since ufshcd_device_init() may call scsi_add_host(), only call scsi_add_host() from ufshcd_add_scsi_host() if the SCSI host has not yet been added by ufshcd_device_init(). Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 639e204 commit 69f5eb7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8891,9 +8891,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
88918891
down(&hba->host_sem);
88928892
/* Initialize hba, detect and initialize UFS device */
88938893
probe_start = ktime_get();
8894-
ret = ufshcd_device_init(hba, /*init_dev_params=*/true);
8895-
if (ret == 0)
8896-
ret = ufshcd_probe_hba(hba, true);
8894+
ret = ufshcd_probe_hba(hba, true);
88978895
ufshcd_process_probe_result(hba, probe_start, ret);
88988896
up(&hba->host_sem);
88998897
if (ret)
@@ -10364,7 +10362,8 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
1036410362
{
1036510363
int err;
1036610364

10367-
if (!is_mcq_supported(hba)) {
10365+
if (!hba->scsi_host_added) {
10366+
WARN_ON_ONCE(is_mcq_supported(hba));
1036810367
if (!hba->lsdb_sup) {
1036910368
dev_err(hba->dev,
1037010369
"%s: failed to initialize (legacy doorbell mode not supported)\n",
@@ -10593,6 +10592,11 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1059310592
*/
1059410593
ufshcd_set_ufs_dev_active(hba);
1059510594

10595+
/* Initialize hba, detect and initialize UFS device */
10596+
err = ufshcd_device_init(hba, /*init_dev_params=*/true);
10597+
if (err)
10598+
goto out_disable;
10599+
1059610600
err = ufshcd_add_scsi_host(hba);
1059710601
if (err)
1059810602
goto out_disable;

0 commit comments

Comments
 (0)