Skip to contentSkip to conversation

drm/amdgpu: change default of amdgpu_vram_page_split to 512

PATCH In review Christian König 3 participants 7 messages May 12, 2017 – May 15, 2017 4 messages not in the archive

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

PATCH 1/3 drm/amdgpu: change default of amdgpu_vram_page_split to 512

From: Christian König <[email protected]>

512 is enough for one PD entry on Vega10.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 26fce4d..130c45d 100644
@@ -93,7 +93,7 @@ int amdgpu_vm_size = -1;
 int amdgpu_vm_block_size = -1;
 int amdgpu_vm_fault_stop = 0;
 int amdgpu_vm_debug = 0;
-int amdgpu_vram_page_split = 1024;
+int amdgpu_vram_page_split = 512;
 int amdgpu_exp_hw_support = 0;
 int amdgpu_dc = -1;
 int amdgpu_sched_jobs = 32;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1494596880-3968-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amdgpu: move adjust adjust_mc_addr into the GFX9 vm_flush functions

From: Christian König <[email protected]>

That GFX9 needs a PDE in the registers is entirely GFX9 specific.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 1 +
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 2 ++
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c  | 1 +
 5 files changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -3
index 3e97004..88420dc 100644
@@ -760,11 +760,10 @@ int amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job)
 		patch_offset = amdgpu_ring_init_cond_exec(ring);
 
 	if (ring->funcs->emit_vm_flush && vm_flush_needed) {
-		u64 pd_addr = amdgpu_vm_adjust_mc_addr(adev, job->vm_pd_addr);
 		struct fence *fence;
 
-		trace_amdgpu_vm_flush(ring, job->vm_id, pd_addr);
-		amdgpu_ring_emit_vm_flush(ring, job->vm_id, pd_addr);
+		trace_amdgpu_vm_flush(ring, job->vm_id, job->vm_pd_addr);
+		amdgpu_ring_emit_vm_flush(ring, job->vm_id, job->vm_pd_addr);
 
 		r = amdgpu_fence_emit(ring, &fence);
 		if (r)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
index f31f2a7..6dc75d2 100644
@@ -3759,6 +3759,7 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
+	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
 	pd_addr = pd_addr | 0x1; /* valid bit */
 	/* now only use physical base address of PDE and valid */
 	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -0
index c3ee746..91cf7e6 100644
@@ -1143,6 +1143,7 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
+	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
 	pd_addr = pd_addr | 0x1; /* valid bit */
 	/* now only use physical base address of PDE and valid */
 	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -0
index 499ead3..22f42f3 100644
@@ -1316,6 +1316,7 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t data0, data1, mask;
 	unsigned eng = ring->vm_inv_eng;
 
+	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
 	pd_addr = pd_addr | 0x1; /* valid bit */
 	/* now only use physical base address of PDE and valid */
 	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
@@ -1357,6 +1358,7 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
+	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
 	pd_addr = pd_addr | 0x1; /* valid bit */
 	/* now only use physical base address of PDE and valid */
 	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -0
index ada2d0a..07b2ac7 100644
@@ -926,6 +926,7 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
+	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
 	pd_addr = pd_addr | 0x1; /* valid bit */
 	/* now only use physical base address of PDE and valid */
 	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/3 drm/amdgpu: cleanup adjust_mc_addr handling

In reply to a message not in the archive

From: Christian König <[email protected]>

Rename adjust_mc_addr to get_vm_pde, check the address bits in one place and move setting the valid bit in there as well.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++----------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |  5 +----
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c  |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c |  5 +----
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 10 ++--------
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c  |  5 +----
 10 files changed, 46 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -2
index fadeb55..bc089eb 100644
@@ -309,8 +309,8 @@ struct amdgpu_gart_funcs {
 	/* set pte flags based per asic */
 	uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev,
 				     uint32_t flags);
-	/* adjust mc addr in fb for APU case */
-	u64 (*adjust_mc_addr)(struct amdgpu_device *adev, u64 addr);
+	/* get the pde for a given mc addr */
+	u64 (*get_vm_pde)(struct amdgpu_device *adev, u64 addr);
 	uint32_t (*get_invalidate_req)(unsigned int vm_id);
 };
 
@@ -1816,6 +1816,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev))
 #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
 #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
+#define amdgpu_gart_get_vm_pde(adev, addr) (adev)->gart.gart_funcs->get_vm_pde((adev), (addr))
 #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
 #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
 #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -22
index 88420dc..c10f3ce 100644
@@ -682,16 +682,6 @@ static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
 	return false;
 }
 
