From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: David Laight <David.Laight@aculab.com>
Cc: Ping-Ke Shih <pkshih@realtek.com>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"kvalo@kernel.org" <kvalo@kernel.org>,
"tehuang@realtek.com" <tehuang@realtek.com>,
"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
"tony0620emma@gmail.com" <tony0620emma@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs
Date: Wed, 4 Jan 2023 17:07:40 +0100 [thread overview]
Message-ID: <CAFBinCC9sNvQJcu-SOSrFmo4sCx29K6KwXnc-O6MX9TJEHtXYg@mail.gmail.com> (raw)
In-Reply-To: <ec6a0988f3f943128e0122d50959185a@AcuMS.aculab.com>
On Wed, Jan 4, 2023 at 4:53 PM David Laight <David.Laight@aculab.com> wrote:
>
> From: Martin Blumenstingl
> > Sent: 04 January 2023 15:30
> >
> > Hi Ping-Ke, Hi David,
> >
> > On Sun, Jan 1, 2023 at 2:09 PM Ping-Ke Shih <pkshih@realtek.com> wrote:
> > [...]
> > > Yes, it should not use bit filed. Instead, use a __le16 for all fields, such as
> > I think this can be done in a separate patch.
> > My v2 of this patch has reduced these changes to a minimum, see [0]
> >
> > [...]
> > > struct rtw8821ce_efuse {
> > > ...
> > > u8 data1; // offset 0x100
> > > __le16 data2; // offset 0x101-0x102
> > > ...
> > > } __packed;
> > >
> > > Without __packed, compiler could has pad between data1 and data2,
> > > and then get wrong result.
> > My understanding is that this is the reason why we need __packed.
>
> True, but does it really have to look like that?
> I can't find that version (I don't have a net_next tree).
My understanding is that there's one actual and one potential use-case.
Let's start with the actual one in
drivers/net/wireless/realtek/rtw88/rtw8821c.h:
struct rtw8821c_efuse {
__le16 rtl_id;
u8 res0[0x0e];
...
The second one is a potential one, also in
drivers/net/wireless/realtek/rtw88/rtw8821c.h if we replace the
bitfields by an __le16 (which is my understanding how the data is
modeled in the eFuse):
struct rtw8821ce_efuse {
...
u8 serial_number[8];
__le16 cap_data; /* 0xf4 */
...
(I'm not sure about the "cap_data" name, but I think you get the point)
> Possibly it should be 'u8 data2[2];'
So you're saying we should replace the __le16 with u8 some_name[2];
instead, then we don't need the __packed attribute.
> 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?
Best regards,
Martin
next prev parent reply other threads:[~2023-01-04 16:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-28 13:35 [PATCH 0/4] rtw88: Four fixes found while working on SDIO support Martin Blumenstingl
2022-12-28 13:35 ` [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs Martin Blumenstingl
2022-12-29 9:24 ` Ping-Ke Shih
2022-12-29 10:37 ` Martin Blumenstingl
2022-12-29 11:35 ` Ping-Ke Shih
2022-12-31 16:57 ` David Laight
2023-01-01 11:42 ` Ping-Ke Shih
2023-01-01 11:54 ` David Laight
2023-01-01 13:08 ` Ping-Ke Shih
2023-01-04 15:30 ` Martin Blumenstingl
2023-01-04 15:53 ` David Laight
2023-01-04 16:07 ` Martin Blumenstingl [this message]
2023-01-04 16:31 ` David Laight
2023-01-04 17:49 ` Martin Blumenstingl
2023-01-05 0:56 ` Ping-Ke Shih
2023-01-05 8:34 ` David Laight
2023-01-10 12:02 ` Kalle Valo
2023-01-10 12:34 ` David Laight
2022-12-28 13:35 ` [PATCH 2/4] rtw88: Configure the registers from rtw_bf_assoc() outside the RCU lock Martin Blumenstingl
2022-12-29 9:37 ` Ping-Ke Shih
2022-12-28 13:35 ` [PATCH 3/4] rtw88: Use rtw_iterate_vifs() for rtw_vif_watch_dog_iter() Martin Blumenstingl
2022-12-29 9:39 ` Ping-Ke Shih
2022-12-28 13:35 ` [PATCH 4/4] rtw88: Use non-atomic rtw_iterate_stas() in rtw_ra_mask_info_update() Martin Blumenstingl
2022-12-29 9:39 ` Ping-Ke Shih
2022-12-29 9:26 ` [PATCH 0/4] rtw88: Four fixes found while working on SDIO support Ping-Ke Shih
2022-12-29 10:40 ` Martin Blumenstingl
2022-12-29 11:42 ` Ping-Ke Shih
2023-01-10 12:06 ` Kalle Valo
-- strict thread matches above, loose matches on Subject: below --
2022-12-29 12:48 Martin Blumenstingl
2022-12-29 12:48 ` [PATCH 1/4] rtw88: Add packed attribute to the eFuse structs Martin Blumenstingl
2022-12-29 23:47 ` Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFBinCC9sNvQJcu-SOSrFmo4sCx29K6KwXnc-O6MX9TJEHtXYg@mail.gmail.com \
--to=martin.blumenstingl@googlemail.com \
--cc=David.Laight@aculab.com \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pkshih@realtek.com \
--cc=s.hauer@pengutronix.de \
--cc=tehuang@realtek.com \
--cc=tony0620emma@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).