[PATCH] drm/amdgpu: deduplicate gmc_v11_0 get_vm_pde and get_vm_pte functions

Andre Hirata andrejhirata em usp.br
Sex Abr 17 10:43:14 -03 2026


The gmc_v11_0 implementations of get_vm_pde and get_vm_pte
are currently identical to their gmc_v10_0 counterparts.

Replace the v11_0 versions with wrappers around the v10_0
implementations to eliminate code duplication.

No functional changes intended.

Signed-off-by: Andre Hirata <andrejhirata em usp.br>
Co-developed-by: Gabriel Dimant <gabriel.dimant em usp.br>
Signed-off-by: Gabriel Dimant <gabriel.dimant em usp.br>
Co-developed-by: Guilherme Gabriel <guilhermesangabriel em usp.br>
Signed-off-by: Guilherme Gabriel <guilhermesangabriel em usp.br>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 60 ++------------------------
 1 file changed, 3 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index 94d6631ce..7f0d7bb8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -27,6 +27,7 @@
 
 #include "amdgpu.h"
 #include "amdgpu_atomfirmware.h"
+#include "gmc_v10_0.h"
 #include "gmc_v11_0.h"
 #include "umc_v8_10.h"
 #include "athub/athub_3_0_0_sh_mask.h"
@@ -445,24 +446,7 @@ static void gmc_v11_0_emit_pasid_mapping(struct amdgpu_ring *ring, unsigned int
 static void gmc_v11_0_get_vm_pde(struct amdgpu_device *adev, int level,
 				 uint64_t *addr, uint64_t *flags)
 {
-	if (!(*flags & AMDGPU_PDE_PTE) && !(*flags & AMDGPU_PTE_SYSTEM))
-		*addr = amdgpu_gmc_vram_mc2pa(adev, *addr);
-	BUG_ON(*addr & 0xFFFF00000000003FULL);
-
-	if (!adev->gmc.translate_further)
-		return;
-
-	if (level == AMDGPU_VM_PDB1) {
-		/* Set the block fragment size */
-		if (!(*flags & AMDGPU_PDE_PTE))
-			*flags |= AMDGPU_PDE_BFS(0x9);
-
-	} else if (level == AMDGPU_VM_PDB0) {
-		if (*flags & AMDGPU_PDE_PTE)
-			*flags &= ~AMDGPU_PDE_PTE;
-		else
-			*flags |= AMDGPU_PTE_TF;
-	}
+	gmc_v10_0_get_vm_pde(adev, level, addr, flags);
 }
 
 static void gmc_v11_0_get_vm_pte(struct amdgpu_device *adev,
@@ -471,45 +455,7 @@ static void gmc_v11_0_get_vm_pte(struct amdgpu_device *adev,
 				 uint32_t vm_flags,
 				 uint64_t *flags)
 {
-	if (vm_flags & AMDGPU_VM_PAGE_EXECUTABLE)
-		*flags |= AMDGPU_PTE_EXECUTABLE;
-	else
-		*flags &= ~AMDGPU_PTE_EXECUTABLE;
-
-	switch (vm_flags & AMDGPU_VM_MTYPE_MASK) {
-	case AMDGPU_VM_MTYPE_DEFAULT:
-	case AMDGPU_VM_MTYPE_NC:
-	default:
-		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_NC);
-		break;
-	case AMDGPU_VM_MTYPE_WC:
-		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_WC);
-		break;
-	case AMDGPU_VM_MTYPE_CC:
-		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_CC);
-		break;
-	case AMDGPU_VM_MTYPE_UC:
-		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_UC);
-		break;
-	}
-
-	if (vm_flags & AMDGPU_VM_PAGE_NOALLOC)
-		*flags |= AMDGPU_PTE_NOALLOC;
-	else
-		*flags &= ~AMDGPU_PTE_NOALLOC;
-
-	if (vm_flags & AMDGPU_VM_PAGE_PRT) {
-		*flags |= AMDGPU_PTE_PRT;
-		*flags |= AMDGPU_PTE_SNOOPED;
-		*flags |= AMDGPU_PTE_LOG;
-		*flags |= AMDGPU_PTE_SYSTEM;
-		*flags &= ~AMDGPU_PTE_VALID;
-	}
-
-	if (bo && bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
-			       AMDGPU_GEM_CREATE_EXT_COHERENT |
-			       AMDGPU_GEM_CREATE_UNCACHED))
-		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_UC);
+	gmc_v10_0_get_vm_pte(adev, vm, bo, vm_flags, flags);
 }
 
 static unsigned int gmc_v11_0_get_vbios_fb_size(struct amdgpu_device *adev)
-- 
2.43.0



Mais detalhes sobre a lista de discussão kernel