scsi: ufs: core: Defer adding host to SCSI if MCQ is supported
If MCQ support is present, enabling it after MCQ support has been configured would require reallocating tags and memory. It would also free up the already allocated memory in Single Doorbell Mode. So defer invoking scsi_add_host() until MCQ is configured. Co-developed-by: Can Guo <quic_cang@quicinc.com> Signed-off-by: Can Guo <quic_cang@quicinc.com> Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
305a357d35
commit
0cab4023ec
|
@ -95,6 +95,11 @@
|
||||||
/* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */
|
/* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */
|
||||||
static bool use_mcq_mode = true;
|
static bool use_mcq_mode = true;
|
||||||
|
|
||||||
|
static bool is_mcq_supported(struct ufs_hba *hba)
|
||||||
|
{
|
||||||
|
return hba->mcq_sup && use_mcq_mode;
|
||||||
|
}
|
||||||
|
|
||||||
static int param_set_mcq_mode(const char *val, const struct kernel_param *kp)
|
static int param_set_mcq_mode(const char *val, const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -8292,6 +8297,7 @@ out:
|
||||||
static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
|
static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
struct Scsi_Host *host = hba->host;
|
||||||
|
|
||||||
hba->ufshcd_state = UFSHCD_STATE_RESET;
|
hba->ufshcd_state = UFSHCD_STATE_RESET;
|
||||||
|
|
||||||
|
@ -8326,6 +8332,14 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
|
||||||
ret = ufshcd_device_params_init(hba);
|
ret = ufshcd_device_params_init(hba);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
if (is_mcq_supported(hba) && !hba->scsi_host_added) {
|
||||||
|
ret = scsi_add_host(host, hba->dev);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(hba->dev, "scsi_add_host failed\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
hba->scsi_host_added = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ufshcd_tune_unipro_params(hba);
|
ufshcd_tune_unipro_params(hba);
|
||||||
|
@ -9964,10 +9978,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
|
||||||
hba->is_irq_enabled = true;
|
hba->is_irq_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = scsi_add_host(host, hba->dev);
|
if (!is_mcq_supported(hba)) {
|
||||||
if (err) {
|
err = scsi_add_host(host, hba->dev);
|
||||||
dev_err(hba->dev, "scsi_add_host failed\n");
|
if (err) {
|
||||||
goto out_disable;
|
dev_err(hba->dev, "scsi_add_host failed\n");
|
||||||
|
goto out_disable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hba->tmf_tag_set = (struct blk_mq_tag_set) {
|
hba->tmf_tag_set = (struct blk_mq_tag_set) {
|
||||||
|
|
|
@ -996,6 +996,7 @@ struct ufs_hba {
|
||||||
u32 luns_avail;
|
u32 luns_avail;
|
||||||
bool complete_put;
|
bool complete_put;
|
||||||
bool ext_iid_sup;
|
bool ext_iid_sup;
|
||||||
|
bool scsi_host_added;
|
||||||
bool mcq_sup;
|
bool mcq_sup;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue