* [CI 00/13] Offload GGTT binding to migration engine.
@ 2025-04-04 20:51 Maarten Lankhorst
2025-04-04 20:51 ` [CI 01/13] drm/xe: Use xe_ggtt_map_bo_unlocked for resume Maarten Lankhorst
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Another way of tackling test failure.
Test to see if it passes CI, and for discussion.
Maarten Lankhorst (13):
drm/xe: Use xe_ggtt_map_bo_unlocked for resume
drm/xe: Add xe_ggtt_might_lock
drm/xe: Add xe_ggtt_alloc
drm/xe/display: Remove dereferences of ggtt for tile id
drm/xe/ggtt: Seperate flags and address in PTE encoding
drm/xe/display: Dont poke into GGTT internals to fill a DPT
drm/xe/display: Convert GGTT mapping to use pte_encode_flags
drm/xe: Remove pte_encode_bo callback
drm/xe: Implement a helper for reading out a GGTT PTE at a specified
offset
drm/xe: Add GGTT updates to migration engine
drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT
drm/xe: Allow for optimization of xe_ggtt_map_bo
drm/xe: Move struct xe_ggtt to xe_ggtt.c
drivers/gpu/drm/xe/display/xe_fb_pin.c | 151 ++++-----
drivers/gpu/drm/xe/display/xe_plane_initial.c | 6 +-
.../gpu/drm/xe/instructions/xe_mi_commands.h | 2 +
drivers/gpu/drm/xe/tests/xe_migrate.c | 75 +++++
drivers/gpu/drm/xe/xe_bo.c | 2 +-
drivers/gpu/drm/xe/xe_bo_evict.c | 4 +-
drivers/gpu/drm/xe/xe_ggtt.c | 289 +++++++++++++++---
drivers/gpu/drm/xe/xe_ggtt.h | 21 +-
drivers/gpu/drm/xe/xe_ggtt_types.h | 53 +---
drivers/gpu/drm/xe/xe_migrate.c | 87 ++++++
drivers/gpu/drm/xe/xe_migrate.h | 12 +
drivers/gpu/drm/xe/xe_tile.c | 6 +-
12 files changed, 517 insertions(+), 191 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 17+ messages in thread
* [CI 01/13] drm/xe: Use xe_ggtt_map_bo_unlocked for resume
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 02/13] drm/xe: Add xe_ggtt_might_lock Maarten Lankhorst
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst, Matthew Brost, Lucas De Marchi
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
This is the first step to hide the details of struct xe_ggtt.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/xe_bo_evict.c | 4 +---
drivers/gpu/drm/xe/xe_ggtt.c | 16 +++++++++++++++-
drivers/gpu/drm/xe/xe_ggtt.h | 2 +-
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_bo_evict.c b/drivers/gpu/drm/xe/xe_bo_evict.c
index a1f0661e7b0c8..b72d87d969930 100644
--- a/drivers/gpu/drm/xe/xe_bo_evict.c
+++ b/drivers/gpu/drm/xe/xe_bo_evict.c
@@ -129,9 +129,7 @@ static int xe_bo_restore_and_map_ggtt(struct xe_bo *bo)
if (tile != bo->tile && !(bo->flags & XE_BO_FLAG_GGTTx(tile)))
continue;
- mutex_lock(&tile->mem.ggtt->lock);
- xe_ggtt_map_bo(tile->mem.ggtt, bo);
- mutex_unlock(&tile->mem.ggtt->lock);
+ xe_ggtt_map_bo_unlocked(tile->mem.ggtt, bo);
}
}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 5fcb2b4c2c139..62025d9cb7380 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -591,7 +591,7 @@ bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
* @ggtt: the &xe_ggtt where node will be mapped
* @bo: the &xe_bo to be mapped
*/
-void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
+static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
@@ -609,6 +609,20 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
}
}
+/**
+ * xe_ggtt_map_bo_unlocked - Restore a mapping of a BO into GGTT
+ * @ggtt: the &xe_ggtt where node will be mapped
+ * @bo: the &xe_bo to be mapped
+ *
+ * This is used to restore a GGTT mapping after suspend.
+ */
+void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo)
+{
+ mutex_lock(&ggtt->lock);
+ xe_ggtt_map_bo(ggtt, bo);
+ mutex_unlock(&ggtt->lock);
+}
+
static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 27e7d67de0047..bdf6d0733e2ca 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -24,7 +24,7 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags);
void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate);
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
-void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 02/13] drm/xe: Add xe_ggtt_might_lock
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
2025-04-04 20:51 ` [CI 01/13] drm/xe: Use xe_ggtt_map_bo_unlocked for resume Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 03/13] drm/xe: Add xe_ggtt_alloc Maarten Lankhorst
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst, Matthew Brost
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Another requirement of hiding more of struct xe_ggtt.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_bo.c | 2 +-
drivers/gpu/drm/xe/xe_ggtt.c | 7 +++++++
drivers/gpu/drm/xe/xe_ggtt.h | 7 +++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 3c7c2353d3c86..2f3bd9da6eedc 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -2934,7 +2934,7 @@ void xe_bo_put(struct xe_bo *bo)
#endif
for_each_tile(tile, xe_bo_device(bo), id)
if (bo->ggtt_node[id] && bo->ggtt_node[id]->ggtt)
- might_lock(&bo->ggtt_node[id]->ggtt->lock);
+ xe_ggtt_might_lock(bo->ggtt_node[id]->ggtt);
drm_gem_object_put(&bo->ttm.base);
}
}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 62025d9cb7380..5f4be9f40c9ba 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -176,6 +176,13 @@ static void ggtt_fini(void *arg)
ggtt->scratch = NULL;
}
+#ifdef CONFIG_LOCKDEP
+void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
+{
+ might_lock(&ggtt->lock);
+}
+#endif
+
static void primelockdep(struct xe_ggtt *ggtt)
{
if (!IS_ENABLED(CONFIG_LOCKDEP))
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index bdf6d0733e2ca..62c8ce636939a 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -38,4 +38,11 @@ u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer
void xe_ggtt_assign(const struct xe_ggtt_node *node, u16 vfid);
#endif
+#ifndef CONFIG_LOCKDEP
+static inline void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
+{ }
+#else
+void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
+#endif
+
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 03/13] drm/xe: Add xe_ggtt_alloc
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
2025-04-04 20:51 ` [CI 01/13] drm/xe: Use xe_ggtt_map_bo_unlocked for resume Maarten Lankhorst
2025-04-04 20:51 ` [CI 02/13] drm/xe: Add xe_ggtt_might_lock Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 04/13] drm/xe/display: Remove dereferences of ggtt for tile id Maarten Lankhorst
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst, Matthew Brost, Lucas De Marchi
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Instead of allocating inside xe_tile, create a new function that returns
an allocated struct xe_ggtt from xe_ggtt.c
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 16 ++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 2 ++
drivers/gpu/drm/xe/xe_tile.c | 6 +-----
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 5f4be9f40c9ba..b197b835ed442 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -160,6 +160,22 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
}
}
+/**
+ * xe_ggtt_alloc - Allocate a GGTT for a given &xe_tile
+ * @tile: &xe_tile
+ *
+ * Allocates a &xe_ggtt for a given tile.
+ *
+ * Return: &xe_ggtt on success, or NULL when out of memory.
+ */
+struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile)
+{
+ struct xe_ggtt *ggtt = drmm_kzalloc(&tile_to_xe(tile)->drm, sizeof(*ggtt), GFP_KERNEL);
+ if (ggtt)
+ ggtt->tile = tile;
+ return ggtt;
+}
+
static void ggtt_fini_early(struct drm_device *drm, void *arg)
{
struct xe_ggtt *ggtt = arg;
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 62c8ce636939a..0bab1fd7cc817 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -9,7 +9,9 @@
#include "xe_ggtt_types.h"
struct drm_printer;
+struct xe_tile;
+struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);
diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
index 6f303d4097d6e..86e9811e60ba0 100644
--- a/drivers/gpu/drm/xe/xe_tile.c
+++ b/drivers/gpu/drm/xe/xe_tile.c
@@ -88,13 +88,9 @@
*/
static int xe_tile_alloc(struct xe_tile *tile)
{
- struct drm_device *drm = &tile_to_xe(tile)->drm;
-
- tile->mem.ggtt = drmm_kzalloc(drm, sizeof(*tile->mem.ggtt),
- GFP_KERNEL);
+ tile->mem.ggtt = xe_ggtt_alloc(tile);
if (!tile->mem.ggtt)
return -ENOMEM;
- tile->mem.ggtt->tile = tile;
return 0;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 04/13] drm/xe/display: Remove dereferences of ggtt for tile id
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (2 preceding siblings ...)
2025-04-04 20:51 ` [CI 03/13] drm/xe: Add xe_ggtt_alloc Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 05/13] drm/xe/ggtt: Seperate flags and address in PTE encoding Maarten Lankhorst
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Obtain the id from the root tile. Likely this can be hardcoded to 0,
but use the clean solution of obtaining root id and doing that.
to_xe_device(ggtt->tile) can also be easily replaced with xe.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index d918ae1c80618..d509def82b134 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -199,14 +199,15 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
struct drm_gem_object *obj = intel_fb_bo(&fb->base);
struct xe_bo *bo = gem_to_xe_bo(obj);
struct xe_device *xe = to_xe_device(fb->base.dev);
- struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
+ struct xe_tile *tile0 = xe_device_get_root_tile(xe);
+ struct xe_ggtt *ggtt = tile0->mem.ggtt;
u32 align;
int ret;
/* TODO: Consider sharing framebuffer mapping?
* embed i915_vma inside intel_framebuffer
*/
- xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
+ xe_pm_runtime_get_noresume(xe);
ret = mutex_lock_interruptible(&ggtt->lock);
if (ret)
goto out;
@@ -215,8 +216,8 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
align = max_t(u32, align, SZ_64K);
- if (bo->ggtt_node[ggtt->tile->id] && view->type == I915_GTT_VIEW_NORMAL) {
- vma->node = bo->ggtt_node[ggtt->tile->id];
+ if (bo->ggtt_node[tile0->id] && view->type == I915_GTT_VIEW_NORMAL) {
+ vma->node = bo->ggtt_node[tile0->id];
} else if (view->type == I915_GTT_VIEW_NORMAL) {
u32 x, size = bo->ttm.base.size;
@@ -271,7 +272,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
out_unlock:
mutex_unlock(&ggtt->lock);
out:
- xe_pm_runtime_put(tile_to_xe(ggtt->tile));
+ xe_pm_runtime_put(xe);
return ret;
}
@@ -348,7 +349,7 @@ static struct i915_vma *__xe_pin_fb_vma(const struct intel_framebuffer *fb,
static void __xe_unpin_fb_vma(struct i915_vma *vma)
{
- u8 tile_id = vma->node->ggtt->tile->id;
+ u8 tile_id = xe_device_get_root_tile(xe_bo_device(vma->bo))->id;
if (!refcount_dec_and_test(&vma->ref))
return;
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 05/13] drm/xe/ggtt: Seperate flags and address in PTE encoding
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (3 preceding siblings ...)
2025-04-04 20:51 ` [CI 04/13] drm/xe/display: Remove dereferences of ggtt for tile id Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 06/13] drm/xe/display: Dont poke into GGTT internals to fill a DPT Maarten Lankhorst
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Pinning large linear display framebuffers is becoming a bottleneck.
My plan of attack is doing a custom walk over the BO, this allows for
easier optimization of consecutive entries.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/xe_ggtt.c | 92 +++++++++++++++++++++---------
drivers/gpu/drm/xe/xe_ggtt.h | 2 +
drivers/gpu/drm/xe/xe_ggtt_types.h | 5 +-
3 files changed, 72 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index b197b835ed442..8e1976bceb44f 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -27,6 +27,7 @@
#include "xe_map.h"
#include "xe_mmio.h"
#include "xe_pm.h"
+#include "xe_res_cursor.h"
#include "xe_sriov.h"
#include "xe_wa.h"
#include "xe_wopcm.h"
@@ -64,13 +65,9 @@
* give us the correct placement for free.
*/
-static u64 xelp_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
- u16 pat_index)
+static u64 xelp_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
- u64 pte;
-
- pte = xe_bo_addr(bo, bo_offset, XE_PAGE_SIZE);
- pte |= XE_PAGE_PRESENT;
+ u64 pte = XE_PAGE_PRESENT;
if (xe_bo_is_vram(bo) || xe_bo_is_stolen_devmem(bo))
pte |= XE_GGTT_PTE_DM;
@@ -78,13 +75,17 @@ static u64 xelp_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
return pte;
}
-static u64 xelpg_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
- u16 pat_index)
+static u64 xelp_ggtt_encode_bo(struct xe_bo *bo, u64 bo_offset, u16 pat_index)
+{
+ return xelp_ggtt_pte_flags(bo, pat_index) | xe_bo_addr(bo, bo_offset, XE_PAGE_SIZE);
+}
+
+static u64 xelpg_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
struct xe_device *xe = xe_bo_device(bo);
u64 pte;
- pte = xelp_ggtt_pte_encode_bo(bo, bo_offset, pat_index);
+ pte = xelp_ggtt_pte_flags(bo, pat_index);
xe_assert(xe, pat_index <= 3);
@@ -97,6 +98,12 @@ static u64 xelpg_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
return pte;
}
+static u64 xelpg_ggtt_encode_bo(struct xe_bo *bo, u64 bo_offset,
+ u16 pat_index)
+{
+ return xelpg_ggtt_pte_flags(bo, pat_index) | xe_bo_addr(bo, bo_offset, XE_PAGE_SIZE);
+}
+
static unsigned int probe_gsm_size(struct pci_dev *pdev)
{
u16 gmch_ctl, ggms;
@@ -149,8 +156,9 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
xe_tile_assert(ggtt->tile, start < end);
if (ggtt->scratch)
- scratch_pte = ggtt->pt_ops->pte_encode_bo(ggtt->scratch, 0,
- pat_index);
+ scratch_pte = xe_bo_addr(ggtt->scratch, 0, XE_PAGE_SIZE) |
+ ggtt->pt_ops->pte_encode_flags(ggtt->scratch,
+ pat_index);
else
scratch_pte = 0;
@@ -210,17 +218,20 @@ static void primelockdep(struct xe_ggtt *ggtt)
}
static const struct xe_ggtt_pt_ops xelp_pt_ops = {
- .pte_encode_bo = xelp_ggtt_pte_encode_bo,
+ .pte_encode_bo = xelp_ggtt_encode_bo,
+ .pte_encode_flags = xelp_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte,
};
static const struct xe_ggtt_pt_ops xelpg_pt_ops = {
- .pte_encode_bo = xelpg_ggtt_pte_encode_bo,
+ .pte_encode_bo = xelpg_ggtt_encode_bo,
+ .pte_encode_flags = xelpg_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte,
};
static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
- .pte_encode_bo = xelpg_ggtt_pte_encode_bo,
+ .pte_encode_bo = xelpg_ggtt_encode_bo,
+ .pte_encode_flags = xelpg_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte_and_flush,
};
@@ -612,23 +623,46 @@ bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
/**
* xe_ggtt_map_bo - Map the BO into GGTT
* @ggtt: the &xe_ggtt where node will be mapped
+ * @node: the &xe_ggtt_node where this BO is mapped
* @bo: the &xe_bo to be mapped
+ * @pat_index: Which pat_index to use.
*/
-static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
+void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ struct xe_bo *bo, u16 pat_index)
{
- u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
- u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
- u64 start;
- u64 offset, pte;
- if (XE_WARN_ON(!bo->ggtt_node[ggtt->tile->id]))
+ u64 start, pte;
+ struct xe_res_cursor cur;
+
+ if (XE_WARN_ON(!node))
return;
- start = bo->ggtt_node[ggtt->tile->id]->base.start;
+ start = node->base.start;
- for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
- pte = ggtt->pt_ops->pte_encode_bo(bo, offset, pat_index);
- ggtt->pt_ops->ggtt_set_pte(ggtt, start + offset, pte);
+ pte = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
+ if (!xe_bo_is_vram(bo) && !xe_bo_is_stolen(bo)) {
+ xe_assert(xe_bo_device(bo), bo->ttm.ttm);
+
+ for (xe_res_first_sg(xe_bo_sg(bo), 0, bo->size, &cur);
+ cur.remaining;
+ xe_res_next(&cur, XE_PAGE_SIZE)) {
+ u64 addr = xe_res_dma(&cur);
+
+ ggtt->pt_ops->ggtt_set_pte(ggtt, start + cur.start, addr | pte);
+ }
+ } else {
+ u64 end = start + bo->size;
+
+ /* Prepend GPU offset */
+ pte |= vram_region_gpu_offset(bo->ttm.resource);
+
+ for (xe_res_first(bo->ttm.resource, 0, bo->size, &cur);
+ cur.remaining;
+ xe_res_next(&cur, XE_PAGE_SIZE)) {
+
+ ggtt->pt_ops->ggtt_set_pte(ggtt, end - cur.remaining,
+ pte + cur.start);
+ }
}
}
@@ -641,8 +675,11 @@ static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
*/
void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
+ u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
+ u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
+
mutex_lock(&ggtt->lock);
- xe_ggtt_map_bo(ggtt, bo);
+ xe_ggtt_map_bo(ggtt, bo->ggtt_node[ggtt->tile->id], bo, pat_index);
mutex_unlock(&ggtt->lock);
}
@@ -682,7 +719,10 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
xe_ggtt_node_fini(bo->ggtt_node[tile_id]);
bo->ggtt_node[tile_id] = NULL;
} else {
- xe_ggtt_map_bo(ggtt, bo);
+ u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
+ u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
+
+ xe_ggtt_map_bo(ggtt, bo->ggtt_node[tile_id], bo, pat_index);
}
mutex_unlock(&ggtt->lock);
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 0bab1fd7cc817..c48da99908848 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -26,6 +26,8 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags);
void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate);
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
+void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ struct xe_bo *bo, u16 pat_index);
void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index cb02b7994a9ac..06b1a602dd8d1 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -74,8 +74,11 @@ struct xe_ggtt_node {
* Which can vary from platform to platform.
*/
struct xe_ggtt_pt_ops {
- /** @pte_encode_bo: Encode PTE address for a given BO */
+ /** @pte_encode_bo: Encode PTE flags for a given BO */
u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index);
+
+ /** @pte_encode_flags: Encode PTE flags for a given BO */
+ u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
/** @ggtt_set_pte: Directly write into GGTT's PTE */
void (*ggtt_set_pte)(struct xe_ggtt *ggtt, u64 addr, u64 pte);
};
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 06/13] drm/xe/display: Dont poke into GGTT internals to fill a DPT
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (4 preceding siblings ...)
2025-04-04 20:51 ` [CI 05/13] drm/xe/ggtt: Seperate flags and address in PTE encoding Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 07/13] drm/xe/display: Convert GGTT mapping to use pte_encode_flags Maarten Lankhorst
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
For DPT, it is sufficient to get the GGTT encode flags to fill the DPT.
Create a function to return the encode flags, and then encode using the
BO address.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 20 +++++++++-----------
drivers/gpu/drm/xe/xe_ggtt.c | 15 +++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 2 ++
3 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index d509def82b134..5392e46a3a134 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -23,6 +23,7 @@ write_dpt_rotated(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs, u32 bo_
struct xe_device *xe = xe_bo_device(bo);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
u32 column, row;
+ u64 pte = xe_ggtt_encode_pte_flags(ggtt, bo, xe->pat.idx[XE_CACHE_NONE]);
/* TODO: Maybe rewrite so we can traverse the bo addresses sequentially,
* by writing dpt/ggtt in a different order?
@@ -32,10 +33,9 @@ write_dpt_rotated(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs, u32 bo_
u32 src_idx = src_stride * (height - 1) + column + bo_ofs;
for (row = 0; row < height; row++) {
- u64 pte = ggtt->pt_ops->pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]);
+ u64 addr = xe_bo_addr(bo, src_idx * XE_PAGE_SIZE, XE_PAGE_SIZE);
- iosys_map_wr(map, *dpt_ofs, u64, pte);
+ iosys_map_wr(map, *dpt_ofs, u64, pte | addr);
*dpt_ofs += 8;
src_idx -= src_stride;
}
@@ -55,17 +55,15 @@ write_dpt_remapped(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
{
struct xe_device *xe = xe_bo_device(bo);
struct xe_ggtt *ggtt = xe_device_get_root_tile(xe)->mem.ggtt;
- u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index)
- = ggtt->pt_ops->pte_encode_bo;
u32 column, row;
+ u64 pte = xe_ggtt_encode_pte_flags(ggtt, bo, xe->pat.idx[XE_CACHE_NONE]);
for (row = 0; row < height; row++) {
u32 src_idx = src_stride * row + bo_ofs;
for (column = 0; column < width; column++) {
- iosys_map_wr(map, *dpt_ofs, u64,
- pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]));
+ u64 addr = xe_bo_addr(bo, src_idx * XE_PAGE_SIZE, XE_PAGE_SIZE);
+ iosys_map_wr(map, *dpt_ofs, u64, pte | addr);
*dpt_ofs += 8;
src_idx++;
@@ -129,13 +127,13 @@ static int __xe_pin_fb_vma_dpt(const struct intel_framebuffer *fb,
return PTR_ERR(dpt);
if (view->type == I915_GTT_VIEW_NORMAL) {
+ u64 pte = xe_ggtt_encode_pte_flags(ggtt, bo, xe->pat.idx[XE_CACHE_NONE]);
u32 x;
for (x = 0; x < size / XE_PAGE_SIZE; x++) {
- u64 pte = ggtt->pt_ops->pte_encode_bo(bo, x * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]);
+ u64 addr = xe_bo_addr(bo, x * XE_PAGE_SIZE, XE_PAGE_SIZE);
- iosys_map_wr(&dpt->vmap, x * 8, u64, pte);
+ iosys_map_wr(&dpt->vmap, x * 8, u64, pte | addr);
}
} else if (view->type == I915_GTT_VIEW_REMAPPED) {
const struct intel_remapped_info *remap_info = &view->remapped;
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 8e1976bceb44f..5ea2f9fac85d4 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -918,3 +918,18 @@ u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer
return total;
}
+
+/**
+ * xe_ggtt_encode_pte_flags - Get PTE encoding flags for BO
+ * @ggtt: &xe_ggtt
+ * @bo: &xe_bo
+ * @pat_index: The pat_index for the PTE.
+ *
+ * This function returns the pte_flags for a given BO, without address.
+ * It's used for DPT to fill a GGTT mapped BO with a linear lookup table.
+ */
+u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt,
+ struct xe_bo *bo, u16 pat_index)
+{
+ return ggtt->pt_ops->pte_encode_flags(bo, pat_index);
+}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index c48da99908848..437ba65f33860 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -49,4 +49,6 @@ static inline void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
#endif
+u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
+
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 07/13] drm/xe/display: Convert GGTT mapping to use pte_encode_flags
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (5 preceding siblings ...)
2025-04-04 20:51 ` [CI 06/13] drm/xe/display: Dont poke into GGTT internals to fill a DPT Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 08/13] drm/xe: Remove pte_encode_bo callback Maarten Lankhorst
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Another small step in removing pte_encode_bo callback.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 5392e46a3a134..9059b56bc23c8 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -171,15 +171,15 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo
{
struct xe_device *xe = xe_bo_device(bo);
u32 column, row;
+ u64 pte = ggtt->pt_ops->pte_encode_flags(bo, xe->pat.idx[XE_CACHE_NONE]);
for (column = 0; column < width; column++) {
u32 src_idx = src_stride * (height - 1) + column + bo_ofs;
for (row = 0; row < height; row++) {
- u64 pte = ggtt->pt_ops->pte_encode_bo(bo, src_idx * XE_PAGE_SIZE,
- xe->pat.idx[XE_CACHE_NONE]);
+ u64 addr = xe_bo_addr(bo, src_idx * XE_PAGE_SIZE, XE_PAGE_SIZE);
- ggtt->pt_ops->ggtt_set_pte(ggtt, *ggtt_ofs, pte);
+ ggtt->pt_ops->ggtt_set_pte(ggtt, *ggtt_ofs, pte | addr);
*ggtt_ofs += XE_PAGE_SIZE;
src_idx -= src_stride;
}
@@ -217,26 +217,19 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
if (bo->ggtt_node[tile0->id] && view->type == I915_GTT_VIEW_NORMAL) {
vma->node = bo->ggtt_node[tile0->id];
} else if (view->type == I915_GTT_VIEW_NORMAL) {
- u32 x, size = bo->ttm.base.size;
-
vma->node = xe_ggtt_node_init(ggtt);
if (IS_ERR(vma->node)) {
ret = PTR_ERR(vma->node);
goto out_unlock;
}
- ret = xe_ggtt_node_insert_locked(vma->node, size, align, 0);
+ ret = xe_ggtt_node_insert_locked(vma->node, bo->size, align, 0);
if (ret) {
xe_ggtt_node_fini(vma->node);
goto out_unlock;
}
- for (x = 0; x < size; x += XE_PAGE_SIZE) {
- u64 pte = ggtt->pt_ops->pte_encode_bo(bo, x,
- xe->pat.idx[XE_CACHE_NONE]);
-
- ggtt->pt_ops->ggtt_set_pte(ggtt, vma->node->base.start + x, pte);
- }
+ xe_ggtt_map_bo(ggtt, vma->node, bo, xe->pat.idx[XE_CACHE_NONE]);
} else {
u32 i, ggtt_ofs;
const struct intel_rotation_info *rot_info = &view->rotated;
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 08/13] drm/xe: Remove pte_encode_bo callback
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (6 preceding siblings ...)
2025-04-04 20:51 ` [CI 07/13] drm/xe/display: Convert GGTT mapping to use pte_encode_flags Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 09/13] drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset Maarten Lankhorst
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
The users inside display have been converted to use thepte_encode_flags
callback, we can now remove the pte_encode_bo cb.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/xe_ggtt.c | 14 --------------
drivers/gpu/drm/xe/xe_ggtt_types.h | 3 ---
2 files changed, 17 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 5ea2f9fac85d4..36d3a0d6aa24a 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -75,11 +75,6 @@ static u64 xelp_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
return pte;
}
-static u64 xelp_ggtt_encode_bo(struct xe_bo *bo, u64 bo_offset, u16 pat_index)
-{
- return xelp_ggtt_pte_flags(bo, pat_index) | xe_bo_addr(bo, bo_offset, XE_PAGE_SIZE);
-}
-
static u64 xelpg_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
struct xe_device *xe = xe_bo_device(bo);
@@ -98,12 +93,6 @@ static u64 xelpg_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
return pte;
}
-static u64 xelpg_ggtt_encode_bo(struct xe_bo *bo, u64 bo_offset,
- u16 pat_index)
-{
- return xelpg_ggtt_pte_flags(bo, pat_index) | xe_bo_addr(bo, bo_offset, XE_PAGE_SIZE);
-}
-
static unsigned int probe_gsm_size(struct pci_dev *pdev)
{
u16 gmch_ctl, ggms;
@@ -218,19 +207,16 @@ static void primelockdep(struct xe_ggtt *ggtt)
}
static const struct xe_ggtt_pt_ops xelp_pt_ops = {
- .pte_encode_bo = xelp_ggtt_encode_bo,
.pte_encode_flags = xelp_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte,
};
static const struct xe_ggtt_pt_ops xelpg_pt_ops = {
- .pte_encode_bo = xelpg_ggtt_encode_bo,
.pte_encode_flags = xelpg_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte,
};
static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
- .pte_encode_bo = xelpg_ggtt_encode_bo,
.pte_encode_flags = xelpg_ggtt_pte_flags,
.ggtt_set_pte = xe_ggtt_set_pte_and_flush,
};
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index 06b1a602dd8d1..c5e999d58ff2a 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -74,9 +74,6 @@ struct xe_ggtt_node {
* Which can vary from platform to platform.
*/
struct xe_ggtt_pt_ops {
- /** @pte_encode_bo: Encode PTE flags for a given BO */
- u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index);
-
/** @pte_encode_flags: Encode PTE flags for a given BO */
u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
/** @ggtt_set_pte: Directly write into GGTT's PTE */
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 09/13] drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (7 preceding siblings ...)
2025-04-04 20:51 ` [CI 08/13] drm/xe: Remove pte_encode_bo callback Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 10/13] drm/xe: Add GGTT updates to migration engine Maarten Lankhorst
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Split the GGTT PTE readout to a separate function, this is useful for
adding testcases in the next commit, and also cleaner than manually
reading out GGTT.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/display/xe_plane_initial.c | 6 +-----
drivers/gpu/drm/xe/xe_ggtt.c | 12 ++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_plane_initial.c b/drivers/gpu/drm/xe/display/xe_plane_initial.c
index 4ca0cb5711941..67f712472ca26 100644
--- a/drivers/gpu/drm/xe/display/xe_plane_initial.c
+++ b/drivers/gpu/drm/xe/display/xe_plane_initial.c
@@ -87,12 +87,8 @@ initial_plane_bo(struct xe_device *xe,
base = round_down(plane_config->base, page_size);
if (IS_DGFX(xe)) {
- u64 __iomem *gte = tile0->mem.ggtt->gsm;
- u64 pte;
+ u64 pte = xe_ggtt_read_pte(tile0->mem.ggtt, base);
- gte += base / XE_PAGE_SIZE;
-
- pte = ioread64(gte);
if (!(pte & XE_GGTT_PTE_DM)) {
drm_err(&xe->drm,
"Initial plane programming missing DM bit\n");
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 36d3a0d6aa24a..54d54ee25e9c3 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -919,3 +919,15 @@ u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt,
{
return ggtt->pt_ops->pte_encode_flags(bo, pat_index);
}
+
+/**
+ * xe_ggtt_read_pte - Read a PTE from the GGTT
+ * @ggtt: &xe_ggtt
+ * @offset: the offset for which the mapping should be read.
+ *
+ * Used by testcases, and by display reading out an inherited bios FB.
+ */
+u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)
+{
+ return ioread64(ggtt->gsm + (offset / XE_PAGE_SIZE));
+}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 437ba65f33860..600a76526cf34 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -50,5 +50,6 @@ void xe_ggtt_might_lock(struct xe_ggtt *ggtt);
#endif
u64 xe_ggtt_encode_pte_flags(struct xe_ggtt *ggtt, struct xe_bo *bo, u16 pat_index);
+u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset);
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 10/13] drm/xe: Add GGTT updates to migration engine
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (8 preceding siblings ...)
2025-04-04 20:51 ` [CI 09/13] drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 11/13] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Allow for pipelining of GGTT updates, as pinning huge buffers to GGTT
might end up being really slow.
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
.../gpu/drm/xe/instructions/xe_mi_commands.h | 2 +
drivers/gpu/drm/xe/tests/xe_migrate.c | 74 ++++++++++++++++
drivers/gpu/drm/xe/xe_migrate.c | 87 +++++++++++++++++++
drivers/gpu/drm/xe/xe_migrate.h | 12 +++
4 files changed, 175 insertions(+)
diff --git a/drivers/gpu/drm/xe/instructions/xe_mi_commands.h b/drivers/gpu/drm/xe/instructions/xe_mi_commands.h
index eba582058d550..11477ef8fd241 100644
--- a/drivers/gpu/drm/xe/instructions/xe_mi_commands.h
+++ b/drivers/gpu/drm/xe/instructions/xe_mi_commands.h
@@ -48,6 +48,8 @@
#define MI_LRI_FORCE_POSTED REG_BIT(12)
#define MI_LRI_LEN(x) (((x) & 0xff) + 1)
+#define MI_UPDATE_GTT __MI_INSTR(0x23)
+
#define MI_FLUSH_DW __MI_INSTR(0x26)
#define MI_FLUSH_DW_PROTECTED_MEM_EN REG_BIT(22)
#define MI_FLUSH_DW_STORE_INDEX REG_BIT(21)
diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
index d5fe0ea889ad8..d6770ed4126c1 100644
--- a/drivers/gpu/drm/xe/tests/xe_migrate.c
+++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
@@ -365,6 +365,79 @@ static void xe_migrate_sanity_kunit(struct kunit *test)
migrate_test_run_device(xe);
}
+static void update_gtt(void *arg, u32 ggtt_offset, u32 local_offset, u64 *pte, u32 num_pte)
+{
+ while (num_pte--) {
+ *pte++ = 0x1234567890000abcULL | local_offset;
+
+ local_offset += XE_PAGE_SIZE;
+ }
+}
+
+static void xe_migrate_test_ggtt(struct kunit *test,
+ struct xe_migrate *m,
+ struct xe_ggtt *ggtt)
+{
+ struct xe_ggtt_node *node = xe_ggtt_node_init(ggtt);
+ struct dma_fence *fence;
+ u32 i;
+ int ret;
+
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, node);
+ if (IS_ERR(node))
+ return;
+
+ ret = xe_ggtt_node_insert(node, SZ_32M, XE_PAGE_SIZE);
+ KUNIT_ASSERT_EQ(test, ret, 0);
+ if (ret)
+ goto out;
+
+ fence = xe_migrate_update_gtt(m, update_gtt, NULL, node->base.start, node->base.size / XE_PAGE_SIZE);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fence);
+ if (IS_ERR(fence))
+ goto out;
+
+ dma_fence_wait(fence, false);
+
+ for (i = 0; i < node->base.size; i += SZ_1M) {
+ u64 pte = xe_ggtt_read_pte(ggtt, node->base.start + i);
+ u64 expected = 0x1234567890000abc | i;
+
+ check(pte, expected, "GGTT update doesn't match expected update", test);
+
+ }
+ dma_fence_put(fence);
+
+out:
+ xe_ggtt_node_remove(node, false);
+}
+
+static void xe_migrate_test_ggtt_device(struct kunit *test, struct xe_device *xe)
+{
+ struct xe_tile *tile;
+ int id;
+
+ xe_pm_runtime_get(xe);
+
+ for_each_tile(tile, xe, id) {
+ struct xe_migrate *m = tile->migrate;
+
+ kunit_info(test, "Testing tile id %d.\n", id);
+ xe_vm_lock(m->q->vm, false);
+ xe_migrate_test_ggtt(test, m, tile->mem.ggtt);
+ xe_vm_unlock(m->q->vm);
+ }
+
+ xe_pm_runtime_put(xe);
+}
+
+static void xe_migrate_ggtt_kunit(struct kunit *test)
+{
+ struct xe_device *xe = test->priv;
+
+ xe_migrate_test_ggtt_device(test, xe);
+}
+
static struct dma_fence *blt_copy(struct xe_tile *tile,
struct xe_bo *src_bo, struct xe_bo *dst_bo,
bool copy_only_ccs, const char *str, struct kunit *test)
@@ -773,6 +846,7 @@ static void xe_validate_ccs_kunit(struct kunit *test)
static struct kunit_case xe_migrate_tests[] = {
KUNIT_CASE_PARAM(xe_migrate_sanity_kunit, xe_pci_live_device_gen_param),
+ KUNIT_CASE_PARAM(xe_migrate_ggtt_kunit, xe_pci_live_device_gen_param),
KUNIT_CASE_PARAM(xe_validate_ccs_kunit, xe_pci_live_device_gen_param),
{}
};
diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index c1277d599a11d..cf35ba0487d51 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -1723,6 +1723,93 @@ struct dma_fence *xe_migrate_from_vram(struct xe_migrate *m,
#endif
+struct dma_fence *xe_migrate_update_gtt(struct xe_migrate *m,
+ xe_migrate_update_gtt_cb set_ptes_cb,
+ void *arg,
+ u32 ggtt_offset, u32 num_pte)
+{
+ struct xe_gt *gt = m->tile->primary_gt;
+ struct xe_device *xe = gt_to_xe(gt);
+ struct dma_fence *fence = NULL;
+ u32 local_offset = 0;
+ int err;
+
+ while (num_pte) {
+ struct xe_sched_job *job;
+ struct xe_bb *bb;
+ u32 batch_size, update_idx;
+ bool usm = xe->info.has_usm;
+ /*
+ * batch up to 33 MI_UPDATE_GTT commands,
+ * this is enough to map a 64MiB 3840x2160x8 buffer
+ * with the size ending up just above 32kB.
+ */
+ u32 avail_ptes = min(num_pte, 33 * 511);
+ num_pte -= avail_ptes;
+
+ /* 2 * MI_BATCH_BUFFER_END + align + #PTEs + MI_UPDATE_GTT */
+ batch_size = 4 + 2 * avail_ptes + 2 * DIV_ROUND_UP(avail_ptes, 511);
+
+ bb = xe_bb_new(gt, batch_size, usm);
+ if (IS_ERR(bb)) {
+ err = PTR_ERR(bb);
+ goto err_sync;
+ }
+
+ bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
+ bb->len++; /* align to u64 */
+ update_idx = bb->len;
+ while (avail_ptes) {
+ u32 batched_ptes = min(avail_ptes, 511);
+ bb->cs[bb->len++] = MI_UPDATE_GTT | (2 * batched_ptes);
+ bb->cs[bb->len++] = ggtt_offset + local_offset;
+
+ set_ptes_cb(arg, ggtt_offset, local_offset, (u64 *)&bb->cs[bb->len], batched_ptes);
+ bb->len += 2 * batched_ptes;
+
+ local_offset += XE_PAGE_SIZE * batched_ptes;
+ avail_ptes -= batched_ptes;
+ }
+
+ job = xe_bb_create_migration_job(m->q, bb,
+ xe_migrate_batch_base(m, usm),
+ update_idx);
+ if (IS_ERR(job)) {
+ err = PTR_ERR(job);
+ goto err;
+ }
+
+ xe_sched_job_add_migrate_flush(job, MI_FLUSH_DW_CCS);
+
+ mutex_lock(&m->job_mutex);
+ xe_sched_job_arm(job);
+ dma_fence_put(fence);
+ fence = dma_fence_get(&job->drm.s_fence->finished);
+ xe_sched_job_push(job);
+
+ dma_fence_put(m->fence);
+ m->fence = dma_fence_get(fence);
+
+ mutex_unlock(&m->job_mutex);
+
+ xe_bb_free(bb, fence);
+ continue;
+
+err:
+ xe_bb_free(bb, NULL);
+err_sync:
+ /* Sync partial copies if any. FIXME: job_mutex? */
+ if (fence) {
+ dma_fence_wait(fence, false);
+ dma_fence_put(fence);
+ }
+
+ return ERR_PTR(err);
+ }
+
+ return fence;
+}
+
#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
#include "tests/xe_migrate.c"
#endif
diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
index 6ff9a963425c1..e03f28b7a021d 100644
--- a/drivers/gpu/drm/xe/xe_migrate.h
+++ b/drivers/gpu/drm/xe/xe_migrate.h
@@ -130,4 +130,16 @@ xe_migrate_update_pgtables(struct xe_migrate *m,
void xe_migrate_wait(struct xe_migrate *m);
struct xe_exec_queue *xe_tile_migrate_exec_queue(struct xe_tile *tile);
+
+typedef void (*xe_migrate_update_gtt_cb)(void *arg,
+ u32 ggtt_offset,
+ u32 local_offset,
+ u64 *pte,
+ u32 num_pte);
+
+struct dma_fence *xe_migrate_update_gtt(struct xe_migrate *m,
+ xe_migrate_update_gtt_cb set_ptes_cb,
+ void *arg,
+ u32 ggtt_offset, u32 num_pte);
+
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 11/13] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (9 preceding siblings ...)
2025-04-04 20:51 ` [CI 10/13] drm/xe: Add GGTT updates to migration engine Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 12/13] drm/xe: Allow for optimization of xe_ggtt_map_bo Maarten Lankhorst
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst, Matthew Brost
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
The rotation details belong in xe_fb_pin.c, while the operations involving
GGTT belong to xe_ggtt.c. As directly locking xe_ggtt etc results in
exposing all of xe_ggtt details anyway, create a special function that
allocates a ggtt_node, and allow display to populate it using a callback
as a compromise.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 107 +++++++++++--------------
drivers/gpu/drm/xe/xe_ggtt.c | 83 ++++++++++++++-----
drivers/gpu/drm/xe/xe_ggtt.h | 9 ++-
drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +-
4 files changed, 123 insertions(+), 84 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 9059b56bc23c8..5220e433d8a6e 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -166,12 +166,13 @@ static int __xe_pin_fb_vma_dpt(const struct intel_framebuffer *fb,
}
static void
-write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo_ofs,
+write_ggtt_rotated(struct xe_ggtt *ggtt, u32 *ggtt_ofs,
+ u64 pte_flags,
+ xe_ggtt_set_pte_fn write_pte,
+ struct xe_bo *bo, u32 bo_ofs,
u32 width, u32 height, u32 src_stride, u32 dst_stride)
{
- struct xe_device *xe = xe_bo_device(bo);
u32 column, row;
- u64 pte = ggtt->pt_ops->pte_encode_flags(bo, xe->pat.idx[XE_CACHE_NONE]);
for (column = 0; column < width; column++) {
u32 src_idx = src_stride * (height - 1) + column + bo_ofs;
@@ -179,7 +180,7 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo
for (row = 0; row < height; row++) {
u64 addr = xe_bo_addr(bo, src_idx * XE_PAGE_SIZE, XE_PAGE_SIZE);
- ggtt->pt_ops->ggtt_set_pte(ggtt, *ggtt_ofs, pte | addr);
+ write_pte(ggtt, *ggtt_ofs, pte_flags | addr);
*ggtt_ofs += XE_PAGE_SIZE;
src_idx -= src_stride;
}
@@ -189,6 +190,28 @@ write_ggtt_rotated(struct xe_bo *bo, struct xe_ggtt *ggtt, u32 *ggtt_ofs, u32 bo
}
}
+struct fb_rotate_args {
+ const struct i915_gtt_view *view;
+ struct xe_bo *bo;
+};
+
+static void write_ggtt_rotated_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ u64 pte_flags, xe_ggtt_set_pte_fn write_pte, void *data)
+{
+ struct fb_rotate_args *args = data;
+ struct xe_bo *bo = args->bo;
+ const struct intel_rotation_info *rot_info = &args->view->rotated;
+ u32 ggtt_ofs = node->base.start;
+
+ for (u32 i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
+ write_ggtt_rotated(ggtt, &ggtt_ofs, pte_flags, write_pte,
+ bo, rot_info->plane[i].offset,
+ rot_info->plane[i].width,
+ rot_info->plane[i].height,
+ rot_info->plane[i].src_stride,
+ rot_info->plane[i].dst_stride);
+}
+
static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
const struct i915_gtt_view *view,
struct i915_vma *vma,
@@ -199,70 +222,38 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
struct xe_device *xe = to_xe_device(fb->base.dev);
struct xe_tile *tile0 = xe_device_get_root_tile(xe);
struct xe_ggtt *ggtt = tile0->mem.ggtt;
- u32 align;
- int ret;
-
- /* TODO: Consider sharing framebuffer mapping?
- * embed i915_vma inside intel_framebuffer
- */
- xe_pm_runtime_get_noresume(xe);
- ret = mutex_lock_interruptible(&ggtt->lock);
- if (ret)
- goto out;
+ u32 align, size;
+ int ret = 0;
align = XE_PAGE_SIZE;
- if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
+ if (xe_bo_is_vram(bo) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K)
align = max_t(u32, align, SZ_64K);
+ /* Fast case, preallocated GGTT view? */
if (bo->ggtt_node[tile0->id] && view->type == I915_GTT_VIEW_NORMAL) {
vma->node = bo->ggtt_node[tile0->id];
- } else if (view->type == I915_GTT_VIEW_NORMAL) {
- vma->node = xe_ggtt_node_init(ggtt);
- if (IS_ERR(vma->node)) {
- ret = PTR_ERR(vma->node);
- goto out_unlock;
- }
-
- ret = xe_ggtt_node_insert_locked(vma->node, bo->size, align, 0);
- if (ret) {
- xe_ggtt_node_fini(vma->node);
- goto out_unlock;
- }
-
- xe_ggtt_map_bo(ggtt, vma->node, bo, xe->pat.idx[XE_CACHE_NONE]);
- } else {
- u32 i, ggtt_ofs;
- const struct intel_rotation_info *rot_info = &view->rotated;
-
- /* display seems to use tiles instead of bytes here, so convert it back.. */
- u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
-
- vma->node = xe_ggtt_node_init(ggtt);
- if (IS_ERR(vma->node)) {
- ret = PTR_ERR(vma->node);
- goto out_unlock;
- }
+ return 0;
+ }
- ret = xe_ggtt_node_insert_locked(vma->node, size, align, 0);
- if (ret) {
- xe_ggtt_node_fini(vma->node);
- goto out_unlock;
- }
+ /* TODO: Consider sharing framebuffer mapping?
+ * embed i915_vma inside intel_framebuffer
+ */
+ xe_pm_runtime_get_noresume(xe);
- ggtt_ofs = vma->node->base.start;
+ if (view->type == I915_GTT_VIEW_NORMAL)
+ size = bo->size;
+ else
+ /* display uses tiles instead of bytes here, so convert it back.. */
+ size = intel_rotation_info_size(&view->rotated) * XE_PAGE_SIZE;
- for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
- write_ggtt_rotated(bo, ggtt, &ggtt_ofs,
- rot_info->plane[i].offset,
- rot_info->plane[i].width,
- rot_info->plane[i].height,
- rot_info->plane[i].src_stride,
- rot_info->plane[i].dst_stride);
- }
+ vma->node = xe_ggtt_node_insert_transform(ggtt, bo, xe->pat.idx[XE_CACHE_NONE],
+ ALIGN(size, align), align,
+ view->type == I915_GTT_VIEW_NORMAL ?
+ NULL : write_ggtt_rotated_node,
+ &(struct fb_rotate_args){view, bo});
+ if (IS_ERR(vma->node))
+ ret = PTR_ERR(vma->node);
-out_unlock:
- mutex_unlock(&ggtt->lock);
-out:
xe_pm_runtime_put(xe);
return ret;
}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 54d54ee25e9c3..2d4fe207ff62b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -509,19 +509,7 @@ void xe_ggtt_node_remove_balloon(struct xe_ggtt_node *node)
xe_ggtt_node_fini(node);
}
-/**
- * xe_ggtt_node_insert_locked - Locked version to insert a &xe_ggtt_node into the GGTT
- * @node: the &xe_ggtt_node to be inserted
- * @size: size of the node
- * @align: alignment constrain of the node
- * @mm_flags: flags to control the node behavior
- *
- * It cannot be called without first having called xe_ggtt_init() once.
- * To be used in cases where ggtt->lock is already taken.
- *
- * Return: 0 on success or a negative error code on failure.
- */
-int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
+static int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags)
{
return drm_mm_insert_node_generic(&node->ggtt->mm, &node->base, size, align, 0,
@@ -561,8 +549,8 @@ int xe_ggtt_node_insert(struct xe_ggtt_node *node, u32 size, u32 align)
* This struct will then be freed after the node removal upon xe_ggtt_node_remove()
* or xe_ggtt_node_remove_balloon().
* Having %xe_ggtt_node struct allocated doesn't mean that the node is already allocated
- * in GGTT. Only the xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
- * xe_ggtt_node_insert_balloon() will ensure the node is inserted or reserved in GGTT.
+ * in GGTT. Only the xe_ggtt_node_insert(), xe_ggtt_node_insert_balloon() will
+ * ensure the node is inserted or reserved in GGTT.
*
* Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise.
**/
@@ -583,9 +571,9 @@ struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt)
* xe_ggtt_node_fini - Forcebly finalize %xe_ggtt_node struct
* @node: the &xe_ggtt_node to be freed
*
- * If anything went wrong with either xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
- * or xe_ggtt_node_insert_balloon(); and this @node is not going to be reused, then,
- * this function needs to be called to free the %xe_ggtt_node struct
+ * If anything went wrong with either xe_ggtt_node_insert(), or
+ * xe_ggtt_node_insert_balloon(); and this @node is not going to be reused,
+ * then this function needs to be called to free the %xe_ggtt_node struct
**/
void xe_ggtt_node_fini(struct xe_ggtt_node *node)
{
@@ -613,10 +601,9 @@ bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
* @bo: the &xe_bo to be mapped
* @pat_index: Which pat_index to use.
*/
-void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- struct xe_bo *bo, u16 pat_index)
+static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ struct xe_bo *bo, u16 pat_index)
{
-
u64 start, pte;
struct xe_res_cursor cur;
@@ -669,6 +656,60 @@ void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo)
mutex_unlock(&ggtt->lock);
}
+/**
+ * xe_ggtt_node_insert_transform - Insert a newly allocated &xe_ggtt_node into the GGTT
+ * @ggtt: the &xe_ggtt where the node will inserted/reserved.
+ * @bo: The bo to be transformed
+ * @pat_index: Which pat_index to use for the bo.
+ * @size: size of the node
+ * @align: required alignment for node
+ * @transform: transformation function that will populate the GGTT node, or NULL for linear mapping.
+ * @arg: Extra argument to pass to the transformation function.
+ *
+ * This function allows inserting a GGTT node with a custom transformation function.
+ * This is useful for display to allow inserting rotated framebuffers to GGTT.
+ *
+ * Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise.
+ */
+struct xe_ggtt_node *xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt,
+ struct xe_bo *bo,
+ u16 pat_index,
+ u32 size, u32 align, xe_ggtt_transform_cb transform, void *arg)
+{
+ struct xe_ggtt_node *node;
+ int ret;
+
+ node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(node))
+ return ERR_CAST(node);
+
+ if (mutex_lock_interruptible(&ggtt->lock) < 0) {
+ ret = -ERESTARTSYS;
+ goto err;
+ }
+
+ ret = xe_ggtt_node_insert_locked(node, size, align, 0);
+ if (ret)
+ goto err_unlock;
+
+ if (transform) {
+ u64 pte_flags = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
+ transform(ggtt, node, pte_flags, ggtt->pt_ops->ggtt_set_pte, arg);
+ } else {
+ xe_ggtt_map_bo(ggtt, node, bo, pat_index);
+ }
+
+
+ mutex_unlock(&ggtt->lock);
+ return node;
+
+err_unlock:
+ mutex_unlock(&ggtt->lock);
+err:
+ xe_ggtt_node_fini(node);
+ return ERR_PTR(ret);
+}
+
static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 600a76526cf34..c07b8add6be2d 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -22,12 +22,13 @@ int xe_ggtt_node_insert_balloon(struct xe_ggtt_node *node,
void xe_ggtt_node_remove_balloon(struct xe_ggtt_node *node);
int xe_ggtt_node_insert(struct xe_ggtt_node *node, u32 size, u32 align);
-int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
- u32 size, u32 align, u32 mm_flags);
+struct xe_ggtt_node *
+xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt,
+ struct xe_bo *bo, u16 pat_index,
+ u32 size, u32 align,
+ xe_ggtt_transform_cb transform, void *arg);
void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate);
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
-void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- struct xe_bo *bo, u16 pat_index);
void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index c5e999d58ff2a..18b5466ae8e6f 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -69,6 +69,11 @@ struct xe_ggtt_node {
bool invalidate_on_remove;
};
+typedef void (*xe_ggtt_set_pte_fn)(struct xe_ggtt *ggtt, u64 addr, u64 pte);
+typedef void (*xe_ggtt_transform_cb)(struct xe_ggtt *ggtt,
+ struct xe_ggtt_node *node,
+ u64 pte_flags,
+ xe_ggtt_set_pte_fn set_pte, void *arg);
/**
* struct xe_ggtt_pt_ops - GGTT Page table operations
* Which can vary from platform to platform.
@@ -76,8 +81,9 @@ struct xe_ggtt_node {
struct xe_ggtt_pt_ops {
/** @pte_encode_flags: Encode PTE flags for a given BO */
u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
+
/** @ggtt_set_pte: Directly write into GGTT's PTE */
- void (*ggtt_set_pte)(struct xe_ggtt *ggtt, u64 addr, u64 pte);
+ xe_ggtt_set_pte_fn ggtt_set_pte;
};
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 12/13] drm/xe: Allow for optimization of xe_ggtt_map_bo
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (10 preceding siblings ...)
2025-04-04 20:51 ` [CI 11/13] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 20:51 ` [CI 13/13] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/xe/tests/xe_migrate.c | 1 +
drivers/gpu/drm/xe/xe_ggtt.c | 74 ++++++++++++++++++---------
2 files changed, 50 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/xe/tests/xe_migrate.c b/drivers/gpu/drm/xe/tests/xe_migrate.c
index d6770ed4126c1..772b6db3784d9 100644
--- a/drivers/gpu/drm/xe/tests/xe_migrate.c
+++ b/drivers/gpu/drm/xe/tests/xe_migrate.c
@@ -9,6 +9,7 @@
#include "tests/xe_kunit_helpers.h"
#include "tests/xe_pci_test.h"
+#include "xe_ggtt.h"
#include "xe_pci.h"
#include "xe_pm.h"
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 2d4fe207ff62b..4c6a92f9f9f38 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -25,6 +25,7 @@
#include "xe_gt_sriov_vf.h"
#include "xe_gt_tlb_invalidation.h"
#include "xe_map.h"
+#include "xe_migrate.h"
#include "xe_mmio.h"
#include "xe_pm.h"
#include "xe_res_cursor.h"
@@ -594,6 +595,25 @@ bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
return drm_mm_node_allocated(&node->base);
}
+struct xe_ggtt_cb_data {
+ struct xe_res_cursor cur;
+ u64 pte_flags;
+ bool sysmem;
+};
+
+static void xe_ggtt_map_bo_cb(void *args, u32 ggtt_offset, u32 local_offset, u64 *ptes, u32 num_ptes)
+{
+ struct xe_ggtt_cb_data *data = args;
+
+ while (num_ptes--) {
+ u64 addr = data->sysmem ? xe_res_dma(&data->cur) : data->cur.start;
+
+ *ptes++ = data->pte_flags + addr;
+
+ xe_res_next(&data->cur, XE_PAGE_SIZE);
+ }
+}
+
/**
* xe_ggtt_map_bo - Map the BO into GGTT
* @ggtt: the &xe_ggtt where node will be mapped
@@ -602,39 +622,43 @@ bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
* @pat_index: Which pat_index to use.
*/
static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- struct xe_bo *bo, u16 pat_index)
+ struct xe_bo *bo, u16 pat_index, bool allow_accel)
{
- u64 start, pte;
- struct xe_res_cursor cur;
+ struct xe_ggtt_cb_data data;
+ struct dma_fence *fence = NULL;
if (XE_WARN_ON(!node))
return;
- start = node->base.start;
-
- pte = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
- if (!xe_bo_is_vram(bo) && !xe_bo_is_stolen(bo)) {
+ data.pte_flags = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
+ data.sysmem = !xe_bo_is_vram(bo) && !xe_bo_is_stolen(bo);
+ if (data.sysmem) {
xe_assert(xe_bo_device(bo), bo->ttm.ttm);
- for (xe_res_first_sg(xe_bo_sg(bo), 0, bo->size, &cur);
- cur.remaining;
- xe_res_next(&cur, XE_PAGE_SIZE)) {
- u64 addr = xe_res_dma(&cur);
-
- ggtt->pt_ops->ggtt_set_pte(ggtt, start + cur.start, addr | pte);
- }
+ xe_res_first_sg(xe_bo_sg(bo), 0, bo->size, &data.cur);
} else {
- u64 end = start + bo->size;
-
/* Prepend GPU offset */
- pte |= vram_region_gpu_offset(bo->ttm.resource);
+ data.pte_flags |= vram_region_gpu_offset(bo->ttm.resource);
+
+ xe_res_first(bo->ttm.resource, 0, bo->size, &data.cur);
+ }
+
+ if (allow_accel && node->base.size >= SZ_4K && ggtt->tile->migrate)
+ fence = xe_migrate_update_gtt(ggtt->tile->migrate, xe_ggtt_map_bo_cb, &data,
+ node->base.start,
+ node->base.size / XE_PAGE_SIZE);
+
+ if (!IS_ERR_OR_NULL(fence)) {
+ dma_fence_wait(fence, false);
+ dma_fence_put(fence);
+ } else {
+ /* Eat error, force map */
- for (xe_res_first(bo->ttm.resource, 0, bo->size, &cur);
- cur.remaining;
- xe_res_next(&cur, XE_PAGE_SIZE)) {
+ for (u32 local_offset = 0; local_offset < node->base.size; local_offset += XE_PAGE_SIZE) {
+ u64 pte;
+ xe_ggtt_map_bo_cb(&data, node->base.start, local_offset, &pte, 1);
- ggtt->pt_ops->ggtt_set_pte(ggtt, end - cur.remaining,
- pte + cur.start);
+ ggtt->pt_ops->ggtt_set_pte(ggtt, node->base.start + local_offset, pte);
}
}
}
@@ -652,7 +676,7 @@ void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo)
u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
mutex_lock(&ggtt->lock);
- xe_ggtt_map_bo(ggtt, bo->ggtt_node[ggtt->tile->id], bo, pat_index);
+ xe_ggtt_map_bo(ggtt, bo->ggtt_node[ggtt->tile->id], bo, pat_index, false);
mutex_unlock(&ggtt->lock);
}
@@ -696,7 +720,7 @@ struct xe_ggtt_node *xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt,
u64 pte_flags = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
transform(ggtt, node, pte_flags, ggtt->pt_ops->ggtt_set_pte, arg);
} else {
- xe_ggtt_map_bo(ggtt, node, bo, pat_index);
+ xe_ggtt_map_bo(ggtt, node, bo, pat_index, true);
}
@@ -749,7 +773,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
- xe_ggtt_map_bo(ggtt, bo->ggtt_node[tile_id], bo, pat_index);
+ xe_ggtt_map_bo(ggtt, bo->ggtt_node[tile_id], bo, pat_index, false);
}
mutex_unlock(&ggtt->lock);
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [CI 13/13] drm/xe: Move struct xe_ggtt to xe_ggtt.c
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (11 preceding siblings ...)
2025-04-04 20:51 ` [CI 12/13] drm/xe: Allow for optimization of xe_ggtt_map_bo Maarten Lankhorst
@ 2025-04-04 20:51 ` Maarten Lankhorst
2025-04-04 22:20 ` ✓ CI.Patch_applied: success for Offload GGTT binding to migration engine Patchwork
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: Maarten Lankhorst @ 2025-04-04 20:51 UTC (permalink / raw)
To: intel-xe; +Cc: Maarten Lankhorst, Matthew Brost
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
No users left outside of xe_ggtt.c, so we can make the struct private.
This prevents us from accidentally touching it before init.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 50 ++++++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt_types.h | 49 -----------------------------
2 files changed, 50 insertions(+), 49 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 4c6a92f9f9f38..9c46d538744de 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -66,6 +66,56 @@
* give us the correct placement for free.
*/
+/**
+ * struct xe_ggtt_pt_ops - GGTT Page table operations
+ * Which can vary from platform to platform.
+ */
+struct xe_ggtt_pt_ops {
+ /** @pte_encode_flags: Encode PTE flags for a given BO */
+ u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
+
+ /** @ggtt_set_pte: Directly write into GGTT's PTE */
+ xe_ggtt_set_pte_fn ggtt_set_pte;
+};
+
+/**
+ * struct xe_ggtt - Main GGTT struct
+ *
+ * In general, each tile can contains its own Global Graphics Translation Table
+ * (GGTT) instance.
+ */
+struct xe_ggtt {
+ /** @tile: Back pointer to tile where this GGTT belongs */
+ struct xe_tile *tile;
+ /** @size: Total size of this GGTT */
+ u64 size;
+
+#define XE_GGTT_FLAGS_64K BIT(0)
+ /**
+ * @flags: Flags for this GGTT
+ * Acceptable flags:
+ * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
+ */
+ unsigned int flags;
+ /** @scratch: Internal object allocation used as a scratch page */
+ struct xe_bo *scratch;
+ /** @lock: Mutex lock to protect GGTT data */
+ struct mutex lock;
+ /**
+ * @gsm: The iomem pointer to the actual location of the translation
+ * table located in the GSM for easy PTE manipulation
+ */
+ u64 __iomem *gsm;
+ /** @pt_ops: Page Table operations per platform */
+ const struct xe_ggtt_pt_ops *pt_ops;
+ /** @mm: The memory manager used to manage individual GGTT allocations */
+ struct drm_mm mm;
+ /** @access_count: counts GGTT writes */
+ unsigned int access_count;
+ /** @wq: Dedicated unordered work queue to process node removals */
+ struct workqueue_struct *wq;
+};
+
static u64 xelp_ggtt_pte_flags(struct xe_bo *bo, u16 pat_index)
{
u64 pte = XE_PAGE_PRESENT;
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index 18b5466ae8e6f..4f1fd3c456a3b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -13,44 +13,6 @@
struct xe_bo;
struct xe_gt;
-/**
- * struct xe_ggtt - Main GGTT struct
- *
- * In general, each tile can contains its own Global Graphics Translation Table
- * (GGTT) instance.
- */
-struct xe_ggtt {
- /** @tile: Back pointer to tile where this GGTT belongs */
- struct xe_tile *tile;
- /** @size: Total size of this GGTT */
- u64 size;
-
-#define XE_GGTT_FLAGS_64K BIT(0)
- /**
- * @flags: Flags for this GGTT
- * Acceptable flags:
- * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
- */
- unsigned int flags;
- /** @scratch: Internal object allocation used as a scratch page */
- struct xe_bo *scratch;
- /** @lock: Mutex lock to protect GGTT data */
- struct mutex lock;
- /**
- * @gsm: The iomem pointer to the actual location of the translation
- * table located in the GSM for easy PTE manipulation
- */
- u64 __iomem *gsm;
- /** @pt_ops: Page Table operations per platform */
- const struct xe_ggtt_pt_ops *pt_ops;
- /** @mm: The memory manager used to manage individual GGTT allocations */
- struct drm_mm mm;
- /** @access_count: counts GGTT writes */
- unsigned int access_count;
- /** @wq: Dedicated unordered work queue to process node removals */
- struct workqueue_struct *wq;
-};
-
/**
* struct xe_ggtt_node - A node in GGTT.
*
@@ -74,16 +36,5 @@ typedef void (*xe_ggtt_transform_cb)(struct xe_ggtt *ggtt,
struct xe_ggtt_node *node,
u64 pte_flags,
xe_ggtt_set_pte_fn set_pte, void *arg);
-/**
- * struct xe_ggtt_pt_ops - GGTT Page table operations
- * Which can vary from platform to platform.
- */
-struct xe_ggtt_pt_ops {
- /** @pte_encode_flags: Encode PTE flags for a given BO */
- u64 (*pte_encode_flags)(struct xe_bo *bo, u16 pat_index);
-
- /** @ggtt_set_pte: Directly write into GGTT's PTE */
- xe_ggtt_set_pte_fn ggtt_set_pte;
-};
#endif
--
2.45.2
^ permalink raw reply related [flat|nested] 17+ messages in thread
* ✓ CI.Patch_applied: success for Offload GGTT binding to migration engine.
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (12 preceding siblings ...)
2025-04-04 20:51 ` [CI 13/13] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
@ 2025-04-04 22:20 ` Patchwork
2025-04-04 22:20 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-04 22:21 ` ✗ CI.KUnit: failure " Patchwork
15 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2025-04-04 22:20 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: intel-xe
== Series Details ==
Series: Offload GGTT binding to migration engine.
URL : https://patchwork.freedesktop.org/series/147283/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 60b7ecc2c5c9 drm-tip: 2025y-04m-04d-21h-49m-10s UTC integration manifest
=== git am output follows ===
Applying: drm/xe: Use xe_ggtt_map_bo_unlocked for resume
Applying: drm/xe: Add xe_ggtt_might_lock
Applying: drm/xe: Add xe_ggtt_alloc
Applying: drm/xe/display: Remove dereferences of ggtt for tile id
Applying: drm/xe/ggtt: Seperate flags and address in PTE encoding
Applying: drm/xe/display: Dont poke into GGTT internals to fill a DPT
Applying: drm/xe/display: Convert GGTT mapping to use pte_encode_flags
Applying: drm/xe: Remove pte_encode_bo callback
Applying: drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset
Applying: drm/xe: Add GGTT updates to migration engine
Applying: drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT
Applying: drm/xe: Allow for optimization of xe_ggtt_map_bo
Applying: drm/xe: Move struct xe_ggtt to xe_ggtt.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* ✗ CI.checkpatch: warning for Offload GGTT binding to migration engine.
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (13 preceding siblings ...)
2025-04-04 22:20 ` ✓ CI.Patch_applied: success for Offload GGTT binding to migration engine Patchwork
@ 2025-04-04 22:20 ` Patchwork
2025-04-04 22:21 ` ✗ CI.KUnit: failure " Patchwork
15 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2025-04-04 22:20 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: intel-xe
== Series Details ==
Series: Offload GGTT binding to migration engine.
URL : https://patchwork.freedesktop.org/series/147283/
State : warning
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
99e5a866b5e13f134e606a3e29d9508d97826fb3
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit b841150be30aa44160b01b980e5e1b21973c1ce9
Author: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Date: Fri Apr 4 22:51:38 2025 +0200
drm/xe: Move struct xe_ggtt to xe_ggtt.c
No users left outside of xe_ggtt.c, so we can make the struct private.
This prevents us from accidentally touching it before init.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
+ /mt/dim checkpatch 60b7ecc2c5c979cfb8863272348bd6724559b5be drm-intel
8c24473d7425 drm/xe: Use xe_ggtt_map_bo_unlocked for resume
efb1765095a8 drm/xe: Add xe_ggtt_might_lock
6561142b2785 drm/xe: Add xe_ggtt_alloc
-:32: WARNING:LINE_SPACING: Missing a blank line after declarations
#32: FILE: drivers/gpu/drm/xe/xe_ggtt.c:174:
+ struct xe_ggtt *ggtt = drmm_kzalloc(&tile_to_xe(tile)->drm, sizeof(*ggtt), GFP_KERNEL);
+ if (ggtt)
total: 0 errors, 1 warnings, 0 checks, 45 lines checked
265b2e61533b drm/xe/display: Remove dereferences of ggtt for tile id
bd31243cc807 drm/xe/ggtt: Seperate flags and address in PTE encoding
-:4: WARNING:TYPO_SPELLING: 'Seperate' may be misspelled - perhaps 'Separate'?
#4:
Subject: [PATCH] drm/xe/ggtt: Seperate flags and address in PTE encoding
^^^^^^^^
-:160: CHECK:BRACES: Blank lines aren't necessary after an open brace '{'
#160: FILE: drivers/gpu/drm/xe/xe_ggtt.c:662:
+ xe_res_next(&cur, XE_PAGE_SIZE)) {
+
total: 0 errors, 1 warnings, 1 checks, 187 lines checked
6bbab76ab925 drm/xe/display: Dont poke into GGTT internals to fill a DPT
-:54: WARNING:LINE_SPACING: Missing a blank line after declarations
#54: FILE: drivers/gpu/drm/xe/display/xe_fb_pin.c:66:
+ u64 addr = xe_bo_addr(bo, src_idx * XE_PAGE_SIZE, XE_PAGE_SIZE);
+ iosys_map_wr(map, *dpt_ofs, u64, pte | addr);
total: 0 errors, 1 warnings, 0 checks, 79 lines checked
561200a57963 drm/xe/display: Convert GGTT mapping to use pte_encode_flags
44bc13c512cd drm/xe: Remove pte_encode_bo callback
6c4acc7dab03 drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset
b311525f8d78 drm/xe: Add GGTT updates to migration engine
-:59: WARNING:LONG_LINE: line length of 109 exceeds 100 columns
#59: FILE: drivers/gpu/drm/xe/tests/xe_migrate.c:392:
+ fence = xe_migrate_update_gtt(m, update_gtt, NULL, node->base.start, node->base.size / XE_PAGE_SIZE);
-:72: CHECK:BRACES: Blank lines aren't necessary before a close brace '}'
#72: FILE: drivers/gpu/drm/xe/tests/xe_migrate.c:405:
+
+ }
-:146: WARNING:LINE_SPACING: Missing a blank line after declarations
#146: FILE: drivers/gpu/drm/xe/xe_migrate.c:1750:
+ u32 avail_ptes = min(num_pte, 33 * 511);
+ num_pte -= avail_ptes;
-:162: WARNING:LINE_SPACING: Missing a blank line after declarations
#162: FILE: drivers/gpu/drm/xe/xe_migrate.c:1766:
+ u32 batched_ptes = min(avail_ptes, 511);
+ bb->cs[bb->len++] = MI_UPDATE_GTT | (2 * batched_ptes);
-:165: WARNING:LONG_LINE: line length of 107 exceeds 100 columns
#165: FILE: drivers/gpu/drm/xe/xe_migrate.c:1769:
+ set_ptes_cb(arg, ggtt_offset, local_offset, (u64 *)&bb->cs[bb->len], batched_ptes);
total: 0 errors, 4 warnings, 1 checks, 203 lines checked
370de65c82ec drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT
-:190: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#190: FILE: drivers/gpu/drm/xe/xe_ggtt.c:513:
+static int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags)
-:252: WARNING:LONG_LINE: line length of 114 exceeds 100 columns
#252: FILE: drivers/gpu/drm/xe/xe_ggtt.c:677:
+ u32 size, u32 align, xe_ggtt_transform_cb transform, void *arg)
-:272: WARNING:LINE_SPACING: Missing a blank line after declarations
#272: FILE: drivers/gpu/drm/xe/xe_ggtt.c:697:
+ u64 pte_flags = ggtt->pt_ops->pte_encode_flags(bo, pat_index);
+ transform(ggtt, node, pte_flags, ggtt->pt_ops->ggtt_set_pte, arg);
-:277: CHECK:LINE_SPACING: Please don't use multiple blank lines
#277: FILE: drivers/gpu/drm/xe/xe_ggtt.c:702:
+
+
total: 0 errors, 2 warnings, 2 checks, 296 lines checked
b0fdd9c59a0b drm/xe: Allow for optimization of xe_ggtt_map_bo
-:7: WARNING:COMMIT_MESSAGE: Missing commit description - Add an appropriate one
-:42: WARNING:LONG_LINE: line length of 101 exceeds 100 columns
#42: FILE: drivers/gpu/drm/xe/xe_ggtt.c:604:
+static void xe_ggtt_map_bo_cb(void *args, u32 ggtt_offset, u32 local_offset, u64 *ptes, u32 num_ptes)
-:114: WARNING:LONG_LINE: line length of 106 exceeds 100 columns
#114: FILE: drivers/gpu/drm/xe/xe_ggtt.c:657:
+ for (u32 local_offset = 0; local_offset < node->base.size; local_offset += XE_PAGE_SIZE) {
-:116: WARNING:LINE_SPACING: Missing a blank line after declarations
#116: FILE: drivers/gpu/drm/xe/xe_ggtt.c:659:
+ u64 pte;
+ xe_ggtt_map_bo_cb(&data, node->base.start, local_offset, &pte, 1);
total: 0 errors, 4 warnings, 0 checks, 128 lines checked
b841150be30a drm/xe: Move struct xe_ggtt to xe_ggtt.c
^ permalink raw reply [flat|nested] 17+ messages in thread
* ✗ CI.KUnit: failure for Offload GGTT binding to migration engine.
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
` (14 preceding siblings ...)
2025-04-04 22:20 ` ✗ CI.checkpatch: warning " Patchwork
@ 2025-04-04 22:21 ` Patchwork
15 siblings, 0 replies; 17+ messages in thread
From: Patchwork @ 2025-04-04 22:21 UTC (permalink / raw)
To: Maarten Lankhorst; +Cc: intel-xe
== Series Details ==
Series: Offload GGTT binding to migration engine.
URL : https://patchwork.freedesktop.org/series/147283/
State : failure
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:In file included from ../include/kunit/static_stub.h:18,
from ../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:6,
from ../drivers/gpu/drm/xe/xe_guc_buf.c:175:
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c: In function ‘replacement_xe_managed_bo_create_pin_map’:
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:45:66: error: invalid use of undefined type ‘struct xe_ggtt’
45 | drm_mm_insert_node_in_range(&ggtt->mm,
| ^~
../include/kunit/test.h:776:22: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
776 | const typeof(right) __right = (right); \
| ^~~~~
../include/kunit/test.h:1350:9: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’
1350 | KUNIT_BINARY_INT_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1347:9: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
1347 | KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
| ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:44:17: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
44 | KUNIT_ASSERT_EQ(test, 0,
| ^~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:45:66: error: invalid use of undefined type ‘struct xe_ggtt’
45 | drm_mm_insert_node_in_range(&ggtt->mm,
| ^~
../include/kunit/test.h:776:40: note: in definition of macro ‘KUNIT_BASE_BINARY_ASSERTION’
776 | const typeof(right) __right = (right); \
| ^~~~~
../include/kunit/test.h:1350:9: note: in expansion of macro ‘KUNIT_BINARY_INT_ASSERTION’
1350 | KUNIT_BINARY_INT_ASSERTION(test, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
../include/kunit/test.h:1347:9: note: in expansion of macro ‘KUNIT_ASSERT_EQ_MSG’
1347 | KUNIT_ASSERT_EQ_MSG(test, left, right, NULL)
| ^~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:44:17: note: in expansion of macro ‘KUNIT_ASSERT_EQ’
44 | KUNIT_ASSERT_EQ(test, 0,
| ^~~~~~~~~~~~~~~
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c: In function ‘guc_buf_test_init’:
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:70:26: error: invalid use of undefined type ‘struct xe_ggtt’
70 | drm_mm_init(&ggtt->mm, DUT_GGTT_START, DUT_GGTT_SIZE);
| ^~
In file included from ../include/linux/seqlock.h:19,
from ../include/linux/mmzone.h:17,
from ../include/linux/gfp.h:7,
from ../include/drm/drm_managed.h:6,
from ../drivers/gpu/drm/xe/xe_guc_buf.c:7:
../drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c:71:25: error: invalid use of undefined type ‘struct xe_ggtt’
71 | mutex_init(&ggtt->lock);
| ^~
../include/linux/mutex.h:64:23: note: in definition of macro ‘mutex_init’
64 | __mutex_init((mutex), #mutex, &__key); \
| ^~~~~
make[7]: *** [../scripts/Makefile.build:207: drivers/gpu/drm/xe/xe_guc_buf.o] Error 1
make[7]: *** Waiting for unfinished jobs....
make[6]: *** [../scripts/Makefile.build:465: drivers/gpu/drm/xe] Error 2
make[6]: *** Waiting for unfinished jobs....
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
make[5]: *** [../scripts/Makefile.build:465: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:465: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:465: drivers] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [/kernel/Makefile:1994: .] Error 2
make[1]: *** [/kernel/Makefile:251: __sub-make] Error 2
make: *** [Makefile:251: __sub-make] Error 2
[22:20:45] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[22:20:49] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make all compile_commands.json ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2025-04-04 22:21 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 20:51 [CI 00/13] Offload GGTT binding to migration engine Maarten Lankhorst
2025-04-04 20:51 ` [CI 01/13] drm/xe: Use xe_ggtt_map_bo_unlocked for resume Maarten Lankhorst
2025-04-04 20:51 ` [CI 02/13] drm/xe: Add xe_ggtt_might_lock Maarten Lankhorst
2025-04-04 20:51 ` [CI 03/13] drm/xe: Add xe_ggtt_alloc Maarten Lankhorst
2025-04-04 20:51 ` [CI 04/13] drm/xe/display: Remove dereferences of ggtt for tile id Maarten Lankhorst
2025-04-04 20:51 ` [CI 05/13] drm/xe/ggtt: Seperate flags and address in PTE encoding Maarten Lankhorst
2025-04-04 20:51 ` [CI 06/13] drm/xe/display: Dont poke into GGTT internals to fill a DPT Maarten Lankhorst
2025-04-04 20:51 ` [CI 07/13] drm/xe/display: Convert GGTT mapping to use pte_encode_flags Maarten Lankhorst
2025-04-04 20:51 ` [CI 08/13] drm/xe: Remove pte_encode_bo callback Maarten Lankhorst
2025-04-04 20:51 ` [CI 09/13] drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset Maarten Lankhorst
2025-04-04 20:51 ` [CI 10/13] drm/xe: Add GGTT updates to migration engine Maarten Lankhorst
2025-04-04 20:51 ` [CI 11/13] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
2025-04-04 20:51 ` [CI 12/13] drm/xe: Allow for optimization of xe_ggtt_map_bo Maarten Lankhorst
2025-04-04 20:51 ` [CI 13/13] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
2025-04-04 22:20 ` ✓ CI.Patch_applied: success for Offload GGTT binding to migration engine Patchwork
2025-04-04 22:20 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-04 22:21 ` ✗ CI.KUnit: failure " Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox