[PATCH] drm/amd/pm: avoid unaligned access warnings
Alex Deucher
alexdeucher at gmail.com
Wed Feb 15 04:30:36 UTC 2023
Applied. Thanks!
Alex
On Tue, Feb 14, 2023 at 1:58 AM Jonathan Gray <jsg at jsg.id.au> wrote:
>
> When building on OpenBSD/arm64 with clang 15, unaligned access
> warnings are seen when a union is embedded inside a packed struct.
>
> drm/amd/pm/powerplay/hwmgr/vega20_pptable.h:136:17: error: field
> smcPPTable within 'struct _ATOM_VEGA20_POWERPLAYTABLE' is less aligned
> than 'PPTable_t' and is usually due to
> 'struct _ATOM_VEGA20_POWERPLAYTABLE' being packed, which can lead to
> unaligned accesses [-Werror,-Wunaligned-access]
> PPTable_t smcPPTable;
> ^
>
> Make PPTable_t packed to avoid this.
>
> Signed-off-by: Jonathan Gray <jsg at jsg.id.au>
> ---
> drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h | 2 ++
> drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h | 2 ++
> drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h | 2 ++
> .../gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h | 2 ++
> .../gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h | 2 ++
> .../amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h | 2 ++
> .../drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h | 2 ++
> .../gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h | 2 ++
> .../gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h | 2 ++
> 9 files changed, 18 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h b/drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h
> index fdc6b7a57bc9..c2efc70ef288 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h
> +++ b/drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h
> @@ -358,6 +358,7 @@ typedef struct {
> QuadraticInt_t SsCurve;
> } DpmDescriptor_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> uint32_t Version;
>
> @@ -609,6 +610,7 @@ typedef struct {
> uint32_t MmHubPadding[8];
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h b/drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h
> index 2818c98ff5ca..faae4b918d90 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h
> +++ b/drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h
> @@ -122,6 +122,7 @@ typedef struct {
> uint16_t Vid; /* min voltage in SVI2 VID */
> } DisplayClockTable_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> /* PowerTune */
> uint16_t SocketPowerLimit; /* Watts */
> @@ -323,6 +324,7 @@ typedef struct {
> uint32_t MmHubPadding[3]; /* SMU internal use */
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz)
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h b/drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h
> index b6ffd08784e7..6456bea5d2d5 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h
> +++ b/drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h
> @@ -245,6 +245,7 @@ typedef struct {
> QuadraticInt_t SsCurve;
> } DpmDescriptor_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> uint32_t Version;
>
> @@ -508,6 +509,7 @@ typedef struct {
> uint32_t MmHubPadding[7];
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
>
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h
> index 43d43d6addc0..d518dee18e1b 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h
> @@ -464,6 +464,7 @@ typedef struct {
> uint16_t Padding16;
> } DpmDescriptor_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> uint32_t Version;
>
> @@ -733,6 +734,7 @@ typedef struct {
> uint32_t MmHubPadding[8]; // SMU internal use
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // Time constant parameters for clock averages in ms
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h
> index 04752ade1016..c5c1943fb6a1 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h
> @@ -515,6 +515,7 @@ typedef struct {
> uint32_t BoardLevelEnergyAccumulator;
> } OutOfBandMonitor_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> uint32_t Version;
>
> @@ -814,6 +815,7 @@ typedef struct {
> uint32_t MmHubPadding[8]; // SMU internal use
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // Time constant parameters for clock averages in ms
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
> index 351a4af429b3..aa6d29de4002 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h
> @@ -599,6 +599,7 @@ typedef struct {
> uint16_t Fmax;
> } UclkDpmChangeRange_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> // MAJOR SECTION: SKU PARAMETERS
>
> @@ -957,6 +958,7 @@ typedef struct {
> uint32_t MmHubPadding[8]; // SMU internal use
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // MAJOR SECTION: SKU PARAMETERS
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h
> index 7a6075daa7b2..90200f31ff52 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h
> @@ -267,6 +267,7 @@ typedef struct {
> QuadraticInt_t SsCurve; // Slow-slow curve (GHz->V)
> } DpmDescriptor_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> uint32_t Version;
>
> @@ -448,6 +449,7 @@ typedef struct {
> uint32_t reserved[14];
>
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // Time constant parameters for clock averages in ms
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h
> index 4bc7aee4d44f..b686fb68a6e7 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h
> @@ -1347,10 +1347,12 @@ typedef struct {
> uint32_t MmHubPadding[8];
> } BoardTable_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> SkuTable_t SkuTable;
> BoardTable_t BoardTable;
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // Time constant parameters for clock averages in ms
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h
> index 48a3a3952ceb..4c46a0392451 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h
> +++ b/drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h
> @@ -1380,10 +1380,12 @@ typedef struct {
> uint32_t MmHubPadding[8];
> } BoardTable_t;
>
> +#pragma pack(push, 1)
> typedef struct {
> SkuTable_t SkuTable;
> BoardTable_t BoardTable;
> } PPTable_t;
> +#pragma pack(pop)
>
> typedef struct {
> // Time constant parameters for clock averages in ms
> --
> 2.39.1
>
More information about the amd-gfx
mailing list