mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 18:09:56 +00:00
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>
This commit is contained in:
committed by
Martin K. Petersen
parent
639e2043b5
commit
69f5eb78d4
@@ -8891,9 +8891,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
|
|||||||
down(&hba->host_sem);
|
down(&hba->host_sem);
|
||||||
/* Initialize hba, detect and initialize UFS device */
|
/* Initialize hba, detect and initialize UFS device */
|
||||||
probe_start = ktime_get();
|
probe_start = ktime_get();
|
||||||
ret = ufshcd_device_init(hba, /*init_dev_params=*/true);
|
ret = ufshcd_probe_hba(hba, true);
|
||||||
if (ret == 0)
|
|
||||||
ret = ufshcd_probe_hba(hba, true);
|
|
||||||
ufshcd_process_probe_result(hba, probe_start, ret);
|
ufshcd_process_probe_result(hba, probe_start, ret);
|
||||||
up(&hba->host_sem);
|
up(&hba->host_sem);
|
||||||
if (ret)
|
if (ret)
|
||||||
@@ -10364,7 +10362,8 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!is_mcq_supported(hba)) {
|
if (!hba->scsi_host_added) {
|
||||||
|
WARN_ON_ONCE(is_mcq_supported(hba));
|
||||||
if (!hba->lsdb_sup) {
|
if (!hba->lsdb_sup) {
|
||||||
dev_err(hba->dev,
|
dev_err(hba->dev,
|
||||||
"%s: failed to initialize (legacy doorbell mode not supported)\n",
|
"%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)
|
|||||||
*/
|
*/
|
||||||
ufshcd_set_ufs_dev_active(hba);
|
ufshcd_set_ufs_dev_active(hba);
|
||||||
|
|
||||||
|
/* Initialize hba, detect and initialize UFS device */
|
||||||
|
err = ufshcd_device_init(hba, /*init_dev_params=*/true);
|
||||||
|
if (err)
|
||||||
|
goto out_disable;
|
||||||
|
|
||||||
err = ufshcd_add_scsi_host(hba);
|
err = ufshcd_add_scsi_host(hba);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_disable;
|
goto out_disable;
|
||||||
|
|||||||
Reference in New Issue
Block a user