Skip to content

Commit f989fa2

Browse files
jonathangrayalexdeucher
authored andcommitted
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: Jonathan Gray <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6e60cba commit f989fa2

File tree

9 files changed

+18
-0
lines changed

9 files changed

+18
-0
lines changed

drivers/gpu/drm/amd/pm/powerplay/inc/smu11_driver_if.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ typedef struct {
358358
QuadraticInt_t SsCurve;
359359
} DpmDescriptor_t;
360360

361+
#pragma pack(push, 1)
361362
typedef struct {
362363
uint32_t Version;
363364

@@ -609,6 +610,7 @@ typedef struct {
609610
uint32_t MmHubPadding[8];
610611

611612
} PPTable_t;
613+
#pragma pack(pop)
612614

613615
typedef struct {
614616

drivers/gpu/drm/amd/pm/powerplay/inc/smu9_driver_if.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ typedef struct {
122122
uint16_t Vid; /* min voltage in SVI2 VID */
123123
} DisplayClockTable_t;
124124

125+
#pragma pack(push, 1)
125126
typedef struct {
126127
/* PowerTune */
127128
uint16_t SocketPowerLimit; /* Watts */
@@ -323,6 +324,7 @@ typedef struct {
323324
uint32_t MmHubPadding[3]; /* SMU internal use */
324325

325326
} PPTable_t;
327+
#pragma pack(pop)
326328

327329
typedef struct {
328330
uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz)

drivers/gpu/drm/amd/pm/powerplay/inc/vega12/smu9_driver_if.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ typedef struct {
245245
QuadraticInt_t SsCurve;
246246
} DpmDescriptor_t;
247247

248+
#pragma pack(push, 1)
248249
typedef struct {
249250
uint32_t Version;
250251

@@ -508,6 +509,7 @@ typedef struct {
508509
uint32_t MmHubPadding[7];
509510

510511
} PPTable_t;
512+
#pragma pack(pop)
511513

512514
typedef struct {
513515

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_arcturus.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ typedef struct {
464464
uint16_t Padding16;
465465
} DpmDescriptor_t;
466466

467+
#pragma pack(push, 1)
467468
typedef struct {
468469
uint32_t Version;
469470

@@ -733,6 +734,7 @@ typedef struct {
733734
uint32_t MmHubPadding[8]; // SMU internal use
734735

735736
} PPTable_t;
737+
#pragma pack(pop)
736738

737739
typedef struct {
738740
// Time constant parameters for clock averages in ms

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_navi10.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ typedef struct {
515515
uint32_t BoardLevelEnergyAccumulator;
516516
} OutOfBandMonitor_t;
517517

518+
#pragma pack(push, 1)
518519
typedef struct {
519520
uint32_t Version;
520521

@@ -814,6 +815,7 @@ typedef struct {
814815
uint32_t MmHubPadding[8]; // SMU internal use
815816

816817
} PPTable_t;
818+
#pragma pack(pop)
817819

818820
typedef struct {
819821
// Time constant parameters for clock averages in ms

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu11_driver_if_sienna_cichlid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ typedef struct {
599599
uint16_t Fmax;
600600
} UclkDpmChangeRange_t;
601601

602+
#pragma pack(push, 1)
602603
typedef struct {
603604
// MAJOR SECTION: SKU PARAMETERS
604605

@@ -957,6 +958,7 @@ typedef struct {
957958
uint32_t MmHubPadding[8]; // SMU internal use
958959

959960
} PPTable_t;
961+
#pragma pack(pop)
960962

961963
typedef struct {
962964
// MAJOR SECTION: SKU PARAMETERS

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_aldebaran.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ typedef struct {
267267
QuadraticInt_t SsCurve; // Slow-slow curve (GHz->V)
268268
} DpmDescriptor_t;
269269

270+
#pragma pack(push, 1)
270271
typedef struct {
271272
uint32_t Version;
272273

@@ -448,6 +449,7 @@ typedef struct {
448449
uint32_t reserved[14];
449450

450451
} PPTable_t;
452+
#pragma pack(pop)
451453

452454
typedef struct {
453455
// Time constant parameters for clock averages in ms

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_0.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,10 +1347,12 @@ typedef struct {
13471347
uint32_t MmHubPadding[8];
13481348
} BoardTable_t;
13491349

1350+
#pragma pack(push, 1)
13501351
typedef struct {
13511352
SkuTable_t SkuTable;
13521353
BoardTable_t BoardTable;
13531354
} PPTable_t;
1355+
#pragma pack(pop)
13541356

13551357
typedef struct {
13561358
// Time constant parameters for clock averages in ms

drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu13_driver_if_v13_0_7.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,10 +1380,12 @@ typedef struct {
13801380
uint32_t MmHubPadding[8];
13811381
} BoardTable_t;
13821382

1383+
#pragma pack(push, 1)
13831384
typedef struct {
13841385
SkuTable_t SkuTable;
13851386
BoardTable_t BoardTable;
13861387
} PPTable_t;
1388+
#pragma pack(pop)
13871389

13881390
typedef struct {
13891391
// Time constant parameters for clock averages in ms

0 commit comments

Comments
 (0)