drm/amd/display: avoid unaligned access warnings
Subsystems (3)
PATCH 1/1 drm/amd/display: avoid unaligned access warnings
When building on OpenBSD/arm64 with clang 15, unaligned access warnings are seen when a union is embedded inside a packed struct.
drm/amd/display/dmub/inc/dmub_cmd.h:941:18: error: field
cursor_copy_src within 'struct dmub_rb_cmd_mall' is less aligned than 'union dmub_addr' and is usually due to 'struct dmub_rb_cmd_mall' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
union dmub_addr cursor_copy_src; /**< Cursor copy address */
^drm/amd/display/dmub/inc/dmub_cmd.h:942:18: error: field cursor_copy_dst
within 'struct dmub_rb_cmd_mall' is less aligned than 'union dmub_addr' and is usually due to 'struct dmub_rb_cmd_mall' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
union dmub_addr cursor_copy_dst; /**< Cursor copy destination */
^
Add pragma pack around dmub_addr to avoid this.
--- drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +2 -0
@@ -162,6 +162,7 @@ extern "C" {#define dmub_udelay (microseconds) udelay(microseconds)#endif +#pragma pack(push, 1)/** * union dmub_addr - DMUB physical/virtual 64-bit address. */
@@ -172,6 +173,7 @@ union dmub_addr { } u;/*<< Low/high bit access */ uint64_t quad_part;/*<< 64 bit address */ }; +#pragma pack(pop)/** * Dirty rect definition.
Signature · 1 line
2.39.1
Alex Deucher
AppliedApplied. Thanks!
Quoted 49 lines · Jonathan Gray
When building on OpenBSD/arm64 with clang 15, unaligned access warnings are seen when a union is embedded inside a packed struct.
drm/amd/display/dmub/inc/dmub_cmd.h:941:18: error: field
cursor_copy_srcwithin 'structdmub_rb_cmd_mall' is less aligned than 'uniondmub_addr' and is usually due to 'structdmub_rb_cmd_mall' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
uniondmub_addrcursor_copy_src; /**< Cursor copy address */
^drm/amd/display/dmub/inc/dmub_cmd.h:942:18: error: fieldcursor_copy_dst
within 'structdmub_rb_cmd_mall' is less aligned than 'uniondmub_addr' and is usually due to 'structdmub_rb_cmd_mall' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
uniondmub_addrcursor_copy_dst; /**< Cursor copy destination */
^Add pragma pack around
dmub_addrto avoid this.Signed-off-by Jonathan Gray <[email protected]>--- drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +2
-1@@ -162,6 +162,7 @@ extern "C" {#define dmub_udelay (microseconds) udelay(microseconds)#endif +#pragma pack(push, 1)/** * union dmub_addr - DMUB physical/virtual 64-bit address. */ @@ -172,6 +173,7 @@ union dmub_addr { } u;/*<< Low/high bit access */ uint64_t quad_part;/*<< 64 bit address */ }; +#pragma pack(pop)/** * Dirty rect definition. -- 2.39.1