Skip to content

Commit 0c60eb0

Browse files
KyoungrulKimmartinkpetersen
authored andcommitted
scsi: ufs: core: Check LSDBS cap when !mcq
If the user sets use_mcq_mode to 0, the host will try to activate the LSDB mode unconditionally even when the LSDBS of device HCI cap is 1. This makes commands time out and causes device probing to fail. To prevent that problem, check the LSDBS cap when MCQ is not supported. Signed-off-by: Kyoungrul Kim <k831.kim@samsung.com> Link: https://lore.kernel.org/r/20240709232520epcms2p8ebdb5c4fccc30a6221390566589bf122@epcms2p8 Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 23cef42 commit 0c60eb0

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2416,7 +2416,17 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
24162416
return err;
24172417
}
24182418

2419+
/*
2420+
* The UFSHCI 3.0 specification does not define MCQ_SUPPORT and
2421+
* LSDB_SUPPORT, but [31:29] as reserved bits with reset value 0s, which
2422+
* means we can simply read values regardless of version.
2423+
*/
24192424
hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
2425+
/*
2426+
* 0h: legacy single doorbell support is available
2427+
* 1h: indicate that legacy single doorbell support has been removed
2428+
*/
2429+
hba->lsdb_sup = !FIELD_GET(MASK_LSDB_SUPPORT, hba->capabilities);
24202430
if (!hba->mcq_sup)
24212431
return 0;
24222432

@@ -10494,6 +10504,12 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
1049410504
}
1049510505

1049610506
if (!is_mcq_supported(hba)) {
10507+
if (!hba->lsdb_sup) {
10508+
dev_err(hba->dev, "%s: failed to initialize (legacy doorbell mode not supported)\n",
10509+
__func__);
10510+
err = -EINVAL;
10511+
goto out_disable;
10512+
}
1049710513
err = scsi_add_host(host, hba->dev);
1049810514
if (err) {
1049910515
dev_err(hba->dev, "scsi_add_host failed\n");

include/ufs/ufshcd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ struct ufs_hba {
11091109
bool ext_iid_sup;
11101110
bool scsi_host_added;
11111111
bool mcq_sup;
1112+
bool lsdb_sup;
11121113
bool mcq_enabled;
11131114
struct ufshcd_res_info res[RES_MAX];
11141115
void __iomem *mcq_base;

include/ufs/ufshci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ enum {
7777
MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT = 0x02000000,
7878
MASK_UIC_DME_TEST_MODE_SUPPORT = 0x04000000,
7979
MASK_CRYPTO_SUPPORT = 0x10000000,
80+
MASK_LSDB_SUPPORT = 0x20000000,
8081
MASK_MCQ_SUPPORT = 0x40000000,
8182
};
8283

0 commit comments

Comments
 (0)