scsi: ufs: add retry for query descriptors
Query commands have 100ms timeout and it may timeout if they are issued in parallel to ongoing read/write SCSI commands, this change adds the retry (max: 10) in case command timeouts. Change-Id: If60e2dd85614c8e383018b1286a625a5e53f872f Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit is contained in:
parent
e90b56093b
commit
5b5bf8724c
1 changed files with 40 additions and 65 deletions
|
@ -3055,21 +3055,7 @@ static int ufshcd_query_attr_retry(struct ufs_hba *hba,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static int __ufshcd_query_descriptor(struct ufs_hba *hba,
|
||||||
* ufshcd_query_descriptor - API function for sending descriptor requests
|
|
||||||
* hba: per-adapter instance
|
|
||||||
* opcode: attribute opcode
|
|
||||||
* idn: attribute idn to access
|
|
||||||
* index: index field
|
|
||||||
* selector: selector field
|
|
||||||
* desc_buf: the buffer that contains the descriptor
|
|
||||||
* buf_len: length parameter passed to the device
|
|
||||||
*
|
|
||||||
* Returns 0 for success, non-zero in case of failure.
|
|
||||||
* The buf_len parameter will contain, on return, the length parameter
|
|
||||||
* received on the response.
|
|
||||||
*/
|
|
||||||
int ufshcd_query_descriptor(struct ufs_hba *hba,
|
|
||||||
enum query_opcode opcode, enum desc_idn idn, u8 index,
|
enum query_opcode opcode, enum desc_idn idn, u8 index,
|
||||||
u8 selector, u8 *desc_buf, int *buf_len)
|
u8 selector, u8 *desc_buf, int *buf_len)
|
||||||
{
|
{
|
||||||
|
@ -3132,6 +3118,37 @@ out:
|
||||||
ufshcd_release_all(hba);
|
ufshcd_release_all(hba);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ufshcd_query_descriptor - API function for sending descriptor requests
|
||||||
|
* hba: per-adapter instance
|
||||||
|
* opcode: attribute opcode
|
||||||
|
* idn: attribute idn to access
|
||||||
|
* index: index field
|
||||||
|
* selector: selector field
|
||||||
|
* desc_buf: the buffer that contains the descriptor
|
||||||
|
* buf_len: length parameter passed to the device
|
||||||
|
*
|
||||||
|
* Returns 0 for success, non-zero in case of failure.
|
||||||
|
* The buf_len parameter will contain, on return, the length parameter
|
||||||
|
* received on the response.
|
||||||
|
*/
|
||||||
|
int ufshcd_query_descriptor(struct ufs_hba *hba,
|
||||||
|
enum query_opcode opcode, enum desc_idn idn, u8 index,
|
||||||
|
u8 selector, u8 *desc_buf, int *buf_len)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
int retries;
|
||||||
|
|
||||||
|
for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
|
||||||
|
err = __ufshcd_query_descriptor(hba, opcode, idn, index,
|
||||||
|
selector, desc_buf, buf_len);
|
||||||
|
if (!err || err == -EINVAL)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
EXPORT_SYMBOL(ufshcd_query_descriptor);
|
EXPORT_SYMBOL(ufshcd_query_descriptor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3236,39 +3253,12 @@ static inline int ufshcd_read_power_desc(struct ufs_hba *hba,
|
||||||
u8 *buf,
|
u8 *buf,
|
||||||
u32 size)
|
u32 size)
|
||||||
{
|
{
|
||||||
int err = 0;
|
return ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size);
|
||||||
int retries;
|
|
||||||
|
|
||||||
for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
|
|
||||||
/* Read descriptor*/
|
|
||||||
err = ufshcd_read_desc(hba, QUERY_DESC_IDN_POWER, 0, buf, size);
|
|
||||||
if (!err)
|
|
||||||
break;
|
|
||||||
dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size)
|
int ufshcd_read_device_desc(struct ufs_hba *hba, u8 *buf, u32 size)
|
||||||
{
|
{
|
||||||
int err = 0;
|
return ufshcd_read_desc(hba, QUERY_DESC_IDN_DEVICE, 0, buf, size);
|
||||||
int retries;
|
|
||||||
|
|
||||||
for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
|
|
||||||
/* Read descriptor*/
|
|
||||||
err = ufshcd_read_desc(hba,
|
|
||||||
QUERY_DESC_IDN_DEVICE, 0, buf, size);
|
|
||||||
if (!err)
|
|
||||||
break;
|
|
||||||
dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err)
|
|
||||||
dev_err(hba->dev, "%s: reading Device Desc failed. err = %d\n",
|
|
||||||
__func__, err);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3285,16 +3275,9 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, u8 *buf,
|
||||||
u32 size, bool ascii)
|
u32 size, bool ascii)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
int retries;
|
|
||||||
|
|
||||||
for (retries = 0; retries < QUERY_REQ_RETRIES; retries++) {
|
|
||||||
err = ufshcd_read_desc(hba,
|
err = ufshcd_read_desc(hba,
|
||||||
QUERY_DESC_IDN_STRING, desc_index, buf, size);
|
QUERY_DESC_IDN_STRING, desc_index, buf, size);
|
||||||
if (!err)
|
|
||||||
break;
|
|
||||||
dev_dbg(hba->dev, "%s: error %d retrying %d\n", __func__, err,
|
|
||||||
retries);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
dev_err(hba->dev, "%s: reading String Desc failed after %d retries. err = %d\n",
|
dev_err(hba->dev, "%s: reading String Desc failed after %d retries. err = %d\n",
|
||||||
|
@ -4505,24 +4488,16 @@ static void ufshcd_set_queue_depth(struct scsi_device *sdev)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
u8 lun_qdepth;
|
u8 lun_qdepth;
|
||||||
int retries;
|
|
||||||
struct ufs_hba *hba;
|
struct ufs_hba *hba;
|
||||||
|
|
||||||
hba = shost_priv(sdev->host);
|
hba = shost_priv(sdev->host);
|
||||||
|
|
||||||
lun_qdepth = hba->nutrs;
|
lun_qdepth = hba->nutrs;
|
||||||
for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
|
|
||||||
/* Read descriptor*/
|
|
||||||
ret = ufshcd_read_unit_desc_param(hba,
|
ret = ufshcd_read_unit_desc_param(hba,
|
||||||
ufshcd_scsi_to_upiu_lun(sdev->lun),
|
ufshcd_scsi_to_upiu_lun(sdev->lun),
|
||||||
UNIT_DESC_PARAM_LU_Q_DEPTH,
|
UNIT_DESC_PARAM_LU_Q_DEPTH,
|
||||||
&lun_qdepth,
|
&lun_qdepth,
|
||||||
sizeof(lun_qdepth));
|
sizeof(lun_qdepth));
|
||||||
if (!ret || ret == -ENOTSUPP)
|
|
||||||
break;
|
|
||||||
|
|
||||||
dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some WLUN doesn't support unit descriptor */
|
/* Some WLUN doesn't support unit descriptor */
|
||||||
if (ret == -EOPNOTSUPP)
|
if (ret == -EOPNOTSUPP)
|
||||||
|
|
Loading…
Add table
Reference in a new issue