Offload GGTT binding to migration engine.
Subsystems (3)
cover Offload GGTT binding to migration engine.
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(-)
Signature · 1 line
2.45.2
PATCH 1/13 drm/xe: Use xe_ggtt_map_bo_unlocked for resume
From: Maarten Lankhorst <[email protected]>
This is the first step to hide the details of struct xe_ggtt.
--- 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(-)
drivers/gpu/drm/xe/xe_bo_evict.c +1 -3
@@ -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); } }
drivers/gpu/drm/xe/xe_ggtt.c +15 -1
@@ -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) {
drivers/gpu/drm/xe/xe_ggtt.h +1 -1
@@ -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);
Signature · 1 line
2.45.2
PATCH 2/13 drm/xe: Add xe_ggtt_might_lock
In reply to Maarten LankhorstFrom: Maarten Lankhorst <[email protected]>
Another requirement of hiding more of struct xe_ggtt.
--- 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(-)
drivers/gpu/drm/xe/xe_bo.c +1 -1
@@ -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); } }
drivers/gpu/drm/xe/xe_ggtt.c +7 -0
@@ -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 ))
drivers/gpu/drm/xe/xe_ggtt.h +7 -0
@@ -38,4 +38,11 @@ u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printervoid 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
Signature · 1 line
2.45.2
PATCH 3/13 drm/xe: Add xe_ggtt_alloc
In reply to Maarten LankhorstFrom: Maarten Lankhorst <[email protected]>
Instead of allocating inside xe_tile, create a new function that returns an allocated struct xe_ggtt from xe_ggtt.c
--- 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(-)
drivers/gpu/drm/xe/xe_ggtt.c +16 -0
@@ -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;
drivers/gpu/drm/xe/xe_ggtt.h +2 -0
@@ -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);
drivers/gpu/drm/xe/xe_tile.c +1 -5
@@ -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 ; }
Signature · 1 line
2.45.2
PATCH 4/13 drm/xe/display: Remove dereferences of ggtt for tile id
In reply to Maarten LankhorstObtain 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.
--- drivers/gpu/drm/xe/display/xe_fb_pin.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +7 -6
@@ -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 ;
Signature · 1 line
2.45.2
PATCH 5/13 drm/xe/ggtt: Seperate flags and address in PTE encoding
In reply to Maarten LankhorstPinning 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.
--- 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(-)
drivers/gpu/drm/xe/xe_ggtt.c +66 -26
@@ -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);
drivers/gpu/drm/xe/xe_ggtt.h +2 -0
@@ -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,
drivers/gpu/drm/xe/xe_ggtt_types.h +4 -1
@@ -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); };
Signature · 1 line
2.45.2
PATCH 6/13 drm/xe/display: Dont poke into GGTT internals to fill a DPT
In reply to Maarten LankhorstFor 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.
--- 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(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +9 -11
@@ -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;
drivers/gpu/drm/xe/xe_ggtt.c +15 -0
@@ -918,3 +918,18 @@ u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printerreturn 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); +}
drivers/gpu/drm/xe/xe_ggtt.h +2 -0
@@ -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
Signature · 1 line
2.45.2
PATCH 7/13 drm/xe/display: Convert GGTT mapping to use pte_encode_flags
In reply to Maarten LankhorstAnother small step in removing pte_encode_bo callback.
--- drivers/gpu/drm/xe/display/xe_fb_pin.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +5 -12
@@ -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;
Signature · 1 line
2.45.2
PATCH 8/13 drm/xe: Remove pte_encode_bo callback
In reply to Maarten LankhorstThe users inside display have been converted to use thepte_encode_flags callback, we can now remove the pte_encode_bo cb.
--- drivers/gpu/drm/xe/xe_ggtt.c | 14 -------------- drivers/gpu/drm/xe/xe_ggtt_types.h | 3 --- 2 files changed, 17 deletions(-)
drivers/gpu/drm/xe/xe_ggtt.c +0 -14
@@ -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, };
drivers/gpu/drm/xe/xe_ggtt_types.h +0 -3
@@ -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 */
Signature · 1 line
2.45.2
PATCH 9/13 drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset
In reply to Maarten LankhorstSplit 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.
--- 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(-)
drivers/gpu/drm/xe/display/xe_plane_initial.c +1 -5
@@ -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" );
drivers/gpu/drm/xe/xe_ggtt.c +12 -0
@@ -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 )); +}
drivers/gpu/drm/xe/xe_ggtt.h +1 -0
@@ -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
Signature · 1 line
2.45.2
PATCH 10/13 drm/xe: Add GGTT updates to migration engine
In reply to Maarten LankhorstAllow for pipelining of GGTT updates, as pinning huge buffers to GGTT might end up being really slow.
--- .../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(+)
drivers/gpu/drm/xe/instructions/xe_mi_commands.h +2 -0
@@ -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)
drivers/gpu/drm/xe/tests/xe_migrate.c +74 -0
86 lines not on this page · raw message
drivers/gpu/drm/xe/xe_migrate.c +87 -0
93 lines not on this page · raw message
drivers/gpu/drm/xe/xe_migrate.h +12 -0
@@ -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
Signature · 1 line
2.45.2
PATCH 11/13 drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT
In reply to Maarten LankhorstFrom: Maarten Lankhorst <[email protected]>
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.
--- 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(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +49 -58
@@ -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 bofor (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; }
drivers/gpu/drm/xe/xe_ggtt.c +62 -21
114 lines not on this page · raw message
drivers/gpu/drm/xe/xe_ggtt.h +5 -4
@@ -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,
drivers/gpu/drm/xe/xe_ggtt_types.h +7 -1
@@ -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
Signature · 1 line
2.45.2
PATCH 12/13 drm/xe: Allow for optimization of xe_ggtt_map_bo
In reply to Maarten Lankhorst--- drivers/gpu/drm/xe/tests/xe_migrate.c | 1 + drivers/gpu/drm/xe/xe_ggtt.c | 74 ++++++++++++++++++--------- 2 files changed, 50 insertions(+), 25 deletions(-)
drivers/gpu/drm/xe/tests/xe_migrate.c +1 -0
@@ -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"
drivers/gpu/drm/xe/xe_ggtt.c +49 -25
121 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH 13/13 drm/xe: Move struct xe_ggtt to xe_ggtt.c
In reply to Maarten LankhorstFrom: Maarten Lankhorst <[email protected]>
No users left outside of xe_ggtt.c, so we can make the struct private.
This prevents us from accidentally touching it before init.
--- drivers/gpu/drm/xe/xe_ggtt.c | 50 ++++++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_ggtt_types.h | 49 ----------------------------- 2 files changed, 50 insertions(+), 49 deletions(-)
drivers/gpu/drm/xe/xe_ggtt.c +50 -0
@@ -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 ;
drivers/gpu/drm/xe/xe_ggtt_types.h +0 -49
60 lines not on this page · raw message
Signature · 1 line
2.45.2
Patchwork
CI✓ CI.Patch_applied: success for Offload GGTT binding to migration engine.
In reply to Maarten Lankhorst== Series Details ==
== 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
✗ CI.checkpatch: warning for Offload GGTT binding to migration engine.
In reply to Maarten Lankhorst== Series Details ==
== 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 <[email protected]> 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.
+ /mt/dim checkpatch 60b7ecc2c5c979cfb8863272348bd6724559b5be drm-intel 8c24473d7425 drm/xe: Use xe_ggtt_map_bo_unlocked for resume efb1765095a8 drm/xe: Add xe_ggtt_might_lock6561142b2785 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 checked561200a57963 drm/xe/display: Convert GGTT mapping to use pte_encode_flags 44bc13c512cd drm/xe: Remove pte_encode_bo callback6c4acc7dab03 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
Patchwork
CI✗ CI.KUnit: failure for Offload GGTT binding to migration engine.
In reply to Maarten Lankhorst== Series Details ==
== 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