-static u64 amdgpu_vm_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
-{
-	u64 addr = mc_addr;
-
-	if (adev->gart.gart_funcs->adjust_mc_addr)
-		addr = adev->gart.gart_funcs->adjust_mc_addr(adev, addr);
-
-	return addr;
-}
-
 bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
 				  struct amdgpu_job *job)
 {
@@ -1034,19 +1024,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
 		    (count == AMDGPU_VM_MAX_UPDATE_SIZE)) {
 
 			if (count) {
-				uint64_t pt_addr =
-					amdgpu_vm_adjust_mc_addr(adev, last_pt);
+				uint64_t entry;
 
+				entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 				if (shadow)
 					amdgpu_vm_do_set_ptes(&params,
 							      last_shadow,
-							      pt_addr, count,
-							      incr,
-							      AMDGPU_PTE_VALID);
+							      entry, count,
+							      incr, 0);
 
 				amdgpu_vm_do_set_ptes(&params, last_pde,
-						      pt_addr, count, incr,
-						      AMDGPU_PTE_VALID);
+						      entry, count, incr, 0);
 			}
 
 			count = 1;
@@ -1059,14 +1047,16 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
 	}
 
 	if (count) {
-		uint64_t pt_addr = amdgpu_vm_adjust_mc_addr(adev, last_pt);
+		uint64_t entry;
+
+		entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 
 		if (vm->root.bo->shadow)
-			amdgpu_vm_do_set_ptes(&params, last_shadow, pt_addr,
-					      count, incr, AMDGPU_PTE_VALID);
+			amdgpu_vm_do_set_ptes(&params, last_shadow, entry,
+					      count, incr, 0);
 
-		amdgpu_vm_do_set_ptes(&params, last_pde, pt_addr,
-				      count, incr, AMDGPU_PTE_VALID);
+		amdgpu_vm_do_set_ptes(&params, last_pde, entry,
+				      count, incr, 0);
 	}
 
 	if (params.ib->length_dw == 0) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -4
index 6dc75d2..9e241d4 100644
@@ -3759,10 +3759,7 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	gfx_v9_0_write_data_to_reg(ring, usepfp, true,
 				   hub->ctx0_ptb_addr_lo32 + (2 * vm_id),
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +6 -0
index 1e6263a..445f6f4 100644
@@ -395,6 +395,11 @@ static uint64_t gmc_v6_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev,
 					      bool value)
 {
@@ -1127,6 +1132,7 @@ static const struct amdgpu_gart_funcs gmc_v6_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v6_0_gart_set_pte_pde,
 	.set_prt = gmc_v6_0_set_prt,
+	.get_vm_pde = gmc_v6_0_get_vm_pde,
 	.get_vm_pte_flags = gmc_v6_0_get_vm_pte_flags
 };
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 967505b..b9d86e1 100644
@@ -472,6 +472,11 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 /**
  * gmc_v8_0_set_fault_enable_default - update VM fault handling
  *
@@ -1293,7 +1298,8 @@ static const struct amdgpu_gart_funcs gmc_v7_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v7_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v7_0_gart_set_pte_pde,
 	.set_prt = gmc_v7_0_set_prt,
-	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v7_0_get_vm_pde
 };
 
 static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +7 -1
index 3b5ea0f..de8bfb6 100644
@@ -656,6 +656,11 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 /**
  * gmc_v8_0_set_fault_enable_default - update VM fault handling
  *
@@ -1612,7 +1617,8 @@ static const struct amdgpu_gart_funcs gmc_v8_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v8_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v8_0_gart_set_pte_pde,
 	.set_prt = gmc_v8_0_set_prt,
-	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v8_0_get_vm_pde
 };
 
 static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -4
index 19e1027..523157a 100644
@@ -358,17 +358,19 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
-static u64 gmc_v9_0_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
+static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr)
 {
-	return adev->vm_manager.vram_base_offset + mc_addr - adev->mc.vram_start;
+	addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start;
+	BUG_ON(addr & 0xFFFF00000000003FULL);
+	return addr | AMDGPU_PTE_VALID;
 }
 
 static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v9_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v9_0_gart_set_pte_pde,
-	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
-	.adjust_mc_addr = gmc_v9_0_adjust_mc_addr,
 	.get_invalidate_req = gmc_v9_0_get_invalidate_req,
+	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v9_0_get_vm_pde
 };
 
 static void gmc_v9_0_set_gart_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -4
index 91cf7e6..af98ed2 100644
@@ -1143,10 +1143,7 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -8
index 22f42f3..c8f4c34 100644
@@ -1316,10 +1316,7 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t data0, data1, mask;
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
 	data1 = upper_32_bits(pd_addr);
@@ -1358,10 +1355,7 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE);
 	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -4
index 07b2ac7..b1bda0e 100644
@@ -926,10 +926,7 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, VCE_CMD_REG_WRITE);
 	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1494596880-3968-3-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#5 lore raw

Re: [PATCH 3/3] drm/amdgpu: cleanup adjust_mc_addr handling

Hi Christian,

One comment inline [FK]. If this is not a problem, then feel free to add my R-B for the whole series.

Kent, when we adopt this change, we need to convert the PDE back to an address, because KFD needs to fill just the page directory base address into the map_process HIQ packet. I think the existing amdgpu_amdkfd_gpuvm_get_process_page_dir already takes care of that just by right-shifting the address.

Regards,
Felix

Quoted 70 lines · Christian König

From: Christian König <[email protected]>

Rename adjust_mc_addr to get_vm_pde, check the address bits in one place and move setting the valid bit in there as well.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  5 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++----------------------
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |  5 +----
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c  |  6 ++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +++++++-
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c |  5 +----
 drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 10 ++--------
 drivers/gpu/drm/amd/amdgpu/vce_v4_0.c  |  5 +----
 10 files changed, 46 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -2
index fadeb55..bc089eb 100644
@@ -309,8 +309,8 @@ struct amdgpu_gart_funcs {
 	/* set pte flags based per asic */
 	uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev,
 				     uint32_t flags);
