Re: [PATCH v1 1/3] scsi: ufs: Let UPIU completion trace print RSP UPIU

From: Bean Huo
Date: Tue May 25 2021 - 15:28:42 EST


On Sun, 2021-05-23 at 18:24 -0700, Bart Van Assche wrote:
> On 5/23/21 2:14 PM, Bean Huo wrote:
>
> > + rq_rsp = (struct utp_upiu_req *)hba-
> > >lrb[tag].ucd_rsp_ptr;
>
>
> So a pointer to a response (hba->lrb[tag].ucd_rsp_ptr) is cast to a
>
> pointer to a request (struct utp_upiu_req *)? That seems really odd
> to
>
> me. Please explain.

Bart,

these two structures have the same size, and inside the structures,
the both unions have the same members(not exactly 100% identical).

struct utp_upiu_rsp {
struct utp_upiu_header header;
union {
struct utp_cmd_rsp sr;
struct utp_upiu_query qr;
};
};


struct utp_upiu_req {
struct utp_upiu_header header;
union {
struct utp_upiu_cmd sc;
struct utp_upiu_query qr;
struct utp_upiu_query uc;
};
};

Use one point for response and request both, no problem here. It is
true that looks very ood, and very difficult to read them.

If this is problem, I can change the code, let them more readable.

how do you think?

Bean