netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
To: linux-wireless@vger.kernel.org
Cc: tony0620emma@gmail.com, kvalo@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Ping-Ke Shih <pkshih@realtek.com>,
	David Laight <David.Laight@aculab.com>
Subject: [PATCH v1 RFC] wifi: rtw88: Validate the eFuse structs
Date: Sun,  8 Jan 2023 22:31:14 +0100	[thread overview]
Message-ID: <20230108213114.547135-1-martin.blumenstingl@googlemail.com> (raw)

Add static assertions for the PCIe/USB offsets inside the eFuse structs
to ensure that the compiler doesn't add padding anywhere (relevant)
inside the structs.

Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Suggested-by: David Laight <David.Laight@aculab.com>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
This is the continuation of my patch from [0] where initially I added
__packed attributes to the eFuse structs. David raised concerns that
this is the "sledgehammer" way of doing things and it can impact
performance.

So this implementation is my understanding of David's suggestion from
[1] (and Ping-Ke also suggested a similar approach for debugging a
size difference I've been seeing with / without __packed).


[0] https://lore.kernel.org/linux-wireless/20221228133547.633797-2-martin.blumenstingl@googlemail.com/
[1] https://lore.kernel.org/linux-wireless/4c4551c787ee4fc9ac40b34707d7365a@AcuMS.aculab.com/


 drivers/net/wireless/realtek/rtw88/rtw8723d.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8821c.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822b.h | 5 +++++
 drivers/net/wireless/realtek/rtw88/rtw8822c.h | 5 +++++
 4 files changed, 20 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
index a356318a5c15..b1747a22135c 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
@@ -83,6 +83,11 @@ struct rtw8723d_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8723d_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8723de_efuse) == 14);
+static_assert(offsetof(struct rtw8723d_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8723du_efuse) == 59);
+
 extern const struct rtw_chip_info rtw8723d_hw_spec;
 
 /* phy status page0 */
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.h b/drivers/net/wireless/realtek/rtw88/rtw8821c.h
index 1c81260f3a54..70fdc7bf2b64 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.h
@@ -97,6 +97,11 @@ struct rtw8821c_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8821c_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8821ce_efuse) == 49);
+static_assert(offsetof(struct rtw8821c_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8821cu_efuse) == 304);
+
 static inline void
 _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 {
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822b.h b/drivers/net/wireless/realtek/rtw88/rtw8822b.h
index 01d3644e0c94..5d24ce7a8943 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822b.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822b.h
@@ -97,6 +97,11 @@ struct rtw8822b_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8822b_efuse, e) == 0xd0);
+static_assert(sizeof(struct rtw8822be_efuse) == 49);
+static_assert(offsetof(struct rtw8822b_efuse, u) == 0xd0);
+static_assert(sizeof(struct rtw8822bu_efuse) == 304);
+
 static inline void
 _rtw_write32s_mask(struct rtw_dev *rtwdev, u32 addr, u32 mask, u32 data)
 {
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8822c.h b/drivers/net/wireless/realtek/rtw88/rtw8822c.h
index 479d5d769c52..4c5402008387 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8822c.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8822c.h
@@ -96,6 +96,11 @@ struct rtw8822c_efuse {
 	};
 };
 
+static_assert(offsetof(struct rtw8822c_efuse, e) == 0x120);
+static_assert(sizeof(struct rtw8822ce_efuse) == 47);
+static_assert(offsetof(struct rtw8822c_efuse, u) == 0x120);
+static_assert(sizeof(struct rtw8822cu_efuse) == 122);
+
 enum rtw8822c_dpk_agc_phase {
 	RTW_DPK_GAIN_CHECK,
 	RTW_DPK_GAIN_LARGE,
-- 
2.39.0


                 reply	other threads:[~2023-01-08 21:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230108213114.547135-1-martin.blumenstingl@googlemail.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=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).