-	/* adjust mc addr in fb for APU case */
-	u64 (*adjust_mc_addr)(struct amdgpu_device *adev, u64 addr);
+	/* get the pde for a given mc addr */
+	u64 (*get_vm_pde)(struct amdgpu_device *adev, u64 addr);
 	uint32_t (*get_invalidate_req)(unsigned int vm_id);
 };
 
@@ -1816,6 +1816,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev))
 #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
 #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
+#define amdgpu_gart_get_vm_pde(adev, addr) (adev)->gart.gart_funcs->get_vm_pde((adev), (addr))
 #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
 #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
 #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -12
index 88420dc..c10f3ce 100644
@@ -682,16 +682,6 @@ static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
 	return false;
 }
 
-static u64 amdgpu_vm_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
-{
-	u64 addr = mc_addr;
-
-	if (adev->gart.gart_funcs->adjust_mc_addr)
-		addr = adev->gart.gart_funcs->adjust_mc_addr(adev, addr);
-
-	return addr;
-}
-
 bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
 				  struct amdgpu_job *job)
 {
@@ -1034,19 +1024,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
 		    (count == AMDGPU_VM_MAX_UPDATE_SIZE)) {
 
 			if (count) {
-				uint64_t pt_addr =
-					amdgpu_vm_adjust_mc_addr(adev, last_pt);
+				uint64_t entry;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_level(struct amdgpu_device *adev, · line 1034

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -3
 
+				entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 				if (shadow)
 					amdgpu_vm_do_set_ptes(&params,
 							      last_shadow,
-							      pt_addr, count,
-							      incr,
-							      AMDGPU_PTE_VALID);
+							      entry, count,
+							      incr, 0);

[FK] For count >=3 this would result in an SDMA_OP_PTEPDE packet with flags=0 and the flags included in the address. Could SDMA mask out the flags bits from the address before it applies the flags? The SDMA 4.0 MAS includes pseudo code that looks like it wouldn't. But then the flags are kind of redundant in the packet.

Quoted 200 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -7
 				amdgpu_vm_do_set_ptes(&params, last_pde,
-						      pt_addr, count, incr,
-						      AMDGPU_PTE_VALID);
+						      entry, count, incr, 0);
 			}
 
 			count = 1;
@@ -1059,14 +1047,16 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
 	}
 
 	if (count) {
-		uint64_t pt_addr = amdgpu_vm_adjust_mc_addr(adev, last_pt);
+		uint64_t entry;
+
+		entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 
 		if (vm->root.bo->shadow)
-			amdgpu_vm_do_set_ptes(&params, last_shadow, pt_addr,
-					      count, incr, AMDGPU_PTE_VALID);
+			amdgpu_vm_do_set_ptes(&params, last_shadow, entry,
+					      count, incr, 0);
 
-		amdgpu_vm_do_set_ptes(&params, last_pde, pt_addr,
-				      count, incr, AMDGPU_PTE_VALID);
+		amdgpu_vm_do_set_ptes(&params, last_pde, entry,
+				      count, incr, 0);
 	}
 
 	if (params.ib->length_dw == 0) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -4
