All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v3 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries
@ 2026-12-01 23:07 Zongyao Bai
  2026-12-01 23:07 ` [RESEND PATCH v3 1/3] drm/xe/forcewake: add delayed release with hysteresis Zongyao Bai
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Zongyao Bai @ 2026-12-01 23:07 UTC (permalink / raw)
  To: intel-xe; +Cc: jia.yao, rodrigo.vivi, Zongyao Bai

RESEND: add the per-patch changelog to the commit messages, no code
change.

Engine-cycle queries are issued repeatedly by profilers such as VTune
and PTI to correlate CPU and GPU timestamps, for example through Level
Zero zeDeviceGetGlobalTimestamps(). Each query wakes the engine
forcewake domain and puts it to sleep again, and waiting for both
acknowledgments dominates the query latency.

This series adds an opt-in delayed release to forcewake. After the
final reference to a domain is dropped with xe_force_wake_put_delay(),
the domain stays awake for a short hold time, and a get within that
time reuses it without another wake request or ACK wait. The domain is
put to sleep from a delayed work in process context, so the sleep ACK
is waited for as in a regular put. The work sleeps only domains whose
hold time expired and that are still unreferenced, and requeues itself
for the rest. The hold time is 5 ms, and never less than two jiffies.

Delayed release must not outlive the device being powered off, reset
or removed. System and runtime suspend flush it: the pending work is
canceled and the held domains are put to sleep, while delayed release
stays available after resume. GT shutdown, device removal and
post-registration probe failure stop it: the work is disabled for good,
and a later delayed put puts the domain to sleep right away.

Only engine-cycle queries opt in. All other forcewake users keep
releasing immediately.

v3 (all from Sashiko review):
- xe_pm_runtime_get_if_active() only returns true/false, so the delayed
  release work could not tell "suspend in progress" from "runtime PM
  disabled" and returned early in both. Use pm_runtime_get_if_active()
  instead and do not drop the work while a runtime suspend is in
  progress. The work never resumes the device and handles three cases:
  a. runtime PM active: put the expired domains to sleep as before.
  b. runtime suspend in progress: requeue and retry later.
     b1. If the suspend completes, xe_force_wake_flush() cancels the
         work and settles the delayed domains.
     b2. If it aborts, the device returns to RPM_ACTIVE and the next
         run puts the expired domains to sleep.
  c. runtime PM disabled (e.g. CONFIG_PM=n): the device stays powered,
     so release the domains without a runtime PM reference.

- Do not count domains in delayed release as held in
  xe_force_wake_assert_held(), since they are awake with no reference
  and may be put to sleep by the delayed release work at any time.


v2 (all suggested by Rodrigo Vivi):
- Define the hold time in milliseconds and convert it with
  msecs_to_jiffies(), keeping it at least two jiffies. (Rodrigo)
- Pass the hold time to __xe_force_wake_put() instead of a bool, with
  0 meaning an immediate release. (Rodrigo)
- Replace the queue_delayed_work()/delayed_work_pending() check with a
  delayed_enabled flag protected by the forcewake lock and cleared by
  xe_force_wake_stop(). (Rodrigo)
- Use xe_pm_runtime_get_if_active() in the delayed work instead of
  asserting that the device is not runtime suspended. (Rodrigo)
- Rebase on drm-xe-next (4af7fae27dc6).

Zongyao Bai (3):
  drm/xe/forcewake: add delayed release with hysteresis
  drm/xe/forcewake: flush delayed release at power and teardown
    boundaries
  drm/xe/query: use delayed forcewake release for engine-cycle queries

 drivers/gpu/drm/xe/xe_device.c           |  11 +
 drivers/gpu/drm/xe/xe_force_wake.c       | 245 ++++++++++++++++++++---
 drivers/gpu/drm/xe/xe_force_wake.h       |  42 +++-
 drivers/gpu/drm/xe/xe_force_wake_types.h |  48 +++++
 drivers/gpu/drm/xe/xe_gt.c               |  15 +-
 drivers/gpu/drm/xe/xe_query.c            |   2 +-
 6 files changed, 330 insertions(+), 33 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-12-02 17:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 23:07 [RESEND PATCH v3 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries Zongyao Bai
2026-12-01 23:07 ` [RESEND PATCH v3 1/3] drm/xe/forcewake: add delayed release with hysteresis Zongyao Bai
2026-12-01 23:30   ` sashiko-bot
2026-12-01 23:07 ` [RESEND PATCH v3 2/3] drm/xe/forcewake: flush delayed release at power and teardown boundaries Zongyao Bai
2026-12-01 23:24   ` sashiko-bot
2026-12-02  0:18     ` Bai, Zongyao
2026-12-02 17:42       ` Rodrigo Vivi
2026-12-01 23:07 ` [RESEND PATCH v3 3/3] drm/xe/query: use delayed forcewake release for engine-cycle queries Zongyao Bai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.