]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe: Replace use of system_wq with tlb_inval->timeout_wq
authorMarco Crivellari <marco.crivellari@suse.com>
Mon, 12 Jan 2026 09:44:06 +0000 (10:44 +0100)
committerMatthew Brost <matthew.brost@intel.com>
Wed, 14 Jan 2026 07:39:09 +0000 (23:39 -0800)
This patch continues the effort to refactor workqueue APIs, which has begun
with the changes introducing new workqueues and a new alloc_workqueue flag:

   commit 128ea9f6ccfb ("workqueue: Add system_percpu_wq and system_dfl_wq")
   commit 930c2ea566af ("workqueue: Add new WQ_PERCPU flag")

The point of the refactoring is to eventually alter the default behavior of
workqueues to become unbound by default so that their workload placement is
optimized by the scheduler.

Before that to happen, workqueue users must be converted to the better named
new workqueues with no intended behaviour changes:

   system_wq -> system_percpu_wq
   system_unbound_wq -> system_dfl_wq

This way the old obsolete workqueues (system_wq, system_unbound_wq) can be
removed in the future.

After a carefully evaluation, because this is the fence signaling path, we
changed the code in order to use one of the Xe's workqueue.

So, a new workqueue named 'timeout_wq' has been added to
'struct xe_tlb_inval' and has been initialized with 'gt->ordered_wq'
changing the system_wq uses with tlb_inval->timeout_wq.

Link: https://lore.kernel.org/all/20250221112003.1dSuoGyc@linutronix.de/
Suggested-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Marco Crivellari <marco.crivellari@suse.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260112094406.82641-1-marco.crivellari@suse.com
drivers/gpu/drm/xe/xe_tlb_inval.c
drivers/gpu/drm/xe/xe_tlb_inval_types.h

index dec0422481648071a0775887a0ebd885c8f69bff..61b99cf0a7338e5ac08241866d2a6208c3d6baf4 100644 (file)
@@ -94,7 +94,7 @@ static void xe_tlb_inval_fence_timeout(struct work_struct *work)
                xe_tlb_inval_fence_signal(fence);
        }
        if (!list_empty(&tlb_inval->pending_fences))
-               queue_delayed_work(system_wq, &tlb_inval->fence_tdr,
+               queue_delayed_work(tlb_inval->timeout_wq, &tlb_inval->fence_tdr,
                                   timeout_delay);
        spin_unlock_irq(&tlb_inval->pending_lock);
 }
@@ -146,6 +146,10 @@ int xe_gt_tlb_inval_init_early(struct xe_gt *gt)
        if (IS_ERR(tlb_inval->job_wq))
                return PTR_ERR(tlb_inval->job_wq);
 
+       tlb_inval->timeout_wq = gt->ordered_wq;
+       if (IS_ERR(tlb_inval->timeout_wq))
+               return PTR_ERR(tlb_inval->timeout_wq);
+
        /* XXX: Blindly setting up backend to GuC */
        xe_guc_tlb_inval_init_early(&gt->uc.guc, tlb_inval);
 
@@ -240,7 +244,7 @@ static void xe_tlb_inval_fence_prep(struct xe_tlb_inval_fence *fence)
        list_add_tail(&fence->link, &tlb_inval->pending_fences);
 
        if (list_is_singular(&tlb_inval->pending_fences))
-               queue_delayed_work(system_wq, &tlb_inval->fence_tdr,
+               queue_delayed_work(tlb_inval->timeout_wq, &tlb_inval->fence_tdr,
                                   tlb_inval->ops->timeout_delay(tlb_inval));
        spin_unlock_irq(&tlb_inval->pending_lock);
 
@@ -399,7 +403,7 @@ void xe_tlb_inval_done_handler(struct xe_tlb_inval *tlb_inval, int seqno)
        }
 
        if (!list_empty(&tlb_inval->pending_fences))
-               mod_delayed_work(system_wq,
+               mod_delayed_work(tlb_inval->timeout_wq,
                                 &tlb_inval->fence_tdr,
                                 tlb_inval->ops->timeout_delay(tlb_inval));
        else
index 48d1503e8460c34648010340e483292c6043e977..3b089f90f0021c697ce400f63c380b5e01129b97 100644 (file)
@@ -109,6 +109,8 @@ struct xe_tlb_inval {
        struct workqueue_struct *job_wq;
        /** @tlb_inval.lock: protects TLB invalidation fences */
        spinlock_t lock;
+       /** @timeout_wq: schedules TLB invalidation fence timeouts */
+       struct workqueue_struct *timeout_wq;
 };
 
 /**