Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/amdgpu: gmc_v*_sw_init() calls amdgpu_bo_fini() with
  GART/PDB0 BOs pinned
--

commit 4e2abeed7577cfdf2a67e81d9af414ebfbc361c6
Author: Mario Limonciello <[email protected]>

drm/amdgpu: unwind bo_init on GMC sw_init failure

This commit unwinds amdgpu_bo_init() and amdgpu_vm_manager_init() when
gmc_v*_sw_init() fails after initializing the memory manager across GMC v6
through v12.

> diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> index 49f593fe2a876..e59fee3955af0 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
> @@ -861,7 +861,7 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block 
> *ip_block)
>  
>       r = gmc_v10_0_gart_init(adev);
>       if (r)
> -             return r;
> +             goto err_bo_fini;
>  
>       /*
>        * number of VMs
> @@ -880,9 +880,15 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block 
> *ip_block)
>  
>       r = amdgpu_gmc_ras_sw_init(adev);
>       if (r)
> -             return r;
> +             goto err_vm_fini;
>  
>       return 0;
> +
> +err_vm_fini:
> +     amdgpu_vm_manager_fini(adev);
> +err_bo_fini:
> +     amdgpu_bo_fini(adev);
> +     return r;
>  }

[Severity: Medium]
Does jumping to err_vm_fini tear down TTM while adev->gart.bo is still
pinned?

gmc_v10_0_gart_init() allocates and pins adev->gart.bo in VRAM.  If
amdgpu_gmc_ras_sw_init() fails, err_vm_fini calls amdgpu_bo_fini() without
first freeing the GART table as gmc_v10_0_sw_fini() does.  Because pinned
BOs cannot be evicted during amdgpu_ttm_fini(), gpu_buddy_fini() and
drm_mm_takedown() hit warnings and leak the pinned BOs and their backing
allocations.

The same missing GART cleanup affects the err_vm_fini paths in GMC v7, v8,
v9, v11, and v12.  On GMC v9 and v12, gmc_v*_gart_init() also allocates
and pins adev->gmc.pdb0_bo when amdgpu_gmc_is_pdb0_enabled() is true, so
both err_vm_fini and a failure in amdgpu_gmc_pdb0_alloc() within
gmc_v*_gart_init() reach amdgpu_bo_fini() with pinned BOs still allocated.

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

Reply via email to