Skip to content

Commit 72e9792

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Move the MCQ scsi_add_host() call
Whether or not MCQ is used, call scsi_add_host() from ufshcd_add_scsi_host(). For MCQ this patch swaps the order of the scsi_add_host() and UFS device initialization. This patch prepares for combining the two scsi_add_host() calls. 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 b6195d0 commit 72e9792

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10344,8 +10344,25 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
1034410344
{
1034510345
int err;
1034610346

10347-
if (!hba->scsi_host_added) {
10348-
WARN_ON_ONCE(is_mcq_supported(hba));
10347+
if (is_mcq_supported(hba)) {
10348+
ufshcd_mcq_enable(hba);
10349+
err = ufshcd_alloc_mcq(hba);
10350+
if (!err) {
10351+
ufshcd_config_mcq(hba);
10352+
} else {
10353+
/* Continue with SDB mode */
10354+
ufshcd_mcq_disable(hba);
10355+
use_mcq_mode = false;
10356+
dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
10357+
err);
10358+
}
10359+
err = scsi_add_host(hba->host, hba->dev);
10360+
if (err) {
10361+
dev_err(hba->dev, "scsi_add_host failed\n");
10362+
return err;
10363+
}
10364+
hba->scsi_host_added = true;
10365+
} else {
1034910366
if (!hba->lsdb_sup) {
1035010367
dev_err(hba->dev,
1035110368
"%s: failed to initialize (legacy doorbell mode not supported)\n",
@@ -10606,26 +10623,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1060610623
if (err)
1060710624
goto out_disable;
1060810625

10609-
if (is_mcq_supported(hba)) {
10610-
ufshcd_mcq_enable(hba);
10611-
err = ufshcd_alloc_mcq(hba);
10612-
if (!err) {
10613-
ufshcd_config_mcq(hba);
10614-
} else {
10615-
/* Continue with SDB mode */
10616-
ufshcd_mcq_disable(hba);
10617-
use_mcq_mode = false;
10618-
dev_err(hba->dev, "MCQ mode is disabled, err=%d\n",
10619-
err);
10620-
}
10621-
err = scsi_add_host(host, hba->dev);
10622-
if (err) {
10623-
dev_err(hba->dev, "scsi_add_host failed\n");
10624-
goto out_disable;
10625-
}
10626-
hba->scsi_host_added = true;
10627-
}
10628-
1062910626
err = ufshcd_post_device_init(hba);
1063010627

1063110628
initialized:

0 commit comments

Comments
 (0)