drm/xe: Privatize struct xe_ggtt.
Subsystems (3)
v5 cover drm/xe: Privatize struct xe_ggtt.
Clean up SRIOV-VF handling and pop the balloons, move struct xe_ggtt to xe_ggtt.c, and clean up the API's slightly by removing a separate xe_gtt_node_init() step.
This makes the xe_ggtt_node_allocated obsolete, as we only create allocated nodes now.
Changes since last version:
- Some small fixes and cleanups.
- Didn't rename xe_ggtt_node_insert, as I feel the correct name would then be xe_ggtt_insert_ggtt_node().
Maarten Lankhorst (5):
drm/xe: Make xe_ggtt_node offset relative to starting offset drm/xe: Rewrite GGTT VF initialization
drm/xe: Move struct xe_ggtt to xe_ggtt.c
drm/xe: Make xe_ggtt_node_insert return a node drm/xe: Remove xe_ggtt_node_allocated
drivers/gpu/drm/xe/display/xe_fb_pin.c | 3 +- drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c | 6 +- drivers/gpu/drm/xe/xe_device_types.h | 2 - drivers/gpu/drm/xe/xe_ggtt.c | 339 ++++++++------------ drivers/gpu/drm/xe/xe_ggtt.h | 12 +- drivers/gpu/drm/xe/xe_ggtt_types.h | 60 +--- drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 36 +-- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 27 +- drivers/gpu/drm/xe/xe_tile_sriov_vf.c | 198 +----------- drivers/gpu/drm/xe/xe_tile_sriov_vf.h | 3 - 10 files changed, 175 insertions(+), 511 deletions(-)
Signature · 1 line
2.51.0
PATCH v5 1/5 drm/xe: Make xe_ggtt_node offset relative to starting offset
Fix all functions that use node->start to use xe_ggtt_node_addr, and add ggtt->start to node->start.
This will make node shifting for SR-IOV VF a one-liner, instead of manually changing each GGTT node's base address.
--- drivers/gpu/drm/xe/xe_ggtt.c | 56 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-)
drivers/gpu/drm/xe/xe_ggtt.c +34 -22
@@ -299,7 +299,7 @@ static void __xe_ggtt_init_early(struct xe_ggtt *ggtt, u64 start, u64 size) { ggtt->start = start; ggtt->size = size; -drm_mm_init (&ggtt->mm, start, size); +drm_mm_init (&ggtt->mm,0 , size); }int xe_ggtt_init_kunit (struct xe_ggtt *ggtt,u32 start,u32 size)
@@ -401,7 +401,7 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)/* Display may have allocated inside ggtt, so be careful with clearing here */ mutex_lock (&ggtt->lock);drm_mm_for_each_hole (hole, &ggtt->mm, start, end) -xe_ggtt_clear (ggtt, start, end - start); +xe_ggtt_clear (ggtt, ggtt->start + start, end - start);xe_ggtt_invalidate (ggtt);mutex_unlock (&ggtt->lock);
@@ -418,7 +418,7 @@ static void ggtt_node_remove(struct xe_ggtt_node *node)mutex_lock (&ggtt->lock);if (bound) -xe_ggtt_clear (ggtt, node->base.start, node->base.size); +xe_ggtt_clear (ggtt,xe_ggtt_node_addr (node),xe_ggtt_node_size (node));drm_mm_remove_node (&node->base); node->base.size =0 ;mutex_unlock (&ggtt->lock);
@@ -570,16 +570,17 @@ int xe_ggtt_node_insert_balloon_locked(struct xe_ggtt_node *node, u64 start, u64xe_tile_assert (ggtt->tile,IS_ALIGNED (start,XE_PAGE_SIZE ));xe_tile_assert (ggtt->tile,IS_ALIGNED (end,XE_PAGE_SIZE ));xe_tile_assert (ggtt->tile, !drm_mm_node_allocated (&node->base)); +xe_assert (xe, start >= ggtt->start);lockdep_assert_held (&ggtt->lock); node->base.color =0 ; - node->base.start = start; + node->base.start = start - ggtt->start; node->base.size = end - start; err =drm_mm_reserve_node (&ggtt->mm, &node->base);if (xe_tile_WARN (ggtt->tile, err,"Failed to balloon GGTT %#llx-%#llx (%pe)\n" , - node->base.start, node->base.start + node->base.size,ERR_PTR (err))) +xe_ggtt_node_addr (node),xe_ggtt_node_addr (node) + node->base.size,ERR_PTR (err)))return err;xe_ggtt_dump_node (ggtt, &node->base,"balloon" );
@@ -770,7 +771,7 @@ static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,if (XE_WARN_ON (!node))return ; - start = node->base.start; + start =xe_ggtt_node_addr (node); end = start +xe_bo_size (bo);if (!xe_bo_is_vram (bo) && !xe_bo_is_stolen (bo)) {
@@ -891,6 +892,14 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, }mutex_lock (&ggtt->lock); +xe_assert (xe, start >= ggtt->start || !start); +xe_assert (xe, end >= ggtt->start); + +if (start) + start -= ggtt->start; + + end -= ggtt->start; + err =drm_mm_insert_node_in_range (&ggtt->mm, &bo->ggtt_node[tile_id]->base,xe_bo_size (bo), alignment,0 , start, end,0 );if (err) {
@@ -1002,16 +1011,17 @@ static u64 xe_encode_vfid_pte(u16 vfid)return FIELD_PREP (GGTT_PTE_VFID , vfid) |XE_PAGE_PRESENT ; } -static void xe_ggtt_assign_locked (struct xe_ggtt *ggtt,const struct drm_mm_node *node,u16 vfid) +static void xe_ggtt_assign_locked (const struct xe_ggtt_node *node,u16 vfid) { -u64 start = node->start; -u64 size = node->size; +struct xe_ggtt *ggtt = node->ggtt; +u64 start =xe_ggtt_node_addr (node); +u64 size =xe_ggtt_node_size (node);u64 end = start + size -1 ;u64 pte =xe_encode_vfid_pte (vfid);lockdep_assert_held (&ggtt->lock); -if (!drm_mm_node_allocated (node)) +if (!xe_ggtt_node_allocated (node))return ;while (start < end) {
@@ -1033,9 +1043,11 @@ static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node*/ void xe_ggtt_assign (const struct xe_ggtt_node *node,u16 vfid) { -mutex_lock (&node->ggtt->lock); -xe_ggtt_assign_locked (node->ggtt, &node->base, vfid); -mutex_unlock (&node->ggtt->lock); +if (!node) +return ; + +guard (mutex)(&node->ggtt->lock); +xe_ggtt_assign_locked (node, vfid); }/**
@@ -1057,14 +1069,14 @@ int xe_ggtt_node_save(struct xe_ggtt_node *node, void *dst, size_t size, u16 vfiif (!node)return -ENOENT ; -guard (mutex)(&node->ggtt->lock); + ggtt = node->ggtt; +guard (mutex)(&ggtt->lock);if (xe_ggtt_node_pt_size (node) != size)return -EINVAL ; - ggtt = node->ggtt; - start = node->base.start; - end = start + node->base.size -1 ; + start =xe_ggtt_node_addr (node); + end = start +xe_ggtt_node_size (node) -1 ;while (start < end) { pte = ggtt->pt_ops->ggtt_get_pte (ggtt, start);
@@ -1097,14 +1109,14 @@ int xe_ggtt_node_load(struct xe_ggtt_node *node, const void *src, size_t size, uif (!node)return -ENOENT ; -guard (mutex)(&node->ggtt->lock); + ggtt = node->ggtt; +guard (mutex)(&ggtt->lock);if (xe_ggtt_node_pt_size (node) != size)return -EINVAL ; - ggtt = node->ggtt; - start = node->base.start; - end = start + node->base.size -1 ; + start =xe_ggtt_node_addr (node); + end = start +xe_ggtt_node_size (node) -1 ;while (start < end) { vfid_pte =u64_replace_bits (*buf++, vfid,GGTT_PTE_VFID );
@@ -1211,7 +1223,7 @@ u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)*/ u64 xe_ggtt_node_addr (const struct xe_ggtt_node *node) { -return node->base.start; +return node->base.start + node->ggtt->start; }/**
Signature · 1 line
2.51.0
Re: [PATCH v5 1/5] drm/xe: Make xe_ggtt_node offset relative to starting offset
Quoted 8 lines · Maarten Lankhorst
Fix all functions that use
node->startto usexe_ggtt_node_addr, and addggtt->starttonode->start.This will make node shifting for SR-IOV VF a one-liner, instead of manually changing each GGTT node's base address.
Signed-off-by Maarten Lankhorst <[email protected]>---
no change log ;( can you please include it in next spin?
Quoted 35 lines
drivers/gpu/drm/xe/xe_ggtt.c | 56 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-)drivers/gpu/drm/xe/xe_ggtt.c +3
-3@@ -299,7 +299,7 @@ static void __xe_ggtt_init_early(struct xe_ggtt *ggtt, u64 start, u64 size) { ggtt->start = start; ggtt->size = size; -drm_mm_init (&ggtt->mm, start, size); +drm_mm_init (&ggtt->mm,0 , size); }int xe_ggtt_init_kunit (struct xe_ggtt *ggtt,u32 start,u32 size)@@ -401,7 +401,7 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)/* Display may have allocated inside ggtt, so be careful with clearing here */ mutex_lock (&ggtt->lock);drm_mm_for_each_hole (hole, &ggtt->mm, start, end) -xe_ggtt_clear (ggtt, start, end - start); +xe_ggtt_clear (ggtt, ggtt->start + start, end - start);xe_ggtt_invalidate (ggtt);mutex_unlock (&ggtt->lock);@@ -418,7 +418,7 @@ static void ggtt_node_remove(struct xe_ggtt_node *node)mutex_lock (&ggtt->lock);if (bound) -xe_ggtt_clear (ggtt, node->base.start, node->base.size); +xe_ggtt_clear (ggtt,xe_ggtt_node_addr (node),xe_ggtt_node_size (node));drm_mm_remove_node (&node->base); node->base.size =0 ;mutex_unlock (&ggtt->lock);
drivers/gpu/drm/xe/xe_ggtt.c int xe_ggtt_node_insert_balloon_locked(struct xe_ggtt_node *node, u64 start, u64 · line 573
Quoted 4 lines
drivers/gpu/drm/xe/xe_ggtt.c +1
-0@@ -570,16 +570,17 @@ int xe_ggtt_node_insert_balloon_locked(struct xe_ggtt_node *node, u64 start, u64xe_tile_assert (ggtt->tile,IS_ALIGNED (start,XE_PAGE_SIZE ));xe_tile_assert (ggtt->tile,IS_ALIGNED (end,XE_PAGE_SIZE ));xe_tile_assert (ggtt->tile, !drm_mm_node_allocated (&node->base)); +xe_assert (xe, start >= ggtt->start);
this should be xe_tile_assert(...)
Quoted 25 lines
drivers/gpu/drm/xe/xe_ggtt.c +3
-3lockdep_assert_held (&ggtt->lock); node->base.color =0 ; - node->base.start = start; + node->base.start = start - ggtt->start; node->base.size = end - start; err =drm_mm_reserve_node (&ggtt->mm, &node->base);if (xe_tile_WARN (ggtt->tile, err,"Failed to balloon GGTT %#llx-%#llx (%pe)\n" , - node->base.start, node->base.start + node->base.size,ERR_PTR (err))) +xe_ggtt_node_addr (node),xe_ggtt_node_addr (node) + node->base.size,ERR_PTR (err)))return err;xe_ggtt_dump_node (ggtt, &node->base,"balloon" );@@ -770,7 +771,7 @@ static void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,if (XE_WARN_ON (!node))return ; - start = node->base.start; + start =xe_ggtt_node_addr (node); end = start +xe_bo_size (bo);if (!xe_bo_is_vram (bo) && !xe_bo_is_stolen (bo)) {
drivers/gpu/drm/xe/xe_ggtt.c static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, · line 896
Quoted 5 lines
drivers/gpu/drm/xe/xe_ggtt.c +2
-0@@ -891,6 +892,14 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, }mutex_lock (&ggtt->lock); +xe_assert (xe, start >= ggtt->start || !start); +xe_assert (xe, end >= ggtt->start);
ditto
Quoted 32 lines
drivers/gpu/drm/xe/xe_ggtt.c +11
-4+ +if (start) + start -= ggtt->start; + + end -= ggtt->start; + err =drm_mm_insert_node_in_range (&ggtt->mm, &bo->ggtt_node[tile_id]->base,xe_bo_size (bo), alignment,0 , start, end,0 );if (err) {@@ -1002,16 +1011,17 @@ static u64 xe_encode_vfid_pte(u16 vfid)return FIELD_PREP (GGTT_PTE_VFID , vfid) |XE_PAGE_PRESENT ; } -static void xe_ggtt_assign_locked (struct xe_ggtt *ggtt,const struct drm_mm_node *node,u16 vfid) +static void xe_ggtt_assign_locked (const struct xe_ggtt_node *node,u16 vfid) { -u64 start = node->start; -u64 size = node->size; +struct xe_ggtt *ggtt = node->ggtt; +u64 start =xe_ggtt_node_addr (node); +u64 size =xe_ggtt_node_size (node);u64 end = start + size -1 ;u64 pte =xe_encode_vfid_pte (vfid);lockdep_assert_held (&ggtt->lock); -if (!drm_mm_node_allocated (node)) +if (!xe_ggtt_node_allocated (node))return ;while (start < end) {
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node · line 1047
Quoted 8 lines
drivers/gpu/drm/xe/xe_ggtt.c +2
-3@@ -1033,9 +1043,11 @@ static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node*/ void xe_ggtt_assign (const struct xe_ggtt_node *node,u16 vfid) { -mutex_lock (&node->ggtt->lock); -xe_ggtt_assign_locked (node->ggtt, &node->base, vfid); -mutex_unlock (&node->ggtt->lock); +if (!node) +return ;
I'm still not convinced that we need this extra check it's an error to pass NULL here
and current code complies with it
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node · line 1049
Quoted 2 lines
drivers/gpu/drm/xe/xe_ggtt.c +2
-0+ +guard (mutex)(&node->ggtt->lock);
if you don't want a separate patch that converts lock/unlock to guard then at least mention that change in the commit msg
Quoted 51 lines
drivers/gpu/drm/xe/xe_ggtt.c +10
-9+xe_ggtt_assign_locked (node, vfid); }/** @@ -1057,14 +1069,14 @@ int xe_ggtt_node_save(struct xe_ggtt_node *node, void *dst, size_t size, u16 vfiif (!node)return -ENOENT ; -guard (mutex)(&node->ggtt->lock); + ggtt = node->ggtt; +guard (mutex)(&ggtt->lock);if (xe_ggtt_node_pt_size (node) != size)return -EINVAL ; - ggtt = node->ggtt; - start = node->base.start; - end = start + node->base.size -1 ; + start =xe_ggtt_node_addr (node); + end = start +xe_ggtt_node_size (node) -1 ;while (start < end) { pte = ggtt->pt_ops->ggtt_get_pte (ggtt, start);@@ -1097,14 +1109,14 @@ int xe_ggtt_node_load(struct xe_ggtt_node *node, const void *src, size_t size, uif (!node)return -ENOENT ; -guard (mutex)(&node->ggtt->lock); + ggtt = node->ggtt; +guard (mutex)(&ggtt->lock);if (xe_ggtt_node_pt_size (node) != size)return -EINVAL ; - ggtt = node->ggtt; - start = node->base.start; - end = start + node->base.size -1 ; + start =xe_ggtt_node_addr (node); + end = start +xe_ggtt_node_size (node) -1 ;while (start < end) { vfid_pte =u64_replace_bits (*buf++, vfid,GGTT_PTE_VFID );@@ -1211,7 +1223,7 @@ u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)*/ u64 xe_ggtt_node_addr (const struct xe_ggtt_node *node) { -return node->base.start; +return node->base.start + node->ggtt->start; }/**
PATCH v5 2/5 drm/xe: Rewrite GGTT VF initialization
In reply to Maarten LankhorstThe previous code was using a complicated system with 2 balloons to set GGTT size and adjust GGTT offset. While it works, it's overly complicated.
A better approach is to set the offset and size when initializing GGTT, this removes the need for adding balloons. The resize function only needs readjust ggtt->start to have GGTT at the new offset.
This removes the need to manipulate the internals of xe_ggtt outside of xe_ggtt, and cleans up a lot of now unneeded code.
--- drivers/gpu/drm/xe/xe_device_types.h | 2 - drivers/gpu/drm/xe/xe_ggtt.c | 164 ++++----------------- drivers/gpu/drm/xe/xe_ggtt.h | 5 +- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 27 +++- drivers/gpu/drm/xe/xe_tile_sriov_vf.c | 198 +------------------------- drivers/gpu/drm/xe/xe_tile_sriov_vf.h | 3 - 6 files changed, 54 insertions(+), 345 deletions(-)
drivers/gpu/drm/xe/xe_device_types.h +0 -2
@@ -228,8 +228,6 @@ struct xe_tile {struct xe_lmtt lmtt; } pf;struct { -/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */ -struct xe_ggtt_node *ggtt_balloon[2 ];/** @sriov.vf.self_config: VF configuration data */ struct xe_tile_sriov_vf_selfconfig self_config; } vf;
drivers/gpu/drm/xe/xe_ggtt.c +29 -135
219 lines not on this page · raw message
drivers/gpu/drm/xe/xe_ggtt.h +1 -4
@@ -19,10 +19,7 @@ int xe_ggtt_init(struct xe_ggtt *ggtt);struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt);void xe_ggtt_node_fini (struct xe_ggtt_node *node); -int xe_ggtt_node_insert_balloon_locked (struct xe_ggtt_node *node, -u64 start,u64 size); -void xe_ggtt_node_remove_balloon_locked (struct xe_ggtt_node *node); -void xe_ggtt_shift_nodes_locked (struct xe_ggtt *ggtt,s64 shift); +void xe_ggtt_shift_nodes (struct xe_ggtt *ggtt,u64 new_base);u64 xe_ggtt_start (struct xe_ggtt *ggtt);u64 xe_ggtt_size (struct xe_ggtt *ggtt);
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +20 -7
@@ -488,7 +488,6 @@ u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt)static int vf_get_ggtt_info (struct xe_gt *gt) {struct xe_tile *tile =gt_to_tile (gt); -struct xe_ggtt *ggtt = tile->mem.ggtt;struct xe_guc *guc = >->uc.guc;u64 start, size, ggtt_size;s64 shift;
@@ -496,8 +495,6 @@ static int vf_get_ggtt_info(struct xe_gt *gt)xe_gt_assert (gt,IS_SRIOV_VF (gt_to_xe (gt))); -guard (mutex)(&ggtt->lock); - err =guc_action_query_single_klv64 (guc,GUC_KLV_VF_CFG_GGTT_START_KEY , &start);if (unlikely (err))return err;
@@ -509,8 +506,20 @@ static int vf_get_ggtt_info(struct xe_gt *gt)if (!size)return -ENODATA ; +/* +* This function is called once during xe_guc_init_noalloc(), +* at which point ggtt_size = 0 and we have to initialize everything, +* and ggtt is not yet initialized. +* +* After init this can be called repeatedly from post migration fixups, +* at which point we inform the GGTT of the new base address. +* xe_ggtt_shift_nodes() may be called multiple times for each migration, +* but will be a noop if the base is unchanged. +*/ ggtt_size =xe_tile_sriov_vf_ggtt (tile); -if (ggtt_size && ggtt_size != size) { +if (!ggtt_size) { +xe_tile_sriov_vf_ggtt_store (tile, size); + }else if (ggtt_size != size) {xe_gt_sriov_err (gt,"Unexpected GGTT reassignment: %lluK != %lluK\n" , size /SZ_1K , ggtt_size /SZ_1K );return -EREMCHG ;
@@ -521,12 +530,16 @@ static int vf_get_ggtt_info(struct xe_gt *gt) shift = start - (s64 )xe_tile_sriov_vf_ggtt_base (tile);xe_tile_sriov_vf_ggtt_base_store (tile, start); -xe_tile_sriov_vf_ggtt_store (tile, size); -if (shift && shift != start) { +if (ggtt_size) { +/* +* Since we're not holding a lock, the shift value may be +* calculated incorrectly. +* This is only used for a debug print so it's harmless. +*/ xe_gt_sriov_info (gt,"Shifting GGTT base by %lld to 0x%016llx\n" , shift, start); -xe_tile_sriov_vf_fixup_ggtt_nodes_locked (gt_to_tile (gt), shift); +xe_ggtt_shift_nodes (tile->mem.ggtt, start); }if (xe_sriov_vf_migration_supported (gt_to_xe (gt))) {
drivers/gpu/drm/xe/xe_tile_sriov_vf.c +4 -194
236 lines not on this page · raw message
drivers/gpu/drm/xe/xe_tile_sriov_vf.h +0 -3
@@ -10,9 +10,6 @@struct xe_tile ; -int xe_tile_sriov_vf_prepare_ggtt (struct xe_tile *tile); -void xe_tile_sriov_vf_deballoon_ggtt_locked (struct xe_tile *tile); -void xe_tile_sriov_vf_fixup_ggtt_nodes_locked (struct xe_tile *tile,s64 shift);u64 xe_tile_sriov_vf_ggtt (struct xe_tile *tile);void xe_tile_sriov_vf_ggtt_store (struct xe_tile *tile,u64 ggtt_size);u64 xe_tile_sriov_vf_ggtt_base (struct xe_tile *tile);
Signature · 1 line
2.51.0
Re: [PATCH v5 2/5] drm/xe: Rewrite GGTT VF initialization
Quoted 54 lines · Maarten Lankhorst
The previous code was using a complicated system with 2 balloons to set GGTT size and adjust GGTT offset. While it works, it's overly complicated.
A better approach is to set the offset and size when initializing GGTT, this removes the need for adding balloons. The resize function only needs readjust
ggtt->startto have GGTT at the new offset.This removes the need to manipulate the internals of
xe_ggttoutside ofxe_ggtt, and cleans up a lot of now unneeded code.Signed-off-by Maarten Lankhorst <[email protected]>Co-developed-by Matthew Brost <[email protected]>--- drivers/gpu/drm/xe/xe_device_types.h | 2 - drivers/gpu/drm/xe/xe_ggtt.c | 164 ++++----------------- drivers/gpu/drm/xe/xe_ggtt.h | 5 +- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 27 +++- drivers/gpu/drm/xe/xe_tile_sriov_vf.c | 198 +------------------------- drivers/gpu/drm/xe/xe_tile_sriov_vf.h | 3 - 6 files changed, 54 insertions(+), 345 deletions(-)drivers/gpu/drm/xe/xe_device_types.h +0
-2@@ -228,8 +228,6 @@ struct xe_tile {struct xe_lmtt lmtt; } pf;struct { -/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */ -struct xe_ggtt_node *ggtt_balloon[2 ];/** @sriov.vf.self_config: VF configuration data */ struct xe_tile_sriov_vf_selfconfig self_config; } vf;drivers/gpu/drm/xe/xe_ggtt.c +2
-2@@ -70,8 +70,8 @@* struct xe_ggtt_node - A node in GGTT. * * This struct needs to be initialized (only-once) with xe_ggtt_node_init() before any node -* insertion, reservation, or 'ballooning'. -* It will, then, be finalized by either xe_ggtt_node_remove() or xe_ggtt_node_deballoon(). +* insertion or reservation. +* It will, then, be finalized by xe_ggtt_node_remove(). */ struct xe_ggtt_node {/** @ggtt: Back pointer to xe_ggtt where this region will be inserted at */ @@ -347,9 +347,15 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) ggtt_start = wopcm; ggtt_size = (gsm_size /8 ) * (u64 )XE_PAGE_SIZE - ggtt_start; }else {
drivers/gpu/drm/xe/xe_ggtt.c int xe_ggtt_init_early(struct xe_ggtt *ggtt) · line 356
Quoted 10 lines
drivers/gpu/drm/xe/xe_ggtt.c +7
-3-/* GGTT is expected to be 4GiB */ - ggtt_start = wopcm; - ggtt_size =SZ_4G - ggtt_start; + ggtt_start =xe_tile_sriov_vf_ggtt_base (ggtt->tile); + ggtt_size =xe_tile_sriov_vf_ggtt (ggtt->tile); + +if (ggtt_start < wopcm || ggtt_start >GUC_GGTT_TOP || + ggtt_size >GUC_GGTT_TOP - ggtt_start) { +xe_tile_err (ggtt->tile,"Invalid GGTT configuration: %#llx-%#llx\n" , + ggtt_start, ggtt_start + ggtt_size -1 );
nit: probably it would be better to catch such invalid config sooner, right after we get that from the GuC but then we would have to expose some function from xe_ggtt to make that validation that xe_gt_vf code could use
Quoted 97 lines
drivers/gpu/drm/xe/xe_ggtt.c +3
-79+return -ERANGE ; + } } ggtt->gsm = ggtt->tile->mmio.regs +SZ_8M ;@@ -377,17 +383,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)if (err)return err; - err =devm_add_action_or_reset (xe->drm.dev, dev_fini_ggtt, ggtt); -if (err) -return err; - -if (IS_SRIOV_VF (xe)) { - err =xe_tile_sriov_vf_prepare_ggtt (ggtt->tile); -if (err) -return err; - } - -return 0 ; +return devm_add_action_or_reset (xe->drm.dev, dev_fini_ggtt, ggtt); }ALLOW_ERROR_INJECTION (xe_ggtt_init_early,ERRNO );/* See xe_pci_probe() */ @@ -538,120 +534,21 @@ static void xe_ggtt_invalidate(struct xe_ggtt *ggtt)ggtt_invalidate_gt_tlb (ggtt->tile->media_gt); } -static void xe_ggtt_dump_node (struct xe_ggtt *ggtt, -const struct drm_mm_node *node,const char *description) -{ -char buf[10 ]; - -if (IS_ENABLED (CONFIG_DRM_XE_DEBUG )) { -string_get_size (node->size,1 ,STRING_UNITS_2 , buf,sizeof (buf)); -xe_tile_dbg (ggtt->tile,"GGTT %#llx-%#llx (%s) %s\n" , - node->start, node->start + node->size, buf, description); - } -} - -/** -* xe_ggtt_node_insert_balloon_locked - prevent allocation of specified GGTT addresses -* @node: the &xe_ggtt_node to hold reserved GGTT node -* @start: the starting GGTT address of the reserved region -* @end: then end GGTT address of the reserved region -* -* To be used in cases where ggtt->lock is already taken. -* Use xe_ggtt_node_remove_balloon_locked() to release a reserved GGTT node. -* -* Return: 0 on success or a negative error code on failure. -*/ -int xe_ggtt_node_insert_balloon_locked (struct xe_ggtt_node *node,u64 start,u64 end) -{ -struct xe_ggtt *ggtt = node->ggtt; -int err; - -xe_tile_assert (ggtt->tile, start < end); -xe_tile_assert (ggtt->tile,IS_ALIGNED (start,XE_PAGE_SIZE )); -xe_tile_assert (ggtt->tile,IS_ALIGNED (end,XE_PAGE_SIZE )); -xe_tile_assert (ggtt->tile, !drm_mm_node_allocated (&node->base)); -xe_assert (xe, start >= ggtt->start); -lockdep_assert_held (&ggtt->lock); - - node->base.color =0 ; - node->base.start = start - ggtt->start; - node->base.size = end - start; - - err =drm_mm_reserve_node (&ggtt->mm, &node->base); - -if (xe_tile_WARN (ggtt->tile, err,"Failed to balloon GGTT %#llx-%#llx (%pe)\n" , -xe_ggtt_node_addr (node),xe_ggtt_node_addr (node) + node->base.size,ERR_PTR (err))) -return err; - -xe_ggtt_dump_node (ggtt, &node->base,"balloon" ); -return 0 ; -} -/** -* xe_ggtt_node_remove_balloon_locked - release a reserved GGTT region -* @node: the &xe_ggtt_node with reserved GGTT region -* -* To be used in cases where ggtt->lock is already taken. -* See xe_ggtt_node_insert_balloon_locked() for details. -*/ -void xe_ggtt_node_remove_balloon_locked (struct xe_ggtt_node *node) -{ -if (!xe_ggtt_node_allocated (node)) -return ; - -lockdep_assert_held (&node->ggtt->lock); - -xe_ggtt_dump_node (node->ggtt, &node->base,"remove-balloon" ); - -drm_mm_remove_node (&node->base); -} - -static void xe_ggtt_assert_fit (struct xe_ggtt *ggtt,u64 start,u64 size)
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_invalidate(struct xe_ggtt *ggtt) · line 538
Quoted 10 lines
drivers/gpu/drm/xe/xe_ggtt.c +1
-9-{ -struct xe_tile *tile = ggtt->tile; - -xe_tile_assert (tile, start >= ggtt->start); -xe_tile_assert (tile, start + size <= ggtt->start + ggtt->size); -} - -/** -* xe_ggtt_shift_nodes_locked - Shift GGTT nodes to adjust for a change in usable address range. +* xe_ggtt_shift_nodes - Shift GGTT nodes to adjust for a change in usable address range.
nit: while use of () is not so popular, it's still the correct notation that IMO we should follow
xe_ggtt_shift_nodes() - ...
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_invalidate(struct xe_ggtt *ggtt) · line 540
Quoted 7 lines
drivers/gpu/drm/xe/xe_ggtt.c +1
-5* @ggtt: the &xe_ggtt struct instance -* @shift: change to the location of area provisioned for current VF -* -* This function moves all nodes from the GGTT VM, to a temp list. These nodes are expected -* to represent allocations in range formerly assigned to current VF, before the range changed. -* When the GGTT VM is completely clear of any nodes, they are re-added with shifted offsets. +* @new_start: new location of area provisioned for current VF
nit: since this function is void and all validation of new_start param is done with asserts, maybe it's worth to mention/list below what are our expectations for this 'new_start' ?
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_invalidate(struct xe_ggtt *ggtt) · line 542
Quoted 7 lines
drivers/gpu/drm/xe/xe_ggtt.c +1
-5* -* The function has no ability of failing - because it shifts existing nodes, without -* any additional processing. If the nodes were successfully existing at the old address, -* they will do the same at the new one. A fail inside this function would indicate that -* the list of nodes was either already damaged, or that the shift brings the address range -* outside of valid bounds. Both cases justify an assert rather than error code. +* Adjust the base offset of the GGTT.
nit: this sounds more like an implementation detail
since function name is about "nodes" we should explain the connection here
"To adjust location of all allocated GGTT nodes, this function "changes the base offset of the GGTT, since all nodes refer to it.
Quoted 110 lines
drivers/gpu/drm/xe/xe_ggtt.c +14
-32*/ -void xe_ggtt_shift_nodes_locked (struct xe_ggtt *ggtt,s64 shift) +void xe_ggtt_shift_nodes (struct xe_ggtt *ggtt,u64 new_start) { -struct xe_tile *tile__maybe_unused = ggtt->tile; -struct drm_mm_node *node, *tmpn; -LIST_HEAD (temp_list_head); - -lockdep_assert_held (&ggtt->lock); +guard (mutex)(&ggtt->lock); -if (IS_ENABLED (CONFIG_DRM_XE_DEBUG )) -drm_mm_for_each_node_safe (node, tmpn, &ggtt->mm) -xe_ggtt_assert_fit (ggtt, node->start + shift, node->size); +xe_tile_assert (ggtt->tile, new_start >=xe_wopcm_size (tile_to_xe (ggtt->tile))); +xe_tile_assert (ggtt->tile, new_start + ggtt->size <=GUC_GGTT_TOP ); -drm_mm_for_each_node_safe (node, tmpn, &ggtt->mm) { -drm_mm_remove_node (node); -list_add (&node->node_list, &temp_list_head); - } - -list_for_each_entry_safe (node, tmpn, &temp_list_head, node_list) { -list_del (&node->node_list); - node->start += shift; -drm_mm_reserve_node (&ggtt->mm, node); -xe_tile_assert (tile,drm_mm_node_allocated (node)); - } +WRITE_ONCE (ggtt->start, new_start); } static int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node,@@ -692,12 +589,8 @@ int xe_ggtt_node_insert(struct xe_ggtt_node *node, u32 size, u32 align)* * This function will allocate the struct %xe_ggtt_node and return its pointer. * This struct will then be freed after the node removal upon xe_ggtt_node_remove() -* or xe_ggtt_node_remove_balloon_locked(). -* -* Having %xe_ggtt_node struct allocated doesn't mean that the node is already -* allocated in GGTT. Only xe_ggtt_node_insert(), allocation through -* xe_ggtt_node_insert_transform(), or xe_ggtt_node_insert_balloon_locked() will ensure the node is inserted or reserved -* in GGTT. +* Having %xe_ggtt_node struct allocated doesn't mean that the node is already allocated +* in GGTT. Only xe_ggtt_node_insert() will ensure the node is inserted or reserved in GGTT. * * Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise. **/ @@ -718,9 +611,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_locked(); 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() 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) {@@ -892,8 +785,8 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo, }mutex_lock (&ggtt->lock); -xe_assert (xe, start >= ggtt->start || !start); -xe_assert (xe, end >= ggtt->start); +xe_tile_assert (ggtt->tile, start >= ggtt->start || !start); +xe_tile_assert (ggtt->tile, end >= ggtt->start);if (start) start -= ggtt->start;@@ -1223,7 +1116,8 @@ u64 xe_ggtt_read_pte(struct xe_ggtt *ggtt, u64 offset)*/ u64 xe_ggtt_node_addr (const struct xe_ggtt_node *node) { -return node->base.start + node->ggtt->start; +/* pairs with WRITE_ONCE in xe_ggtt_shift_nodes() */ +return node->base.start +READ_ONCE (node->ggtt->start); }/** drivers/gpu/drm/xe/xe_ggtt.h +1
-4@@ -19,10 +19,7 @@ int xe_ggtt_init(struct xe_ggtt *ggtt);struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt);void xe_ggtt_node_fini (struct xe_ggtt_node *node); -int xe_ggtt_node_insert_balloon_locked (struct xe_ggtt_node *node, -u64 start,u64 size); -void xe_ggtt_node_remove_balloon_locked (struct xe_ggtt_node *node); -void xe_ggtt_shift_nodes_locked (struct xe_ggtt *ggtt,s64 shift); +void xe_ggtt_shift_nodes (struct xe_ggtt *ggtt,u64 new_base);u64 xe_ggtt_start (struct xe_ggtt *ggtt);u64 xe_ggtt_size (struct xe_ggtt *ggtt);drivers/gpu/drm/xe/xe_gt_sriov_vf.c +0
-1@@ -488,7 +488,6 @@ u32 xe_gt_sriov_vf_gmdid(struct xe_gt *gt)static int vf_get_ggtt_info (struct xe_gt *gt) {struct xe_tile *tile =gt_to_tile (gt); -struct xe_ggtt *ggtt = tile->mem.ggtt;struct xe_guc *guc = >->uc.guc;u64 start, size, ggtt_size;s64 shift;
drivers/gpu/drm/xe/xe_gt_sriov_vf.c static int vf_get_ggtt_info(struct xe_gt *gt) · line 499
Quoted 4 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +0
-1@@ -496,8 +495,6 @@ static int vf_get_ggtt_info(struct xe_gt *gt)xe_gt_assert (gt,IS_SRIOV_VF (gt_to_xe (gt))); -guard (mutex)(&ggtt->lock);
nit: as we now drop this mutex and run all below code lockless, maybe it's worth to separate pure "get" code from "apply" code?
drivers/gpu/drm/xe/xe_gt_sriov_vf.c static int vf_get_ggtt_info(struct xe_gt *gt) · line 512
Quoted 12 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +4
-1- err =guc_action_query_single_klv64 (guc,GUC_KLV_VF_CFG_GGTT_START_KEY , &start);if (unlikely (err))return err;@@ -509,8 +506,20 @@ static int vf_get_ggtt_info(struct xe_gt *gt)if (!size)return -ENODATA ; +/* +* This function is called once during xe_guc_init_noalloc(), +* at which point ggtt_size = 0 and we have to initialize everything, +* and ggtt is not yet initialized.
s/and ggtt/and GGTT
drivers/gpu/drm/xe/xe_gt_sriov_vf.c static int vf_get_ggtt_info(struct xe_gt *gt) · line 521
Quoted 10 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +8
-1+* +* After init this can be called repeatedly from post migration fixups, +* at which point we inform the GGTT of the new base address. +* xe_ggtt_shift_nodes() may be called multiple times for each migration, +* but will be a noop if the base is unchanged. +*/ ggtt_size =xe_tile_sriov_vf_ggtt (tile); -if (ggtt_size && ggtt_size != size) { +if (!ggtt_size) { +xe_tile_sriov_vf_ggtt_store (tile, size);
since we know this case is for the first time query, maybe we should do all that's needed and exit?
xe_tile_sriov_vf_ggtt_base_store(tile, start); or: xe_tile_sriov_vf_ggtt_init(tile, start, size); return 0; }
drivers/gpu/drm/xe/xe_gt_sriov_vf.c static int vf_get_ggtt_info(struct xe_gt *gt) · line 534
Quoted 12 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +2
-2+ }else if (ggtt_size != size) {xe_gt_sriov_err (gt,"Unexpected GGTT reassignment: %lluK != %lluK\n" , size /SZ_1K , ggtt_size /SZ_1K );return -EREMCHG ;@@ -521,12 +530,16 @@ static int vf_get_ggtt_info(struct xe_gt *gt) shift = start - (s64 )xe_tile_sriov_vf_ggtt_base (tile);xe_tile_sriov_vf_ggtt_base_store (tile, start); -xe_tile_sriov_vf_ggtt_store (tile, size); -if (shift && shift != start) { +if (ggtt_size) {
then this 'if' would be redundant
drivers/gpu/drm/xe/xe_gt_sriov_vf.c static int vf_get_ggtt_info(struct xe_gt *gt) · line 542
Quoted 9 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +6
-1+/* +* Since we're not holding a lock, the shift value may be +* calculated incorrectly. +* This is only used for a debug print so it's harmless. +*/ xe_gt_sriov_info (gt,"Shifting GGTT base by %lld to 0x%016llx\n" , shift, start); -xe_tile_sriov_vf_fixup_ggtt_nodes_locked (gt_to_tile (gt), shift); +xe_ggtt_shift_nodes (tile->mem.ggtt, start);
hmm, it's a shame that even if we have and call tile level function we still have to touch directly ggtt from the gt level function
maybe this could be a part of xe_tile_sriov_vf_ggtt_base_store() or
xe_tile_sriov_vf_ggtt_reinit(tile, start);
Quoted 262 lines
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +0
-0}if (xe_sriov_vf_migration_supported (gt_to_xe (gt))) {drivers/gpu/drm/xe/xe_tile_sriov_vf.c +4
-194@@ -14,173 +14,12 @@#include "xe_tile_sriov_vf.h" #include "xe_wopcm.h" -static int vf_init_ggtt_balloons (struct xe_tile *tile) -{ -struct xe_ggtt *ggtt = tile->mem.ggtt; - -xe_tile_assert (tile,IS_SRIOV_VF (tile_to_xe (tile))); - - tile->sriov.vf.ggtt_balloon[0 ] =xe_ggtt_node_init (ggtt); -if (IS_ERR (tile->sriov.vf.ggtt_balloon[0 ])) -return PTR_ERR (tile->sriov.vf.ggtt_balloon[0 ]); - - tile->sriov.vf.ggtt_balloon[1 ] =xe_ggtt_node_init (ggtt); -if (IS_ERR (tile->sriov.vf.ggtt_balloon[1 ])) { -xe_ggtt_node_fini (tile->sriov.vf.ggtt_balloon[0 ]); -return PTR_ERR (tile->sriov.vf.ggtt_balloon[1 ]); - } - -return 0 ; -} - -/** -* xe_tile_sriov_vf_balloon_ggtt_locked - Insert balloon nodes to limit used GGTT address range. -* @tile: the &xe_tile struct instance -* -* Return: 0 on success or a negative error code on failure. -*/ -static int xe_tile_sriov_vf_balloon_ggtt_locked (struct xe_tile *tile) -{ -u64 ggtt_base = tile->sriov.vf.self_config.ggtt_base; -u64 ggtt_size = tile->sriov.vf.self_config.ggtt_size; -struct xe_device *xe =tile_to_xe (tile); -u64 wopcm =xe_wopcm_size (xe); -u64 start, end; -int err; - -xe_tile_assert (tile,IS_SRIOV_VF (xe)); -xe_tile_assert (tile, ggtt_size); -lockdep_assert_held (&tile->mem.ggtt->lock); - -/* -* VF can only use part of the GGTT as allocated by the PF: -* -* WOPCM GUC_GGTT_TOP -* |<------------ Total GGTT size ------------------>| -* -* VF GGTT base -->|<- size ->| -* -* +--------------------+----------+-----------------+ -* |////////////////////| block |\\\\\\\\\\\\\\\\\| -* +--------------------+----------+-----------------+ -* -* |<--- balloon[0] --->|<-- VF -->|<-- balloon[1] ->| -*/ - -if (ggtt_base < wopcm || ggtt_base >GUC_GGTT_TOP || - ggtt_size >GUC_GGTT_TOP - ggtt_base) { -xe_sriov_err (xe,"tile%u: Invalid GGTT configuration: %#llx-%#llx\n" , - tile->id, ggtt_base, ggtt_base + ggtt_size -1 ); -return -ERANGE ; - } - - start = wopcm; - end = ggtt_base; -if (end != start) { - err =xe_ggtt_node_insert_balloon_locked (tile->sriov.vf.ggtt_balloon[0 ], - start, end); -if (err) -return err; - } - - start = ggtt_base + ggtt_size; - end =GUC_GGTT_TOP ; -if (end != start) { - err =xe_ggtt_node_insert_balloon_locked (tile->sriov.vf.ggtt_balloon[1 ], - start, end); -if (err) { -xe_ggtt_node_remove_balloon_locked (tile->sriov.vf.ggtt_balloon[0 ]); -return err; - } - } - -return 0 ; -} - -static int vf_balloon_ggtt (struct xe_tile *tile) -{ -struct xe_ggtt *ggtt = tile->mem.ggtt; -int err; - -mutex_lock (&ggtt->lock); - err =xe_tile_sriov_vf_balloon_ggtt_locked (tile); -mutex_unlock (&ggtt->lock); - -return err; -} - -/** -* xe_tile_sriov_vf_deballoon_ggtt_locked - Remove balloon nodes. -* @tile: the &xe_tile struct instance -*/ -void xe_tile_sriov_vf_deballoon_ggtt_locked (struct xe_tile *tile) -{ -xe_tile_assert (tile,IS_SRIOV_VF (tile_to_xe (tile))); - -xe_ggtt_node_remove_balloon_locked (tile->sriov.vf.ggtt_balloon[1 ]); -xe_ggtt_node_remove_balloon_locked (tile->sriov.vf.ggtt_balloon[0 ]); -} - -static void vf_deballoon_ggtt (struct xe_tile *tile) -{ -mutex_lock (&tile->mem.ggtt->lock); -xe_tile_sriov_vf_deballoon_ggtt_locked (tile); -mutex_unlock (&tile->mem.ggtt->lock); -} - -static void vf_fini_ggtt_balloons (struct xe_tile *tile) -{ -xe_tile_assert (tile,IS_SRIOV_VF (tile_to_xe (tile))); - -xe_ggtt_node_fini (tile->sriov.vf.ggtt_balloon[1 ]); -xe_ggtt_node_fini (tile->sriov.vf.ggtt_balloon[0 ]); -} - -static void cleanup_ggtt (struct drm_device *drm,void *arg) -{ -struct xe_tile *tile = arg; - -vf_deballoon_ggtt (tile); -vf_fini_ggtt_balloons (tile); -} - -/** -* xe_tile_sriov_vf_prepare_ggtt - Prepare a VF's GGTT configuration. -* @tile: the &xe_tile -* -* This function is for VF use only. -* -* Return: 0 on success or a negative error code on failure. -*/ -int xe_tile_sriov_vf_prepare_ggtt (struct xe_tile *tile) -{ -struct xe_device *xe =tile_to_xe (tile); -int err; - - err =vf_init_ggtt_balloons (tile); -if (err) -return err; - - err =vf_balloon_ggtt (tile); -if (err) { -vf_fini_ggtt_balloons (tile); -return err; - } - -return drmm_add_action_or_reset (&xe->drm, cleanup_ggtt, tile); -} -/** * DOC: GGTT nodes shifting during VF post-migration recovery * * The first fixup applied to the VF KMD structures as part of post-migration * recovery is shifting nodes within &xe_ggtt instance. The nodes are moved * from range previously assigned to this VF, into newly provisioned area. -* The changes include balloons, which are resized accordingly. -* -* The balloon nodes are there to eliminate unavailable ranges from use: one -* reserves the GGTT area below the range for current VF, and another one -* reserves area above. * * Below is a GGTT layout of example VF, with a certain address range assigned to * said VF, and inaccessible areas above and below: @@ -198,10 +37,6 @@ int xe_tile_sriov_vf_prepare_ggtt(struct xe_tile *tile)* * |<------- inaccessible for VF ------->|<VF owned>|<-- inaccessible for VF ->| * -* GGTT nodes used for tracking allocations: -* -* |<---------- balloon ------------>|<- nodes->|<----- balloon ------>| -* * After the migration, GGTT area assigned to the VF might have shifted, either * to lower or to higher address. But we expect the total size and extra areas to * be identical, as migration can only happen between matching platforms. @@ -219,37 +54,12 @@ int xe_tile_sriov_vf_prepare_ggtt(struct xe_tile *tile)* So the VF has a new slice of GGTT assigned, and during migration process, the * memory content was copied to that new area. But the &xe_ggtt nodes are still * tracking allocations using the old addresses. The nodes within VF owned area -* have to be shifted, and balloon nodes need to be resized to properly mask out -* areas not owned by the VF. -* -* Fixed &xe_ggtt nodes used for tracking allocations: -* -* |<------ balloon ------>|<- nodes->|<----------- balloon ----------->| +* have to be shifted, and the start offset for GGTT adjusted. * -* Due to use of GPU profiles, we do not expect the old and new GGTT ares to +* Due to use of GPU profiles, we do not expect the old and new GGTT areas to * overlap; but our node shifting will fix addresses properly regardless. */ -/** -* xe_tile_sriov_vf_fixup_ggtt_nodes_locked - Shift GGTT allocations to match assigned range. -* @tile: the &xe_tile struct instance -* @shift: the shift value -* -* Since Global GTT is not virtualized, each VF has an assigned range -* within the global space. This range might have changed during migration, -* which requires all memory addresses pointing to GGTT to be shifted. -*/ -void xe_tile_sriov_vf_fixup_ggtt_nodes_locked (struct xe_tile *tile,s64 shift) -{ -struct xe_ggtt *ggtt = tile->mem.ggtt; - -lockdep_assert_held (&ggtt->lock); - -xe_tile_sriov_vf_deballoon_ggtt_locked (tile); -xe_ggtt_shift_nodes_locked (ggtt, shift); -xe_tile_sriov_vf_balloon_ggtt_locked (tile); -} -/** * xe_tile_sriov_vf_lmem - VF LMEM configuration. * @tile: the &xe_tile @@ -330,7 +140,7 @@ u64 xe_tile_sriov_vf_ggtt_base(struct xe_tile *tile)xe_tile_assert (tile,IS_SRIOV_VF (tile_to_xe (tile))); -return config->ggtt_base; +return READ_ONCE (config->ggtt_base); }/** @@ -346,5 +156,5 @@ void xe_tile_sriov_vf_ggtt_base_store(struct xe_tile *tile, u64 ggtt_base)xe_tile_assert (tile,IS_SRIOV_VF (tile_to_xe (tile))); - config->ggtt_base = ggtt_base; +WRITE_ONCE (config->ggtt_base, ggtt_base); }drivers/gpu/drm/xe/xe_tile_sriov_vf.h +0
-3@@ -10,9 +10,6 @@struct xe_tile ; -int xe_tile_sriov_vf_prepare_ggtt (struct xe_tile *tile); -void xe_tile_sriov_vf_deballoon_ggtt_locked (struct xe_tile *tile); -void xe_tile_sriov_vf_fixup_ggtt_nodes_locked (struct xe_tile *tile,s64 shift);u64 xe_tile_sriov_vf_ggtt (struct xe_tile *tile);void xe_tile_sriov_vf_ggtt_store (struct xe_tile *tile,u64 ggtt_size);u64 xe_tile_sriov_vf_ggtt_base (struct xe_tile *tile);
Re: [PATCH v5 2/5] drm/xe: Rewrite GGTT VF initialization
Hey,
Den 2026-01-20 kl. 17:11, skrev Michal Wajdeczko:
Quoted 62 lines · Maarten Lankhorst
Quoted 59 lines
The previous code was using a complicated system with 2 balloons to set GGTT size and adjust GGTT offset. While it works, it's overly complicated.
A better approach is to set the offset and size when initializing GGTT, this removes the need for adding balloons. The resize function only needs readjust
ggtt->startto have GGTT at the new offset.This removes the need to manipulate the internals of
xe_ggttoutside ofxe_ggtt, and cleans up a lot of now unneeded code.Signed-off-by Maarten Lankhorst <[email protected]>Co-developed-by Matthew Brost <[email protected]>--- drivers/gpu/drm/xe/xe_device_types.h | 2 - drivers/gpu/drm/xe/xe_ggtt.c | 164 ++++----------------- drivers/gpu/drm/xe/xe_ggtt.h | 5 +- drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 27 +++- drivers/gpu/drm/xe/xe_tile_sriov_vf.c | 198 +------------------------- drivers/gpu/drm/xe/xe_tile_sriov_vf.h | 3 - 6 files changed, 54 insertions(+), 345 deletions(-)drivers/gpu/drm/xe/xe_device_types.h +0
-2@@ -228,8 +228,6 @@ struct xe_tile {struct xe_lmtt lmtt; } pf;struct { -/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */ -struct xe_ggtt_node *ggtt_balloon[2 ];/** @sriov.vf.self_config: VF configuration data */ struct xe_tile_sriov_vf_selfconfig self_config; } vf;drivers/gpu/drm/xe/xe_ggtt.c +4
-5@@ -70,8 +70,8 @@* struct xe_ggtt_node - A node in GGTT. * * This struct needs to be initialized (only-once) with xe_ggtt_node_init() before any node -* insertion, reservation, or 'ballooning'. -* It will, then, be finalized by either xe_ggtt_node_remove() or xe_ggtt_node_deballoon(). +* insertion or reservation. +* It will, then, be finalized by xe_ggtt_node_remove(). */ struct xe_ggtt_node {/** @ggtt: Back pointer to xe_ggtt where this region will be inserted at */ @@ -347,9 +347,15 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) ggtt_start = wopcm; ggtt_size = (gsm_size /8 ) * (u64 )XE_PAGE_SIZE - ggtt_start; }else { -/* GGTT is expected to be 4GiB */ - ggtt_start = wopcm; - ggtt_size =SZ_4G - ggtt_start; + ggtt_start =xe_tile_sriov_vf_ggtt_base (ggtt->tile); + ggtt_size =xe_tile_sriov_vf_ggtt (ggtt->tile);
Quoted 8 lines
drivers/gpu/drm/xe/xe_ggtt.c int xe_ggtt_init_early(struct xe_ggtt *ggtt) · line 356
Quoted 5 lines
drivers/gpu/drm/xe/xe_ggtt.c +5
-0+ +if (ggtt_start < wopcm || ggtt_start >GUC_GGTT_TOP || + ggtt_size >GUC_GGTT_TOP - ggtt_start) { +xe_tile_err (ggtt->tile,"Invalid GGTT configuration: %#llx-%#llx\n" , + ggtt_start, ggtt_start + ggtt_size -1 );nit: probably it would be better to catch such invalid config sooner, right after we get that from the GuC but then we would have to expose some function from
xe_ggttto make that validation thatxe_gt_vfcode could use
Yeah, I'm seriously tempted to remove all xe_tile_sriov_gvf_ggtt*() calls, make the ggtt_init function call the requied calls directly, and rename xe_ggtt_shift_nodes to xe_ggtt_notify_vf_move(), and have it do the same calls there with a return value if sanitization fails.
Stashing the values, only to use them in only 1 other place is too complicated, should be OK to call directly, IMO.
Think I should go all the way here?
Kind regards,
~Maarten
PATCH v5 3/5 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 | 55 +++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_ggtt.h | 1 + drivers/gpu/drm/xe/xe_ggtt_types.h | 60 +----------------------------- 3 files changed, 58 insertions(+), 58 deletions(-)
drivers/gpu/drm/xe/xe_ggtt.c +55 -0
@@ -84,6 +84,61 @@ struct xe_ggtt_node {bool invalidate_on_remove; }; +/** +* 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; + +/** @ggtt_get_pte: Directly read from GGTT's PTE */ +u64 (*ggtt_get_pte)(struct xe_ggtt *ggtt,u64 addr); +}; + +/** +* 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; +/** @start: Start offset of GGTT */ +u64 start; +/** @size: Total usable 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.h +1 -0
@@ -9,6 +9,7 @@#include "xe_ggtt_types.h" struct drm_printer ; +struct xe_bo ;struct xe_tile ;struct drm_exec ;
drivers/gpu/drm/xe/xe_ggtt_types.h +2 -58
74 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v5 4/5 drm/xe: Make xe_ggtt_node_insert return a node
In reply to Maarten LankhorstThis extra step is easier to handle inside xe_ggtt.c and makes xe_ggtt_node_allocated a simple null check instead, as the intermediate state 'allocated but not inserted' is no longer used.
Privatize xe_ggtt_node_fini() as it's no longer used outside of xe_ggtt.c
--- drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c | 6 +- drivers/gpu/drm/xe/xe_ggtt.c | 75 +++++++++------------ drivers/gpu/drm/xe/xe_ggtt.h | 5 +- drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 24 +------ 4 files changed, 36 insertions(+), 74 deletions(-)
drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c +1 -5
@@ -38,12 +38,8 @@ static struct xe_bo *replacement_xe_managed_bo_create_pin_map(struct xe_device *if (flags &XE_BO_FLAG_GGTT ) {struct xe_ggtt *ggtt = tile->mem.ggtt; - bo->ggtt_node[tile->id] =xe_ggtt_node_init (ggtt); + bo->ggtt_node[tile->id] =xe_ggtt_node_insert (ggtt,xe_bo_size (bo),SZ_4K );KUNIT_ASSERT_NOT_ERR_OR_NULL (test, bo->ggtt_node[tile->id]); - -KUNIT_ASSERT_EQ (test,0 , -xe_ggtt_node_insert (bo->ggtt_node[tile->id], -xe_bo_size (bo),SZ_4K )); }return bo;
drivers/gpu/drm/xe/xe_ggtt.c +30 -45
95 lines not on this page · raw message
drivers/gpu/drm/xe/xe_ggtt.h +2 -3
@@ -18,13 +18,12 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt);int xe_ggtt_init_kunit (struct xe_ggtt *ggtt,u32 reserved,u32 size);int xe_ggtt_init (struct xe_ggtt *ggtt); -struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt); -void xe_ggtt_node_fini (struct xe_ggtt_node *node);void xe_ggtt_shift_nodes (struct xe_ggtt *ggtt,u64 new_base);u64 xe_ggtt_start (struct xe_ggtt *ggtt);u64 xe_ggtt_size (struct xe_ggtt *ggtt); -int xe_ggtt_node_insert (struct xe_ggtt_node *node,u32 size,u32 align); +struct xe_ggtt_node * +xe_ggtt_node_insert (struct xe_ggtt *ggtt,u32 size,u32 align);struct xe_ggtt_node * xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt, struct xe_bo *bo, u64 pte,
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c +3 -21
@@ -482,23 +482,9 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6return err ?: err2; } -static void pf_release_ggtt (struct xe_tile *tile,struct xe_ggtt_node *node) -{ -if (xe_ggtt_node_allocated (node)) { -/* -* explicit GGTT PTE assignment to the PF using xe_ggtt_assign() -* is redundant, as PTE will be implicitly re-assigned to PF by -* the xe_ggtt_clear() called by below xe_ggtt_remove_node(). -*/ -xe_ggtt_node_remove (node, false); - }else { -xe_ggtt_node_fini (node); - } -} -static void pf_release_vf_config_ggtt (struct xe_gt *gt,struct xe_gt_sriov_config *config) { -pf_release_ggtt (gt_to_tile (gt), config->ggtt_region); +xe_ggtt_node_remove (config->ggtt_region, false); config->ggtt_region =NULL ; }
@@ -533,14 +519,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)if (!size)return 0 ; - node =xe_ggtt_node_init (ggtt); + node =xe_ggtt_node_insert (ggtt, size, alignment);if (IS_ERR (node))return PTR_ERR (node); - err =xe_ggtt_node_insert (node, size, alignment); -if (unlikely (err)) - goto err; -xe_ggtt_assign (node, vfid);xe_gt_sriov_dbg_verbose (gt,"VF%u assigned GGTT %llx-%llx\n" , vfid,xe_ggtt_node_addr (node),xe_ggtt_node_addr (node) + size -1 );
@@ -552,7 +534,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size) config->ggtt_region = node;return 0 ; err: -pf_release_ggtt (tile, node); +xe_ggtt_node_remove (node, false);return err; }
Signature · 1 line
2.51.0
Re: [PATCH v5 4/5] drm/xe: Make xe_ggtt_node_insert return a node
Quoted 39 lines · Maarten Lankhorst
This extra step is easier to handle inside
xe_ggtt.cand makesxe_ggtt_node_allocateda simple null check instead, as the intermediate state 'allocated but not inserted' is no longer used.Privatize
xe_ggtt_node_fini()as it's no longer used outside ofxe_ggtt.cSigned-off-by Maarten Lankhorst <[email protected]>Reviewed-by Matthew Brost <[email protected]>--- drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c | 6 +- drivers/gpu/drm/xe/xe_ggtt.c | 75 +++++++++------------ drivers/gpu/drm/xe/xe_ggtt.h | 5 +- drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 24 +------ 4 files changed, 36 insertions(+), 74 deletions(-)drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c +1
-5@@ -38,12 +38,8 @@ static struct xe_bo *replacement_xe_managed_bo_create_pin_map(struct xe_device *if (flags &XE_BO_FLAG_GGTT ) {struct xe_ggtt *ggtt = tile->mem.ggtt; - bo->ggtt_node[tile->id] =xe_ggtt_node_init (ggtt); + bo->ggtt_node[tile->id] =xe_ggtt_node_insert (ggtt,xe_bo_size (bo),SZ_4K );KUNIT_ASSERT_NOT_ERR_OR_NULL (test, bo->ggtt_node[tile->id]); - -KUNIT_ASSERT_EQ (test,0 , -xe_ggtt_node_insert (bo->ggtt_node[tile->id], -xe_bo_size (bo),SZ_4K )); }return bo;drivers/gpu/drm/xe/xe_ggtt.c +0
-0
drivers/gpu/drm/xe/xe_ggtt.c static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt) · line 461
Quoted 4 lines
drivers/gpu/drm/xe/xe_ggtt.c +1
-0@@ -458,6 +458,11 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)mutex_unlock (&ggtt->lock); } +static void xe_ggtt_node_fini (struct xe_ggtt_node *node)
nit: since it's static, it doesn't need to have xe_ prefix (see below ggtt_node_remove)
Quoted 61 lines
drivers/gpu/drm/xe/xe_ggtt.c +8
-39+{ +kfree (node); +} +static void ggtt_node_remove (struct xe_ggtt_node *node) {struct xe_ggtt *ggtt = node->ggtt;@@ -613,43 +618,7 @@ static int xe_ggtt_node_insert_locked(struct xe_ggtt_node *node, mm_flags); } -/** -* xe_ggtt_node_insert - 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 -* -* It cannot be called without first having called xe_ggtt_init() once. -* -* Return: 0 on success or a negative error code on failure. -*/ -int xe_ggtt_node_insert (struct xe_ggtt_node *node,u32 size,u32 align) -{ -int ret; - -if (!node || !node->ggtt) -return -ENOENT ; - -mutex_lock (&node->ggtt->lock); - ret =xe_ggtt_node_insert_locked (node, size, align, -DRM_MM_INSERT_HIGH ); -mutex_unlock (&node->ggtt->lock); - -return ret; -} - -/** -* xe_ggtt_node_init - Initialize %xe_ggtt_node struct -* @ggtt: the &xe_ggtt where the new node will later be inserted/reserved. -* -* This function will allocate the struct %xe_ggtt_node and return its pointer. -* This struct will then be freed after the node removal upon xe_ggtt_node_remove() -* Having %xe_ggtt_node struct allocated doesn't mean that the node is already allocated -* in GGTT. Only xe_ggtt_node_insert() will ensure the node is inserted or reserved in GGTT. -* -* Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise. -**/ -struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt) +static struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt) {struct xe_ggtt_node *node =kzalloc (sizeof (*node),GFP_NOFS );@@ -663,16 +632,32 @@ 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 +* xe_ggtt_node_insert - Insert a &xe_ggtt_node into the GGTT +* @ggtt: the @ggtt into which the node should be inserted. +* @size: size of the node
drivers/gpu/drm/xe/xe_ggtt.c struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt) · line 642
Quoted 10 lines
drivers/gpu/drm/xe/xe_ggtt.c +4
-5+* @align: alignment constrain of the node * -* If anything went wrong with either xe_ggtt_node_insert() 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) +* Return: &xe_ggtt_node on success or a ERR_PTR on failure. +*/ +struct xe_ggtt_node *xe_ggtt_node_insert (struct xe_ggtt *ggtt,u32 size,u32 align)
wrong naming, this should be:
xe_ggtt_insert_node()
drivers/gpu/drm/xe/xe_ggtt.c struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt) · line 651
Quoted 10 lines
drivers/gpu/drm/xe/xe_ggtt.c +8
-1{ -kfree (node); +struct xe_ggtt_node *node; +int ret; + + node =xe_ggtt_node_init (ggtt); +if (IS_ERR (node)) +return node; + +mutex_lock (&ggtt->lock);
nit: since you've changed many other places to use guard() maybe here it should be scoped_guard() ? or do everything under guard() as both node_init/fini could be called under mutex
Quoted 86 lines
drivers/gpu/drm/xe/xe_ggtt.c +9
-0+ ret =xe_ggtt_node_insert_locked (node, size, align, +DRM_MM_INSERT_HIGH ); +mutex_unlock (&ggtt->lock); +if (ret) { +xe_ggtt_node_fini (node); +return ERR_PTR (ret); + } + +return node; }/** drivers/gpu/drm/xe/xe_ggtt.h +2
-3@@ -18,13 +18,12 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt);int xe_ggtt_init_kunit (struct xe_ggtt *ggtt,u32 reserved,u32 size);int xe_ggtt_init (struct xe_ggtt *ggtt); -struct xe_ggtt_node *xe_ggtt_node_init (struct xe_ggtt *ggtt); -void xe_ggtt_node_fini (struct xe_ggtt_node *node);void xe_ggtt_shift_nodes (struct xe_ggtt *ggtt,u64 new_base);u64 xe_ggtt_start (struct xe_ggtt *ggtt);u64 xe_ggtt_size (struct xe_ggtt *ggtt); -int xe_ggtt_node_insert (struct xe_ggtt_node *node,u32 size,u32 align); +struct xe_ggtt_node * +xe_ggtt_node_insert (struct xe_ggtt *ggtt,u32 size,u32 align);struct xe_ggtt_node * xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt, struct xe_bo *bo, u64 pte,drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c +3
-21@@ -482,23 +482,9 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6return err ?: err2; } -static void pf_release_ggtt (struct xe_tile *tile,struct xe_ggtt_node *node) -{ -if (xe_ggtt_node_allocated (node)) { -/* -* explicit GGTT PTE assignment to the PF using xe_ggtt_assign() -* is redundant, as PTE will be implicitly re-assigned to PF by -* the xe_ggtt_clear() called by below xe_ggtt_remove_node(). -*/ -xe_ggtt_node_remove (node, false); - }else { -xe_ggtt_node_fini (node); - } -} -static void pf_release_vf_config_ggtt (struct xe_gt *gt,struct xe_gt_sriov_config *config) { -pf_release_ggtt (gt_to_tile (gt), config->ggtt_region); +xe_ggtt_node_remove (config->ggtt_region, false); config->ggtt_region =NULL ; }@@ -533,14 +519,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)if (!size)return 0 ; - node =xe_ggtt_node_init (ggtt); + node =xe_ggtt_node_insert (ggtt, size, alignment);if (IS_ERR (node))return PTR_ERR (node); - err =xe_ggtt_node_insert (node, size, alignment); -if (unlikely (err)) - goto err; -xe_ggtt_assign (node, vfid);xe_gt_sriov_dbg_verbose (gt,"VF%u assigned GGTT %llx-%llx\n" , vfid,xe_ggtt_node_addr (node),xe_ggtt_node_addr (node) + size -1 );@@ -552,7 +534,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size) config->ggtt_region = node;return 0 ; err: -pf_release_ggtt (tile, node); +xe_ggtt_node_remove (node, false);return err; }
PATCH v5 5/5 drm/xe: Remove xe_ggtt_node_allocated
In reply to Maarten LankhorstWith the intermediate state gone, no longer useful. Just check against NULL where needed.
--- drivers/gpu/drm/xe/display/xe_fb_pin.c | 3 +-- drivers/gpu/drm/xe/xe_ggtt.c | 17 ----------------- drivers/gpu/drm/xe/xe_ggtt.h | 1 - drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 12 ++++++------ 4 files changed, 7 insertions(+), 26 deletions(-)
drivers/gpu/drm/xe/display/xe_fb_pin.c +1 -2
@@ -352,8 +352,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)if (vma->dpt)xe_bo_unpin_map_no_vm (vma->dpt); -else if (!xe_ggtt_node_allocated (vma->bo->ggtt_node[tile_id]) || - vma->bo->ggtt_node[tile_id] != vma->node) +else if (vma->bo->ggtt_node[tile_id] != vma->node)xe_ggtt_node_remove (vma->node, false);ttm_bo_reserve (&vma->bo->ttm, false, false,NULL );
drivers/gpu/drm/xe/xe_ggtt.c +0 -17
@@ -660,20 +660,6 @@ struct xe_ggtt_node *xe_ggtt_node_insert(struct xe_ggtt *ggtt, u32 size, u32 alireturn node; } -/** -* xe_ggtt_node_allocated - Check if node is allocated in GGTT -* @node: the &xe_ggtt_node to be inspected -* -* Return: True if allocated, False otherwise. -*/ -bool xe_ggtt_node_allocated (const struct xe_ggtt_node *node) -{ -if (!node || !node->ggtt) -return false; - -return drm_mm_node_allocated (&node->base); -} -/** * xe_ggtt_node_pt_size() - Get the size of page table entries needed to map a GGTT node. * @node: the &xe_ggtt_node
@@ -954,9 +940,6 @@ static void xe_ggtt_assign_locked(const struct xe_ggtt_node *node, u16 vfid)lockdep_assert_held (&ggtt->lock); -if (!xe_ggtt_node_allocated (node)) -return ; -while (start < end) { ggtt->pt_ops->ggtt_set_pte (ggtt, start, pte); start +=XE_PAGE_SIZE ;
drivers/gpu/drm/xe/xe_ggtt.h +0 -1
@@ -30,7 +30,6 @@ xe_ggtt_node_insert_transform(struct xe_ggtt *ggtt, u64 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);size_t xe_ggtt_node_pt_size (const struct xe_ggtt_node *node);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,struct drm_exec *exec);
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c +6 -6
@@ -279,7 +279,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config, {struct xe_ggtt_node *node = config->ggtt_region; -if (!xe_ggtt_node_allocated (node)) +if (!node)return 0 ;return encode_ggtt (cfg,xe_ggtt_node_addr (node),xe_ggtt_node_size (node), details);
@@ -503,7 +503,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size) size =round_up (size, alignment); -if (xe_ggtt_node_allocated (config->ggtt_region)) { +if (config->ggtt_region) { err =pf_distribute_config_ggtt (tile, vfid,0 ,0 );if (unlikely (err))return err;
@@ -514,7 +514,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)if (unlikely (err))return err; } -xe_gt_assert (gt, !xe_ggtt_node_allocated (config->ggtt_region)); +xe_gt_assert (gt, !config->ggtt_region);if (!size)return 0 ;
@@ -544,7 +544,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)struct xe_ggtt_node *node = config->ggtt_region;xe_gt_assert (gt,xe_gt_is_main_type (gt)); -return xe_ggtt_node_allocated (node) ?xe_ggtt_node_size (node) :0 ; +return node ?xe_ggtt_node_size (node) :0 ; }/**
@@ -2558,7 +2558,7 @@ int xe_gt_sriov_pf_config_release(struct xe_gt *gt, unsigned int vfid, bool forcstatic void pf_sanitize_ggtt (struct xe_ggtt_node *ggtt_region,unsigned int vfid) { -if (xe_ggtt_node_allocated (ggtt_region)) +if (ggtt_region)xe_ggtt_assign (ggtt_region, vfid); }
@@ -3017,7 +3017,7 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)for (n =1 ; n <= total_vfs; n++) { config = >->sriov.pf.vfs[n].config; -if (!xe_ggtt_node_allocated (config->ggtt_region)) +if (!config->ggtt_region)continue ; string_get_size(xe_ggtt_node_size(config->ggtt_region), 1, STRING_UNITS_2,
Signature · 1 line
2.51.0