Re: [PATCH] drm/amdgpu: Dynamically initialize IP instance attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 17, 2022 at 11:36 AM Luben Tuikov <luben.tuikov@xxxxxxx> wrote:
>
> Dynamically initialize IP instance attributes. This eliminates bugs
> stemming from adding new attributes to an IP instance.
>
> Cc: Alex Deucher <Alexander.Deucher@xxxxxxx>
> Reported-by: Tom StDenis <tom.stdenis@xxxxxxx>
> Fixes: c10b6aa7417b0a ("drm/amdgpu: Add "harvest" to IP discovery sysfs")
> Signed-off-by: Luben Tuikov <luben.tuikov@xxxxxxx>

Acked-by: Alex Deucher ,alexander.deucher@xxxxxxx>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> index 6c7ec058125e1d..5848fec5c39251 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
> @@ -482,16 +482,7 @@ static struct ip_hw_instance_attr ip_hw_attr[] = {
>         __ATTR_RO(base_addr),
>  };
>
> -static struct attribute *ip_hw_instance_attrs[] = {
> -       &ip_hw_attr[0].attr,
> -       &ip_hw_attr[1].attr,
> -       &ip_hw_attr[2].attr,
> -       &ip_hw_attr[3].attr,
> -       &ip_hw_attr[4].attr,
> -       &ip_hw_attr[5].attr,
> -       &ip_hw_attr[6].attr,
> -       NULL,
> -};
> +static struct attribute *ip_hw_instance_attrs[ARRAY_SIZE(ip_hw_attr) + 1];
>  ATTRIBUTE_GROUPS(ip_hw_instance);
>
>  #define to_ip_hw_instance(x) container_of(x, struct ip_hw_instance, kobj)
> @@ -789,7 +780,7 @@ static int amdgpu_discovery_sysfs_recurse(struct amdgpu_device *adev)
>  static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
>  {
>         struct kset *die_kset;
> -       int res;
> +       int res, ii;
>
>         adev->ip_top = kzalloc(sizeof(*adev->ip_top), GFP_KERNEL);
>         if (!adev->ip_top)
> @@ -814,6 +805,10 @@ static int amdgpu_discovery_sysfs_init(struct amdgpu_device *adev)
>                 goto Err;
>         }
>
> +       for (ii = 0; ii < ARRAY_SIZE(ip_hw_attr); ii++)
> +               ip_hw_instance_attrs[ii] = &ip_hw_attr[ii].attr;
> +       ip_hw_instance_attrs[ii] = NULL;
> +
>         res = amdgpu_discovery_sysfs_recurse(adev);
>
>         return res;
>
> base-commit: f736148ca7bf82654141a4411409c2d7a9e2269b
> --
> 2.35.1.129.gb80121027d
>



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux