All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang@amd.com>
To: "Christian König" <christian.koenig@amd.com>,
	"Philip Yang" <Philip.Yang@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Felix Kuehling" <felix.kuehling@amd.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Aveline Noir" <jm5905938@gmail.com>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Xiaogang Chen <xiaogang.chen@amd.com>,
	Oak Zeng <Oak.Zeng@amd.com>, "Jenny Liu" <Jenny-Jing.Liu@amd.com>,
	Zhu Lingshan <lingshan.zhu@amd.com>,
	"Honglei Huang" <honglei1.huang@amd.com>,
	Junhua Shen <Junhua.Shen@amd.com>, Yiru Ma <yiru.ma@amd.com>,
	Huang Rui <ray.huang@amd.com>, Honglei Huang <honghuan@amd.com>
Subject: [PATCH v11 01/22] drm/amdgpu: decouple PTE encoding from buffer objects
Date: Fri, 27 Nov 2026 16:41:24 +0800	[thread overview]
Message-ID: <20261127084149.925625-2-ray.huang@amd.com> (raw)
In-Reply-To: <20261127084149.925625-1-ray.huang@amd.com>

From: Honglei Huang <honghuan@amd.com>

Describe backing memory with struct amdgpu_gmc_pte_mem instead of a BO
pointer. The GMC encoders need the owning device, memory placement,
partition and coherence flags, not the BO itself. Populate this
description in existing BO callers and update KFD and UALink callers
with the common interface.

Provide an optional destination address: convert VRAM offsets using
the owning device's VRAM base and leave system DMA/IOVA addresses
unchanged. Existing callers without an address output pass NULL.

Keep BO reservation checking in amdgpu_sync_resv(). The NPA debug
message no longer reports the TTM resource range. This prerequisite
does not introduce SVM UAPI, attribute types or a separate SVM callback.

Suggested-by: Christian König <christian.koenig@amd.com>
Suggested-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Honglei Huang <honghuan@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c    | 34 ++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h    | 24 ++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 12 +++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     |  6 ++--
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c     |  8 ++---
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c     |  8 ++---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c     |  6 ++--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c     | 31 +++++++++-----------
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c      |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c      |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c      |  2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c      | 25 +++++++---------
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c       |  3 +-
 13 files changed, 106 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
index 08d3ff61edccd..c47d43e1193be 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c
@@ -410,6 +410,40 @@ void amdgpu_gmc_set_agp_default(struct amdgpu_device *adev,
 	mc->agp_size = 0;
 }
 
+/**
+ * amdgpu_gmc_pte_mem_from_bo() - Describe the backing memory of a BO
+ * @bo: BO backing the mapping.
+ * @mem: Output description for amdgpu_gmc_get_vm_pte().
+ */
+void amdgpu_gmc_pte_mem_from_bo(struct amdgpu_bo *bo,
+				struct amdgpu_gmc_pte_mem *mem)
+{
+	mem->adev = amdgpu_ttm_adev(bo->tbo.bdev);
+	mem->flags = bo->flags;
+	mem->mem_type = bo->tbo.resource ? bo->tbo.resource->mem_type :
+					   TTM_PL_SYSTEM;
+	mem->mem_id = KFD_XCP_MEM_ID(mem->adev, bo->xcp_id);
+}
+
+/**
+ * amdgpu_gmc_get_vm_pte() - Encode a GPU mapping's address and flags
+ * @adev: Device receiving the mapping.
+ * @vm: Address space receiving the mapping.
+ * @mem: Backing memory, or NULL if unknown.
+ * @vm_flags: AMDGPU_VM_PAGE_* and AMDGPU_VM_MTYPE_* mapping flags.
+ * @dst: Optional address in @mem; VRAM offsets become GPU addresses.
+ * @pte_flags: Base PTE flags, updated with the hardware specific bits.
+ */
+void amdgpu_gmc_get_vm_pte(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+			   const struct amdgpu_gmc_pte_mem *mem, u32 vm_flags,
+			   u64 *dst, u64 *pte_flags)
+{
+	if (dst && mem && mem->mem_type == TTM_PL_VRAM)
+		*dst += mem->adev->vm_manager.vram_base_offset;
+
+	adev->gmc.gmc_funcs->get_vm_pte(adev, vm, mem, vm_flags, pte_flags);
+}
+
 /**
  * amdgpu_gmc_fault_key - get hask key from vm fault address and pasid
  *
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
index 8f0672ed5b67f..37ae9730c802b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h
@@ -150,6 +150,20 @@ struct amdgpu_vmhub {
 	const struct amdgpu_vmhub_funcs *vmhub_funcs;
 };
 
+/**
+ * struct amdgpu_gmc_pte_mem - Backing memory of a GPU mapping
+ * @adev: Device owning the memory.
+ * @flags: AMDGPU_GEM_CREATE_* coherence and caching flags.
+ * @mem_type: TTM placement of the memory.
+ * @mem_id: Memory partition of the memory, or -1.
+ */
+struct amdgpu_gmc_pte_mem {
+	struct amdgpu_device *adev;
+	u64 flags;
+	u32 mem_type;
+	s8 mem_id;
+};
+
 /*
  * GPU MC structures, functions & helpers
  */
