Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20241016201249.2256266-8-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
69f5eb78 639e2043

+8 -4
+8 -4
drivers/ufs/core/ufshcd.c
··· 8891 8891 down(&hba->host_sem); 8892 8892 /* Initialize hba, detect and initialize UFS device */ 8893 8893 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); 8897 8895 ufshcd_process_probe_result(hba, probe_start, ret); 8898 8896 up(&hba->host_sem); 8899 8897 if (ret) ··· 10362 10364 { 10363 10365 int err; 10364 10366 10365 - if (!is_mcq_supported(hba)) { 10367 + if (!hba->scsi_host_added) { 10368 + WARN_ON_ONCE(is_mcq_supported(hba)); 10366 10369 if (!hba->lsdb_sup) { 10367 10370 dev_err(hba->dev, 10368 10371 "%s: failed to initialize (legacy doorbell mode not supported)\n", ··· 10591 10592 * ufshcd_probe_hba(). 10592 10593 */ 10593 10594 ufshcd_set_ufs_dev_active(hba); 10595 + 10596 + /* Initialize hba, detect and initialize UFS device */ 10597 + err = ufshcd_device_init(hba, /*init_dev_params=*/true); 10598 + if (err) 10599 + goto out_disable; 10594 10600 10595 10601 err = ufshcd_add_scsi_host(hba); 10596 10602 if (err)