Message ID | 20240905220214.738506-9-bvanassche@acm.org |
---|---|
State | Superseded |
Headers | show |
Series | Simplify the UFS driver initialization code | expand |
On 9/5/2024 3:01 PM, Bart Van Assche wrote: > 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 > ufshcd_post_device_init() calls. This patch also prepares for moving > both scsi_add_host() calls into ufshcd_add_scsi_host(). This patch fixes the issue about scsi_add_host() being called twice introduced in patch #7. It also acknowledged the order swap I mentioned in patch #6. > > Signed-off-by: Bart Van Assche <bvanassche@acm.org> > --- > drivers/ufs/core/ufshcd.c | 39 +++++++++++++++++++-------------------- > 1 file changed, 19 insertions(+), 20 deletions(-) > > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index 014bc74390af..b46e9b526839 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -10379,7 +10379,25 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba) > { > int err; > > - if (!is_mcq_supported(hba)) { > + if (is_mcq_supported(hba)) { > + ufshcd_mcq_enable(hba); > + err = ufshcd_alloc_mcq(hba); > + if (!err) { > + ufshcd_config_mcq(hba); > + } else { > + /* Continue with SDB mode */ > + ufshcd_mcq_disable(hba); > + use_mcq_mode = false; > + dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", > + err); > + } > + err = scsi_add_host(hba->host, hba->dev); > + if (err) { > + dev_err(hba->dev, "scsi_add_host failed\n"); > + return err; > + } > + hba->scsi_host_added = true; > + } else { > err = scsi_add_host(hba->host, hba->dev); > if (err) { > dev_err(hba->dev, "scsi_add_host failed\n"); > @@ -10623,25 +10641,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) > err = ufshcd_device_params_init(hba); > if (err) > goto out_disable; > - if (is_mcq_supported(hba)) { > - ufshcd_mcq_enable(hba); > - err = ufshcd_alloc_mcq(hba); > - if (!err) { > - ufshcd_config_mcq(hba); > - } else { > - /* Continue with SDB mode */ > - ufshcd_mcq_disable(hba); > - use_mcq_mode = false; > - dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", > - err); > - } > - err = scsi_add_host(host, hba->dev); > - if (err) { > - dev_err(hba->dev, "scsi_add_host failed\n"); > - goto out_disable; > - } > - hba->scsi_host_added = true; > - } > > err = ufshcd_post_device_init(hba); > if (err) >
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 014bc74390af..b46e9b526839 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -10379,7 +10379,25 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba) { int err; - if (!is_mcq_supported(hba)) { + if (is_mcq_supported(hba)) { + ufshcd_mcq_enable(hba); + err = ufshcd_alloc_mcq(hba); + if (!err) { + ufshcd_config_mcq(hba); + } else { + /* Continue with SDB mode */ + ufshcd_mcq_disable(hba); + use_mcq_mode = false; + dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", + err); + } + err = scsi_add_host(hba->host, hba->dev); + if (err) { + dev_err(hba->dev, "scsi_add_host failed\n"); + return err; + } + hba->scsi_host_added = true; + } else { err = scsi_add_host(hba->host, hba->dev); if (err) { dev_err(hba->dev, "scsi_add_host failed\n"); @@ -10623,25 +10641,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq) err = ufshcd_device_params_init(hba); if (err) goto out_disable; - if (is_mcq_supported(hba)) { - ufshcd_mcq_enable(hba); - err = ufshcd_alloc_mcq(hba); - if (!err) { - ufshcd_config_mcq(hba); - } else { - /* Continue with SDB mode */ - ufshcd_mcq_disable(hba); - use_mcq_mode = false; - dev_err(hba->dev, "MCQ mode is disabled, err=%d\n", - err); - } - err = scsi_add_host(host, hba->dev); - if (err) { - dev_err(hba->dev, "scsi_add_host failed\n"); - goto out_disable; - } - hba->scsi_host_added = true; - } err = ufshcd_post_device_init(hba); if (err)
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 ufshcd_post_device_init() calls. This patch also prepares for moving both scsi_add_host() calls into ufshcd_add_scsi_host(). Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/ufs/core/ufshcd.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)