Skip to content

Commit 0cab402

Browse files
Asutosh Dasmartinkpetersen
authored andcommitted
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 <[email protected]> Signed-off-by: Can Guo <[email protected]> Signed-off-by: Asutosh Das <[email protected]> Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 305a357 commit 0cab402

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@
9595
/* UFSHC 4.0 compliant HC support this mode, refer param_set_mcq_mode() */
9696
static bool use_mcq_mode = true;
9797

98+
static bool is_mcq_supported(struct ufs_hba *hba)
99+
{
100+
return hba->mcq_sup && use_mcq_mode;
101+
}
102+
98103
static int param_set_mcq_mode(const char *val, const struct kernel_param *kp)
99104
{
100105
int ret;
@@ -8292,6 +8297,7 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
82928297
static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
82938298
{
82948299
int ret;
8300+
struct Scsi_Host *host = hba->host;
82958301

82968302
hba->ufshcd_state = UFSHCD_STATE_RESET;
82978303

@@ -8326,6 +8332,14 @@ static int ufshcd_device_init(struct ufs_hba *hba, bool init_dev_params)
83268332
ret = ufshcd_device_params_init(hba);
83278333
if (ret)
83288334
return ret;
8335+
if (is_mcq_supported(hba) && !hba->scsi_host_added) {
8336+
ret = scsi_add_host(host, hba->dev);
8337+
if (ret) {
8338+
dev_err(hba->dev, "scsi_add_host failed\n");
8339+
return ret;
8340+
}
8341+
hba->scsi_host_added = true;
8342+
}
83298343
}
83308344

83318345
ufshcd_tune_unipro_params(hba);
@@ -9964,10 +9978,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
99649978
hba->is_irq_enabled = true;
99659979
}
99669980

9967-
err = scsi_add_host(host, hba->dev);
9968-
if (err) {
9969-
dev_err(hba->dev, "scsi_add_host failed\n");
9970-
goto out_disable;
9981+
if (!is_mcq_supported(hba)) {
9982+
err = scsi_add_host(host, hba->dev);
9983+
if (err) {
9984+
dev_err(hba->dev, "scsi_add_host failed\n");
9985+
goto out_disable;
9986+
}
99719987
}
99729988

99739989
hba->tmf_tag_set = (struct blk_mq_tag_set) {

include/ufs/ufshcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ struct ufs_hba {
996996
u32 luns_avail;
997997
bool complete_put;
998998
bool ext_iid_sup;
999+
bool scsi_host_added;
9991000
bool mcq_sup;
10001001
};
10011002

0 commit comments

Comments
 (0)