Commit a70e91b8 authored by Yaniv Gardi's avatar Yaniv Gardi Committed by Martin K. Petersen

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.
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 583fa62d
...@@ -1875,21 +1875,7 @@ static int ufshcd_query_attr_retry(struct ufs_hba *hba, ...@@ -1875,21 +1875,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.
*/
static 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)
{ {
...@@ -1953,6 +1939,39 @@ static int ufshcd_query_descriptor(struct ufs_hba *hba, ...@@ -1953,6 +1939,39 @@ static int ufshcd_query_descriptor(struct ufs_hba *hba,
return err; return err;
} }
/**
* ufshcd_query_descriptor_retry - 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_retry(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_retry);
/** /**
* ufshcd_read_desc_param - read the specified descriptor parameter * ufshcd_read_desc_param - read the specified descriptor parameter
* @hba: Pointer to adapter instance * @hba: Pointer to adapter instance
...@@ -1995,9 +2014,9 @@ static int ufshcd_read_desc_param(struct ufs_hba *hba, ...@@ -1995,9 +2014,9 @@ static int ufshcd_read_desc_param(struct ufs_hba *hba,
return -ENOMEM; return -ENOMEM;
} }
ret = ufshcd_query_descriptor(hba, UPIU_QUERY_OPCODE_READ_DESC, ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC,
desc_id, desc_index, 0, desc_buf, desc_id, desc_index, 0, desc_buf,
&buff_len); &buff_len);
if (ret || (buff_len < ufs_query_desc_max_size[desc_id]) || if (ret || (buff_len < ufs_query_desc_max_size[desc_id]) ||
(desc_buf[QUERY_DESC_LENGTH_OFFSET] != (desc_buf[QUERY_DESC_LENGTH_OFFSET] !=
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment