soc/fsl: qbman: fix conflicting alignment attributes
PATCH 1/1 soc/fsl: qbman: fix conflicting alignment attributes
From: Arnd Bergmann <[email protected]>
When building with W=1, gcc points out that the __packed attribute on struct qm_eqcr_entry conflicts with the 8-byte alignment attribute on struct qm_fd inside it:
drivers/soc/fsl/qbman/qman.c:189:1: error: alignment 1 of 'struct qm_eqcr_entry' is less than 8 [-Werror=packed-not-aligned]
I assume that the alignment attribute is the correct one, and that qm_eqcr_entry cannot actually be unaligned in memory, so add the same alignment on the outer struct.
--- drivers/soc/fsl/qbman/qman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/fsl/qbman/qman.c +1 -1
@@ -186,7 +186,7 @@ struct qm_eqcr_entry {__be32 tag;struct qm_fd fd;u8 __reserved3[32 ]; -} __packed; +} __packed__aligned(8) ;#define QM_EQCR_VERB_VBIT 0x80#define QM_EQCR_VERB_CMD_MASK 0x61/* but only one value; */ #define QM_EQCR_VERB_CMD_ENQUEUE 0x01
Signature · 1 line
2.29.2
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When building with W=1, gcc points out that the
__packedattribute on structqm_eqcr_entryconflicts with the 8-byte alignment attribute on structqm_fdinside it:
drivers/soc/fsl/qbman/qman.c:189:1: error: alignment 1 of 'structqm_eqcr_entry' is less than 8 [-Werror=packed-not-aligned]I assume that the alignment attribute is the correct one, and that
qm_eqcr_entrycannot actually be unaligned in memory, so add the same alignment on the outer struct.Fixes c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/soc/fsl/qbman/qman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/soc/fsl/qbman/qman.c +0
-0
drivers/soc/fsl/qbman/qman.c struct qm_eqcr_entry { · line 189
Quoted 5 lines
drivers/soc/fsl/qbman/qman.c +1
-1@@ -186,7 +186,7 @@ struct qm_eqcr_entry {__be32 tag;struct qm_fd fd;u8 __reserved3[32 ]; -} __packed; +} __packed__aligned(8) ;
The EQCR structure is actually aligned on 64-byte from the manual. But probably 8 is enough to let the compiler not complain.
Quoted 6 lines
drivers/soc/fsl/qbman/qman.c +0
-1#define QM_EQCR_VERB_VBIT 0x80#define QM_EQCR_VERB_CMD_MASK 0x61/* but only one value; */ #define QM_EQCR_VERB_CMD_ENQUEUE 0x01 --2.29.2
Quoted 20 lines · Li Yang
Quoted 19 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
When building with W=1, gcc points out that the
__packedattribute on structqm_eqcr_entryconflicts with the 8-byte alignment attribute on structqm_fdinside it:
drivers/soc/fsl/qbman/qman.c:189:1: error: alignment 1 of 'structqm_eqcr_entry' is less than 8 [-Werror=packed-not-aligned]I assume that the alignment attribute is the correct one, and that
qm_eqcr_entrycannot actually be unaligned in memory, so add the same alignment on the outer struct.Fixes c535e923bb97 ("soc/fsl: Introduce DPAA 1.x QMan device driver")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/soc/fsl/qbman/qman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
drivers/soc/fsl/qbman/qman.c struct qm_eqcr_entry { · line 189
Quoted 10 lines
drivers/soc/fsl/qbman/qman.c +1
-1@@ -186,7 +186,7 @@ struct qm_eqcr_entry {__be32 tag;struct qm_fd fd;u8 __reserved3[32 ]; -} __packed; +} __packed__aligned(8) ;The EQCR structure is actually aligned on 64-byte from the manual. But probably 8 is enough to let the compiler not complain.
The important bit is that all members inside are at most 8-byte long and naturally aligned, so the compiler can now optimize the accesses because it can assume that each member can be updated atomically.
Marking a structure as unaligned with the __packed attribute can lead to rather unoptimized code, which is particularly important when the structure is mapped as uncached -- accessing it one byte at a time means you have eight times the latency for a simple read. I think on arm64, the compiler doesn't actually have to do that, but at least if you run a 32-bit kernel, the packing would prevent the use of ldrd or ldm instructions that need an aligned word.
Arnd
Arnd Bergmann
AppliedFrom: Arnd Bergmann <[email protected]>
Quoted 9 lines · Arnd Bergmann
When building with W=1, gcc points out that the
__packedattribute on structqm_eqcr_entryconflicts with the 8-byte alignment attribute on structqm_fdinside it:
drivers/soc/fsl/qbman/qman.c:189:1: error: alignment 1 of 'structqm_eqcr_entry' is less than 8 [-Werror=packed-not-aligned]I assume that the alignment attribute is the correct one, and that
qm_eqcr_entrycannot actually be unaligned in memory, so add the same alignment on the outer struct.
Applied to arm/fixes
[1/1] soc/fsl: qbman: fix conflicting alignment attributes
commit: b9ab2619047edc1c6c07dc68963d84a5979f0abe
Arnd