Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] drm/amdgpu: incomplete refactoring, kcalloc still used for identical 
buffers
--

commit 8b9c2e12d9fb1d601e7dde3709be635bf6ad1f1b
Author: Lalit Shankar Chowdhury <[email protected]>
Subject: drm/amdgpu: replace kcalloc() with kzalloc_objs()

This commit replaces kcalloc() with kzalloc_objs() across several files
in the AMDGPU driver to simplify object allocations. The commit message
states that it is a non-functional change.

> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c 
> b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> index 72fd3022b6062..76793a5caa701 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
[ ... ]
> @@ -202,7 +202,7 @@ static int vcn_v1_0_sw_init(struct amdgpu_ip_block 
> *ip_block)
>       r = jpeg_v1_0_sw_init(ip_block);
>  
>       /* Allocate memory for VCN IP Dump buffer */
> -     ptr = kcalloc(adev->vcn.num_vcn_inst * reg_count, sizeof(uint32_t), 
> GFP_KERNEL);
> +     ptr = kzalloc_objs(*ptr, adev->vcn.num_vcn_inst * reg_count);

[Severity: Low]
Could we also update the identical IP dump buffer allocation in
amdgpu_vcn_reg_dump_init() in drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c?

It looks like the refactoring might be incomplete. While this file and
others (jpeg, sdma, gfx) were successfully updated to use kzalloc_objs(),
several other instances using kcalloc() for identical buffer types were missed.

For example:

drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c:amdgpu_vcn_reg_dump_init() {
    ...
        adev->vcn.ip_dump = kcalloc(adev->vcn.num_vcn_inst * count,
                                     sizeof(uint32_t), GFP_KERNEL);
    ...
}

Other files that still use kcalloc() include amdgpu_ras.c,
amdgpu_ras_eeprom.c, and atom.c. Does it make sense to update these
as well to ensure the memory allocation API remains consistent across
the subsystem?

>       if (!ptr) {
>               DRM_ERROR("Failed to allocate memory for VCN IP Dump\n");
>               adev->vcn.ip_dump = NULL;

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to