Skip to content

drm/amd/pm: Replace one-element arrays with flexible-array members

Gustavo A. R. Silva amd-gfx dri-devel linux-hardening lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest14 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14drm/amd/pm: Replace one-element array with flexible-array memberdrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c +1 more+8 -120 replies
2/14drm/amd/pm: Replace one-element array with flexible-array member in struct vi_dpm_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h+1 -10 replies
3/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_clock_arraydrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c +1 more+11 -180 replies
4/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_uvd_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+5 -80 replies
5/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_acp_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+5 -80 replies
6/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_phase_shedding_limits_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+5 -90 replies
7/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_vce_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+5 -80 replies
8/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_cac_leakage_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+6 -90 replies
9/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_samu_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/inc/hwmgr.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/processpptables.c+5 -80 replies
10/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr_ppt.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_processpptables.c+27 -560 replies
11/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_mm_clock_voltage_dependency_tabledrivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr_ppt.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_processpptables.c+8 -140 replies
12/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_voltage_lookup_tabledrivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr_ppt.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_processpptables.c+7 -150 replies
13/14drm/amd/pm: Replace one-element array with flexible-array in struct phm_ppt_v1_pcie_tabledrivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr_ppt.h drivers/gpu/drm/amd/pm/powerplay/hwmgr/process_pptables_v1_0.c drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_processpptables.c+13 -210 replies
14/14drm/amd/pm: Replace one-element array with flexible-array in struct ATOM_Vega10_GFXCLK_Dependency_Tabledrivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_pptable.h+1 -11 reply

Reviews trailers per patch

None of the 14 patches has a Reviewed-by or Acked-by.

Patchkernel test robot
1/14Build-tested-by
2/14Build-tested-by
3/14Build-tested-by
4/14Build-tested-by
5/14Build-tested-by
6/14Build-tested-by
7/14Build-tested-by
8/14Build-tested-by
9/14Build-tested-by
10/14Build-tested-by
11/14Build-tested-by
12/14Build-tested-by
13/14Build-tested-by
14/14Build-tested-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/14] drm/amd/pm: Replace one-element arrays with flexible-array members

Hi all,

This series aims to replace one-element arrays with flexible-array members.

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 flexible-array members, instead of one-element arrays, and use the struct_size() helper to calculate the size for the dynamic memory allocation.

Also, save some heap space in the process. More on this on each individual patch.

This series also addresses multiple of the following sorts of warnings:

drivers/gpu/drm/amd/amdgpu/../pm/powerplay/hwmgr/smu8_hwmgr.c:1515:37:
warning: array subscript 1 is above array bounds of ‘const struct phm_clock_voltage_dependency_record[1]’ [-Warray-bounds]

which, in this case, they are false positives, but nervertheless should be fixed in order to enable -Warray-bounds[3][4].

[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
[3] https://git.kernel.org/linus/44720996e2d79e47d508b0abe99b931a726a3197
[4] https://github.com/KSPP/linux/issues/109

Gustavo A. R. Silva (14):
drm/amd/pm: Replace one-element array with flexible-array member drm/amd/pm: Replace one-element array with flexible-array member in
struct vi_dpm_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_clock_array
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_uvd_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_acp_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_phase_shedding_limits_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_vce_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_cac_leakage_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_samu_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_ppt_v1_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_ppt_v1_mm_clock_voltage_dependency_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_ppt_v1_voltage_lookup_table
drm/amd/pm: Replace one-element array with flexible-array in struct
phm_ppt_v1_pcie_table
drm/amd/pm: Replace one-element array with flexible-array in struct
ATOM_Vega10_GFXCLK_Dependency_Table

 drivers/gpu/drm/amd/pm/inc/hwmgr.h            | 20 ++---
 .../drm/amd/pm/powerplay/hwmgr/hwmgr_ppt.h    |  8 +-
 .../powerplay/hwmgr/process_pptables_v1_0.c   | 85 +++++++-----------
 .../amd/pm/powerplay/hwmgr/processpptables.c  | 85 +++++++-----------
 .../drm/amd/pm/powerplay/hwmgr/smu8_hwmgr.c   |  2 +-
 .../drm/amd/pm/powerplay/hwmgr/smu_helper.c   |  5 +-
 .../amd/pm/powerplay/hwmgr/vega10_pptable.h   |  2 +-
 .../powerplay/hwmgr/vega10_processpptables.c  | 88 ++++++-------------
 8 files changed, 107 insertions(+), 188 deletions(-)
Signature · 6 lines
2.27.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx