All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Zongyao Bai <zongyao.bai@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH v4 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries
Date: Wed, 2 Dec 2026 21:50:03 -0500	[thread overview]
Message-ID: <axDY24EgrjlRs2-r@intel.com> (raw)
In-Reply-To: <20261202232308.917828-1-zongyao.bai@intel.com>

On Wed, Dec 02, 2026 at 11:23:05PM +0000, Zongyao Bai wrote:
> 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.

pushed to drm-xe-next, thanks

> 
> 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
> 

      parent reply	other threads:[~2026-12-03  2:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Rodrigo Vivi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axDY24EgrjlRs2-r@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=zongyao.bai@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.