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

Alex Deucher alexdeucher at gmail.com
Thu Oct 8 15:53:36 UTC 2020


On Thu, Oct 8, 2020 at 3:20 AM Christian König <christian.koenig at amd.com> wrote:
>
> Am 07.10.20 um 18:01 schrieb Gustavo A. R. Silva:
> > 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.
>
> Ah! Nice to see that finally be documented and cleaned up.
>
> Feel free to add an Acked-by: Christian König <christian.koenig at amd.com>

Applied 1-13.  patch 14 is changing a file shared with firmware, so I
left it for consistency.

Thanks!

Alex

>
> I also know about a case where we don't use struct_size in the DMA-buf code.
>
> I'm the maintainer of that stuff as well, so be prepared to get patches
> thrown at you to clean that up as well.
>
> Thanks,
> Christian.
>
> >
> > 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://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFlexible_array_member&data=02%7C01%7Cchristian.koenig%40amd.com%7C5312862a3b8c41838ef508d86ad969c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637376829947099179&sdata=5LEWyR8pYSxmHsqhHiYiOS%2BPPk%2Fm5suOc6H7f5cIBL4%3D&reserved=0
> > [2] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kernel.org%2Fdoc%2Fhtml%2Fv5.9-rc1%2Fprocess%2Fdeprecated.html%23zero-length-and-one-element-arrays&data=02%7C01%7Cchristian.koenig%40amd.com%7C5312862a3b8c41838ef508d86ad969c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637376829947099179&sdata=wOqxnNkA9FnOI%2BfB3dHn9RU7cqPJ62qqGCK9gsd2i%2Bo%3D&reserved=0
> > [3] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Flinus%2F44720996e2d79e47d508b0abe99b931a726a3197&data=02%7C01%7Cchristian.koenig%40amd.com%7C5312862a3b8c41838ef508d86ad969c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637376829947099179&sdata=x%2BSJeOrQA11HXoTaZEdyLyNWL9rC4GngDyoDMRBUn4M%3D&reserved=0
> > [4] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FKSPP%2Flinux%2Fissues%2F109&data=02%7C01%7Cchristian.koenig%40amd.com%7C5312862a3b8c41838ef508d86ad969c1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637376829947099179&sdata=48155uVo7AboCdSZfsTP10i2rHfBJctG%2F432lD%2BpfHo%3D&reserved=0
> >
> > 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(-)
> >
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list