index 6dc75d2..9e241d4 100644
@@ -3759,10 +3759,7 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	gfx_v9_0_write_data_to_reg(ring, usepfp, true,
 				   hub->ctx0_ptb_addr_lo32 + (2 * vm_id),
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +6 -0
index 1e6263a..445f6f4 100644
@@ -395,6 +395,11 @@ static uint64_t gmc_v6_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev,
 					      bool value)
 {
@@ -1127,6 +1132,7 @@ static const struct amdgpu_gart_funcs gmc_v6_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v6_0_gart_set_pte_pde,
 	.set_prt = gmc_v6_0_set_prt,
+	.get_vm_pde = gmc_v6_0_get_vm_pde,
 	.get_vm_pte_flags = gmc_v6_0_get_vm_pte_flags
 };
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 967505b..b9d86e1 100644
@@ -472,6 +472,11 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 /**
  * gmc_v8_0_set_fault_enable_default - update VM fault handling
  *
@@ -1293,7 +1298,8 @@ static const struct amdgpu_gart_funcs gmc_v7_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v7_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v7_0_gart_set_pte_pde,
 	.set_prt = gmc_v7_0_set_prt,
-	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v7_0_get_vm_pde
 };
 
 static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +7 -1
index 3b5ea0f..de8bfb6 100644
@@ -656,6 +656,11 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
+static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
 /**
  * gmc_v8_0_set_fault_enable_default - update VM fault handling
  *
@@ -1612,7 +1617,8 @@ static const struct amdgpu_gart_funcs gmc_v8_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v8_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v8_0_gart_set_pte_pde,
 	.set_prt = gmc_v8_0_set_prt,
-	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v8_0_get_vm_pde
 };
 
 static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -4
index 19e1027..523157a 100644
@@ -358,17 +358,19 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,
 	return pte_flag;
 }
 
-static u64 gmc_v9_0_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
+static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr)
 {
-	return adev->vm_manager.vram_base_offset + mc_addr - adev->mc.vram_start;
+	addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start;
+	BUG_ON(addr & 0xFFFF00000000003FULL);
+	return addr | AMDGPU_PTE_VALID;
 }
 
 static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = {
 	.flush_gpu_tlb = gmc_v9_0_gart_flush_gpu_tlb,
 	.set_pte_pde = gmc_v9_0_gart_set_pte_pde,
-	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
-	.adjust_mc_addr = gmc_v9_0_adjust_mc_addr,
 	.get_invalidate_req = gmc_v9_0_get_invalidate_req,
+	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v9_0_get_vm_pde
 };
 
 static void gmc_v9_0_set_gart_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -4
index 91cf7e6..af98ed2 100644
@@ -1143,10 +1143,7 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -8
index 22f42f3..c8f4c34 100644
@@ -1316,10 +1316,7 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t data0, data1, mask;
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
 	data1 = upper_32_bits(pd_addr);
@@ -1358,10 +1355,7 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE);
 	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +0 -0
index 07b2ac7..b1bda0e 100644
@@ -926,10 +926,7 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring,
 	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);

drivers/gpu/drm/amd/amdgpu/vce_v4_0.c static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring, · line 932

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -4
 	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
 	amdgpu_ring_write(ring, VCE_CMD_REG_WRITE);
 	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 674b18c3-045e-2c77-1349-b1f24e72067c-5C7GfCeVMHo@public.gmane.org

#7 lore raw

Re: [PATCH 3/3] drm/amdgpu: cleanup adjust_mc_addr handling

Quoted 86 lines · Felix Kuehling

Hi Christian,

One comment inline [FK]. If this is not a problem, then feel free to add my R-B for the whole series.

Kent, when we adopt this change, we need to convert the PDE back to an address, because KFD needs to fill just the page directory base address into the map_process HIQ packet. I think the existing amdgpu_amdkfd_gpuvm_get_process_page_dir already takes care of that just by right-shifting the address.

Regards,
Felix

Quoted 71 lines · Christian König

From: Christian König <[email protected]>

Rename adjust_mc_addr to get_vm_pde, check the address bits in one place and move setting the valid bit in there as well.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  5 +++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++----------------------
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |  5 +----
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c  |  6 ++++++
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +++++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +++++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 10 ++++++----
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c |  5 +----
  drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 10 ++--------
  drivers/gpu/drm/amd/amdgpu/vce_v4_0.c  |  5 +----
  10 files changed, 46 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -2
index fadeb55..bc089eb 100644
@@ -309,8 +309,8 @@ struct amdgpu_gart_funcs {
  	/* set pte flags based per asic */
  	uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev,
  				     uint32_t flags);
