Commit f989fa29 authored by Jonathan Gray's avatar Jonathan Gray Committed by Alex Deucher

drm/amd/pm: 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/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: default avatarJonathan Gray <jsg@jsg.id.au>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6e60cba6
...@@ -358,6 +358,7 @@ typedef struct { ...@@ -358,6 +358,7 @@ typedef struct {
QuadraticInt_t SsCurve; QuadraticInt_t SsCurve;
} DpmDescriptor_t; } DpmDescriptor_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
uint32_t Version; uint32_t Version;
...@@ -609,6 +610,7 @@ typedef struct { ...@@ -609,6 +610,7 @@ typedef struct {
uint32_t MmHubPadding[8]; uint32_t MmHubPadding[8];
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
......
...@@ -122,6 +122,7 @@ typedef struct { ...@@ -122,6 +122,7 @@ typedef struct {
uint16_t Vid; /* min voltage in SVI2 VID */ uint16_t Vid; /* min voltage in SVI2 VID */
} DisplayClockTable_t; } DisplayClockTable_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
/* PowerTune */ /* PowerTune */
uint16_t SocketPowerLimit; /* Watts */ uint16_t SocketPowerLimit; /* Watts */
...@@ -323,6 +324,7 @@ typedef struct { ...@@ -323,6 +324,7 @@ typedef struct {
uint32_t MmHubPadding[3]; /* SMU internal use */ uint32_t MmHubPadding[3]; /* SMU internal use */
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz) uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz)
......
...@@ -245,6 +245,7 @@ typedef struct { ...@@ -245,6 +245,7 @@ typedef struct {
QuadraticInt_t SsCurve; QuadraticInt_t SsCurve;
} DpmDescriptor_t; } DpmDescriptor_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
uint32_t Version; uint32_t Version;
...@@ -508,6 +509,7 @@ typedef struct { ...@@ -508,6 +509,7 @@ typedef struct {
uint32_t MmHubPadding[7]; uint32_t MmHubPadding[7];
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
......
...@@ -464,6 +464,7 @@ typedef struct { ...@@ -464,6 +464,7 @@ typedef struct {
uint16_t Padding16; uint16_t Padding16;
} DpmDescriptor_t; } DpmDescriptor_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
uint32_t Version; uint32_t Version;
...@@ -733,6 +734,7 @@ typedef struct { ...@@ -733,6 +734,7 @@ typedef struct {
uint32_t MmHubPadding[8]; // SMU internal use uint32_t MmHubPadding[8]; // SMU internal use
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// Time constant parameters for clock averages in ms // Time constant parameters for clock averages in ms
......
...@@ -515,6 +515,7 @@ typedef struct { ...@@ -515,6 +515,7 @@ typedef struct {
uint32_t BoardLevelEnergyAccumulator; uint32_t BoardLevelEnergyAccumulator;
} OutOfBandMonitor_t; } OutOfBandMonitor_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
uint32_t Version; uint32_t Version;
...@@ -814,6 +815,7 @@ typedef struct { ...@@ -814,6 +815,7 @@ typedef struct {
uint32_t MmHubPadding[8]; // SMU internal use uint32_t MmHubPadding[8]; // SMU internal use
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// Time constant parameters for clock averages in ms // Time constant parameters for clock averages in ms
......
...@@ -599,6 +599,7 @@ typedef struct { ...@@ -599,6 +599,7 @@ typedef struct {
uint16_t Fmax; uint16_t Fmax;
} UclkDpmChangeRange_t; } UclkDpmChangeRange_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
// MAJOR SECTION: SKU PARAMETERS // MAJOR SECTION: SKU PARAMETERS
...@@ -957,6 +958,7 @@ typedef struct { ...@@ -957,6 +958,7 @@ typedef struct {
uint32_t MmHubPadding[8]; // SMU internal use uint32_t MmHubPadding[8]; // SMU internal use
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// MAJOR SECTION: SKU PARAMETERS // MAJOR SECTION: SKU PARAMETERS
......
...@@ -267,6 +267,7 @@ typedef struct { ...@@ -267,6 +267,7 @@ typedef struct {
QuadraticInt_t SsCurve; // Slow-slow curve (GHz->V) QuadraticInt_t SsCurve; // Slow-slow curve (GHz->V)
} DpmDescriptor_t; } DpmDescriptor_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
uint32_t Version; uint32_t Version;
...@@ -448,6 +449,7 @@ typedef struct { ...@@ -448,6 +449,7 @@ typedef struct {
uint32_t reserved[14]; uint32_t reserved[14];
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// Time constant parameters for clock averages in ms // Time constant parameters for clock averages in ms
......
...@@ -1347,10 +1347,12 @@ typedef struct { ...@@ -1347,10 +1347,12 @@ typedef struct {
uint32_t MmHubPadding[8]; uint32_t MmHubPadding[8];
} BoardTable_t; } BoardTable_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
SkuTable_t SkuTable; SkuTable_t SkuTable;
BoardTable_t BoardTable; BoardTable_t BoardTable;
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// Time constant parameters for clock averages in ms // Time constant parameters for clock averages in ms
......
...@@ -1380,10 +1380,12 @@ typedef struct { ...@@ -1380,10 +1380,12 @@ typedef struct {
uint32_t MmHubPadding[8]; uint32_t MmHubPadding[8];
} BoardTable_t; } BoardTable_t;
#pragma pack(push, 1)
typedef struct { typedef struct {
SkuTable_t SkuTable; SkuTable_t SkuTable;
BoardTable_t BoardTable; BoardTable_t BoardTable;
} PPTable_t; } PPTable_t;
#pragma pack(pop)
typedef struct { typedef struct {
// Time constant parameters for clock averages in ms // Time constant parameters for clock averages in ms
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment