Skip to contentSkip to conversation

wifi: rtw88: 8814a: add __packed to ensure efuse map size

PATCH In review Ping-Ke Shih 2 participants 4 messages Apr 10 – Apr 20 Realtek wireless driver (rtw88)

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

PATCH 1/1 wifi: rtw88: 8814a: add __packed to ensure efuse map size

All nested sture/union used by efuse map should be packed. Otherwise, a arm-linux-gnueabi-gcc compiler might throw errors due to size assertion.

In file included from include/linux/bitfield.h:10,

                    from include/linux/fortify-string.h:5,
                    from include/linux/string.h:389,
                    from include/linux/uuid.h:11,
                    from include/linux/mod_devicetable.h:14,
                    from include/linux/usb.h:5,
                    from drivers/net/wireless/realtek/rtw88/rtw8814a.c:5:
Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct rtw8814a_efuse) == 512"

    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                            ^~~~~~~~~~~~~~
Fixes 1a7545784642 ("wifi: rtw88: Add rtw8814a.{c,h}")
Cc Bitterblue Smith <[email protected]>
---
 drivers/net/wireless/realtek/rtw88/main.h     | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8814a.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/main.h +1 -1
index 9c0b746540b0..3cc7c2666c1c 100644
@@ -471,7 +471,7 @@ struct rtw_2g_txpwr_idx {
 	struct rtw_2g_ns_pwr_idx_diff ht_2s_diff;
 	struct rtw_2g_ns_pwr_idx_diff ht_3s_diff;
 	struct rtw_2g_ns_pwr_idx_diff ht_4s_diff;
-};
+} __packed;
 
 struct rtw_5g_ht_1s_pwr_idx_diff {
 #ifdef __LITTLE_ENDIAN
drivers/net/wireless/realtek/rtw88/rtw8814a.h +1 -1
index c57c7c8f915e..a0d9446e2043 100644
@@ -51,7 +51,7 @@ struct rtw8814a_efuse {
 	union {
 		struct rtw8814au_efuse u;
 		struct rtw8814ae_efuse e;
-	};
+	} __packed;
 	u8 res5[0x122];			/* 0xde */
 } __packed;
 

base-commit: 929298742bb5dfacd53ea99cf989cc81210f90a3

Signature · 1 line
2.25.1
#1 lore raw
Quoted 19 lines · Ping-Ke Shih

All nested sture/union used by efuse map should be packed. Otherwise, a arm-linux-gnueabi-gcc compiler might throw errors due to size assertion.

In file included from include/linux/bitfield.h:10,

                    from include/linux/fortify-string.h:5,
                    from include/linux/string.h:389,
                    from include/linux/uuid.h:11,
                    from include/linux/mod_devicetable.h:14,
                    from include/linux/usb.h:5,
                    from drivers/net/wireless/realtek/rtw88/rtw8814a.c:5:
Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct rtw8814a_efuse) == 512"

    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                            ^~~~~~~~~~~~~~
Fixes 1a7545784642 ("wifi: rtw88: Add rtw8814a.{c,h}")
Cc Bitterblue Smith <[email protected]>
Quoted 5 lines
---
 drivers/net/wireless/realtek/rtw88/main.h     | 2 +-
 drivers/net/wireless/realtek/rtw88/rtw8814a.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Thank you for taking care of this. Actually, every chip's efuse struct has a union like this missing __packed, not just RTL8814A. Most of them don't have a static_assert.

Quoted 28 lines
drivers/net/wireless/realtek/rtw88/main.h +1 -1
index 9c0b746540b0..3cc7c2666c1c 100644
@@ -471,7 +471,7 @@ struct rtw_2g_txpwr_idx {
 	struct rtw_2g_ns_pwr_idx_diff ht_2s_diff;
 	struct rtw_2g_ns_pwr_idx_diff ht_3s_diff;
 	struct rtw_2g_ns_pwr_idx_diff ht_4s_diff;
-};
+} __packed;
 
 struct rtw_5g_ht_1s_pwr_idx_diff {
 #ifdef __LITTLE_ENDIAN
drivers/net/wireless/realtek/rtw88/rtw8814a.h +1 -1
index c57c7c8f915e..a0d9446e2043 100644
@@ -51,7 +51,7 @@ struct rtw8814a_efuse {
 	union {
 		struct rtw8814au_efuse u;
 		struct rtw8814ae_efuse e;
-	};
+	} __packed;
 	u8 res5[0x122];			/* 0xde */
 } __packed;
 

base-commit: 929298742bb5dfacd53ea99cf989cc81210f90a3

author maintainer
#2 lore raw
Quoted 26 lines · Bitterblue Smith
Quoted 19 lines · Ping-Ke Shih

All nested sture/union used by efuse map should be packed. Otherwise, a arm-linux-gnueabi-gcc compiler might throw errors due to size assertion.

    In file included from include/linux/bitfield.h:10,
                     from include/linux/fortify-string.h:5, from include/linux/string.h:389,
                     from include/linux/uuid.h:11,
                     from include/linux/mod_devicetable.h:14, from include/linux/usb.h:5,
                     from drivers/net/wireless/realtek/rtw88/rtw8814a.c:5:

Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct rtw8814a_efuse) == 512"

     #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~~~~~~~~~~~

Fixes 1a7545784642 ("wifi: rtw88: Add rtw8814a.{c,h}")
Cc Bitterblue Smith <[email protected]>
Quoted 5 lines

---
  drivers/net/wireless/realtek/rtw88/main.h     | 2 +- drivers/net/wireless/realtek/rtw88/rtw8814a.h | 2 +-

  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

Thank you for taking care of this. Actually, every chip's efuse struct has a union like this missing __packed, not just RTL8814A. Most of them don't have a static_assert.

Indeed. I added size assetion of efuse map entirely to rtw88 and rtw89 [1], hoping we can find and address this kind of problem earlier.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#t

author maintainer
#3 lore raw
Quoted 35 lines · Ping-Ke Shih
Quoted 4 lines · Bitterblue Smith
Quoted 3 lines · Ping-Ke Shih

All nested sture/union used by efuse map should be packed. Otherwise, a arm-linux-gnueabi-gcc compiler might throw errors due to size assertion.

Quoted 8 lines
Quoted 8 lines

    In file included from include/linux/bitfield.h:10,
                     from include/linux/fortify-string.h:5, from include/linux/string.h:389,
                     from include/linux/uuid.h:11,
                     from include/linux/mod_devicetable.h:14, from include/linux/usb.h:5,
                     from drivers/net/wireless/realtek/rtw88/rtw8814a.c:5:

Quoted 1 line
Quoted 1 line

include/linux/build_bug.h:78:41: error: static assertion failed: "sizeof(struct rtw8814a_efuse)

== 512"

Quoted 14 lines
Quoted 8 lines

     #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) ^~~~~~~~~~~~~~

Fixes 1a7545784642 ("wifi: rtw88: Add rtw8814a.{c,h}")
Cc Bitterblue Smith <[email protected]>
Quoted 5 lines

---
  drivers/net/wireless/realtek/rtw88/main.h     | 2 +- drivers/net/wireless/realtek/rtw88/rtw8814a.h | 2 +-

  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 4 lines

Thank you for taking care of this. Actually, every chip's efuse struct has a union like this missing __packed, not just RTL8814A. Most of them don't have a static_assert.

Quoted 5 lines

Indeed. I added size assetion of efuse map entirely to rtw88 and rtw89 [1], hoping we can find and address this kind of problem earlier.

[1] https://lore.kernel.org/linux-wireless/[email protected]/T/#t

As discussion in original link [2], the ARM OABI should not be used anymore. I'd drop this patch, and also drop patches to assert efuse size of rtw88 and rtw89 [1].

[2] https://lore.kernel.org/oe-kbuild-all/[email protected]/