@@ -175,7 +189,7 @@ struct amdgpu_gmc_funcs {
 	/* get the pte flags to use for PTEs */
 	void (*get_vm_pte)(struct amdgpu_device *adev,
 			   struct amdgpu_vm *vm,
-			   struct amdgpu_bo *bo,
+			   const struct amdgpu_gmc_pte_mem *mem,
 			   uint32_t vm_flags,
 			   uint64_t *pte_flags);
 	/* override per-page pte flags */
@@ -375,9 +389,11 @@ struct amdgpu_gmc {
 #define amdgpu_gmc_emit_flush_gpu_tlb(r, vmid, addr) (r)->adev->gmc.gmc_funcs->emit_flush_gpu_tlb((r), (vmid), (addr))
 #define amdgpu_gmc_emit_pasid_mapping(r, vmid, pasid) (r)->adev->gmc.gmc_funcs->emit_pasid_mapping((r), (vmid), (pasid))
 #define amdgpu_gmc_get_vm_pde(adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))
-#define amdgpu_gmc_get_vm_pte(adev, vm, bo, vm_flags, pte_flags) \
-	((adev)->gmc.gmc_funcs->get_vm_pte((adev), (vm), (bo), (vm_flags), \
-					   (pte_flags)))
+void amdgpu_gmc_pte_mem_from_bo(struct amdgpu_bo *bo,
+				struct amdgpu_gmc_pte_mem *mem);
+void amdgpu_gmc_get_vm_pte(struct amdgpu_device *adev, struct amdgpu_vm *vm,
+			   const struct amdgpu_gmc_pte_mem *mem, u32 vm_flags,
+			   u64 *dst, u64 *pte_flags);
 #define amdgpu_gmc_override_vm_pte_flags(adev, vm, addr, pte_flags)	\
 	(adev)->gmc.gmc_funcs->override_vm_pte_flags			\
 		((adev), (vm), (addr), (pte_flags))
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
index dd0653e6194b7..45654d9561abf 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c
@@ -2032,13 +2032,15 @@ static u64 amdgpu_ualink_get_export_pte_flags(struct amdgpu_device *adev,
 				       u64 mapping_flags)
 {
 	u64 pte_flags = adev->gmc.init_pte_flags;
+	struct amdgpu_gmc_pte_mem mem;
 
 	pte_flags |= (AMDGPU_PTE_VALID | AMDGPU_PTE_READABLE |
 		      AMDGPU_PTE_WRITEABLE);
 	mapping_flags |= AMDGPU_VM_MTYPE_DEFAULT;
 
-	amdgpu_gmc_get_vm_pte(adev, &adev->ualink.npa_vm, bo, mapping_flags,
-			      &pte_flags);
+	amdgpu_gmc_pte_mem_from_bo(bo, &mem);
+	amdgpu_gmc_get_vm_pte(adev, &adev->ualink.npa_vm, &mem, mapping_flags,
+			      NULL, &pte_flags);
 
 	return pte_flags;
 }
@@ -4951,6 +4953,7 @@ static int amdgpu_ualink_metadata_npa_mapping(struct amdgpu_device *adev)
 	struct amdgpu_ualink_remote *remote = to_remote(adev);
 	u32 dst_accel_id = ualink_accel_id(adev);
 	u64 timeout = msecs_to_jiffies(2000);
+	struct amdgpu_gmc_pte_mem mem;
 	struct amdgpu_bo *bos[2];
 	u32 n_bos;
 	struct dma_fence *fence;
@@ -4977,8 +4980,9 @@ static int amdgpu_ualink_metadata_npa_mapping(struct amdgpu_device *adev)
 					    remote->ring_bo->tbo.resource);
 	dev_dbg(adev->dev, "init pte_flags 0x%llx\n", pte_flags);
 
-	amdgpu_gmc_get_vm_pte(adev, &adev->ualink.npa_vm, remote->ring_bo,
-			      AMDGPU_VM_MTYPE_DEFAULT, &pte_flags);
+	amdgpu_gmc_pte_mem_from_bo(remote->ring_bo, &mem);
+	amdgpu_gmc_get_vm_pte(adev, &adev->ualink.npa_vm, &mem,
+			      AMDGPU_VM_MTYPE_DEFAULT, NULL, &pte_flags);
 	dev_dbg(adev->dev, "after get coherent pte_flags 0x%llx\n", pte_flags);
 
 	if (ualink_addr_mode(adev) == AMDGPU_UALINK_ADDR_MODE_SOURCE_ALIAS) {
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 792b87ee2fc3c..9fcafed0b598c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1400,6 +1400,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 	struct amdgpu_bo *bo = bo_va->base.bo;
 	struct amdgpu_vm *vm = bo_va->base.vm;
 	struct amdgpu_bo_va_mapping *mapping;
+	struct amdgpu_gmc_pte_mem pte_mem;
 	struct dma_fence **last_update;
 	dma_addr_t *pages_addr = NULL;
 	struct ttm_resource *mem;
@@ -1466,6 +1467,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 		bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
 		vram_base = bo_adev->vm_manager.vram_base_offset;
 		uncached = (bo->flags & AMDGPU_GEM_CREATE_UNCACHED) != 0;
+		amdgpu_gmc_pte_mem_from_bo(bo, &pte_mem);
 	} else {
 		flags = 0x0;
 		vram_base = 0;
@@ -1497,8 +1499,8 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
 			update_flags &= ~AMDGPU_PTE_WRITEABLE;
 
 		/* Apply ASIC specific mapping flags */
-		amdgpu_gmc_get_vm_pte(adev, vm, bo, mapping->flags,
-				      &update_flags);
+		amdgpu_gmc_get_vm_pte(adev, vm, bo ? &pte_mem : NULL,
+				      mapping->flags, NULL, &update_flags);
 
 		trace_amdgpu_vm_bo_update(mapping);
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
index 49f593fe2a876..62ce278bc9ea6 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c
@@ -477,7 +477,7 @@ static void gmc_v10_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v10_0_get_vm_pte(struct amdgpu_device *adev,
 				 struct amdgpu_vm *vm,
-				 struct amdgpu_bo *bo,
+				 const struct amdgpu_gmc_pte_mem *mem,
 				 uint32_t vm_flags,
 				 uint64_t *flags)
 {
@@ -516,9 +516,9 @@ static void gmc_v10_0_get_vm_pte(struct amdgpu_device *adev,
 		*flags &= ~AMDGPU_PTE_VALID;
 	}
 
-	if (bo && bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
-			       AMDGPU_GEM_CREATE_EXT_COHERENT |
-			       AMDGPU_GEM_CREATE_UNCACHED))
+	if (mem && mem->flags & (AMDGPU_GEM_CREATE_COHERENT |
+				 AMDGPU_GEM_CREATE_EXT_COHERENT |
+				 AMDGPU_GEM_CREATE_UNCACHED))
 		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_UC);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
index bc3b1ffb54886..36fa9927023a7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c
@@ -483,7 +483,7 @@ static void gmc_v11_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v11_0_get_vm_pte(struct amdgpu_device *adev,
 				 struct amdgpu_vm *vm,
-				 struct amdgpu_bo *bo,
+				 const struct amdgpu_gmc_pte_mem *mem,
 				 uint32_t vm_flags,
 				 uint64_t *flags)
 {
@@ -522,9 +522,9 @@ static void gmc_v11_0_get_vm_pte(struct amdgpu_device *adev,
 		*flags &= ~AMDGPU_PTE_VALID;
 	}
 
-	if (bo && bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
-			       AMDGPU_GEM_CREATE_EXT_COHERENT |
-			       AMDGPU_GEM_CREATE_UNCACHED))
+	if (mem && mem->flags & (AMDGPU_GEM_CREATE_COHERENT |
+				 AMDGPU_GEM_CREATE_EXT_COHERENT |
+				 AMDGPU_GEM_CREATE_UNCACHED))
 		*flags = AMDGPU_PTE_MTYPE_NV10(*flags, MTYPE_UC);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
index 3bb13cfed92fe..180543b0bbbb4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c
@@ -510,7 +510,7 @@ static void gmc_v12_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 				 struct amdgpu_vm *vm,
-				 struct amdgpu_bo *bo,
+				 const struct amdgpu_gmc_pte_mem *mem,
 				 uint32_t vm_flags,
 				 uint64_t *flags)
 {
@@ -545,10 +545,10 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
 		*flags &= ~AMDGPU_PTE_VALID;
 	}
 
