Skip to content

Commit 6e1d850

Browse files
Asutosh Dasmartinkpetersen
Asutosh Das
authored andcommitted
scsi: ufs: core: Probe for EXT_IID support
Task Tag is limited to 8 bits and this restricts the number of active I/Os to 255. In multi-circular queue mode, this may not be enough. The specification provides EXT_IID which can be used to increase the number of I/Os if the UFS device and UFSHC support it. This patch adds support to probe for EXT_IID support in UFS device and UFSHC. 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: Avri Altman <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Stanley Chu <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 64b6dea commit 6e1d850

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

drivers/ufs/core/ufshcd.c

+32
Original file line numberDiff line numberDiff line change
@@ -2261,6 +2261,10 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
22612261
if (err)
22622262
dev_err(hba->dev, "crypto setup failed\n");
22632263

2264+
hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP);
2265+
hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT,
2266+
hba->mcq_capabilities);
2267+
22642268
return err;
22652269
}
22662270

@@ -7766,6 +7770,31 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf)
77667770
}
77677771
}
77687772

7773+
static void ufshcd_ext_iid_probe(struct ufs_hba *hba, u8 *desc_buf)
7774+
{
7775+
struct ufs_dev_info *dev_info = &hba->dev_info;
7776+
u32 ext_ufs_feature;
7777+
u32 ext_iid_en = 0;
7778+
int err;
7779+
7780+
/* Only UFS-4.0 and above may support EXT_IID */
7781+
if (dev_info->wspecversion < 0x400)
7782+
goto out;
7783+
7784+
ext_ufs_feature = get_unaligned_be32(desc_buf +
7785+
DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);
7786+
if (!(ext_ufs_feature & UFS_DEV_EXT_IID_SUP))
7787+
goto out;
7788+
7789+
err = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
7790+
QUERY_ATTR_IDN_EXT_IID_EN, 0, 0, &ext_iid_en);
7791+
if (err)
7792+
dev_err(hba->dev, "failed reading bEXTIIDEn. err = %d\n", err);
7793+
7794+
out:
7795+
dev_info->b_ext_iid_en = ext_iid_en;
7796+
}
7797+
77697798
void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
77707799
const struct ufs_dev_quirk *fixups)
77717800
{
@@ -7864,6 +7893,9 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
78647893

78657894
ufshcd_temp_notif_probe(hba, desc_buf);
78667895

7896+
if (hba->ext_iid_sup)
7897+
ufshcd_ext_iid_probe(hba, desc_buf);
7898+
78677899
/*
78687900
* ufshcd_read_string_desc returns size of the string
78697901
* reset the error value

include/ufs/ufs.h

+5
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ enum attr_idn {
169169
QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE = 0x1D,
170170
QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E,
171171
QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F,
172+
QUERY_ATTR_IDN_EXT_IID_EN = 0x2A,
172173
};
173174

174175
/* Descriptor idn for Query requests */
@@ -378,6 +379,7 @@ enum {
378379
UFS_DEV_EXT_TEMP_NOTIF = BIT(6),
379380
UFS_DEV_HPB_SUPPORT = BIT(7),
380381
UFS_DEV_WRITE_BOOSTER_SUP = BIT(8),
382+
UFS_DEV_EXT_IID_SUP = BIT(16),
381383
};
382384
#define UFS_DEV_HPB_SUPPORT_VERSION 0x310
383385

@@ -629,6 +631,9 @@ struct ufs_dev_info {
629631
u8 b_presrv_uspc_en;
630632

631633
bool b_advanced_rpmb_en;
634+
635+
/* UFS EXT_IID Enable */
636+
bool b_ext_iid_en;
632637
};
633638

634639
/*

include/ufs/ufshcd.h

+4
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,7 @@ struct ufs_hba_monitor {
757757
* @outstanding_lock: Protects @outstanding_reqs.
758758
* @outstanding_reqs: Bits representing outstanding transfer requests
759759
* @capabilities: UFS Controller Capabilities
760+
* @mcq_capabilities: UFS Multi Circular Queue capabilities
760761
* @nutrs: Transfer Request Queue depth supported by controller
761762
* @nutmrs: Task Management Queue depth supported by controller
762763
* @reserved_slot: Used to submit device commands. Protected by @dev_cmd.lock.
@@ -841,6 +842,7 @@ struct ufs_hba_monitor {
841842
* device
842843
* @complete_put: whether or not to call ufshcd_rpm_put() from inside
843844
* ufshcd_resume_complete()
845+
* @ext_iid_sup: is EXT_IID is supported by UFSHC
844846
*/
845847
struct ufs_hba {
846848
void __iomem *mmio_base;
@@ -882,6 +884,7 @@ struct ufs_hba {
882884

883885
u32 capabilities;
884886
int nutrs;
887+
u32 mcq_capabilities;
885888
int nutmrs;
886889
u32 reserved_slot;
887890
u32 ufs_version;
@@ -991,6 +994,7 @@ struct ufs_hba {
991994
#endif
992995
u32 luns_avail;
993996
bool complete_put;
997+
bool ext_iid_sup;
994998
};
995999

9961000
#ifdef CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE

include/ufs/ufshci.h

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum {
2222
/* UFSHCI Registers */
2323
enum {
2424
REG_CONTROLLER_CAPABILITIES = 0x00,
25+
REG_MCQCAP = 0x04,
2526
REG_UFS_VERSION = 0x08,
2627
REG_CONTROLLER_DEV_ID = 0x10,
2728
REG_CONTROLLER_PROD_ID = 0x14,
@@ -69,6 +70,12 @@ enum {
6970
MASK_OUT_OF_ORDER_DATA_DELIVERY_SUPPORT = 0x02000000,
7071
MASK_UIC_DME_TEST_MODE_SUPPORT = 0x04000000,
7172
MASK_CRYPTO_SUPPORT = 0x10000000,
73+
MASK_MCQ_SUPPORT = 0x40000000,
74+
};
75+
76+
/* MCQ capability mask */
77+
enum {
78+
MASK_EXT_IID_SUPPORT = 0x00000400,
7279
};
7380

7481
#define UFS_MASK(mask, offset) ((mask) << (offset))

0 commit comments

Comments
 (0)