Skip to contentSkip to conversation

drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

PATCH In review Yifan Zhang 2 participants 5 messages Aug 20, 2025 – Aug 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

AMDGPU_HAS_VRAM is redundant with is_app_apu, as both refer to APUs with no carve-out. Since AMDGPU_HAS_VRAM only occurs once, replace AMDGPU_HAS_VRAM with is_app_apu.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
index ddd472e56f69..01f53700694b 100644
@@ -946,12 +946,6 @@ enum amdgpu_enforce_isolation_mode {
 	AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,
 };
 
-
-/*
- * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
- */
-#define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size)
-
 struct amdgpu_device {
 	struct device			*dev;
 	struct pci_dev			*pdev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
index fa3e55700ad6..4125e73a0647 100644
@@ -880,9 +880,9 @@ static int psp_tmr_init(struct psp_context *psp)
 		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
 					      PSP_TMR_ALIGNMENT,
-					      AMDGPU_HAS_VRAM(psp->adev) ?
-					      AMDGPU_GEM_DOMAIN_VRAM :
-					      AMDGPU_GEM_DOMAIN_GTT,
+					      psp->adev->gmc.is_app_apu ?
+					      AMDGPU_GEM_DOMAIN_GTT :
+					      AMDGPU_GEM_DOMAIN_VRAM,
 					      &psp->tmr_bo, &psp->tmr_mc_addr,
 					      pptr);
 	}
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 32 lines · Yifan Zhang

AMDGPU_HAS_VRAM is redundant with is_app_apu, as both refer to APUs with no carve-out. Since AMDGPU_HAS_VRAM only occurs once, replace AMDGPU_HAS_VRAM with is_app_apu.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
index ddd472e56f69..01f53700694b 100644
@@ -946,12 +946,6 @@ enum amdgpu_enforce_isolation_mode {
 	AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,
 };
 
-
-/*
- * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
- */
-#define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size)
-
 struct amdgpu_device {
 	struct device			*dev;
 	struct pci_dev			*pdev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index fa3e55700ad6..4125e73a0647 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 885

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
@@ -880,9 +880,9 @@ static int psp_tmr_init(struct psp_context *psp)
 		pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
 					      PSP_TMR_ALIGNMENT,
-					      AMDGPU_HAS_VRAM(psp->adev) ?
-					      AMDGPU_GEM_DOMAIN_VRAM :
-					      AMDGPU_GEM_DOMAIN_GTT,
+					      psp->adev->gmc.is_app_apu ?
+					      AMDGPU_GEM_DOMAIN_GTT :
+					      AMDGPU_GEM_DOMAIN_VRAM,

Mhm the logic here is actually completely unnecessary. You can just specify AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT and get VRAM if available and GTT otherwise.

The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
 					      &psp->tmr_bo, &psp->tmr_mc_addr,
 					      pptr);
 	}
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

RE
"The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea."

TMR allocation only happens in psp_hw_init, suppose there is enough VRAM for TMR at that moment. Right ?

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 20, 2025 4:14 PM
To: Zhang, Yifan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

Quoted 33 lines · Yifan Zhang

AMDGPU_HAS_VRAM is redundant with is_app_apu, as both refer to APUs with no carve-out. Since AMDGPU_HAS_VRAM only occurs once, replace AMDGPU_HAS_VRAM with is_app_apu.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
index ddd472e56f69..01f53700694b 100644
@@ -946,12 +946,6 @@ enum amdgpu_enforce_isolation_mode {
      AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,  };
 
-
-/*
- * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
- */
-#define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size)
-
 struct amdgpu_device {
      struct device                   *dev;
      struct pci_dev                  *pdev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index fa3e55700ad6..4125e73a0647 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 885

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
@@ -880,9 +880,9 @@ static int psp_tmr_init(struct psp_context *psp)
              pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
              ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
                                            PSP_TMR_ALIGNMENT,
-                                           AMDGPU_HAS_VRAM(psp->adev) ?
-                                           AMDGPU_GEM_DOMAIN_VRAM :
-                                           AMDGPU_GEM_DOMAIN_GTT,
+                                           psp->adev->gmc.is_app_apu ?
+                                           AMDGPU_GEM_DOMAIN_GTT :
+                                           AMDGPU_GEM_DOMAIN_VRAM,

Mhm the logic here is actually completely unnecessary. You can just specify AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT and get VRAM if available and GTT otherwise.

The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
                                            &psp->tmr_bo, &psp->tmr_mc_addr,
                                            pptr);
      }