-	/* adjust mc addr in fb for APU case */
-	u64 (*adjust_mc_addr)(struct amdgpu_device *adev, u64 addr);
+	/* get the pde for a given mc addr */
+	u64 (*get_vm_pde)(struct amdgpu_device *adev, u64 addr);
  	uint32_t (*get_invalidate_req)(unsigned int vm_id);
  };
 
@@ -1816,6 +1816,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev))
  #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
  #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
+#define amdgpu_gart_get_vm_pde(adev, addr) (adev)->gart.gart_funcs->get_vm_pde((adev), (addr))
  #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
  #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
  #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -12
index 88420dc..c10f3ce 100644
@@ -682,16 +682,6 @@ static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
  	return false;
  }
 
-static u64 amdgpu_vm_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
-{
-	u64 addr = mc_addr;
-
-	if (adev->gart.gart_funcs->adjust_mc_addr)
-		addr = adev->gart.gart_funcs->adjust_mc_addr(adev, addr);
-
-	return addr;
-}
-
  bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
  				  struct amdgpu_job *job)
  {
@@ -1034,19 +1024,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
  		    (count == AMDGPU_VM_MAX_UPDATE_SIZE)) {
 
  			if (count) {
-				uint64_t pt_addr =
-					amdgpu_vm_adjust_mc_addr(adev, last_pt);
+				uint64_t entry;
 
Quoted 13 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_level(struct amdgpu_device *adev, · line 1034

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -3
+				entry = amdgpu_gart_get_vm_pde(adev, last_pt);
  				if (shadow)
  					amdgpu_vm_do_set_ptes(&params,
  							      last_shadow,
-							      pt_addr, count,
-							      incr,
-							      AMDGPU_PTE_VALID);
+							      entry, count,
+							      incr, 0);

[FK] For count >=3 this would result in an SDMA_OP_PTEPDE packet with flags=0 and the flags included in the address. Could SDMA mask out the flags bits from the address before it applies the flags? The SDMA 4.0 MAS includes pseudo code that looks like it wouldn't.

        5.


                 Generate PTE/PDE

It would work like this in C pseudo code:

For (i = 0; i < count; i++)

{

Write ( Mask | ( Initial Value + ( i * Increment ) ) ) to Dest Addr // result is a 64 bit value

Dest Addr += 8 bytes;

}

Yes, it wouldn't.

Regards,
David Zhou

Quoted 211 lines

But then the flags
are kind of redundant in the packet.

Quoted 208 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -7
  				amdgpu_vm_do_set_ptes(&params, last_pde,
-						      pt_addr, count, incr,
-						      AMDGPU_PTE_VALID);
+						      entry, count, incr, 0);
  			}
 
  			count = 1;
@@ -1059,14 +1047,16 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
  	}
 
  	if (count) {
-		uint64_t pt_addr = amdgpu_vm_adjust_mc_addr(adev, last_pt);
+		uint64_t entry;
+
+		entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 
  		if (vm->root.bo->shadow)
-			amdgpu_vm_do_set_ptes(&params, last_shadow, pt_addr,
-					      count, incr, AMDGPU_PTE_VALID);
+			amdgpu_vm_do_set_ptes(&params, last_shadow, entry,
+					      count, incr, 0);
 
-		amdgpu_vm_do_set_ptes(&params, last_pde, pt_addr,
-				      count, incr, AMDGPU_PTE_VALID);
+		amdgpu_vm_do_set_ptes(&params, last_pde, entry,
+				      count, incr, 0);
  	}
 
  	if (params.ib->length_dw == 0) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -4
