Skip to content

Commit 34bb7b8

Browse files
author
Thomas Hellström
committed
drm/xe: Use xe_pm_runtime_get in xe_bo_move() if reclaim-safe.
xe_bo_move() might be called in the TTM swapout path from validation by another TTM device. If so, we are not likely to have a RPM reference. So iff xe_pm_runtime_get() is safe to call from reclaim, use it instead of xe_pm_runtime_get_noresume(). Strictly this is currently needed only if handle_system_ccs is true, but use xe_pm_runtime_get() if possible anyway to increase test coverage. At the same time warn if handle_system_ccs is true and we can't call xe_pm_runtime_get() from reclaim context. This will likely trip if someone tries to enable SRIOV on LNL, without fixing Xe SRIOV runtime resume / suspend. Cc: Rodrigo Vivi <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Matthew Auld <[email protected]> Signed-off-by: Thomas Hellström <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 8da1944 commit 34bb7b8

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,16 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
758758

759759
xe_assert(xe, migrate);
760760
trace_xe_bo_move(bo, new_mem->mem_type, old_mem_type, move_lacks_source);
761-
xe_pm_runtime_get_noresume(xe);
761+
if (xe_rpm_reclaim_safe(xe)) {
762+
/*
763+
* We might be called through swapout in the validation path of
764+
* another TTM device, so unconditionally acquire rpm here.
765+
*/
766+
xe_pm_runtime_get(xe);
767+
} else {
768+
drm_WARN_ON(&xe->drm, handle_system_ccs);
769+
xe_pm_runtime_get_noresume(xe);
770+
}
762771

763772
if (xe_bo_is_pinned(bo) && !xe_bo_is_user(bo)) {
764773
/*

drivers/gpu/drm/xe/xe_pm.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,14 @@ static struct lockdep_map xe_pm_runtime_nod3cold_map = {
7979
};
8080
#endif
8181

82-
static bool __maybe_unused xe_rpm_reclaim_safe(const struct xe_device *xe)
82+
/**
83+
* xe_rpm_reclaim_safe() - Whether runtime resume can be done from reclaim context
84+
* @xe: The xe device.
85+
*
86+
* Return: true if it is safe to runtime resume from reclaim context.
87+
* false otherwise.
88+
*/
89+
bool xe_rpm_reclaim_safe(const struct xe_device *xe)
8390
{
8491
return !xe->d3cold.capable && !xe->info.has_sriov;
8592
}

drivers/gpu/drm/xe/xe_pm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
3131
void xe_pm_assert_unbounded_bridge(struct xe_device *xe);
3232
int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold);
3333
void xe_pm_d3cold_allowed_toggle(struct xe_device *xe);
34+
bool xe_rpm_reclaim_safe(const struct xe_device *xe);
3435
struct task_struct *xe_pm_read_callback_task(struct xe_device *xe);
3536
int xe_pm_module_init(void);
3637

0 commit comments

Comments
 (0)