Skip to content

Commit 391e388

Browse files
Christoph Hellwigmartinkpetersen
authored andcommitted
scsi: ufs: cleanup struct utp_task_req_desc
Remove the pointless task_req_upiu and task_rsp_upiu indirections, which are __le32 arrays always cast to given structures and just add the members directly. Also clean up variables names in use in the callers a bit to make the code more readable. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Avri Altman <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 51aef71 commit 391e388

File tree

3 files changed

+34
-89
lines changed

3 files changed

+34
-89
lines changed

drivers/scsi/ufs/ufs.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -519,36 +519,6 @@ struct utp_upiu_rsp {
519519
};
520520
};
521521

522-
/**
523-
* struct utp_upiu_task_req - Task request UPIU structure
524-
* @header - UPIU header structure DW0 to DW-2
525-
* @input_param1: Input parameter 1 DW-3
526-
* @input_param2: Input parameter 2 DW-4
527-
* @input_param3: Input parameter 3 DW-5
528-
* @reserved: Reserved double words DW-6 to DW-7
529-
*/
530-
struct utp_upiu_task_req {
531-
struct utp_upiu_header header;
532-
__be32 input_param1;
533-
__be32 input_param2;
534-
__be32 input_param3;
535-
__be32 reserved[2];
536-
};
537-
538-
/**
539-
* struct utp_upiu_task_rsp - Task Management Response UPIU structure
540-
* @header: UPIU header structure DW0-DW-2
541-
* @output_param1: Ouput parameter 1 DW3
542-
* @output_param2: Output parameter 2 DW4
543-
* @reserved: Reserved double words DW-5 to DW-7
544-
*/
545-
struct utp_upiu_task_rsp {
546-
struct utp_upiu_header header;
547-
__be32 output_param1;
548-
__be32 output_param2;
549-
__be32 reserved[3];
550-
};
551-
552522
/**
553523
* struct ufs_query_req - parameters for building a query request
554524
* @query_func: UPIU header query function

drivers/scsi/ufs/ufshcd.c

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,11 @@ static void ufshcd_add_query_upiu_trace(struct ufs_hba *hba, unsigned int tag,
326326
static void ufshcd_add_tm_upiu_trace(struct ufs_hba *hba, unsigned int tag,
327327
const char *str)
328328
{
329-
struct utp_task_req_desc *descp;
330-
struct utp_upiu_task_req *task_req;
331329
int off = (int)tag - hba->nutrs;
330+
struct utp_task_req_desc *descp = &hba->utmrdl_base_addr[off];
332331

333-
descp = &hba->utmrdl_base_addr[off];
334-
task_req = (struct utp_upiu_task_req *)descp->task_req_upiu;
335-
trace_ufshcd_upiu(dev_name(hba->dev), str, &task_req->header,
336-
&task_req->input_param1);
332+
trace_ufshcd_upiu(dev_name(hba->dev), str, &descp->req_header,
333+
&descp->input_param1);
337334
}
338335

339336
static void ufshcd_add_command_trace(struct ufs_hba *hba,
@@ -475,22 +472,13 @@ void ufshcd_print_trs(struct ufs_hba *hba, unsigned long bitmap, bool pr_prdt)
475472

476473
static void ufshcd_print_tmrs(struct ufs_hba *hba, unsigned long bitmap)
477474
{
478-
struct utp_task_req_desc *tmrdp;
479475
int tag;
480476

481477
for_each_set_bit(tag, &bitmap, hba->nutmrs) {
482-
tmrdp = &hba->utmrdl_base_addr[tag];
478+
struct utp_task_req_desc *tmrdp = &hba->utmrdl_base_addr[tag];
479+
483480
dev_err(hba->dev, "TM[%d] - Task Management Header\n", tag);
484-
ufshcd_hex_dump("TM TRD: ", &tmrdp->header,
485-
sizeof(struct request_desc_header));
486-
dev_err(hba->dev, "TM[%d] - Task Management Request UPIU\n",
487-
tag);
488-
ufshcd_hex_dump("TM REQ: ", tmrdp->task_req_upiu,
489-
sizeof(struct utp_upiu_req));
490-
dev_err(hba->dev, "TM[%d] - Task Management Response UPIU\n",
491-
tag);
492-
ufshcd_hex_dump("TM RSP: ", tmrdp->task_rsp_upiu,
493-
sizeof(struct utp_task_req_desc));
481+
ufshcd_hex_dump("", tmrdp, sizeof(*tmrdp));
494482
}
495483
}
496484

@@ -4638,31 +4626,22 @@ static void ufshcd_slave_destroy(struct scsi_device *sdev)
46384626
*/
46394627
static int ufshcd_task_req_compl(struct ufs_hba *hba, u32 index, u8 *resp)
46404628
{
4641-
struct utp_task_req_desc *task_req_descp;
4642-
struct utp_upiu_task_rsp *task_rsp_upiup;
4629+
struct utp_task_req_desc *treq = hba->utmrdl_base_addr + index;
46434630
unsigned long flags;
46444631
int ocs_value;
4645-
int task_result;
46464632

46474633
spin_lock_irqsave(hba->host->host_lock, flags);
46484634

46494635
/* Clear completed tasks from outstanding_tasks */
46504636
__clear_bit(index, &hba->outstanding_tasks);
46514637

4652-
task_req_descp = hba->utmrdl_base_addr;
4653-
ocs_value = ufshcd_get_tmr_ocs(&task_req_descp[index]);
4638+
ocs_value = ufshcd_get_tmr_ocs(treq);
46544639

4655-
if (ocs_value == OCS_SUCCESS) {
4656-
task_rsp_upiup = (struct utp_upiu_task_rsp *)
4657-
task_req_descp[index].task_rsp_upiu;
4658-
task_result = be32_to_cpu(task_rsp_upiup->output_param1);
4659-
task_result = task_result & MASK_TM_SERVICE_RESP;
4660-
if (resp)
4661-
*resp = (u8)task_result;
4662-
} else {
4640+
if (ocs_value != OCS_SUCCESS)
46634641
dev_err(hba->dev, "%s: failed, ocs = 0x%x\n",
46644642
__func__, ocs_value);
4665-
}
4643+
else if (resp)
4644+
*resp = be32_to_cpu(treq->output_param1) & MASK_TM_SERVICE_RESP;
46664645
spin_unlock_irqrestore(hba->host->host_lock, flags);
46674646

46684647
return ocs_value;
@@ -5638,8 +5617,7 @@ static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag)
56385617
static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id,
56395618
u8 tm_function, u8 *tm_response)
56405619
{
5641-
struct utp_task_req_desc *task_req_descp;
5642-
struct utp_upiu_task_req *task_req_upiup;
5620+
struct utp_task_req_desc *treq;
56435621
struct Scsi_Host *host;
56445622
unsigned long flags;
56455623
int free_slot;
@@ -5657,29 +5635,23 @@ static int ufshcd_issue_tm_cmd(struct ufs_hba *hba, int lun_id, int task_id,
56575635
ufshcd_hold(hba, false);
56585636

56595637
spin_lock_irqsave(host->host_lock, flags);
5660-
task_req_descp = hba->utmrdl_base_addr;
5661-
task_req_descp += free_slot;
5638+
treq = hba->utmrdl_base_addr + free_slot;
56625639

56635640
/* Configure task request descriptor */
5664-
task_req_descp->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD);
5665-
task_req_descp->header.dword_2 =
5666-
cpu_to_le32(OCS_INVALID_COMMAND_STATUS);
5641+
treq->header.dword_0 = cpu_to_le32(UTP_REQ_DESC_INT_CMD);
5642+
treq->header.dword_2 = cpu_to_le32(OCS_INVALID_COMMAND_STATUS);
56675643

56685644
/* Configure task request UPIU */
5669-
task_req_upiup =
5670-
(struct utp_upiu_task_req *) task_req_descp->task_req_upiu;
56715645
task_tag = hba->nutrs + free_slot;
5672-
task_req_upiup->header.dword_0 =
5673-
UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ, 0,
5674-
lun_id, task_tag);
5675-
task_req_upiup->header.dword_1 =
5676-
UPIU_HEADER_DWORD(0, tm_function, 0, 0);
5646+
treq->req_header.dword_0 = UPIU_HEADER_DWORD(UPIU_TRANSACTION_TASK_REQ,
5647+
0, lun_id, task_tag);
5648+
treq->req_header.dword_1 = UPIU_HEADER_DWORD(0, tm_function, 0, 0);
56775649
/*
56785650
* The host shall provide the same value for LUN field in the basic
56795651
* header and for Input Parameter.
56805652
*/
5681-
task_req_upiup->input_param1 = cpu_to_be32(lun_id);
5682-
task_req_upiup->input_param2 = cpu_to_be32(task_id);
5653+
treq->input_param1 = cpu_to_be32(lun_id);
5654+
treq->input_param2 = cpu_to_be32(task_id);
56835655