index 6dc75d2..9e241d4 100644
@@ -3759,10 +3759,7 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	gfx_v9_0_write_data_to_reg(ring, usepfp, true,
  				   hub->ctx0_ptb_addr_lo32 + (2 * vm_id),
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +6 -0
index 1e6263a..445f6f4 100644
@@ -395,6 +395,11 @@ static uint64_t gmc_v6_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev,
  					      bool value)
  {
@@ -1127,6 +1132,7 @@ static const struct amdgpu_gart_funcs gmc_v6_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v6_0_gart_set_pte_pde,
  	.set_prt = gmc_v6_0_set_prt,
+	.get_vm_pde = gmc_v6_0_get_vm_pde,
  	.get_vm_pte_flags = gmc_v6_0_get_vm_pte_flags
  };
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 967505b..b9d86e1 100644
@@ -472,6 +472,11 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  /**
   * gmc_v8_0_set_fault_enable_default - update VM fault handling
   *
@@ -1293,7 +1298,8 @@ static const struct amdgpu_gart_funcs gmc_v7_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v7_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v7_0_gart_set_pte_pde,
  	.set_prt = gmc_v7_0_set_prt,
-	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v7_0_get_vm_pde
  };
 
  static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +7 -1
index 3b5ea0f..de8bfb6 100644
@@ -656,6 +656,11 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  /**
   * gmc_v8_0_set_fault_enable_default - update VM fault handling
   *
@@ -1612,7 +1617,8 @@ static const struct amdgpu_gart_funcs gmc_v8_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v8_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v8_0_gart_set_pte_pde,
  	.set_prt = gmc_v8_0_set_prt,
-	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v8_0_get_vm_pde
  };
 
  static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -4
index 19e1027..523157a 100644
@@ -358,17 +358,19 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
-static u64 gmc_v9_0_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
+static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr)
  {
-	return adev->vm_manager.vram_base_offset + mc_addr - adev->mc.vram_start;
+	addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start;
+	BUG_ON(addr & 0xFFFF00000000003FULL);
+	return addr | AMDGPU_PTE_VALID;
  }
 
  static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v9_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v9_0_gart_set_pte_pde,
-	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
-	.adjust_mc_addr = gmc_v9_0_adjust_mc_addr,
  	.get_invalidate_req = gmc_v9_0_get_invalidate_req,
+	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v9_0_get_vm_pde
  };
 
  static void gmc_v9_0_set_gart_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -4
index 91cf7e6..af98ed2 100644
@@ -1143,10 +1143,7 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
  			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -8
index 22f42f3..c8f4c34 100644
@@ -1316,10 +1316,7 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t data0, data1, mask;
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
  	data1 = upper_32_bits(pd_addr);
@@ -1358,10 +1355,7 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE);
  	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -4
index 07b2ac7..b1bda0e 100644
@@ -926,10 +926,7 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/vce_v4_0.c static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring, · line 932

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +0 -0
  	amdgpu_ring_write(ring, VCE_CMD_REG_WRITE);
  	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [PATCH 3/3] drm/amdgpu: cleanup adjust_mc_addr handling

Am 15.05.2017 um 05:06 schrieb zhoucm1:

Quoted 25 lines · Felix Kuehling
Quoted 12 lines

[SNIP]

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_level(struct amdgpu_device *adev, · line 1034

Quoted 7 lines

amdgpu_vm_do_set_ptes(&params,
last_shadow,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -3
-							      pt_addr, count,
-							      incr,
-							      AMDGPU_PTE_VALID);
+							      entry, count,
+							      incr, 0);

[FK] For count >=3 this would result in an SDMA_OP_PTEPDE packet with flags=0 and the flags included in the address. Could SDMA mask out the flags bits from the address before it applies the flags? The SDMA 4.0 MAS includes pseudo code that looks like it wouldn't.

        5.


                  Generate PTE/PDE

It would work like this in C pseudo code:

For (i = 0; i < count; i++)

{

Quoted 8 lines

Write ( Mask | ( Initial Value + ( i * Increment ) ) ) to Dest Addr // result is a 64 bit value

Dest Addr += 8 bytes;

}

Yes, it wouldn't.

Well Felix is right with the point that this is actually at least a little bit ugly and not the intended use.

I will just keep setting the valid bit outside of that function.

Regards,
Christian.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#10 lore raw

Re: [PATCH 3/3] drm/amdgpu: cleanup adjust_mc_addr handling

In reply to a message not in the archive

the series is Reviewed-by: Chunming Zhou <[email protected]>

Quoted 280 lines · Christian König

From: Christian König <[email protected]>

Rename adjust_mc_addr to get_vm_pde, check the address bits in one place and move setting the valid bit in there as well.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h    |  5 +++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++----------------------
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c  |  5 +----
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c  |  6 ++++++
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c  |  8 +++++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c  |  8 +++++++-
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c  | 10 ++++++----
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c |  5 +----
  drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c  | 10 ++--------
  drivers/gpu/drm/amd/amdgpu/vce_v4_0.c  |  5 +----
  10 files changed, 46 insertions(+), 50 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -2
index fadeb55..bc089eb 100644
@@ -309,8 +309,8 @@ struct amdgpu_gart_funcs {
  	/* set pte flags based per asic */
  	uint64_t (*get_vm_pte_flags)(struct amdgpu_device *adev,
  				     uint32_t flags);