-	if (bo && bo->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
+	if (mem && mem->flags & AMDGPU_GEM_CREATE_GFX12_DCC)
 		*flags |= AMDGPU_PTE_DCC;
 
-	if (bo && bo->flags & AMDGPU_GEM_CREATE_UNCACHED)
+	if (mem && mem->flags & AMDGPU_GEM_CREATE_UNCACHED)
 		*flags = AMDGPU_PTE_MTYPE_GFX12(*flags, MTYPE_UC);
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
index b676830120026..ef839d6e5cb45 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
@@ -672,17 +672,15 @@ u32 gmc_v12_1_get_coherent_aql_mtype(struct amdgpu_device *adev)
 }
 
 static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev,
-					  struct amdgpu_bo *bo,
+					  const struct amdgpu_gmc_pte_mem *mem,
 					  uint64_t *flags)
 {
-	struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
-	bool is_vram = bo->tbo.resource &&
-		       bo->tbo.resource->mem_type == TTM_PL_VRAM;
-	bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
-				     AMDGPU_GEM_CREATE_EXT_COHERENT);
-	bool ext_coherent = bo->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
+	bool is_vram = mem->mem_type == TTM_PL_VRAM;
+	bool coherent = mem->flags & (AMDGPU_GEM_CREATE_COHERENT |
+				      AMDGPU_GEM_CREATE_EXT_COHERENT);
+	bool ext_coherent = mem->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
 	uint32_t gc_ip_version = amdgpu_ip_version(adev, GC_HWIP, 0);