56845656
ufshcd_vops_setup_task_mgmt(hba, free_slot, tm_function);
56855657

drivers/scsi/ufs/ufshci.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,22 +433,25 @@ struct utp_transfer_req_desc {
433433
__le16 prd_table_offset;
434434
};
435435

436-
/**
437-
* struct utp_task_req_desc - UTMRD structure
438-
* @header: UTMRD header DW-0 to DW-3
439-
* @task_req_upiu: Pointer to task request UPIU DW-4 to DW-11
440-
* @task_rsp_upiu: Pointer to task response UPIU DW12 to DW-19
436+
/*
437+
* UTMRD structure.
441438
*/
442439
struct utp_task_req_desc {
443-
444440
/* DW 0-3 */
445441
struct request_desc_header header;
446442

447-
/* DW 4-11 */
448-
__le32 task_req_upiu[TASK_REQ_UPIU_SIZE_DWORDS];
449-
450-
/* DW 12-19 */
451-
__le32 task_rsp_upiu[TASK_RSP_UPIU_SIZE_DWORDS];
443+
/* DW 4-11 - Task request UPIU structure */
444+
struct utp_upiu_header req_header;
445+
__be32 input_param1;
446+
__be32 input_param2;
447+
__be32 input_param3;
448+
__be32 __reserved1[2];
449+
450+
/* DW 12-19 - Task Management Response UPIU structure */
451+
struct utp_upiu_header rsp_header;
452+
__be32 output_param1;
453+
__be32 output_param2;
454+
__be32 __reserved2[3];
452455
};
453456

454457
#endif /* End of Header */

0 commit comments

Comments
 (0)