-	/* adjust mc addr in fb for APU case */
-	u64 (*adjust_mc_addr)(struct amdgpu_device *adev, u64 addr);
+	/* get the pde for a given mc addr */
+	u64 (*get_vm_pde)(struct amdgpu_device *adev, u64 addr);
  	uint32_t (*get_invalidate_req)(unsigned int vm_id);
  };
 
@@ -1816,6 +1816,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
  #define amdgpu_asic_get_config_memsize(adev) (adev)->asic_funcs->get_config_memsize((adev))
  #define amdgpu_gart_flush_gpu_tlb(adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))
  #define amdgpu_gart_set_pte_pde(adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))
+#define amdgpu_gart_get_vm_pde(adev, addr) (adev)->gart.gart_funcs->get_vm_pde((adev), (addr))
  #define amdgpu_vm_copy_pte(adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count)))
  #define amdgpu_vm_write_pte(adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))
  #define amdgpu_vm_set_pte_pde(adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +12 -22
index 88420dc..c10f3ce 100644
@@ -682,16 +682,6 @@ static bool amdgpu_vm_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
  	return false;
  }
 
-static u64 amdgpu_vm_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
-{
-	u64 addr = mc_addr;
-
-	if (adev->gart.gart_funcs->adjust_mc_addr)
-		addr = adev->gart.gart_funcs->adjust_mc_addr(adev, addr);
-
-	return addr;
-}
-
  bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
  				  struct amdgpu_job *job)
  {
@@ -1034,19 +1024,17 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
  		    (count == AMDGPU_VM_MAX_UPDATE_SIZE)) {
 
  			if (count) {
-				uint64_t pt_addr =
-					amdgpu_vm_adjust_mc_addr(adev, last_pt);
+				uint64_t entry;
 
+				entry = amdgpu_gart_get_vm_pde(adev, last_pt);
  				if (shadow)
  					amdgpu_vm_do_set_ptes(&params,
  							      last_shadow,
-							      pt_addr, count,
-							      incr,
-							      AMDGPU_PTE_VALID);
+							      entry, count,
+							      incr, 0);
 
  				amdgpu_vm_do_set_ptes(&params, last_pde,
-						      pt_addr, count, incr,
-						      AMDGPU_PTE_VALID);
+						      entry, count, incr, 0);
  			}
 
  			count = 1;
