Re: [PATCH v2 5/6] scsi: ufs: rpmb: Use unaligned accessors for RPMB frames

From: David Laight

Date: Thu Jul 23 2026 - 04:13:17 EST


On Wed, 22 Jul 2026 06:54:16 -0700
Bart Van Assche <bvanassche@xxxxxxx> wrote:

> On 7/22/26 5:33 AM, Bean Huo wrote:
> > consider Sashiko's suggestion, it's better to add __packed on struct rpmb_frame
> > {}?
>
> Do not add __packed to an entire data structure. Only use it on
> data structure members that need it.

That depends...
If the structure itself can be misaligned in memory then the structure
needs to be packed.
OTOH if there is (for example) a 32bit field on a 16bit boundary then
just marking that field __packed will remove the pad.
The compiler can then use two 16bit instructions to access the data
rather than four 8bit ones.

David

>
> Thanks,
>
> Bart.
>