maintainer
#3 lore raw
Quoted 6 lines · Yifan

[AMD Official Use Only - AMD Internal Distribution Only]

RE
"The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea."

TMR allocation only happens in psp_hw_init, suppose there is enough VRAM for TMR at that moment. Right ?

Yeah, that's exactly my thinking as well. There is most likely enough VRAM in that situation.

Regards,
Christian.

Quoted 65 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 20, 2025 4:14 PM
To: Zhang, Yifan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

Quoted 33 lines · Yifan Zhang

AMDGPU_HAS_VRAM is redundant with is_app_apu, as both refer to APUs with no carve-out. Since AMDGPU_HAS_VRAM only occurs once, replace AMDGPU_HAS_VRAM with is_app_apu.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
index ddd472e56f69..01f53700694b 100644
@@ -946,12 +946,6 @@ enum amdgpu_enforce_isolation_mode {
      AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,  };
 
-
-/*
- * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
- */
-#define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size)
-
 struct amdgpu_device {
      struct device                   *dev;
      struct pci_dev                  *pdev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index fa3e55700ad6..4125e73a0647 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 885

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
@@ -880,9 +880,9 @@ static int psp_tmr_init(struct psp_context *psp)
              pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
              ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
                                            PSP_TMR_ALIGNMENT,
-                                           AMDGPU_HAS_VRAM(psp->adev) ?
-                                           AMDGPU_GEM_DOMAIN_VRAM :
-                                           AMDGPU_GEM_DOMAIN_GTT,
+                                           psp->adev->gmc.is_app_apu ?
+                                           AMDGPU_GEM_DOMAIN_GTT :
+                                           AMDGPU_GEM_DOMAIN_VRAM,

Mhm the logic here is actually completely unnecessary. You can just specify AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT and get VRAM if available and GTT otherwise.

The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
                                            &psp->tmr_bo, &psp->tmr_mc_addr,
                                            pptr);
      }
#4 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Sure. Will change to AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT.

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 20, 2025 5:38 PM
To: Zhang, Yifan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

Quoted 6 lines · Yifan

[AMD Official Use Only - AMD Internal Distribution Only]

RE
"The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea."

TMR allocation only happens in psp_hw_init, suppose there is enough VRAM for TMR at that moment. Right ?

Yeah, that's exactly my thinking as well. There is most likely enough VRAM in that situation.

Regards,
Christian.

Quoted 66 lines

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 20, 2025 4:14 PM
To: Zhang, Yifan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: replace AMDGPU_HAS_VRAM with is_app_apu

Quoted 33 lines · Yifan Zhang

AMDGPU_HAS_VRAM is redundant with is_app_apu, as both refer to APUs with no carve-out. Since AMDGPU_HAS_VRAM only occurs once, replace AMDGPU_HAS_VRAM with is_app_apu.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     | 6 ------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 +++---
 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -6
index ddd472e56f69..01f53700694b 100644
@@ -946,12 +946,6 @@ enum amdgpu_enforce_isolation_mode {
      AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,  };
 
-
-/*
- * Non-zero (true) if the GPU has VRAM. Zero (false) otherwise.
- */
-#define AMDGPU_HAS_VRAM(_adev) ((_adev)->gmc.real_vram_size)
-
 struct amdgpu_device {
      struct device                   *dev;
      struct pci_dev                  *pdev;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
index fa3e55700ad6..4125e73a0647 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 885

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +3 -3
@@ -880,9 +880,9 @@ static int psp_tmr_init(struct psp_context *psp)
              pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
              ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
                                            PSP_TMR_ALIGNMENT,
-                                           AMDGPU_HAS_VRAM(psp->adev) ?
-                                           AMDGPU_GEM_DOMAIN_VRAM :
-                                           AMDGPU_GEM_DOMAIN_GTT,
+                                           psp->adev->gmc.is_app_apu ?
+                                           AMDGPU_GEM_DOMAIN_GTT :
+                                           AMDGPU_GEM_DOMAIN_VRAM,

Mhm the logic here is actually completely unnecessary. You can just specify AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT and get VRAM if available and GTT otherwise.

The only reason I could come up with why we would need it is to have error handling if not enough VRAM is available for the TMR, but falling back to GTT is then probably still a good idea.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -0
                                            &psp->tmr_bo, &psp->tmr_mc_addr,
                                            pptr);
      }