@@ -1059,14 +1047,16 @@ static int amdgpu_vm_update_level(struct amdgpu_device *adev,
  	}
 
  	if (count) {
-		uint64_t pt_addr = amdgpu_vm_adjust_mc_addr(adev, last_pt);
+		uint64_t entry;
+
+		entry = amdgpu_gart_get_vm_pde(adev, last_pt);
 
  		if (vm->root.bo->shadow)
-			amdgpu_vm_do_set_ptes(&params, last_shadow, pt_addr,
-					      count, incr, AMDGPU_PTE_VALID);
+			amdgpu_vm_do_set_ptes(&params, last_shadow, entry,
+					      count, incr, 0);
 
-		amdgpu_vm_do_set_ptes(&params, last_pde, pt_addr,
-				      count, incr, AMDGPU_PTE_VALID);
+		amdgpu_vm_do_set_ptes(&params, last_pde, entry,
+				      count, incr, 0);
  	}
 
  	if (params.ib->length_dw == 0) {
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -4
index 6dc75d2..9e241d4 100644
@@ -3759,10 +3759,7 @@ static void gfx_v9_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	gfx_v9_0_write_data_to_reg(ring, usepfp, true,
  				   hub->ctx0_ptb_addr_lo32 + (2 * vm_id),
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +6 -0
index 1e6263a..445f6f4 100644
@@ -395,6 +395,11 @@ static uint64_t gmc_v6_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v6_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  static void gmc_v6_0_set_fault_enable_default(struct amdgpu_device *adev,
  					      bool value)
  {
@@ -1127,6 +1132,7 @@ static const struct amdgpu_gart_funcs gmc_v6_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v6_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v6_0_gart_set_pte_pde,
  	.set_prt = gmc_v6_0_set_prt,
+	.get_vm_pde = gmc_v6_0_get_vm_pde,
  	.get_vm_pte_flags = gmc_v6_0_get_vm_pte_flags
  };
 
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 967505b..b9d86e1 100644
@@ -472,6 +472,11 @@ static uint64_t gmc_v7_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v7_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  /**
   * gmc_v8_0_set_fault_enable_default - update VM fault handling
   *
@@ -1293,7 +1298,8 @@ static const struct amdgpu_gart_funcs gmc_v7_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v7_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v7_0_gart_set_pte_pde,
  	.set_prt = gmc_v7_0_set_prt,
-	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v7_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v7_0_get_vm_pde
  };
 
  static const struct amdgpu_irq_src_funcs gmc_v7_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +7 -1
index 3b5ea0f..de8bfb6 100644
@@ -656,6 +656,11 @@ static uint64_t gmc_v8_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
+static uint64_t gmc_v8_0_get_vm_pde(struct amdgpu_device *adev, uint64_t addr)
+{
+	return addr | AMDGPU_PTE_VALID;
+}
+
  /**
   * gmc_v8_0_set_fault_enable_default - update VM fault handling
   *
@@ -1612,7 +1617,8 @@ static const struct amdgpu_gart_funcs gmc_v8_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v8_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v8_0_gart_set_pte_pde,
  	.set_prt = gmc_v8_0_set_prt,
-	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags
+	.get_vm_pte_flags = gmc_v8_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v8_0_get_vm_pde
  };
 
  static const struct amdgpu_irq_src_funcs gmc_v8_0_irq_funcs = {
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -4
index 19e1027..523157a 100644
@@ -358,17 +358,19 @@ static uint64_t gmc_v9_0_get_vm_pte_flags(struct amdgpu_device *adev,
  	return pte_flag;
  }
 
-static u64 gmc_v9_0_adjust_mc_addr(struct amdgpu_device *adev, u64 mc_addr)
+static u64 gmc_v9_0_get_vm_pde(struct amdgpu_device *adev, u64 addr)
  {
-	return adev->vm_manager.vram_base_offset + mc_addr - adev->mc.vram_start;
+	addr = adev->vm_manager.vram_base_offset + addr - adev->mc.vram_start;
+	BUG_ON(addr & 0xFFFF00000000003FULL);
+	return addr | AMDGPU_PTE_VALID;
  }
 
  static const struct amdgpu_gart_funcs gmc_v9_0_gart_funcs = {
  	.flush_gpu_tlb = gmc_v9_0_gart_flush_gpu_tlb,
  	.set_pte_pde = gmc_v9_0_gart_set_pte_pde,
-	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
-	.adjust_mc_addr = gmc_v9_0_adjust_mc_addr,
  	.get_invalidate_req = gmc_v9_0_get_invalidate_req,
+	.get_vm_pte_flags = gmc_v9_0_get_vm_pte_flags,
+	.get_vm_pde = gmc_v9_0_get_vm_pde
  };
 
  static void gmc_v9_0_set_gart_funcs(struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -4
index 91cf7e6..af98ed2 100644
@@ -1143,10 +1143,7 @@ static void sdma_v4_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
  			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c +2 -8
index 22f42f3..c8f4c34 100644
@@ -1316,10 +1316,7 @@ static void uvd_v7_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t data0, data1, mask;
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	data0 = (hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2;
  	data1 = upper_32_bits(pd_addr);
@@ -1358,10 +1355,7 @@ static void uvd_v7_0_enc_ring_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	amdgpu_ring_write(ring, HEVC_ENC_CMD_REG_WRITE);
  	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +0 -0
index 07b2ac7..b1bda0e 100644
@@ -926,10 +926,7 @@ static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring,
  	uint32_t req = ring->adev->gart.gart_funcs->get_invalidate_req(vm_id);

drivers/gpu/drm/amd/amdgpu/vce_v4_0.c static void vce_v4_0_emit_vm_flush(struct amdgpu_ring *ring, · line 932

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c +1 -4
  	unsigned eng = ring->vm_inv_eng;
 
-	pd_addr = ring->adev->gart.gart_funcs->adjust_mc_addr(ring->adev, pd_addr);
-	pd_addr = pd_addr | 0x1; /* valid bit */
-	/* now only use physical base address of PDE and valid */
-	BUG_ON(pd_addr & 0xFFFF00000000003EULL);
+	pd_addr = amdgpu_gart_get_vm_pde(ring->adev, pd_addr);
 
  	amdgpu_ring_write(ring, VCE_CMD_REG_WRITE);
  	amdgpu_ring_write(ring,	(hub->ctx0_ptb_addr_hi32 + vm_id * 2) << 2);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx