Skip to contentSkip to conversation

staging: vt665x: fix alignment constraints

PATCH Superseded Edmundo Carmona Antoranz 2 participants 6 messages Mar 12, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: vt665x: fix alignment constraints

Removing 2 instances of alignment warnings

drivers/staging/vt6655/rxtx.h:153:1: warning: alignment 1 of ‘struct vnt_cts’ is less than 2 [-Wpacked-not-aligned] drivers/staging/vt6655/rxtx.h:163:1: warning: alignment 1 of ‘struct vnt_cts_fb’ is less than 2 [-Wpacked-not-aligned]

This patch is related to 2faf12c57ef (staging: vt665x: fix alignment constraints, 2021-02-04)

The root cause seems to be that _because_ struct ieee80211_cts is marked as __aligned(2), this requires any encapsulating struct to also have an alignment of 2.

---
 drivers/staging/vt6655/rxtx.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/vt6655/rxtx.h +2 -2
index e7061d383306..c3c2c1566882 100644
@@ -150,7 +150,7 @@ struct vnt_cts {
 	u16 reserved;
 	struct ieee80211_cts data;
 	u16 reserved2;
-} __packed;
+} __packed __aligned(2);
 
 struct vnt_cts_fb {
 	struct vnt_phy_field b;
@@ -160,7 +160,7 @@ struct vnt_cts_fb {
 	__le16 cts_duration_ba_f1;
 	struct ieee80211_cts data;
 	u16 reserved2;
-} __packed;
+} __packed __aligned(2);
 
 struct vnt_tx_fifo_head {
 	u8 tx_key[WLAN_KEY_LEN_CCMP];
Signature · 1 line
2.30.1
#1 lore raw
Quoted 4 lines · Edmundo Carmona Antoranz

The root cause seems to be that _because_ struct ieee80211_cts is marked as __aligned(2), this requires any encapsulating struct to also have an alignment of 2.

To make sure of this, I played with an empty struct.

struct a {} __packed __aligned(2);

struct structb {
    struct a blah;
} __packed; <--- got a warning about alignment not being 2.

I would guess that setting the encapsulating struct to be __aligned(4) or higher would also work fine, don't know if I should be more thorough in that regard in the patch comment.

#2 lore raw
Quoted 12 lines · Edmundo Carmona Antoranz
Quoted 4 lines · Edmundo Carmona Antoranz

The root cause seems to be that _because_ struct ieee80211_cts is marked as __aligned(2), this requires any encapsulating struct to also have an alignment of 2.

To make sure of this, I played with an empty struct.

struct a {} __packed __aligned(2);

Quoted 7 lines
struct structb {
    struct a blah;
} __packed; <--- got a warning about alignment not being 2.

I would guess that setting the encapsulating struct to be __aligned(4) or higher would also work fine, don't know if I should be more thorough in that regard in the patch comment.

I think the patch description is clear enough, but it would help to include a reference to my earlier patch that tried to fix the problem before. I don't know why this came back now, maybe my patch was incomplete to start with, or an extra alignment constraint was added to a second indirectly included structure.

Arnd

#3 lore raw
Quoted 4 lines · Arnd Bergmann

I think the patch description is clear enough, but it would help to include a reference to my earlier patch that tried to fix the problem before. I don't

Great! I did mention it in the preceding line to the section I replied to, though. It has it in the patch:

"""
This patch is related to 2faf12c57ef (staging: vt665x: fix alignment constraints, 2021-02-04)

The root cause seems to be that _because_ struct ieee80211_cts is marked as __aligned(2),
this requires any encapsulating struct to also have an alignment of 2. """

Maybe it needs to be formatted in a different fashion? Should I use a longer (like 11 chars, maybe) ID?

#4 lore raw
Quoted 14 lines · Edmundo Carmona Antoranz
Quoted 4 lines · Arnd Bergmann

I think the patch description is clear enough, but it would help to include a reference to my earlier patch that tried to fix the problem before. I don't

Great! I did mention it in the preceding line to the section I replied to, though. It has it in the patch:

"""
This patch is related to 2faf12c57ef (staging: vt665x: fix alignment constraints, 2021-02-04)

Quoted 7 lines

The root cause seems to be that _because_ struct ieee80211_cts is marked as __aligned(2),
this requires any encapsulating struct to also have an alignment of 2. """

Maybe it needs to be formatted in a different fashion? Should I use a longer (like 11 chars, maybe) ID?

My mistake. The normal references use 12-character IDs, but in this case I just missed it because it was in the cleartext.

I would normally use a separate 'Fixes:' line for this.

Arnd

#5 lore raw
Quoted 5 lines · Arnd Bergmann

My mistake. The normal references use 12-character IDs, but in this case I just missed it because it was in the cleartext.

I would normally use a separate 'Fixes:' line for this.

Oh, ok. Let me see its formatting and then I'll send a [PATCH v2]