RE: [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs
From: Ping-Ke Shih
Date: Wed Jan 04 2023 - 20:13:53 EST
> -----Original Message-----
> From: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>
> Sent: Thursday, January 5, 2023 1:49 AM
> To: David Laight <David.Laight@xxxxxxxxxx>
> Cc: Ping-Ke Shih <pkshih@xxxxxxxxxxx>; linux-wireless@xxxxxxxxxxxxxxx; kvalo@xxxxxxxxxx;
> tehuang@xxxxxxxxxxx; s.hauer@xxxxxxxxxxxxxx; tony0620emma@xxxxxxxxx; netdev@xxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx
> Subject: Re: [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs
>
> On Wed, Jan 4, 2023 at 5:31 PM David Laight <David.Laight@xxxxxxxxxx> wrote:
> [...]
> > > > What you may want to do is add compile-time asserts for the
> > > > sizes of the structures.
> > > Do I get you right that something like:
> > > BUILD_BUG_ON(sizeof(rtw8821c_efuse) != 256);
> > > is what you have in mind?
> >
> > That looks like the one...
> I tried this (see the attached patch - it's just meant to show what I
> did, it's not meant to be applied upstream).
> With the attached patch but no other patches this makes the rtw88
> driver compile fine on 6.2-rc2.
I prefer to use static_assert() below the struct if we really need it.
In fact, we only list fields of efuse map we need in the struct, not
full map.
>
> Adding __packed to struct rtw8723d_efuse changes the size of that
> struct for me (I'm compiling for AArch64 / ARM64).
> With the packed attribute it has 267 bytes, without 268 bytes.
Try
static_assert(offsetof(struct rtw8723d_efuse, rf_antenna_option) == 0xc9);
and other fields to bisect which field gets wrong.
Ping-Ke