mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/xe: Move GGTT lock init to alloc
The GGTT lock is needed very early during GT initialization for a VF; move the GGTT lock initialization to the allocation phase. v8: - Rework function structure (Michal) Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://lore.kernel.org/r/20251008214532.3442967-13-matthew.brost@intel.com
This commit is contained in:
@@ -159,6 +159,16 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
|
||||
}
|
||||
}
|
||||
|
||||
static void primelockdep(struct xe_ggtt *ggtt)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_LOCKDEP))
|
||||
return;
|
||||
|
||||
fs_reclaim_acquire(GFP_KERNEL);
|
||||
might_lock(&ggtt->lock);
|
||||
fs_reclaim_release(GFP_KERNEL);
|
||||
}
|
||||
|
||||
/**
|
||||
* xe_ggtt_alloc - Allocate a GGTT for a given &xe_tile
|
||||
* @tile: &xe_tile
|
||||
@@ -169,9 +179,19 @@ static void xe_ggtt_clear(struct xe_ggtt *ggtt, u64 start, u64 size)
|
||||
*/
|
||||
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;
|
||||
struct xe_device *xe = tile_to_xe(tile);
|
||||
struct xe_ggtt *ggtt;
|
||||
|
||||
ggtt = drmm_kzalloc(&xe->drm, sizeof(*ggtt), GFP_KERNEL);
|
||||
if (!ggtt)
|
||||
return NULL;
|
||||
|
||||
if (drmm_mutex_init(&xe->drm, &ggtt->lock))
|
||||
return NULL;
|
||||
|
||||
primelockdep(ggtt);
|
||||
ggtt->tile = tile;
|
||||
|
||||
return ggtt;
|
||||
}
|
||||
|
||||
@@ -180,7 +200,6 @@ static void ggtt_fini_early(struct drm_device *drm, void *arg)
|
||||
struct xe_ggtt *ggtt = arg;
|
||||
|
||||
destroy_workqueue(ggtt->wq);
|
||||
mutex_destroy(&ggtt->lock);
|
||||
drm_mm_takedown(&ggtt->mm);
|
||||
}
|
||||
|
||||
@@ -198,16 +217,6 @@ void xe_ggtt_might_lock(struct xe_ggtt *ggtt)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void primelockdep(struct xe_ggtt *ggtt)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_LOCKDEP))
|
||||
return;
|
||||
|
||||
fs_reclaim_acquire(GFP_KERNEL);
|
||||
might_lock(&ggtt->lock);
|
||||
fs_reclaim_release(GFP_KERNEL);
|
||||
}
|
||||
|
||||
static const struct xe_ggtt_pt_ops xelp_pt_ops = {
|
||||
.pte_encode_flags = xelp_ggtt_pte_flags,
|
||||
.ggtt_set_pte = xe_ggtt_set_pte,
|
||||
@@ -227,8 +236,6 @@ static void __xe_ggtt_init_early(struct xe_ggtt *ggtt, u32 reserved)
|
||||
{
|
||||
drm_mm_init(&ggtt->mm, reserved,
|
||||
ggtt->size - reserved);
|
||||
mutex_init(&ggtt->lock);
|
||||
primelockdep(ggtt);
|
||||
}
|
||||
|
||||
int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size)
|
||||
|
||||
Reference in New Issue
Block a user