aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDolev Raviv <draviv@codeaurora.org>2013-07-29 15:05:58 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-08-26 04:51:25 -0400
commit68078d5cc1a59b2ddfc6982c67308f20f991426a (patch)
tree9fe1fee824c92ff6eacfcb0ebc9f1f39e683966d /drivers
parent5a0b0cb9bee767ef10ff9ce2fb4141af06416288 (diff)
[SCSI] ufs: Set fDeviceInit flag to initiate device initialization
Allow UFS device to complete its initialization and accept SCSI commands by setting fDeviceInit flag. The device may take time for this operation and hence the host should poll until fDeviceInit flag is toggled to zero. This step is mandated by UFS device specification for device initialization completion. Signed-off-by: Dolev Raviv <draviv@codeaurora.org> Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org> Signed-off-by: Santosh Y <santoshsy@gmail.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/ufs/ufs.h96
-rw-r--r--drivers/scsi/ufs/ufshcd.c238
-rw-r--r--drivers/scsi/ufs/ufshcd.h20
-rw-r--r--drivers/scsi/ufs/ufshci.h2
4 files changed, 345 insertions, 11 deletions
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h
index 51b5e3f72bcb..50d32f16ece0 100644
--- a/drivers/scsi/ufs/ufs.h
+++ b/drivers/scsi/ufs/ufs.h
@@ -40,6 +40,10 @@
40#include <linux/types.h> 40#include <linux/types.h>
41 41
42#define MAX_CDB_SIZE 16 42#define MAX_CDB_SIZE 16
43#define GENERAL_UPIU_REQUEST_SIZE 32
44#define QUERY_DESC_MAX_SIZE 256
45#define QUERY_OSF_SIZE (GENERAL_UPIU_REQUEST_SIZE - \
46 (sizeof(struct utp_upiu_header)))
43 47
44#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\ 48#define UPIU_HEADER_DWORD(byte3, byte2, byte1, byte0)\
45 cpu_to_be32((byte3 << 24) | (byte2 << 16) |\ 49 cpu_to_be32((byte3 << 24) | (byte2 << 16) |\
@@ -65,7 +69,7 @@ enum {
65 UPIU_TRANSACTION_COMMAND = 0x01, 69 UPIU_TRANSACTION_COMMAND = 0x01,
66 UPIU_TRANSACTION_DATA_OUT = 0x02, 70 UPIU_TRANSACTION_DATA_OUT = 0x02,
67 UPIU_TRANSACTION_TASK_REQ = 0x04, 71 UPIU_TRANSACTION_TASK_REQ = 0x04,
68 UPIU_TRANSACTION_QUERY_REQ = 0x26, 72 UPIU_TRANSACTION_QUERY_REQ = 0x16,
69}; 73};
70 74
71/* UTP UPIU Transaction Codes Target to Initiator */ 75/* UTP UPIU Transaction Codes Target to Initiator */
@@ -94,8 +98,19 @@ enum {
94 UPIU_TASK_ATTR_ACA = 0x03, 98 UPIU_TASK_ATTR_ACA = 0x03,
95}; 99};
96 100
97/* UTP QUERY Transaction Specific Fields OpCode */ 101/* UPIU Query request function */
98enum { 102enum {
103 UPIU_QUERY_FUNC_STANDARD_READ_REQUEST = 0x01,
104 UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST = 0x81,
105};
106
107/* Flag idn for Query Requests*/
108enum flag_idn {
109 QUERY_FLAG_IDN_FDEVICEINIT = 0x01,
110};
111
112/* UTP QUERY Transaction Specific Fields OpCode */
113enum query_opcode {
99 UPIU_QUERY_OPCODE_NOP = 0x0, 114 UPIU_QUERY_OPCODE_NOP = 0x0,
100 UPIU_QUERY_OPCODE_READ_DESC = 0x1, 115 UPIU_QUERY_OPCODE_READ_DESC = 0x1,
101 UPIU_QUERY_OPCODE_WRITE_DESC = 0x2, 116 UPIU_QUERY_OPCODE_WRITE_DESC = 0x2,
@@ -107,6 +122,21 @@ enum {
107 UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8, 122 UPIU_QUERY_OPCODE_TOGGLE_FLAG = 0x8,
108}; 123};
109 124
125/* Query response result code */
126enum {
127 QUERY_RESULT_SUCCESS = 0x00,
128 QUERY_RESULT_NOT_READABLE = 0xF6,
129 QUERY_RESULT_NOT_WRITEABLE = 0xF7,
130 QUERY_RESULT_ALREADY_WRITTEN = 0xF8,
131 QUERY_RESULT_INVALID_LENGTH = 0xF9,
132 QUERY_RESULT_INVALID_VALUE = 0xFA,
133 QUERY_RESULT_INVALID_SELECTOR = 0xFB,
134 QUERY_RESULT_INVALID_INDEX = 0xFC,
135 QUERY_RESULT_INVALID_IDN = 0xFD,
136 QUERY_RESULT_INVALID_OPCODE = 0xFE,
137 QUERY_RESULT_GENERAL_FAILURE = 0xFF,
138};
139
110/* UTP Transfer Request Command Type (CT) */ 140/* UTP Transfer Request Command Type (CT) */
111enum { 141enum {
112 UPIU_COMMAND_SET_TYPE_SCSI = 0x0, 142 UPIU_COMMAND_SET_TYPE_SCSI = 0x0,
@@ -121,9 +151,10 @@ enum {
121#define UPIU_RSP_CODE_OFFSET 8 151#define UPIU_RSP_CODE_OFFSET 8
122 152
123enum { 153enum {
124 MASK_SCSI_STATUS = 0xFF, 154 MASK_SCSI_STATUS = 0xFF,
125 MASK_TASK_RESPONSE = 0xFF00, 155 MASK_TASK_RESPONSE = 0xFF00,
126 MASK_RSP_UPIU_RESULT = 0xFFFF, 156 MASK_RSP_UPIU_RESULT = 0xFFFF,
157 MASK_QUERY_DATA_SEG_LEN = 0xFFFF,
127}; 158};
128 159
129/* Task management service response */ 160/* Task management service response */
@@ -157,13 +188,40 @@ struct utp_upiu_cmd {
157}; 188};
158 189
159/** 190/**
191 * struct utp_upiu_query - upiu request buffer structure for
192 * query request.
193 * @opcode: command to perform B-0
194 * @idn: a value that indicates the particular type of data B-1
195 * @index: Index to further identify data B-2
196 * @selector: Index to further identify data B-3
197 * @reserved_osf: spec reserved field B-4,5
198 * @length: number of descriptor bytes to read/write B-6,7
199 * @value: Attribute value to be written DW-5
200 * @reserved: spec reserved DW-6,7
201 */
202struct utp_upiu_query {
203 u8 opcode;
204 u8 idn;
205 u8 index;
206 u8 selector;
207 u16 reserved_osf;
208 u16 length;
209 u32 value;
210 u32 reserved[2];
211};
212
213/**
160 * struct utp_upiu_req - general upiu request structure 214 * struct utp_upiu_req - general upiu request structure
161 * @header:UPIU header structure DW-0 to DW-2 215 * @header:UPIU header structure DW-0 to DW-2
162 * @sc: fields structure for scsi command DW-3 to DW-7 216 * @sc: fields structure for scsi command DW-3 to DW-7
217 * @qr: fields structure for query request DW-3 to DW-7
163 */ 218 */
164struct utp_upiu_req { 219struct utp_upiu_req {
165 struct utp_upiu_header header; 220 struct utp_upiu_header header;
166 struct utp_upiu_cmd sc; 221 union {
222 struct utp_upiu_cmd sc;
223 struct utp_upiu_query qr;
224 };
167}; 225};
168 226
169/** 227/**
@@ -184,10 +242,14 @@ struct utp_cmd_rsp {
184 * struct utp_upiu_rsp - general upiu response structure 242 * struct utp_upiu_rsp - general upiu response structure
185 * @header: UPIU header structure DW-0 to DW-2 243 * @header: UPIU header structure DW-0 to DW-2
186 * @sr: fields structure for scsi command DW-3 to DW-12 244 * @sr: fields structure for scsi command DW-3 to DW-12
245 * @qr: fields structure for query request DW-3 to DW-7
187 */ 246 */
188struct utp_upiu_rsp { 247struct utp_upiu_rsp {
189 struct utp_upiu_header header; 248 struct utp_upiu_header header;
190 struct utp_cmd_rsp sr; 249 union {
250 struct utp_cmd_rsp sr;
251 struct utp_upiu_query qr;
252 };
191}; 253};
192 254
193/** 255/**
@@ -220,4 +282,24 @@ struct utp_upiu_task_rsp {
220 u32 reserved[3]; 282 u32 reserved[3];
221}; 283};
222 284
285/**
286 * struct ufs_query_req - parameters for building a query request
287 * @query_func: UPIU header query function
288 * @upiu_req: the query request data
289 */
290struct ufs_query_req {
291 u8 query_func;
292 struct utp_upiu_query upiu_req;
293};
294
295/**
296 * struct ufs_query_resp - UPIU QUERY
297 * @response: device response code
298 * @upiu_res: query response data
299 */
300struct ufs_query_res {
301 u8 response;
302 struct utp_upiu_query upiu_res;
303};
304
223#endif /* End of Header */ 305#endif /* End of Header */
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ed2015672982..7b581f7c3ed5 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -48,6 +48,14 @@
48/* Timeout after 30 msecs if NOP OUT hangs without response */ 48/* Timeout after 30 msecs if NOP OUT hangs without response */
49#define NOP_OUT_TIMEOUT 30 /* msecs */ 49#define NOP_OUT_TIMEOUT 30 /* msecs */
50 50
51/* Query request retries */
52#define QUERY_REQ_RETRIES 10
53/* Query request timeout */
54#define QUERY_REQ_TIMEOUT 30 /* msec */
55
56/* Expose the flag value from utp_upiu_query.value */
57#define MASK_QUERY_UPIU_FLAG_LOC 0xFF
58
51enum { 59enum {
52 UFSHCD_MAX_CHANNEL = 0, 60 UFSHCD_MAX_CHANNEL = 0,
53 UFSHCD_MAX_ID = 1, 61 UFSHCD_MAX_ID = 1,
@@ -341,6 +349,60 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp)
341} 349}
342 350
343/** 351/**
352 * ufshcd_query_to_cpu() - formats the buffer to native cpu endian
353 * @response: upiu query response to convert
354 */
355static inline void ufshcd_query_to_cpu(struct utp_upiu_query *response)
356{
357 response->length = be16_to_cpu(response->length);
358 response->value = be32_to_cpu(response->value);
359}
360
361/**
362 * ufshcd_query_to_be() - formats the buffer to big endian
363 * @request: upiu query request to convert
364 */
365static inline void ufshcd_query_to_be(struct utp_upiu_query *request)
366{
367 request->length = cpu_to_be16(request->length);
368 request->value = cpu_to_be32(request->value);
369}
370
371/**
372 * ufshcd_copy_query_response() - Copy the Query Response and the data
373 * descriptor
374 * @hba: per adapter instance
375 * @lrb - pointer to local reference block
376 */
377static
378void ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
379{
380 struct ufs_query_res *query_res = &hba->dev_cmd.query.response;
381
382 /* Get the UPIU response */
383 query_res->response = ufshcd_get_rsp_upiu_result(lrbp->ucd_rsp_ptr) >>
384 UPIU_RSP_CODE_OFFSET;
385
386 memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE);
387 ufshcd_query_to_cpu(&query_res->upiu_res);
388
389
390 /* Get the descriptor */
391 if (lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) {
392 u8 *descp = (u8 *)&lrbp->ucd_rsp_ptr +
393 GENERAL_UPIU_REQUEST_SIZE;
394 u16 len;
395
396 /* data segment length */
397 len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2) &
398 MASK_QUERY_DATA_SEG_LEN;
399
400 memcpy(hba->dev_cmd.query.descriptor, descp,
401 min_t(u16, len, QUERY_DESC_MAX_SIZE));
402 }
403}
404
405/**
344 * ufshcd_hba_capabilities - Read controller capabilities 406 * ufshcd_hba_capabilities - Read controller capabilities
345 * @hba: per adapter instance 407 * @hba: per adapter instance
346 */ 408 */
@@ -622,6 +684,45 @@ void ufshcd_prepare_utp_scsi_cmd_upiu(struct ufshcd_lrb *lrbp, u32 upiu_flags)
622 (min_t(unsigned short, lrbp->cmd->cmd_len, MAX_CDB_SIZE))); 684 (min_t(unsigned short, lrbp->cmd->cmd_len, MAX_CDB_SIZE)));
623} 685}
624 686
687/**
688 * ufshcd_prepare_utp_query_req_upiu() - fills the utp_transfer_req_desc,
689 * for query requsts
690 * @hba: UFS hba
691 * @lrbp: local reference block pointer
692 * @upiu_flags: flags
693 */
694static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
695 struct ufshcd_lrb *lrbp, u32 upiu_flags)
696{
697 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
698 struct ufs_query *query = &hba->dev_cmd.query;
699 u16 len = query->request.upiu_req.length;
700 u8 *descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE;
701
702 /* Query request header */
703 ucd_req_ptr->header.dword_0 = UPIU_HEADER_DWORD(
704 UPIU_TRANSACTION_QUERY_REQ, upiu_flags,
705 lrbp->lun, lrbp->task_tag);
706 ucd_req_ptr->header.dword_1 = UPIU_HEADER_DWORD(
707 0, query->request.query_func, 0, 0);
708
709 /* Data segment length */
710 ucd_req_ptr->header.dword_2 = UPIU_HEADER_DWORD(
711 0, 0, len >> 8, (u8)len);
712
713 /* Copy the Query Request buffer as is */
714 memcpy(&ucd_req_ptr->qr, &query->request.upiu_req,
715 QUERY_OSF_SIZE);
716 ufshcd_query_to_be(&ucd_req_ptr->qr);
717
718 /* Copy the Descriptor */
719 if ((len > 0) && (query->request.upiu_req.opcode ==
720 UPIU_QUERY_OPCODE_WRITE_DESC)) {
721 memcpy(descp, query->descriptor,
722 min_t(u16, len, QUERY_DESC_MAX_SIZE));
723 }
724}
725
625static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp) 726static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
626{ 727{
627 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; 728 struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr;
@@ -656,7 +757,10 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
656 break; 757 break;
657 case UTP_CMD_TYPE_DEV_MANAGE: 758 case UTP_CMD_TYPE_DEV_MANAGE:
658 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE); 759 ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
659 if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP) 760 if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
761 ufshcd_prepare_utp_query_req_upiu(
762 hba, lrbp, upiu_flags);
763 else if (hba->dev_cmd.type == DEV_CMD_TYPE_NOP)
660 ufshcd_prepare_utp_nop_upiu(lrbp); 764 ufshcd_prepare_utp_nop_upiu(lrbp);
661 else 765 else
662 ret = -EINVAL; 766 ret = -EINVAL;
@@ -800,6 +904,9 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
800 __func__, resp); 904 __func__, resp);
801 } 905 }
802 break; 906 break;
907 case UPIU_TRANSACTION_QUERY_RSP:
908 ufshcd_copy_query_response(hba, lrbp);
909 break;
803 case UPIU_TRANSACTION_REJECT_UPIU: 910 case UPIU_TRANSACTION_REJECT_UPIU:
804 /* TODO: handle Reject UPIU Response */ 911 /* TODO: handle Reject UPIU Response */
805 err = -EPERM; 912 err = -EPERM;
@@ -889,8 +996,8 @@ static inline void ufshcd_put_dev_cmd_tag(struct ufs_hba *hba, int tag)
889 * @cmd_type - specifies the type (NOP, Query...) 996 * @cmd_type - specifies the type (NOP, Query...)
890 * @timeout - time in seconds 997 * @timeout - time in seconds
891 * 998 *
892 * NOTE: There is only one available tag for device management commands. Thus 999 * NOTE: Since there is only one available tag for device management commands,
893 * synchronisation is the responsibilty of the user. 1000 * it is expected you hold the hba->dev_cmd.lock mutex.
894 */ 1001 */
895static int ufshcd_exec_dev_cmd(struct ufs_hba *hba, 1002static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
896 enum dev_cmd_type cmd_type, int timeout) 1003 enum dev_cmd_type cmd_type, int timeout)
@@ -930,6 +1037,76 @@ out_put_tag:
930} 1037}
931 1038
932/** 1039/**
1040 * ufshcd_query_flag() - API function for sending flag query requests
1041 * hba: per-adapter instance
1042 * query_opcode: flag query to perform
1043 * idn: flag idn to access
1044 * flag_res: the flag value after the query request completes
1045 *
1046 * Returns 0 for success, non-zero in case of failure
1047 */
1048static int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
1049 enum flag_idn idn, bool *flag_res)
1050{
1051 struct ufs_query_req *request;
1052 struct ufs_query_res *response;
1053 int err;
1054
1055 BUG_ON(!hba);
1056
1057 mutex_lock(&hba->dev_cmd.lock);
1058 request = &hba->dev_cmd.query.request;
1059 response = &hba->dev_cmd.query.response;
1060 memset(request, 0, sizeof(struct ufs_query_req));
1061 memset(response, 0, sizeof(struct ufs_query_res));
1062
1063 switch (opcode) {
1064 case UPIU_QUERY_OPCODE_SET_FLAG:
1065 case UPIU_QUERY_OPCODE_CLEAR_FLAG:
1066 case UPIU_QUERY_OPCODE_TOGGLE_FLAG:
1067 request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST;
1068 break;
1069 case UPIU_QUERY_OPCODE_READ_FLAG:
1070 request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST;
1071 if (!flag_res) {
1072 /* No dummy reads */
1073 dev_err(hba->dev, "%s: Invalid argument for read request\n",
1074 __func__);
1075 err = -EINVAL;
1076 goto out_unlock;
1077 }
1078 break;
1079 default:
1080 dev_err(hba->dev,
1081 "%s: Expected query flag opcode but got = %d\n",
1082 __func__, opcode);
1083 err = -EINVAL;
1084 goto out_unlock;
1085 }
1086 request->upiu_req.opcode = opcode;
1087 request->upiu_req.idn = idn;
1088
1089 /* Send query request */
1090 err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY,
1091 QUERY_REQ_TIMEOUT);
1092
1093 if (err) {
1094 dev_err(hba->dev,
1095 "%s: Sending flag query for idn %d failed, err = %d\n",
1096 __func__, idn, err);
1097 goto out_unlock;
1098 }
1099
1100 if (flag_res)
1101 *flag_res = (response->upiu_res.value &
1102 MASK_QUERY_UPIU_FLAG_LOC) & 0x1;
1103
1104out_unlock:
1105 mutex_unlock(&hba->dev_cmd.lock);
1106 return err;
1107}
1108
1109/**
933 * ufshcd_memory_alloc - allocate memory for host memory space data structures 1110 * ufshcd_memory_alloc - allocate memory for host memory space data structures
934 * @hba: per adapter instance 1111 * @hba: per adapter instance
935 * 1112 *
@@ -1099,6 +1276,57 @@ static int ufshcd_dme_link_startup(struct ufs_hba *hba)
1099} 1276}
1100 1277
1101/** 1278/**
1279 * ufshcd_complete_dev_init() - checks device readiness
1280 * hba: per-adapter instance
1281 *
1282 * Set fDeviceInit flag and poll until device toggles it.
1283 */
1284static int ufshcd_complete_dev_init(struct ufs_hba *hba)
1285{
1286 int i, retries, err = 0;
1287 bool flag_res = 1;
1288
1289 for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
1290 /* Set the fDeviceInit flag */
1291 err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_SET_FLAG,
1292 QUERY_FLAG_IDN_FDEVICEINIT, NULL);
1293 if (!err || err == -ETIMEDOUT)
1294 break;
1295 dev_dbg(hba->dev, "%s: error %d retrying\n", __func__, err);
1296 }
1297 if (err) {
1298 dev_err(hba->dev,
1299 "%s setting fDeviceInit flag failed with error %d\n",
1300 __func__, err);
1301 goto out;
1302 }
1303
1304 /* poll for max. 100 iterations for fDeviceInit flag to clear */
1305 for (i = 0; i < 100 && !err && flag_res; i++) {
1306 for (retries = QUERY_REQ_RETRIES; retries > 0; retries--) {
1307 err = ufshcd_query_flag(hba,
1308 UPIU_QUERY_OPCODE_READ_FLAG,
1309 QUERY_FLAG_IDN_FDEVICEINIT, &flag_res);
1310 if (!err || err == -ETIMEDOUT)
1311 break;
1312 dev_dbg(hba->dev, "%s: error %d retrying\n", __func__,
1313 err);
1314 }
1315 }
1316 if (err)
1317 dev_err(hba->dev,
1318 "%s reading fDeviceInit flag failed with error %d\n",
1319 __func__, err);
1320 else if (flag_res)
1321 dev_err(hba->dev,
1322 "%s fDeviceInit was not cleared by the device\n",
1323 __func__);
1324
1325out:
1326 return err;
1327}
1328
1329/**
1102 * ufshcd_make_hba_operational - Make UFS controller operational 1330 * ufshcd_make_hba_operational - Make UFS controller operational
1103 * @hba: per adapter instance 1331 * @hba: per adapter instance
1104 * 1332 *
@@ -1953,6 +2181,10 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
1953 if (ret) 2181 if (ret)
1954 goto out; 2182 goto out;
1955 2183
2184 ret = ufshcd_complete_dev_init(hba);
2185 if (ret)
2186 goto out;
2187
1956 scsi_scan_host(hba->host); 2188 scsi_scan_host(hba->host);
1957out: 2189out:
1958 return; 2190 return;
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index c750a90eb9da..6d6fdeb81af8 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -70,6 +70,7 @@
70 70
71enum dev_cmd_type { 71enum dev_cmd_type {
72 DEV_CMD_TYPE_NOP = 0x0, 72 DEV_CMD_TYPE_NOP = 0x0,
73 DEV_CMD_TYPE_QUERY = 0x1,
73}; 74};
74 75
75/** 76/**
@@ -125,6 +126,18 @@ struct ufshcd_lrb {
125}; 126};
126 127
127/** 128/**
129 * struct ufs_query - holds relevent data structures for query request
130 * @request: request upiu and function
131 * @descriptor: buffer for sending/receiving descriptor
132 * @response: response upiu and response
133 */
134struct ufs_query {
135 struct ufs_query_req request;
136 u8 *descriptor;
137 struct ufs_query_res response;
138};
139
140/**
128 * struct ufs_dev_cmd - all assosiated fields with device management commands 141 * struct ufs_dev_cmd - all assosiated fields with device management commands
129 * @type: device management command type - Query, NOP OUT 142 * @type: device management command type - Query, NOP OUT
130 * @lock: lock to allow one command at a time 143 * @lock: lock to allow one command at a time
@@ -136,6 +149,7 @@ struct ufs_dev_cmd {
136 struct mutex lock; 149 struct mutex lock;
137 struct completion *complete; 150 struct completion *complete;
138 wait_queue_head_t tag_wq; 151 wait_queue_head_t tag_wq;
152 struct ufs_query query;
139}; 153};
140 154
141/** 155/**
@@ -233,4 +247,10 @@ static inline void ufshcd_hba_stop(struct ufs_hba *hba)
233 ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE); 247 ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE);
234} 248}
235 249
250static inline void check_upiu_size(void)
251{
252 BUILD_BUG_ON(ALIGNED_UPIU_SIZE <
253 GENERAL_UPIU_REQUEST_SIZE + QUERY_DESC_MAX_SIZE);
254}
255
236#endif /* End of Header */ 256#endif /* End of Header */
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index d5c5f1482d7d..f1e1b7459107 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -39,7 +39,7 @@
39enum { 39enum {
40 TASK_REQ_UPIU_SIZE_DWORDS = 8, 40 TASK_REQ_UPIU_SIZE_DWORDS = 8,
41 TASK_RSP_UPIU_SIZE_DWORDS = 8, 41 TASK_RSP_UPIU_SIZE_DWORDS = 8,
42 ALIGNED_UPIU_SIZE = 128, 42 ALIGNED_UPIU_SIZE = 512,
43}; 43};
44 44
45/* UFSHCI Registers */ 45/* UFSHCI Registers */