diff options
author | Yaniv Gardi <ygardi@codeaurora.org> | 2016-03-10 10:37:14 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-03-14 21:04:45 -0400 |
commit | a70e91b8bbaa3924d6598f9b4d1d468d2c88e6d3 (patch) | |
tree | 914eb7cf0c893c6ee4fb2242868a0992112f899b | |
parent | 583fa62d082483412715af9ab4f528fcf00e4c38 (diff) |
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: Hannes Reinecke <hare@suse.de>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Yaniv Gardi <ygardi@codeaurora.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 4eedb7fafa95..b429a57984a2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c | |||
@@ -1875,21 +1875,7 @@ static int ufshcd_query_attr_retry(struct ufs_hba *hba, | |||
1875 | return ret; | 1875 | return ret; |
1876 | } | 1876 | } |
1877 | 1877 | ||
1878 | /** | 1878 | static int __ufshcd_query_descriptor(struct ufs_hba *hba, |
1879 | * ufshcd_query_descriptor - API function for sending descriptor requests | ||
1880 | * hba: per-adapter instance | ||
1881 | * opcode: attribute opcode | ||
1882 | * idn: attribute idn to access | ||
1883 | * index: index field | ||
1884 | * selector: selector field | ||
1885 | * desc_buf: the buffer that contains the descriptor | ||
1886 | * buf_len: length parameter passed to the device | ||
1887 | * | ||
1888 | * Returns 0 for success, non-zero in case of failure. | ||
1889 | * The buf_len parameter will contain, on return, the length parameter | ||
1890 | * received on the response. | ||
1891 | */ | ||
1892 | static int ufshcd_query_descriptor(struct ufs_hba *hba, | ||
1893 | enum query_opcode opcode, enum desc_idn idn, u8 index, | 1879 | enum query_opcode opcode, enum desc_idn idn, u8 index, |
1894 | u8 selector, u8 *desc_buf, int *buf_len) | 1880 | u8 selector, u8 *desc_buf, int *buf_len) |
1895 | { | 1881 | { |
@@ -1954,6 +1940,39 @@ out: | |||
1954 | } | 1940 | } |
1955 | 1941 | ||
1956 | /** | 1942 | /** |
1943 | * ufshcd_query_descriptor_retry - API function for sending descriptor | ||
1944 | * requests | ||
1945 | * hba: per-adapter instance | ||
1946 | * opcode: attribute opcode | ||
1947 | * idn: attribute idn to access | ||
1948 | * index: index field | ||
1949 | * selector: selector field | ||
1950 | * desc_buf: the buffer that contains the descriptor | ||
1951 | * buf_len: length parameter passed to the device | ||
1952 | * | ||
1953 | * Returns 0 for success, non-zero in case of failure. | ||
1954 | * The buf_len parameter will contain, on return, the length parameter | ||
1955 | * received on the response. | ||
1956 | */ | ||
1957 | int ufshcd_query_descriptor_retry(struct ufs_hba *hba, | ||
1958 | enum query_opcode opcode, enum desc_idn idn, u8 index, | ||
1959 | u8 selector, u8 *desc_buf, int *buf_len) | ||
1960 | { | ||
1961 | int err; | ||
1962 | int retries; | ||
1963 | |||
1964 | for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) { | ||
1965 | err = __ufshcd_query_descriptor(hba, opcode, idn, index, | ||
1966 | selector, desc_buf, buf_len); | ||
1967 | if (!err || err == -EINVAL) | ||
1968 | break; | ||
1969 | } | ||
1970 | |||
1971 | return err; | ||
1972 | } | ||
1973 | EXPORT_SYMBOL(ufshcd_query_descriptor_retry); | ||
1974 | |||
1975 | /** | ||
1957 | * ufshcd_read_desc_param - read the specified descriptor parameter | 1976 | * ufshcd_read_desc_param - read the specified descriptor parameter |
1958 | * @hba: Pointer to adapter instance | 1977 | * @hba: Pointer to adapter instance |
1959 | * @desc_id: descriptor idn value | 1978 | * @desc_id: descriptor idn value |
@@ -1995,9 +2014,9 @@ static int ufshcd_read_desc_param(struct ufs_hba *hba, | |||
1995 | return -ENOMEM; | 2014 | return -ENOMEM; |
1996 | } | 2015 | } |
1997 | 2016 | ||
1998 | ret = ufshcd_query_descriptor(hba, UPIU_QUERY_OPCODE_READ_DESC, | 2017 | ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, |
1999 | desc_id, desc_index, 0, desc_buf, | 2018 | desc_id, desc_index, 0, desc_buf, |
2000 | &buff_len); | 2019 | &buff_len); |
2001 | 2020 | ||
2002 | if (ret || (buff_len < ufs_query_desc_max_size[desc_id]) || | 2021 | if (ret || (buff_len < ufs_query_desc_max_size[desc_id]) || |
2003 | (desc_buf[QUERY_DESC_LENGTH_OFFSET] != | 2022 | (desc_buf[QUERY_DESC_LENGTH_OFFSET] != |