-	bool uncached = bo->flags & AMDGPU_GEM_CREATE_UNCACHED;
+	bool uncached = mem->flags & AMDGPU_GEM_CREATE_UNCACHED;
 	unsigned int mtype, mtype_local, mtype_remote;
 	bool snoop = false;
 	bool is_local = false;
@@ -692,7 +690,7 @@ static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev,
 	case IP_VERSION(12, 1, 0):
 		gmc_v12_1_get_mtypes(adev, &mtype_local, &mtype_remote);
 
-		is_local = (is_vram && adev == bo_adev);
+		is_local = (is_vram && adev == mem->adev);
 		snoop = true;
 		if (uncached) {
 			mtype = MTYPE_UC;
@@ -730,12 +728,10 @@ static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev,
 
 static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev,
 				 struct amdgpu_vm *vm,
-				 struct amdgpu_bo *bo,
+				 const struct amdgpu_gmc_pte_mem *mem,
 				 uint32_t vm_flags,
 				 uint64_t *flags)
 {
-	struct ttm_resource *mem;
-
 	if (vm_flags & AMDGPU_VM_PAGE_EXECUTABLE)
 		*flags |= AMDGPU_PTE_EXECUTABLE;
 	else
@@ -757,15 +753,14 @@ static void gmc_v12_1_get_vm_pte(struct amdgpu_device *adev,
 		break;
 	}
 
-	if (bo) {
-		mem = bo->tbo.resource;
-		if (mem && mem->mem_type == AMDGPU_PL_NPA) {
+	if (mem) {
+		if (mem->mem_type == AMDGPU_PL_NPA) {
 			dev_dbg(adev->dev,
-				"Setting PTE for NPA BO, mem->type: %d, mem->start: %lx, mem->size: %u, cur_flags: %llx\n",
-				mem->mem_type, mem->start, (u32)mem->size, *flags);
+				"Setting PTE for NPA BO, cur_flags: %llx\n",
+				*flags);
 			gmc_v12_1_get_npa_flags(adev, flags);
 		} else if (*flags & AMDGPU_PTE_VALID) {
-			gmc_v12_1_get_coherence_flags(adev, bo, flags);
+			gmc_v12_1_get_coherence_flags(adev, mem, flags);
 		}
 	}
 }
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
index a7c353d1ac09d..e0b5c668a4430 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
@@ -338,7 +338,7 @@ static void gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v6_0_get_vm_pte(struct amdgpu_device *adev,
 				struct amdgpu_vm *vm,
-				struct amdgpu_bo *bo,
+				const struct amdgpu_gmc_pte_mem *mem,
 				uint32_t vm_flags,
 				uint64_t *flags)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
index c09f5153679ea..e946a6ee69628 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
@@ -461,7 +461,7 @@ static void gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v7_0_get_vm_pte(struct amdgpu_device *adev,
 				struct amdgpu_vm *vm,
-				struct amdgpu_bo *bo,
+				const struct amdgpu_gmc_pte_mem *mem,
 				uint32_t vm_flags,
 				uint64_t *flags)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
index 15592027e7c0c..b6d01aeda2b01 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
@@ -673,7 +673,7 @@ static void gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v8_0_get_vm_pte(struct amdgpu_device *adev,
 				struct amdgpu_vm *vm,
-				struct amdgpu_bo *bo,
+				const struct amdgpu_gmc_pte_mem *mem,
 				uint32_t vm_flags,
 				uint64_t *flags)
 {
diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index a705830ef436c..32ad64313cde7 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -1046,24 +1046,21 @@ static void gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, int level,
 
 static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,
 					 struct amdgpu_vm *vm,
-					 struct amdgpu_bo *bo,
+					 const struct amdgpu_gmc_pte_mem *mem,
 					 uint32_t vm_flags,
 					 uint64_t *flags)
 {
-	struct amdgpu_device *bo_adev = amdgpu_ttm_adev(bo->tbo.bdev);
-	bool is_vram = bo->tbo.resource &&
-		bo->tbo.resource->mem_type == TTM_PL_VRAM;
-	bool coherent = bo->flags & (AMDGPU_GEM_CREATE_COHERENT |
-				     AMDGPU_GEM_CREATE_EXT_COHERENT);
-	bool ext_coherent = bo->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
-	bool uncached = bo->flags & AMDGPU_GEM_CREATE_UNCACHED;
+	struct amdgpu_device *bo_adev = mem->adev;
+	bool is_vram = mem->mem_type == TTM_PL_VRAM;
+	bool coherent = mem->flags & (AMDGPU_GEM_CREATE_COHERENT |
+				      AMDGPU_GEM_CREATE_EXT_COHERENT);
+	bool ext_coherent = mem->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
+	bool uncached = mem->flags & AMDGPU_GEM_CREATE_UNCACHED;
 	unsigned int mtype_local, mtype;
 	uint32_t gc_ip_version = amdgpu_ip_version(adev, GC_HWIP, 0);
 	bool snoop = false;
 	bool is_local;
 
-	dma_resv_assert_held(bo->tbo.base.resv);
-
 	switch (gc_ip_version) {
 	case IP_VERSION(9, 4, 1):
 	case IP_VERSION(9, 4, 2):
@@ -1122,7 +1119,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,
 		is_local = (!is_vram && (adev->flags & AMD_IS_APU) &&
 			    num_possible_nodes() <= 1) ||
 			   (is_vram && adev == bo_adev &&
-			    KFD_XCP_MEM_ID(adev, bo->xcp_id) == vm->mem_id);
+			    mem->mem_id == vm->mem_id);
 		snoop = true;
 		if (uncached) {
 			mtype = MTYPE_UC;
@@ -1162,7 +1159,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,
 
 static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
 				struct amdgpu_vm *vm,
-				struct amdgpu_bo *bo,
+				const struct amdgpu_gmc_pte_mem *mem,
 				uint32_t vm_flags,
 				uint64_t *flags)
 {
@@ -1196,8 +1193,8 @@ static void gmc_v9_0_get_vm_pte(struct amdgpu_device *adev,
 		*flags &= ~AMDGPU_PTE_VALID;
 	}
 
-	if ((*flags & AMDGPU_PTE_VALID) && bo)
-		gmc_v9_0_get_coherence_flags(adev, vm, bo, vm_flags, flags);
+	if ((*flags & AMDGPU_PTE_VALID) && mem)
+		gmc_v9_0_get_coherence_flags(adev, vm, mem, vm_flags, flags);
 }
 
 static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index b2d49876a7800..0d419268d8adf 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1409,7 +1409,8 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm,
 	if (gc_ip_version >= IP_VERSION(12, 0, 0))
 		pte_flags |= AMDGPU_PTE_IS_PTE;
 
-	amdgpu_gmc_get_vm_pte(node->adev, vm, NULL, mapping_flags, &pte_flags);
+	amdgpu_gmc_get_vm_pte(node->adev, vm, NULL, mapping_flags,
+			      NULL, &pte_flags);
 	pte_flags |= AMDGPU_PTE_READABLE;
 	if (!(flags & KFD_IOCTL_SVM_FLAG_GPU_RO))
 		pte_flags |= AMDGPU_PTE_WRITEABLE;
-- 
2.53.0


  reply	other threads:[~2026-11-27  8:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  8:41 [PATCH v11 00/22] drm/amdgpu: AMDGPU SVM support based on DRM (Phase 1: single GPU, XNACK on) Huang Rui
2026-11-27  8:41 ` Huang Rui [this message]
2026-11-27  8:41 ` [PATCH v11 02/22] drm/amdgpu: add SVM ioctl UAPI definitions Huang Rui
2026-11-27  8:41 ` [PATCH v11 03/22] drm/amdgpu: add SVM core header and VM integration Huang Rui
2026-11-27  8:41 ` [PATCH v11 04/22] drm/amdgpu: implement SVM attribute tree and helper functions Huang Rui
2026-11-27  8:41 ` [PATCH v11 05/22] drm/amdgpu: implement SVM attribute set/get/clear operations Huang Rui
2026-11-27  8:41 ` [PATCH v11 06/22] drm/amdgpu: add SVM range types and work queue interface Huang Rui
2026-11-27  8:41 ` [PATCH v11 07/22] drm/amdgpu: implement SVM range GPU mapping core Huang Rui
2026-11-27  8:41 ` [PATCH v11 08/22] drm/amdgpu: implement SVM range notifier and GC helpers Huang Rui
2026-11-27  8:41 ` [PATCH v11 09/22] drm/amdgpu: add SVM notifier invalidate callback Huang Rui
2026-11-27  8:41 ` [PATCH v11 10/22] drm/amdgpu: implement SVM initialization and lifecycle Huang Rui
2026-11-27  8:41 ` [PATCH v11 11/22] drm/amdgpu: add SVM ioctl entry and fault handler module Huang Rui
2026-11-27  8:41 ` [PATCH v11 12/22] drm/amdgpu: integrate SVM into build system and VM fault path Huang Rui
2026-11-27  8:41 ` [PATCH v11 13/22] drm/amdgpu: make VM eviction lock read/write to match notifier lock Huang Rui
2026-11-27  8:41 ` [PATCH v11 14/22] drm/amdgpu: recheck range validity after page table allocation Huang Rui
2026-11-27  8:41 ` [PATCH v11 15/22] drm/amdgpu: use drm_gpusvm notifier lock for VM eviction Huang Rui
2026-11-27  8:41 ` [PATCH v11 16/22] drm/pagemap: fix page undercount for compound src entries Huang Rui
2026-11-27  8:41 ` [PATCH v11 17/22] drm/amdgpu: add VRAM migration infrastructure for drm_pagemap Huang Rui
2026-11-27  8:41 ` [PATCH v11 18/22] drm/amdgpu: implement drm_pagemap SDMA migration callbacks Huang Rui
2026-11-27  8:41 ` [PATCH v11 19/22] drm/amdgpu: implement synchronous TTM eviction for SVM BOs Huang Rui
2026-11-27  8:41 ` [PATCH v11 20/22] drm/amdgpu: hook up ZONE_DEVICE registration in device init and reset Huang Rui
2026-11-27  8:41 ` [PATCH v11 21/22] drm/amdgpu: add SVM range migration helpers for drm_pagemap Huang Rui
2026-11-27  8:41 ` [PATCH v11 22/22] drm/amdgpu: integrate VRAM migration into SVM fault and prefetch paths Huang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127084149.925625-2-ray.huang@amd.com \
    --to=ray.huang@amd.com \
    --cc=Jenny-Jing.Liu@amd.com \
    --cc=Junhua.Shen@amd.com \
    --cc=Oak.Zeng@amd.com \
    --cc=Philip.Yang@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=aliceryhl@google.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=felix.kuehling@amd.com \
    --cc=honghuan@amd.com \
    --cc=honglei1.huang@amd.com \
    --cc=jm5905938@gmail.com \
    --cc=lingshan.zhu@amd.com \
    --cc=matthew.brost@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=xiaogang.chen@amd.com \
    --cc=yiru.ma@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.