Alex Deucher
158d823f07
drm/amdgpu/powerplay: Only apply optimized mclk dpm policy on polaris
...
Leads to improper dpm on older parts.
Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1353
Fixes: 8d89b96fe7 ("drm/amd/powerplay: optimize the mclk dpm policy settings")
Reviewed-by: Evan Quan <evan.quan@amd.com >
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-30 01:01:58 -04:00
Evan Quan
52934da275
drm/amd/pm: do not use ixFEATURE_STATUS for checking smc running
...
This reverts commit f878122841 ("drm/amdgpu:
Fix bug where DPM is not enabled after hibernate and resume").
It was intended to fix Hawaii S4(hibernation) issue but break S3. As
ixFEATURE_STATUS is filled with garbage data on resume which can be
only cleared by reloading smc firmware(but that will involve many
changes). So, we will revert this S4 fix and seek a new way.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Tested-by: Sandeep Raghuraman <sandy.8925@gmail.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-30 01:00:50 -04:00
Evan Quan
e6bd6890e8
drm/amd/pm: perform SMC reset on suspend/hibernation
...
So that the succeeding resume can be performed based on
a clean state.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Tested-by: Sandeep Raghuraman <sandy.8925@gmail.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-30 01:00:43 -04:00
Evan Quan
8a76ccd199
drm/amd/pm: correct the baco reset sequence for CI ASICs
...
Correct some registers bitmasks and add mmBIOS_SCRATCH_7
reset.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Tested-by: Sandeep Raghuraman <sandy.8925@gmail.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-30 01:00:27 -04:00
Evan Quan
b1878847ac
drm/amd/pm: drop redundant display setting
...
As this is already performed in smu7_set_power_state_tasks().
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:52 -04:00
Evan Quan
62ff83a4f6
drm/amd/pm: reconfigure smc on display vbitimeout setting change
...
Reconfigure smc display settings on vbitimeout change.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:47 -04:00
Evan Quan
d49873c93f
drm/amd/pm: correct the mclk switching setting
...
Correct the mclk switching setting for multiple displays.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:41 -04:00
Evan Quan
b03fd3e7e6
drm/amd/pm: enable Polaris watermark table setting
...
Enable watermark table setting for Polaris.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:34 -04:00
Evan Quan
690cdc2635
drm/amd/pm: fulfill the Polaris implementation for get_clock_by_type_with_latency()
...
Fulfill Polaris get_clock_by_type_with_latency().
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:28 -04:00
Evan Quan
db6f5c7f95
drm/amd/pm: correct vddc_dep_on_dal_pwrl setup
...
Correct Polaris10 setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:21 -04:00
Evan Quan
9182fefcb8
drm/amd/pm: correct SMC sclk/mclk boot level setup
...
Correct Polaris smc boot level setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:15 -04:00
Evan Quan
8f97e221d6
drm/amd/pm: correct pcie spc cap setup
...
Correct Polaris10 pcie spc cap setting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:09 -04:00
Evan Quan
ba4601feba
drm/amd/pm: correct clk/voltage dependence setup
...
Correct Polaris10 clk/voltage dependence setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 12:00:03 -04:00
Evan Quan
be56f22b62
drm/amd/pm: correct the way to get the highest vddc
...
Populate the correct highest vddc setting on Polaris.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:57 -04:00
Evan Quan
d765129a71
drm/amd/pm: correct sclk/mclk dpm enablement
...
Correct Polaris10 sclk/mclk dpm enablement.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:51 -04:00
Evan Quan
baa495f764
drm/amd/pm: correct smc voltage controller setup
...
Correct Polaris10 smc voltage controller setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:45 -04:00
Evan Quan
326d0ff7aa
drm/amd/pm: correct platformcaps setup
...
Correct Polaris10 platformcaps setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:39 -04:00
Evan Quan
55411d1623
drm/amd/pm: correct VRconfig setting
...
Correct Polaris VRconfig setting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:34 -04:00
Evan Quan
a6d8a6eb3e
drm/amd/pm: correct vddc phase control setting
...
Correct Polaris10 vddc phase control.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:28 -04:00
Evan Quan
b23dbd603b
drm/amd/pm: correct avfs fuse settings
...
Correct Polaris10 avfs fuse setting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:22 -04:00
Evan Quan
dba1953168
drm/amd/pm: correct Polaris DIDT configurations
...
Correct Polaris DIDT enablement.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:16 -04:00
Evan Quan
d8b61d5a0d
drm/amd/pm: correct Polaris powertune table setup
...
Correct powertune table setup for Polaris.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:10 -04:00
Evan Quan
f6638d0e6f
drm/amd/pm: correct the checks for sclk/mclk SS support
...
Correct sclk/mclk SS support checks.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:59:03 -04:00
Evan Quan
a8588b8bb3
drm/amd/pm: correct VR shared rail info
...
Add VR shared rail info.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:57 -04:00
Evan Quan
5f92b48cf6
drm/amd/pm: add mc register table initialization
...
Add mc register table initialization.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:51 -04:00
Evan Quan
8f0804c6b7
drm/amd/pm: add edc leakage controller setting
...
Enable edc controller table setting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:45 -04:00
Evan Quan
9610a3bfde
drm/amd/pm: setup zero rpm parameters for polaris10
...
Only if the ZeroRPM feature is supported.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:39 -04:00
Evan Quan
c420418f1d
drm/amd/pm: correct polaris10 clock stretcher data table setting
...
By using the saved copy of ro_range_maximum and ro_range_minimum.
Correct the setting for "LdoRefSel".
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:33 -04:00
Evan Quan
a90e6fbe47
drm/amd/pm: correct the settings for ro range minimum and maximum
...
Make the settings more precise.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:27 -04:00
Evan Quan
029479acca
drm/amd/pm: drop redundant efuse mask calculations
...
By moving that in atomfw_read_efuse().
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:21 -04:00
Evan Quan
555440822b
drm/amd/pm: optimize AC timing programming
...
Programming AC Timing Parameters is only dependent on MCLK.
No need to nest loop for each SCLK DPM level.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:15 -04:00
Evan Quan
18973c6ec4
drm/amd/powerplay: separate Polaris fan table setup from Tonga
...
Instead of sharing the fan table setup with Tonga, Polaris has
its own fan table setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:08 -04:00
Evan Quan
8c23cc29d5
drm/amd/pm: add PWR_CKS_CNTL setting
...
This is for some special Polaris10 ASICs.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:58:01 -04:00
Evan Quan
7f95a2e01c
drm/amd/pm: drop arb table first byte workaround
...
As this is not needed for polaris.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:48 -04:00
Evan Quan
e9016fc2ad
drm/amd/pm: add pptable VRHotLevel setting
...
Add missing VRHotLevel setting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:42 -04:00
Evan Quan
3a9f6bb21d
drm/amd/pm: correct the BootLinkLevel setup
...
Set the BootLinkLevel as the max level.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:36 -04:00
Evan Quan
a193d97741
drm/amd/pm: correct the ACPI table setup V2
...
Correct the setting for "ActivityLevel".
V2: rich the comment
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:28 -04:00
Evan Quan
0232af1cea
drm/amd/pm: correct mclk table setup
...
Correct the settings for "StutterEnable" and "EnabledForActivity".
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:21 -04:00
Evan Quan
374b0781a0
drm/amd/pm: correct sclk table setup
...
Correct Polaris10 sclk table setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:15 -04:00
Evan Quan
8849fe64f6
drm/amd/pm: correct vddci table setup
...
Make sure the settings are applied only when voltage
controlled by gpio.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:09 -04:00
Evan Quan
3df9931b06
drm/amd/pm: populate smc samu table
...
Add missing smc samu table setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:57:03 -04:00
Evan Quan
10efb75b58
drm/amd/pm: populate smc vddc table
...
Add missing vddc table setup.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-27 11:56:57 -04:00
Evan Quan
4460571bee
drm/amd/pm: increase mclk switch threshold to 200 us
...
To avoid underflow seen on Polaris10 with some 3440x1440
144Hz displays. As the threshold of 190 us cuts too close
to minVBlankTime of 192 us.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-14 15:14:09 -04:00
Gustavo A. R. Silva
bae82e8418
drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_pcie_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_ppt_v1_pcie_table, instead of a one-element array, and use
the struct_size() helper to calculate the size for the allocation.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7db0bc.7Xivn4K83f7XW0ug%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
b44fd9ccfa
drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_voltage_lookup_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_ppt_v1_voltage_lookup_table, instead of a one-element array,
and use the struct_size() helper to calculate the size for the allocation.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7d61df.jWrFfnjxGbjSkPOp%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
03f0a7b857
drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_mm_clock_voltage_dependency_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_ppt_v1_mm_clock_voltage_dependency_table, instead of a
one-element array, and use the struct_size() helper to calculate the
size for the allocation.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7d61e2.qiTVTyG2pVoG8bb0%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
5be63325c5
drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_clock_voltage_dependency_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_ppt_v1_clock_voltage_dependency_table, instead of a one-element
array, and use the struct_size() helper to calculate the size for the
allocation.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7c433c.TTk9rnA+F58kyDUy%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
89c785bb1a
drm/amd/pm: Replace one-element array with flexible-array in struct phm_samu_clock_voltage_dependency_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_samu_clock_voltage_dependency_table, instead of a one-element array,
and use the struct_size() helper to calculate the size for the allocation.
Also, save some heap space as the original code is multiplying
table->numEntries by sizeof(struct phm_samu_clock_voltage_dependency_table)
when it should have been multiplied it by
sizeof(struct phm_samu_clock_voltage_dependency_record) instead.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7c5d3a.ryM4GmZr3e0JeZy+%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
aa8d10a10f
drm/amd/pm: Replace one-element array with flexible-array in struct phm_cac_leakage_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_cac_leakage_table, instead of a one-element array,
and use the struct_size() helper to calculate the size for the allocation.
Also, save some heap space as the original code is multiplying
table->ucNumEntries by sizeof(struct phm_cac_leakage_table) when it
should have been multiplied it by sizeof(struct phm_cac_leakage_record)
instead.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7c5d38.iT%2FQTjN+659XUDo5%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:30 -04:00
Gustavo A. R. Silva
637f7576ec
drm/amd/pm: Replace one-element array with flexible-array in struct phm_vce_clock_voltage_dependency_table
...
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].
Refactor the code according to the use of a flexible-array member in
struct phm_vce_clock_voltage_dependency_table, instead of a one-element array,
and use the struct_size() helper to calculate the size for the allocation.
Also, save some heap space as the original code is multiplying
table->numEntries by sizeof(struct phm_vce_clock_voltage_dependency_table)
when it should have multiplied it by sizeof(struct phm_vce_clock_voltage_dependency_record)
instead.
[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays
Build-tested-by: kernel test robot <lkp@intel.com >
Link: https://lore.kernel.org/lkml/5f7c5d35.pJToGs3H9khZK6ws%25lkp@intel.com/
Acked-by: Christian König <christian.koenig@amd.com >
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:43:29 -04:00