[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4cb20c80-9bb0-e147-e3c0-467f4c8828ba@quicinc.com>
Date: Thu, 27 Mar 2025 14:45:10 -0700
From: "Bao D. Nguyen" <quic_nguyenb@...cinc.com>
To: Bart Van Assche <bvanassche@....org>,
Arthur Simchaev
<Arthur.Simchaev@...disk.com>,
"quic_cang@...cinc.com"
<quic_cang@...cinc.com>,
"quic_nitirawa@...cinc.com"
<quic_nitirawa@...cinc.com>,
"avri.altman@....com" <avri.altman@....com>,
"peter.wang@...iatek.com" <peter.wang@...iatek.com>,
"manivannan.sadhasivam@...aro.org" <manivannan.sadhasivam@...aro.org>,
"minwoo.im@...sung.com" <minwoo.im@...sung.com>,
"adrian.hunter@...el.com"
<adrian.hunter@...el.com>,
"martin.petersen@...cle.com"
<martin.petersen@...cle.com>
CC: "linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
Alim Akhtar
<alim.akhtar@...sung.com>,
"James E.J. Bottomley"
<James.Bottomley@...senPartnership.com>,
Matthias Brugger
<matthias.bgg@...il.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...labora.com>,
Bean Huo <beanhuo@...ron.com>,
Keoseong Park <keosung.park@...sung.com>,
Ziqi Chen
<quic_ziqichen@...cinc.com>,
Al Viro <viro@...iv.linux.org.uk>,
"Gwendal
Grignou" <gwendal@...omium.org>,
Eric Biggers <ebiggers@...gle.com>,
open
list <linux-kernel@...r.kernel.org>,
"moderated list:ARM/Mediatek SoC
support:Keyword:mediatek" <linux-arm-kernel@...ts.infradead.org>,
"moderated
list:ARM/Mediatek SoC support:Keyword:mediatek"
<linux-mediatek@...ts.infradead.org>
Subject: Re: [PATCH v4 1/1] scsi: ufs: core: add device level exception
support
On 3/27/2025 4:36 AM, Bart Van Assche wrote:
> On 3/26/25 7:47 PM, Bao D. Nguyen wrote:
>> On 3/26/2025 3:49 AM, Bart Van Assche wrote:
>>> On 3/25/25 6:15 PM, Bao D. Nguyen wrote:
>>>> The existing "struct utp_upiu_query_v4_0" probably has a bug in it.
>>>> It does not use theĀ __attribute__((__packed__)) attribute. The
>>>> compiler is free to add padding in this structure, resulting in the
>>>> read attribute value being incorrect. I plan to provide a separate
>>>> patch to fix this issue.
>>>
>>> Adding __attribute__((__packed__)) or __packed to data structures that
>>> don't need it is not an improvement but is a change that makes
>>> processing slower on architectures that do not support unaligned
>>> accesses. Instead of adding __packed to data structures in their
>>> entirety, only add it to those members that need it and check the
>>> structure size as follows:
>>>
>>> static_assert(sizeof(...) == ...);
>>>
>> Thank you for the info on this, Bart.
>> IMO, this response upiu data should be __packed because the data
>> coming from the hardware follows a strict format as defined by the
>> spec. If we support __pack each individual field which data may be
>> read by the driver (the attribute read commands) and check the
>> validity of their sizes, it may add some complexity?
>
> Hi Bao,
>
> As explained in my previous email, adding __packed to data structures in
> their entirety is a bad practice. Please don't do this.
>
> Regarding your question: I have not yet seen any data structure that
> represents an on-the-wire data format where every single data member
> has to be annotated with __packed. Only data members that are not
> aligned to a natural boundary need this annotation. Examples are
> available in this header file: include/scsi/srp.h.
>
Thanks Bart. How about we change the current utp_upiu_query_v4_0 to
struct utp_upiu_query_v4_0 {
__u8 opcode;
__u8 idn;
__u8 index;
__u8 selector;
__u8 cmd_specifics[8];
/* private: */
__be32 reserved;
};
Depending on the opcode/transaction, the cmd_specifics[] can be type
casted to access the LENGTH, FLAG_VALUE, VALUE[0:63] fields of the QUERY
UPIU. The __u8 array[8] would also prevent the compiler padding to the data.
Thanks, Bao
Powered by blists - more mailing lists