diff options
| -rw-r--r-- | drivers/scsi/ufs/ufs.h | 36 | ||||
| -rw-r--r-- | drivers/scsi/ufs/ufshcd.c | 42 | ||||
| -rw-r--r-- | drivers/scsi/ufs/ufshci.h | 32 |
3 files changed, 42 insertions, 68 deletions
diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h index 721050090520..f42d1cee652a 100644 --- a/drivers/scsi/ufs/ufs.h +++ b/drivers/scsi/ufs/ufs.h | |||
| @@ -196,9 +196,9 @@ enum { | |||
| 196 | * @dword_2: UPIU header DW-2 | 196 | * @dword_2: UPIU header DW-2 |
| 197 | */ | 197 | */ |
| 198 | struct utp_upiu_header { | 198 | struct utp_upiu_header { |
| 199 | u32 dword_0; | 199 | __be32 dword_0; |
| 200 | u32 dword_1; | 200 | __be32 dword_1; |
| 201 | u32 dword_2; | 201 | __be32 dword_2; |
| 202 | }; | 202 | }; |
| 203 | 203 | ||
| 204 | /** | 204 | /** |
| @@ -207,7 +207,7 @@ struct utp_upiu_header { | |||
| 207 | * @cdb: Command Descriptor Block CDB DW-4 to DW-7 | 207 | * @cdb: Command Descriptor Block CDB DW-4 to DW-7 |
| 208 | */ | 208 | */ |
| 209 | struct utp_upiu_cmd { | 209 | struct utp_upiu_cmd { |
| 210 | u32 exp_data_transfer_len; | 210 | __be32 exp_data_transfer_len; |
| 211 | u8 cdb[MAX_CDB_SIZE]; | 211 | u8 cdb[MAX_CDB_SIZE]; |
| 212 | }; | 212 | }; |
| 213 | 213 | ||
| @@ -228,10 +228,10 @@ struct utp_upiu_query { | |||
| 228 | u8 idn; | 228 | u8 idn; |
| 229 | u8 index; | 229 | u8 index; |
| 230 | u8 selector; | 230 | u8 selector; |
| 231 | u16 reserved_osf; | 231 | __be16 reserved_osf; |
| 232 | u16 length; | 232 | __be16 length; |
| 233 | u32 value; | 233 | __be32 value; |
| 234 | u32 reserved[2]; | 234 | __be32 reserved[2]; |
| 235 | }; | 235 | }; |
| 236 | 236 | ||
| 237 | /** | 237 | /** |
| @@ -256,9 +256,9 @@ struct utp_upiu_req { | |||
| 256 | * @sense_data: Sense data field DW-8 to DW-12 | 256 | * @sense_data: Sense data field DW-8 to DW-12 |
| 257 | */ | 257 | */ |
| 258 | struct utp_cmd_rsp { | 258 | struct utp_cmd_rsp { |
| 259 | u32 residual_transfer_count; | 259 | __be32 residual_transfer_count; |
| 260 | u32 reserved[4]; | 260 | __be32 reserved[4]; |
| 261 | u16 sense_data_len; | 261 | __be16 sense_data_len; |
| 262 | u8 sense_data[18]; | 262 | u8 sense_data[18]; |
| 263 | }; | 263 | }; |
| 264 | 264 | ||
| @@ -286,10 +286,10 @@ struct utp_upiu_rsp { | |||
| 286 | */ | 286 | */ |
| 287 | struct utp_upiu_task_req { | 287 | struct utp_upiu_task_req { |
| 288 | struct utp_upiu_header header; | 288 | struct utp_upiu_header header; |
| 289 | u32 input_param1; | 289 | __be32 input_param1; |
| 290 | u32 input_param2; | 290 | __be32 input_param2; |
| 291 | u32 input_param3; | 291 | __be32 input_param3; |
| 292 | u32 reserved[2]; | 292 | __be32 reserved[2]; |
| 293 | }; | 293 | }; |
| 294 | 294 | ||
| 295 | /** | 295 | /** |
| @@ -301,9 +301,9 @@ struct utp_upiu_task_req { | |||
| 301 | */ | 301 | */ |
| 302 | struct utp_upiu_task_rsp { | 302 | struct utp_upiu_task_rsp { |
| 303 | struct utp_upiu_header header; | 303 | struct utp_upiu_header header; |
| 304 | u32 output_param1; | 304 | __be32 output_param1; |
| 305 | u32 output_param2; | 305 | __be32 output_param2; |
| 306 | u32 reserved[3]; | 306 | __be32 reserved[3]; |
| 307 | }; | 307 | }; |
| 308 | 308 | ||
| 309 | /** | 309 | /** |
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 04884d663e4e..064c9d9d763b 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c | |||
| @@ -163,7 +163,7 @@ static inline int ufshcd_is_device_present(u32 reg_hcs) | |||
| 163 | */ | 163 | */ |
| 164 | static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) | 164 | static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) |
| 165 | { | 165 | { |
| 166 | return lrbp->utr_descriptor_ptr->header.dword_2 & MASK_OCS; | 166 | return le32_to_cpu(lrbp->utr_descriptor_ptr->header.dword_2) & MASK_OCS; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | /** | 169 | /** |
| @@ -176,7 +176,7 @@ static inline int ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp) | |||
| 176 | static inline int | 176 | static inline int |
| 177 | ufshcd_get_tmr_ocs(struct utp_task_req_desc *task_req_descp) | 177 | ufshcd_get_tmr_ocs(struct utp_task_req_desc *task_req_descp) |
| 178 | { | 178 | { |
| 179 | return task_req_descp->header.dword_2 & MASK_OCS; | 179 | return le32_to_cpu(task_req_descp->header.dword_2) & MASK_OCS; |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | /** | 182 | /** |
| @@ -390,26 +390,6 @@ static inline void ufshcd_copy_sense_data(struct ufshcd_lrb *lrbp) | |||
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | /** | 392 | /** |
| 393 | * ufshcd_query_to_cpu() - formats the buffer to native cpu endian | ||
| 394 | * @response: upiu query response to convert | ||
| 395 | */ | ||
| 396 | static inline void ufshcd_query_to_cpu(struct utp_upiu_query *response) | ||
| 397 | { | ||
| 398 | response->length = be16_to_cpu(response->length); | ||
| 399 | response->value = be32_to_cpu(response->value); | ||
| 400 | } | ||
| 401 | |||
| 402 | /** | ||
| 403 | * ufshcd_query_to_be() - formats the buffer to big endian | ||
| 404 | * @request: upiu query request to convert | ||
| 405 | */ | ||
| 406 | static inline void ufshcd_query_to_be(struct utp_upiu_query *request) | ||
| 407 | { | ||
| 408 | request->length = cpu_to_be16(request->length); | ||
| 409 | request->value = cpu_to_be32(request->value); | ||
| 410 | } | ||
| 411 | |||
| 412 | /** | ||
| 413 | * ufshcd_copy_query_response() - Copy the Query Response and the data | 393 | * ufshcd_copy_query_response() - Copy the Query Response and the data |
| 414 | * descriptor | 394 | * descriptor |
| 415 | * @hba: per adapter instance | 395 | * @hba: per adapter instance |
| @@ -425,7 +405,6 @@ void ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) | |||
| 425 | UPIU_RSP_CODE_OFFSET; | 405 | UPIU_RSP_CODE_OFFSET; |
| 426 | 406 | ||
| 427 | memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE); | 407 | memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE); |
| 428 | ufshcd_query_to_cpu(&query_res->upiu_res); | ||
| 429 | 408 | ||
| 430 | 409 | ||
| 431 | /* Get the descriptor */ | 410 | /* Get the descriptor */ |
| @@ -749,7 +728,7 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, | |||
| 749 | { | 728 | { |
| 750 | struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; | 729 | struct utp_upiu_req *ucd_req_ptr = lrbp->ucd_req_ptr; |
| 751 | struct ufs_query *query = &hba->dev_cmd.query; | 730 | struct ufs_query *query = &hba->dev_cmd.query; |
| 752 | u16 len = query->request.upiu_req.length; | 731 | u16 len = be16_to_cpu(query->request.upiu_req.length); |
| 753 | u8 *descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE; | 732 | u8 *descp = (u8 *)lrbp->ucd_req_ptr + GENERAL_UPIU_REQUEST_SIZE; |
| 754 | 733 | ||
| 755 | /* Query request header */ | 734 | /* Query request header */ |
| @@ -766,7 +745,6 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba, | |||
| 766 | /* Copy the Query Request buffer as is */ | 745 | /* Copy the Query Request buffer as is */ |
| 767 | memcpy(&ucd_req_ptr->qr, &query->request.upiu_req, | 746 | memcpy(&ucd_req_ptr->qr, &query->request.upiu_req, |
| 768 | QUERY_OSF_SIZE); | 747 | QUERY_OSF_SIZE); |
| 769 | ufshcd_query_to_be(&ucd_req_ptr->qr); | ||
| 770 | 748 | ||
| 771 | /* Copy the Descriptor */ | 749 | /* Copy the Descriptor */ |
| 772 | if ((len > 0) && (query->request.upiu_req.opcode == | 750 | if ((len > 0) && (query->request.upiu_req.opcode == |
| @@ -1151,7 +1129,7 @@ static int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, | |||
| 1151 | } | 1129 | } |
| 1152 | 1130 | ||
| 1153 | if (flag_res) | 1131 | if (flag_res) |
| 1154 | *flag_res = (response->upiu_res.value & | 1132 | *flag_res = (be32_to_cpu(response->upiu_res.value) & |
| 1155 | MASK_QUERY_UPIU_FLAG_LOC) & 0x1; | 1133 | MASK_QUERY_UPIU_FLAG_LOC) & 0x1; |
| 1156 | 1134 | ||
| 1157 | out_unlock: | 1135 | out_unlock: |
| @@ -1195,7 +1173,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, | |||
| 1195 | switch (opcode) { | 1173 | switch (opcode) { |
| 1196 | case UPIU_QUERY_OPCODE_WRITE_ATTR: | 1174 | case UPIU_QUERY_OPCODE_WRITE_ATTR: |
| 1197 | request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST; | 1175 | request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST; |
| 1198 | request->upiu_req.value = *attr_val; | 1176 | request->upiu_req.value = cpu_to_be32(*attr_val); |
| 1199 | break; | 1177 | break; |
| 1200 | case UPIU_QUERY_OPCODE_READ_ATTR: | 1178 | case UPIU_QUERY_OPCODE_READ_ATTR: |
| 1201 | request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST; | 1179 | request->query_func = UPIU_QUERY_FUNC_STANDARD_READ_REQUEST; |
| @@ -1222,7 +1200,7 @@ int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode, | |||
| 1222 | goto out_unlock; | 1200 | goto out_unlock; |
| 1223 | } | 1201 | } |
| 1224 | 1202 | ||
| 1225 | *attr_val = response->upiu_res.value; | 1203 | *attr_val = be32_to_cpu(response->upiu_res.value); |
| 1226 | 1204 | ||
| 1227 | out_unlock: | 1205 | out_unlock: |
| 1228 | mutex_unlock(&hba->dev_cmd.lock); | 1206 | mutex_unlock(&hba->dev_cmd.lock); |
| @@ -2568,12 +2546,8 @@ ufshcd_issue_tm_cmd(struct ufs_hba *hba, | |||
| 2568 | task_req_upiup->header.dword_1 = | 2546 | task_req_upiup->header.dword_1 = |
| 2569 | UPIU_HEADER_DWORD(0, tm_function, 0, 0); | 2547 | UPIU_HEADER_DWORD(0, tm_function, 0, 0); |
| 2570 | 2548 | ||
| 2571 | task_req_upiup->input_param1 = lrbp->lun; | 2549 | task_req_upiup->input_param1 = cpu_to_be32(lrbp->lun); |
| 2572 | task_req_upiup->input_param1 = | 2550 | task_req_upiup->input_param2 = cpu_to_be32(lrbp->task_tag); |
| 2573 | cpu_to_be32(task_req_upiup->input_param1); | ||
| 2574 | task_req_upiup->input_param2 = lrbp->task_tag; | ||
| 2575 | task_req_upiup->input_param2 = | ||
| 2576 | cpu_to_be32(task_req_upiup->input_param2); | ||
| 2577 | 2551 | ||
| 2578 | /* send command to the controller */ | 2552 | /* send command to the controller */ |
| 2579 | __set_bit(free_slot, &hba->outstanding_tasks); | 2553 | __set_bit(free_slot, &hba->outstanding_tasks); |
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h index 0475c6619a68..9abc7e32b43d 100644 --- a/drivers/scsi/ufs/ufshci.h +++ b/drivers/scsi/ufs/ufshci.h | |||
| @@ -304,10 +304,10 @@ enum { | |||
| 304 | * @size: size of physical segment DW-3 | 304 | * @size: size of physical segment DW-3 |
| 305 | */ | 305 | */ |
| 306 | struct ufshcd_sg_entry { | 306 | struct ufshcd_sg_entry { |
| 307 | u32 base_addr; | 307 | __le32 base_addr; |
| 308 | u32 upper_addr; | 308 | __le32 upper_addr; |
| 309 | u32 reserved; | 309 | __le32 reserved; |
| 310 | u32 size; | 310 | __le32 size; |
| 311 | }; | 311 | }; |
| 312 | 312 | ||
| 313 | /** | 313 | /** |
| @@ -330,10 +330,10 @@ struct utp_transfer_cmd_desc { | |||
| 330 | * @dword3: Descriptor Header DW3 | 330 | * @dword3: Descriptor Header DW3 |
| 331 | */ | 331 | */ |
| 332 | struct request_desc_header { | 332 | struct request_desc_header { |
| 333 | u32 dword_0; | 333 | __le32 dword_0; |
| 334 | u32 dword_1; | 334 | __le32 dword_1; |
| 335 | u32 dword_2; | 335 | __le32 dword_2; |
| 336 | u32 dword_3; | 336 | __le32 dword_3; |
| 337 | }; | 337 | }; |
| 338 | 338 | ||
| 339 | /** | 339 | /** |
| @@ -352,16 +352,16 @@ struct utp_transfer_req_desc { | |||
| 352 | struct request_desc_header header; | 352 | struct request_desc_header header; |
| 353 | 353 | ||
| 354 | /* DW 4-5*/ | 354 | /* DW 4-5*/ |
| 355 | u32 command_desc_base_addr_lo; | 355 | __le32 command_desc_base_addr_lo; |
| 356 | u32 command_desc_base_addr_hi; | 356 | __le32 command_desc_base_addr_hi; |
| 357 | 357 | ||
| 358 | /* DW 6 */ | 358 | /* DW 6 */ |
| 359 | u16 response_upiu_length; | 359 | __le16 response_upiu_length; |
| 360 | u16 response_upiu_offset; | 360 | __le16 response_upiu_offset; |
| 361 | 361 | ||
| 362 | /* DW 7 */ | 362 | /* DW 7 */ |
| 363 | u16 prd_table_length; | 363 | __le16 prd_table_length; |
| 364 | u16 prd_table_offset; | 364 | __le16 prd_table_offset; |
| 365 | }; | 365 | }; |
| 366 | 366 | ||
| 367 | /** | 367 | /** |
| @@ -376,10 +376,10 @@ struct utp_task_req_desc { | |||
| 376 | struct request_desc_header header; | 376 | struct request_desc_header header; |
| 377 | 377 | ||
| 378 | /* DW 4-11 */ | 378 | /* DW 4-11 */ |
| 379 | u32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS]; | 379 | __le32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS]; |
| 380 | 380 | ||
| 381 | /* DW 12-19 */ | 381 | /* DW 12-19 */ |
| 382 | u32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS]; | 382 | __le32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS]; |
| 383 | }; | 383 | }; |
| 384 | 384 | ||
| 385 | #endif /* End of Header */ | 385 | #endif /* End of Header */ |
