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

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 suspend, runtime suspend and PCIe FLR preparation
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.

v4 (from Sashiko review):
- A PCIe FLR prepared through xe_device_suspend(flr) skips
  xe_gt_suspend(), so the delayed release was not flushed before the
  reset. The work could fire while the device is being reset and time
  out waiting for the sleep ACK, or a domain could stay marked awake in
  software after the FLR put it to sleep, making the next get skip the
  wake. Flush delayed release in xe_gt_flr_prepare(). It is flushed
  rather than stopped, as the device is used again after the FLR.
- Warn once if a delayed release is still outstanding at the points
  where the GT MMIO is about to become inaccessible (system suspend,
  hibernation, FLR preparation and runtime suspend). A new path that
  misses the flush is then caught in testing.
- Rebase on drm-xe-next (264ec299c700). Handle the change of
  drm_dev_unregister() to drm_dev_unplug() in the xe_device_probe()
  error path.

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           |  14 ++
 drivers/gpu/drm/xe/xe_force_wake.c       | 271 +++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_force_wake.h       |  43 +++-
 drivers/gpu/drm/xe/xe_force_wake_types.h |  48 ++++
 drivers/gpu/drm/xe/xe_gt.c               |  16 +-
 drivers/gpu/drm/xe/xe_pm.c               |   4 +
 drivers/gpu/drm/xe/xe_query.c            |   2 +-
 7 files changed, 365 insertions(+), 33 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-12-03  2:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 23:23 [PATCH v4 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries Zongyao Bai
2026-12-02 23:23 ` [PATCH v4 1/3] drm/xe/forcewake: add delayed release with hysteresis Zongyao Bai
2026-12-02 23:23 ` [PATCH v4 2/3] drm/xe/forcewake: flush delayed release at power and teardown boundaries Zongyao Bai
2026-12-02 23:23 ` [PATCH v4 3/3] drm/xe/query: use delayed forcewake release for engine-cycle queries Zongyao Bai
2026-12-02 23:35 ` ✗ CI.checkpatch: warning for drm/xe/forcewake: add delayed release for engine-cycle queries (rev3) Patchwork
2026-12-02 23:37 ` ✓ CI.KUnit: success " Patchwork
2026-12-03  0:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-12-03  2:50 ` [PATCH v4 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries Rodrigo Vivi

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.