[Public]

With the original patch accounting underflows. Allocations are accounted in 
kfd_chardev.c doesn’t account for GTT allocations. However, free accounts for 
both GTT and VRAM.

Use of flags is more reliable. I think flags should have used in the first 
place, but I believe originally when vram_usage was first introduced the 
mem->alloc_flags wasn’t used in the free_ function

Best Regards,
Harish


From: Kuehling, Felix <[email protected]>
Sent: Tuesday, October 14, 2025 3:16 PM
To: Kasiviswanathan, Harish <[email protected]>; Liu, Alysa 
<[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Fix vram_usage underflow

On 2025-10-14 13:52, Kasiviswanathan, Harish wrote:

[Public]



Reviewed-by: Harish Kasiviswanathan 
<[email protected]><mailto:[email protected]>

This patch seems to effectively revert your earlier patch

commit f915f3af9984464c308787102990d85d4e988d2c

Author: Harish Kasiviswanathan 
<[email protected]><mailto:[email protected]>

Date:   Fri Apr 28 14:20:00 2023 -0400



    drm/amdgpu: For GFX 9.4.3 APU fix vram_usage value



    For GFX 9.4.3 APP APU VRAM is allocated in GTT domain. While freeing

    memory check for GTT domain instead of VRAM if it is APP APU



    Signed-off-by: Harish Kasiviswanathan 
<[email protected]><mailto:[email protected]>

    Reviewed-by: Felix Kuehling 
<[email protected]><mailto:[email protected]>

    Signed-off-by: Alex Deucher 
<[email protected]><mailto:[email protected]>

Are you sure that's the right thing to do? Are the original reasons for your 
patch no longer valid?

Regards,
  Felix









-----Original Message-----

From: Liu, Alysa <[email protected]><mailto:[email protected]>

Sent: Tuesday, October 14, 2025 9:43 AM

To: [email protected]<mailto:[email protected]>

Cc: Kasiviswanathan, Harish 
<[email protected]><mailto:[email protected]>; Liu, 
Alysa <[email protected]><mailto:[email protected]>

Subject: [PATCH] drm/amdgpu: Fix vram_usage underflow



From: Alysa Liu <[email protected]><mailto:[email protected]>



vram_usage was subtracting non-vram memory size,

which caused it to become negative.



Signed-off-by: Alysa Liu <[email protected]><mailto:[email protected]>

---

 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 4 +---

 1 file changed, 1 insertion(+), 3 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

index 22c1bdc53d2e..c2fa330ff78b 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

@@ -1961,9 +1961,7 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(

         */

        if (size) {

                if (!is_imported &&

-                  (mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_VRAM ||

-                  (adev->apu_prefer_gtt &&

-                   mem->bo->preferred_domains == AMDGPU_GEM_DOMAIN_GTT)))

+                  mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_VRAM)

                        *size = bo_size;

                else

                        *size = 0;

--

2.34.1


Reply via email to