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
Tao Zhou
34c0631bbd
drm/amd/pm: update driver if version for dimgrey_cavefish
...
Per PMFW 59.9.0.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-26 13:27:08 -04:00
Kenneth Feng
891bacb835
drm/amd/pm: remove the average clock value in sysfs
...
if it's fine-grained clock dpm, remove the average clock value and
reflects the real clock.
Signed-off-by: Kenneth Feng <kenneth.feng@amd.com >
Reviewed-by: Likun Gao <Likun.Gao@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-23 15:30:49 -04:00
Kenneth Feng
4e2b3e23b2
drm/amd/pm: fix pp_dpm_fclk
...
fclk value is missing in pp_dpm_fclk. add this to correctly show the current value.
Signed-off-by: Kenneth Feng <kenneth.feng@amd.com >
Reviewed-by: Likun Gao <Likun.Gao@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-21 16:16:54 -04:00
Kenneth Feng
1eeb03c883
drm/amd/pm: fix the wrong fan speed in fan1_input
...
fix the wrong fan speed in fan1_input when the fan control mode is manual.
the fan speed value is not correct when we set manual mode to fan1_enalbe - 1.
since the fan speed in the metrics table always reflects the real fan speed,we
can fetch the fan speed for both auto and manual mode.
Signed-off-by: Kenneth Feng <kenneth.feng@amd.com >
Reviewed-by: Likun Gao <Likun.Gao@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-21 16:15:19 -04:00
Likun Gao
1dc3c5a95b
drm/amd/pm: update driver if file for sienna cichlid
...
Update driver if file for sienna cichlid.
Signed-off-by: Likun Gao <Likun.Gao@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-21 16:14:40 -04:00
Likun Gao
f20c52f40a
drm/amd/pm: fix pcie information for sienna cichlid
...
Fix the function used for sienna cichlid to get correct PCIE information
by pp_dpm_pcie.
Signed-off-by: Likun Gao <Likun.Gao@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-21 16:14:33 -04:00
Kevin Wang
7aeef2aacc
drm/amd/swsmu: correct wrong feature bit mapping
...
1. when smc feature bit isn't mapped,
the feature state isn't showed on sysfs node of pp_features.
2. add pp_features table title
Signed-off-by: Kevin Wang <kevin1.wang@amd.com >
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-21 16:13:57 -04:00
Jiansong Chen
15d67827b0
drm/amd/pm: drop navy_flounder hardcode of using soft pptable
...
Drop navy_flounder hardcode of using soft pptable, so that it
can use pptable from vbios when available.
Signed-off-by: Jiansong Chen <Jiansong.Chen@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-16 14:45:04 -04:00
Kevin Wang
e9073b4362
drm/amd/swsmu: add missing feature map for sienna_cichlid
...
it will cause smu sysfs node of "pp_features" show error.
Signed-off-by: Kevin Wang <kevin1.wang@amd.com >
Reviewed-by: Likun Gao <Likun.Gao@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-16 14:44:44 -04:00
Evan Quan
76c71f00d7
drm/amd/pm: properly setting GPO feature on UMD pstate entering/exiting
...
Disable/enable the GPO feature on UMD pstate entering/exiting.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-15 12:21:17 -04:00
Evan Quan
f2b75bc24d
drm/amd/pm: correct gfx and pcie settings on umd pstate switching(V2)
...
For entering UMD stable Pstate, the operations to enter rlc_safe
mode, disable mgcg_perfmon and disable PCIE aspm are needed. And
the opposite operations should be performed on UMD stable Pstate
exiting.
V2: take those ASICs(CI/SI/VI) which may not support this into
consideration
Signed-off-by: Evan Quan <evan.quan@amd.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-15 12:20:46 -04:00
Evan Quan
585584dbaa
drm/amd/pm: populate Arcturus PCIE link state
...
Populate current link speed, width and clock domain frequency.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-15 12:20:39 -04:00
Evan Quan
7d92c1fd11
drm/amd/pm: populate the bootup LCLK frequency
...
As for other clock domains.
Signed-off-by: Evan Quan <evan.quan@amd.com >
Reviewed-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-15 12:20:31 -04:00
Tom Rix
234de272b7
drm/amdgpu: add missing newline at eof
...
Representative checkpatch.pl warning
WARNING: adding a line without newline at end of file
30: FILE: drivers/gpu/drm/amd/pm/swsmu/smu11/vangogh_ppt.h:30:
+#endif
Signed-off-by: Tom Rix <trix@redhat.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-15 12:20:12 -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
Alex Deucher
cde3359acb
drm/amdgpu/swsmu: init the baco mutex in early_init
...
GPU reset might get called during init time, before
sw_init has been called.
Reviewed-by: Kevin Wang <kevin1.wang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-14 15:13:34 -04:00
Tao Zhou
4da6783908
drm/amdgpu/swsmu: update driver if version for dimgrey_cavefish
...
Per PMFW 59.7.0.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Jiansong Chen <Jiansong.Chen@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:02:48 -04:00
Tao Zhou
7dc2ef4e70
drm/amdgpu/swsmu: update driver if version for dimgrey_cavefish(v2)
...
Per PMFW 59.5.0.
v2: refine subject and commit message, fix typo
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Jiansong Chen <Jiansong.Chen@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:02:31 -04:00
Tao Zhou
4ccc957f15
drm/amdgpu/swsmu: update driver if version for dimgrey_cavefish
...
Update driver if version from 0x5 to 0x6 for dimgrey_cavefish, per PMFW 59.04.0.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:02:29 -04:00
Tao Zhou
e8afbddfa1
drm/amdgpu/swsmu: update driver if version for dimgrey_cavefish
...
Update driver if version from 0x4 to 0x5 for dimgrey_cavefish, per PMFW 59.02.0.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Jiansong Chen <Jiansong.Chen@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:02:09 -04:00
Tao Zhou
4ed032bd13
drm/amdgpu/swsmu: update driver if version for dimgrey_cavefish
...
Update driver if version according to PMFW with version 0x003B0100.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:01:51 -04:00
Tao Zhou
db1f8a8fb2
drm/amdgpu/swsmu: add smu support for dimgrey_cavefish(v2)
...
Reuse sienna_cichlid pp table for dimgrey_cavefish.
v2: update related comment.
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:01:07 -04:00
Tao Zhou
10e0d9ebb0
drm/amdgpu/swsmu: increase size for smu fw_name string
...
A longer chip name needs more space.
v2: define macro for the length of smu fw name
Signed-off-by: Tao Zhou <tao.zhou1@amd.com >
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-12 14:01:02 -04:00
Alex Deucher
75145aab7a
drm/amdgpu/swsmu: clean up a bunch of stale interfaces
...
These were leftover from the initial implementation, but
never used. Drop them.
Reviewed-by: Evan Quan <evan.quan@amd.com >
Noticed-by: Ryan Taylor <ryan.taylor@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:51:04 -04:00
Evan Quan
44d6e160f6
drm/amd/pm: setup APU dpm clock table in SMU HW initialization
...
As the dpm clock table is needed during DC HW initialization.
And that (DC HW initialization) comes before smu_late_init()
where current APU dpm clock table setup is performed. So, NULL
pointer dereference will be triggered. By moving APU dpm clock
table setup to smu_hw_init(), this can be avoided.
Fixes: 02cf91c113 ("drm/amd/powerplay: postpone operations not required for hw setup to late_init")
Signed-off-by: Evan Quan <evan.quan@amd.com >
Reported-by: Dirk Gouders <dirk@gouders.net >
Acked-by: Nirmoy Das <nirmoy.das@amd.com >
Acked-by: Alex Deucher <alexander.deucher@amd.com >
Signed-off-by: Alex Deucher <alexander.deucher@amd.com >
2020-10-09 14:48:56 -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