mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
drm/xe: Guard page-fault worker with runtime PM check
During VM teardown, the VM's runtime PM reference is dropped
asynchronously, allowing the device to autosuspend while stale page
faults belonging to the now-dead VM are still queued. When the
page-fault worker later tries to ack one of these, it calls into
guc_ct_send_locked() on an already-suspended device, tripping:
Assertion `!xe_pm_runtime_suspended(xe)` failed!
WARNING at xe_device.c:1267 xe_device_assert_mem_access+0x11c/0x140 [xe]
A live VM/exec queue always holds a PM reference while it has
outstanding work, so if the device is suspended at ack time, the
owning context is already gone and the fault is stale.
Take a runtime PM reference across the entire pagefault
queue worker to safely deliver acks for torn-down VMs.
v3:
- Move PM ref to the generic xe_pagefault_queue_work using
guard(xe_pm_runtime)(xe) instead of tracking it in the GuC
backend(Matt Brost).
v2:
- Hold PM ref across the entire batch (begin/end) instead of per-ack.
This prevents the device from autosuspending mid-batch, which would
leave write_only acks written but the end flush skipped, and skip
counter++, desyncing the cadence check.(Himal)
- Add a comment explaining stale faults.(Himal)
Fixes: f289f78071 ("drm/xe: Add xe_guc_pagefault layer")
Signed-off-by: Varun Gupta <varun.gupta@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patch.msgid.link/20260907050011.497181-2-varun.gupta@intel.com
Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
(cherry picked from commit fcc2431d2213dc4d04250c4f1ae87d9c3ae0d455)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
[Rodrigo: Added xe_device struct for compatibility while cherry-picking]
This commit is contained in:
parent
df2908090c
commit
20fce5b34b
|
|
@ -16,6 +16,7 @@
|
|||
#include "xe_hw_engine.h"
|
||||
#include "xe_pagefault.h"
|
||||
#include "xe_pagefault_types.h"
|
||||
#include "xe_pm.h"
|
||||
#include "xe_svm.h"
|
||||
#include "xe_trace_bo.h"
|
||||
#include "xe_vm.h"
|
||||
|
|
@ -292,9 +293,17 @@ static void xe_pagefault_queue_work(struct work_struct *w)
|
|||
{
|
||||
struct xe_pagefault_queue *pf_queue =
|
||||
container_of(w, typeof(*pf_queue), worker);
|
||||
struct xe_device *xe = pf_queue->xe;
|
||||
struct xe_pagefault pf;
|
||||
unsigned long threshold;
|
||||
|
||||
/*
|
||||
* A live VM holds a PM reference, but a torn-down VM does not.
|
||||
* Guard the entire worker loop to safely drain stale faults and
|
||||
* prevent autosuspends from desyncing batched CT flushes.
|
||||
*/
|
||||
guard(xe_pm_runtime)(xe);
|
||||
|
||||
#define USM_QUEUE_MAX_RUNTIME_MS 20
|
||||
threshold = jiffies + msecs_to_jiffies(USM_QUEUE_MAX_RUNTIME_MS);
|
||||
|
||||
|
|
@ -365,6 +374,7 @@ static int xe_pagefault_queue_init(struct xe_device *xe,
|
|||
drm_dbg(&xe->drm, "xe_pagefault_entry_size=%d, total_num_eus=%d, pf_queue->size=%u",
|
||||
xe_pagefault_entry_size(), total_num_eus, pf_queue->size);
|
||||
|
||||
pf_queue->xe = xe;
|
||||
spin_lock_init(&pf_queue->lock);
|
||||
INIT_WORK(&pf_queue->worker, xe_pagefault_queue_work);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <linux/workqueue.h>
|
||||
|
||||
struct xe_device;
|
||||
struct xe_gt;
|
||||
struct xe_pagefault;
|
||||
|
||||
|
|
@ -118,6 +119,8 @@ struct xe_pagefault {
|
|||
* queue to absorb the device’s worst-case number of outstanding faults.
|
||||
*/
|
||||
struct xe_pagefault_queue {
|
||||
/** @xe: Back-pointer to the Xe device */
|
||||
struct xe_device *xe;
|
||||
/**
|
||||
* @data: Data in queue containing struct xe_pagefault, protected by
|
||||
* @lock
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user