Gustavo A. R. Silva cc1a54d8f1 drm/radeon/si_dpm: Fix SMU power state load
Create new structure SISLANDS_SMC_SWSTATE_SINGLE, as initialState.levels
and ACPIState.levels are never actually used as flexible arrays. Those
arrays can be used as simple objects of type
SISLANDS_SMC_HW_PERFORMANCE_LEVEL, instead.

Currently, the code fails because flexible array _levels_ in
struct SISLANDS_SMC_SWSTATE doesn't allow for code that access
the first element of initialState.levels and ACPIState.levels
arrays:

4353         table->initialState.levels[0].mclk.vDLL_CNTL =
4354                 cpu_to_be32(si_pi->clock_registers.dll_cntl);
...
4555         table->ACPIState.levels[0].mclk.vDLL_CNTL =
4556                 cpu_to_be32(dll_cntl);

because such element cannot exist without previously allocating
any dynamic memory for it (which never actually happens).

That's why struct SISLANDS_SMC_SWSTATE should only be used as type
for object driverState and new struct SISLANDS_SMC_SWSTATE_SINGLE is
created as type for objects initialState, ACPIState and ULVState.

Also, with the change from one-element array to flexible-array member
in commit 96e27e8d919e ("drm/radeon/si_dpm: Replace one-element array
with flexible-array in struct SISLANDS_SMC_SWSTATE"), the size of
dpmLevels in struct SISLANDS_SMC_STATETABLE should be fixed to be
SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE instead of
SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1.

Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1583
Fixes: 96e27e8d919e ("drm/radeon/si_dpm: Replace one-element array with flexible-array in struct SISLANDS_SMC_SWSTATE")
Cc: stable@vger.kernel.org
Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2021-05-10 18:14:49 -04:00
..
2021-02-02 14:26:02 +01:00
2021-01-31 08:05:46 -07:00
2021-04-02 16:13:13 -07:00
2021-02-22 14:44:39 -08:00
2021-02-23 15:05:10 -08:00
2021-02-22 10:05:12 -08:00
2021-02-22 14:27:07 -08:00
2021-04-06 22:32:33 +02:00
2021-02-22 09:52:55 -08:00
2021-02-28 15:48:25 -08:00
2021-04-13 23:15:09 +02:00
2021-02-24 10:25:37 -08:00
2021-02-24 09:35:54 -08:00
2021-04-09 13:01:48 -07:00
2021-03-21 10:57:35 -07:00
2021-03-30 00:46:49 +02:00
2021-01-28 01:31:42 +01:00
2021-02-25 12:23:49 -08:00
2021-01-21 14:06:00 -07:00
2021-04-10 12:29:19 -07:00
2021-04-07 09:26:50 -07:00
2021-04-03 10:00:53 -07:00
2021-03-18 11:20:35 -07:00
2021-04-13 23:15:09 +02:00
2021-03-18 11:20:35 -07:00
2021-02-09 12:15:07 +01:00
2021-04-09 09:58:42 -07:00