Skip to contentSkip to conversation

drm/xe: Use BO's GT to determine dma_offset when programming PTEs

PATCH Superseded Matthew Brost 3 participants 4 messages Mar 23, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Matthew Brost

author maintainer
#0 lore raw

PATCH 1/1 drm/xe: Use BO's GT to determine dma_offset when programming PTEs

Rather than using the passed in GT, use the BO's GT determine dma_offset when programming PTEs as these two GT's could differ (i.e. mapping a BO from a remote GT). The BO's GT is correct GT to use as this where BO resides, while the passed in GT is where the mapping is created.

---
 drivers/gpu/drm/xe/xe_bo.c | 5 +++++
 drivers/gpu/drm/xe/xe_bo.h | 1 +
 drivers/gpu/drm/xe/xe_pt.c | 4 +++-
 3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_bo.c +5 -0
index 764b3ca9fff7..8beb35aa6f15 100644
@@ -79,6 +79,11 @@ mem_type_to_gt(struct xe_device *xe, u32 mem_type)
 	return xe_device_get_gt(xe, mem_type == XE_PL_STOLEN ? 0 : (mem_type - XE_PL_VRAM0));
 }
 
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo)
+{
+	return mem_type_to_gt(xe_bo_device(bo), bo->ttm.resource->mem_type);
+}
+
 static void try_add_system(struct xe_bo *bo, struct ttm_place *places,
 			   u32 bo_flags, u32 *c)
 {
drivers/gpu/drm/xe/xe_bo.h +1 -0
index f4303810f213..f9abd8036417 100644
@@ -105,6 +105,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt,
 
 int xe_bo_placement_for_flags(struct xe_device *xe, struct xe_bo *bo,
 			      u32 bo_flags);
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo);
 
 static inline struct xe_bo *ttm_to_xe_bo(const struct ttm_buffer_object *bo)
 {
drivers/gpu/drm/xe/xe_pt.c +3 -1
index a2e586ebd9a8..6dc31b030687 100644
@@ -792,10 +792,12 @@ xe_pt_stage_bind(struct xe_gt *gt, struct xe_vma *vma,
 	int ret;
 
 	if (is_vram) {
+		struct xe_gt *bo_gt = xe_bo_to_gt(bo);
+
 		xe_walk.default_pte = GEN12_PPGTT_PTE_LM;
 		if (vma && vma->gpuva.flags & XE_VMA_ATOMIC_PTE_BIT)
 			xe_walk.default_pte |= GEN12_USM_PPGTT_PTE_AE;
-		xe_walk.dma_offset = gt->mem.vram.io_start -
+		xe_walk.dma_offset = bo_gt->mem.vram.io_start -
 			gt_to_xe(gt)->mem.vram.io_start;
 		xe_walk.cache = XE_CACHE_WB;
 	} else {
Signature · 1 line
2.34.1
CI Reviewed-by Matt Roper on v1 1/1
#1 lore raw

[Intel-xe] ✗ CI.Patch_applied: failure for drm/xe: Use BO's GT to determine dma_offset when programming PTEs

== Series Details ==

== Series Details ==

Series: drm/xe: Use BO's GT to determine dma_offset when programming PTEs
URL : https://patchwork.freedesktop.org/series/115533/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: === commit e6f9b3b9a18f2ec7b3aea2bbc7160ef5387dc878

Author:     Matthew Brost <[email protected]>
AuthorDate: Tue Mar 21 18:16:47 2023 -0700
Commit:     Matthew Brost <[email protected]>
CommitDate: Wed Mar 22 12:42:12 2023 -0700

drm/xe: Reinstate render / compute cache invalidation in ring ops

Render / compute engines have additional caches (not just TLBs) that need to be invalidated each batch, reinstate these invalidations in ring ops.

=== git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_pt.c:792
error: drivers/gpu/drm/xe/xe_pt.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: drm/xe: Use BO's GT to determine dma_offset when programming PTEs Patch failed at 0001 drm/xe: Use BO's GT to determine dma_offset when programming PTEs When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

#2 lore raw
In reply to Matthew Brost

Hi.

Good catch. Some comments below.

Quoted 17 lines · Matthew Brost

Rather than using the passed in GT, use the BO's GT determine dma_offset when programming PTEs as these two GT's could differ (i.e. mapping a BO from a remote GT). The BO's GT is correct GT to use as this where BO resides, while the passed in GT is where the mapping is created.

---
  drivers/gpu/drm/xe/xe_bo.c | 5 +++++
  drivers/gpu/drm/xe/xe_bo.h | 1 +
  drivers/gpu/drm/xe/xe_pt.c | 4 +++-
  3 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_bo.c +0 -0
index 764b3ca9fff7..8beb35aa6f15 100644

drivers/gpu/drm/xe/xe_bo.c mem_type_to_gt(struct xe_device *xe, u32 mem_type) · line 82

Quoted 4 lines
drivers/gpu/drm/xe/xe_bo.c +1 -0
@@ -79,6 +79,11 @@ mem_type_to_gt(struct xe_device *xe, u32 mem_type)
  	return xe_device_get_gt(xe, mem_type == XE_PL_STOLEN ? 0 : (mem_type - XE_PL_VRAM0));
  }
 
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo)

Kerneldoc.

drivers/gpu/drm/xe/xe_bo.c mem_type_to_gt(struct xe_device *xe, u32 mem_type) · line 83

Quoted 1 line
drivers/gpu/drm/xe/xe_bo.c +1 -0
+{

XE_WARN_ON_ONCE(!vram) ?

Quoted 11 lines
drivers/gpu/drm/xe/xe_bo.c +3 -0
+	return mem_type_to_gt(xe_bo_device(bo), bo->ttm.resource->mem_type);
+}
+
  static void try_add_system(struct xe_bo *bo, struct ttm_place *places,
  			   u32 bo_flags, u32 *c)
  {
drivers/gpu/drm/xe/xe_bo.h +0 -0
index f4303810f213..f9abd8036417 100644

drivers/gpu/drm/xe/xe_bo.h struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt, · line 107

Quoted 3 lines
drivers/gpu/drm/xe/xe_bo.h +0 -0
@@ -105,6 +105,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt,
 
  int xe_bo_placement_for_flags(struct xe_device *xe, struct xe_bo *bo,
  			      u32 bo_flags);

Newline.

Quoted 12 lines
drivers/gpu/drm/xe/xe_bo.h +1 -0
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo);
 
  static inline struct xe_bo *ttm_to_xe_bo(const struct ttm_buffer_object *bo)
  {
drivers/gpu/drm/xe/xe_pt.c +0 -0
index a2e586ebd9a8..6dc31b030687 100644
@@ -792,10 +792,12 @@ xe_pt_stage_bind(struct xe_gt *gt, struct xe_vma *vma,
  	int ret;
 
  	if (is_vram) {

drivers/gpu/drm/xe/xe_pt.c xe_pt_stage_bind(struct xe_gt *gt, struct xe_vma *vma, · line 803

Quoted 10 lines
drivers/gpu/drm/xe/xe_pt.c +3 -1
+		struct xe_gt *bo_gt = xe_bo_to_gt(bo);
+
  		xe_walk.default_pte = GEN12_PPGTT_PTE_LM;
  		if (vma && vma->gpuva.flags & XE_VMA_ATOMIC_PTE_BIT)
  			xe_walk.default_pte |= GEN12_USM_PPGTT_PTE_AE;
-		xe_walk.dma_offset = gt->mem.vram.io_start -
+		xe_walk.dma_offset = bo_gt->mem.vram.io_start -
  			gt_to_xe(gt)->mem.vram.io_start;
  		xe_walk.cache = XE_CACHE_WB;
  	} else {

Thanks,

Thomas

author maintainer
#3 lore raw
Quoted 17 lines · Thomas Hellström

Hi.

Good catch. Some comments below.

Quoted 12 lines · Matthew Brost

Rather than using the passed in GT, use the BO's GT determine dma_offset when programming PTEs as these two GT's could differ (i.e. mapping a BO from a remote GT). The BO's GT is correct GT to use as this where BO resides, while the passed in GT is where the mapping is created.

---
  drivers/gpu/drm/xe/xe_bo.c | 5 +++++
  drivers/gpu/drm/xe/xe_bo.h | 1 +
  drivers/gpu/drm/xe/xe_pt.c | 4 +++-
  3 files changed, 9 insertions(+), 1 deletion(-)
Quoted 11 lines

drivers/gpu/drm/xe/xe_bo.c mem_type_to_gt(struct xe_device *xe, u32 mem_type) · line 81

Quoted 8 lines
drivers/gpu/drm/xe/xe_bo.c +1 -0
index 764b3ca9fff7..8beb35aa6f15 100644
@@ -79,6 +79,11 @@ mem_type_to_gt(struct xe_device *xe, u32 mem_type)
  	return xe_device_get_gt(xe, mem_type == XE_PL_STOLEN ? 0 : (mem_type - XE_PL_VRAM0));
  }
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo)

Kerneldoc.

Will do.

Quoted 2 lines

drivers/gpu/drm/xe/xe_bo.c mem_type_to_gt(struct xe_device *xe, u32 mem_type) · line 83

Quoted 1 line
drivers/gpu/drm/xe/xe_bo.c +1 -0
+{

XE_WARN_ON_ONCE(!vram) ?

mem_type_to_gt has a BUG_ON for this.

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/xe/xe_bo.c +3 -0
+	return mem_type_to_gt(xe_bo_device(bo), bo->ttm.resource->mem_type);
+}
+
  static void try_add_system(struct xe_bo *bo, struct ttm_place *places,
  			   u32 bo_flags, u32 *c)
  {
Quoted 8 lines

drivers/gpu/drm/xe/xe_bo.h struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt, · line 106

Quoted 7 lines
drivers/gpu/drm/xe/xe_bo.h +0 -0
index f4303810f213..f9abd8036417 100644
@@ -105,6 +105,7 @@ struct xe_bo *xe_bo_create_from_data(struct xe_device *xe, struct xe_gt *gt,
  int xe_bo_placement_for_flags(struct xe_device *xe, struct xe_bo *bo,
  			      u32 bo_flags);

Newline.

Sure.

Matt

Quoted 26 lines
Quoted 10 lines
drivers/gpu/drm/xe/xe_bo.h +1 -0
+struct xe_gt *xe_bo_to_gt(struct xe_bo *bo);
  static inline struct xe_bo *ttm_to_xe_bo(const struct ttm_buffer_object *bo)
  {
drivers/gpu/drm/xe/xe_pt.c +0 -0
index a2e586ebd9a8..6dc31b030687 100644
@@ -792,10 +792,12 @@ xe_pt_stage_bind(struct xe_gt *gt, struct xe_vma *vma,
  	int ret;
  	if (is_vram) {

drivers/gpu/drm/xe/xe_pt.c xe_pt_stage_bind(struct xe_gt *gt, struct xe_vma *vma, · line 802

Quoted 10 lines
drivers/gpu/drm/xe/xe_pt.c +3 -1
+		struct xe_gt *bo_gt = xe_bo_to_gt(bo);
+
  		xe_walk.default_pte = GEN12_PPGTT_PTE_LM;
  		if (vma && vma->gpuva.flags & XE_VMA_ATOMIC_PTE_BIT)
  			xe_walk.default_pte |= GEN12_USM_PPGTT_PTE_AE;
-		xe_walk.dma_offset = gt->mem.vram.io_start -
+		xe_walk.dma_offset = bo_gt->mem.vram.io_start -
  			gt_to_xe(gt)->mem.vram.io_start;
  		xe_walk.cache = XE_CACHE_WB;
  	} else {

Thanks,

Thomas