From: Matthew Auld <matthew.auld@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>, intel-xe@lists.freedesktop.org
Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Subject: Re: [PATCH 1/3] drm/xe: Fix display runtime_pm handling
Date: Fri, 1 Mar 2024 17:47:25 +0000 [thread overview]
Message-ID: <37b53465-2c4b-4099-913d-1cdf6ce3e576@intel.com> (raw)
In-Reply-To: <20240227183725.505699-1-rodrigo.vivi@intel.com>
On 27/02/2024 18:37, Rodrigo Vivi wrote:
> i915's intel_runtime_pm_get_if_in_use actually calls the
> pm_runtime_get_if_active() with ign_usage_count = false, but Xe
> was erroneously calling it with true because of the mem_access cases.
>
> This can lead to unnecessary references getting hold here and device
> never getting into the runtime suspended state.
>
> Let's use directly the 'if_in_use' function provided by linux/pm_runtime.
>
> Also, already start this new function protected from the runtime
> recursion, since runtime_pm will need to call for display functions
> for a proper D3Cold flow.
>
> v2: Update commit message based on Matt's feedback.
> Fix return condition of pm_runtime_get_if_in_use (Matt)
>
> Cc: Anshuman Gupta <anshuman.gupta@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Assuming this is applied on top of: drm/xe: Convert
xe_pm_runtime_{get,put} to void and protect from recursion,
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
> ---
> .../gpu/drm/xe/compat-i915-headers/i915_drv.h | 2 +-
> drivers/gpu/drm/xe/xe_pm.c | 17 +++++++++++++++++
> drivers/gpu/drm/xe/xe_pm.h | 1 +
> 3 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
> index 420eba0e4be0..ad5864d1dd74 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
> @@ -177,7 +177,7 @@ static inline intel_wakeref_t intel_runtime_pm_get_if_in_use(struct xe_runtime_p
> {
> struct xe_device *xe = container_of(pm, struct xe_device, runtime_pm);
>
> - return xe_pm_runtime_get_if_active(xe);
> + return xe_pm_runtime_get_if_in_use(xe);
> }
>
> static inline void intel_runtime_pm_put_unchecked(struct xe_runtime_pm *pm)
> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> index b5511e3c3153..7d7df78f3a2f 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -457,6 +457,23 @@ int xe_pm_runtime_get_if_active(struct xe_device *xe)
> return pm_runtime_get_if_active(xe->drm.dev, true);
> }
>
> +/**
> + * xe_pm_runtime_get_if_in_use - Get a runtime_pm reference and resume if needed
> + * @xe: xe device instance
> + *
> + * Returns: True if device is awake and the reference was taken, false otherwise.
> + */
> +bool xe_pm_runtime_get_if_in_use(struct xe_device *xe)
> +{
> + if (xe_pm_read_callback_task(xe) == current) {
> + /* The device is awake, grab the ref and move on */
> + pm_runtime_get_noresume(xe->drm.dev);
> + return true;
> + }
> +
> + return pm_runtime_get_if_in_use(xe->drm.dev) > 0;
> +}
> +
> /**
> * xe_pm_assert_unbounded_bridge - Disable PM on unbounded pcie parent bridge
> * @xe: xe device instance
> diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
> index 7f5884babb29..bb4723a98405 100644
> --- a/drivers/gpu/drm/xe/xe_pm.h
> +++ b/drivers/gpu/drm/xe/xe_pm.h
> @@ -30,6 +30,7 @@ int xe_pm_runtime_get(struct xe_device *xe);
> int xe_pm_runtime_get_ioctl(struct xe_device *xe);
> int xe_pm_runtime_put(struct xe_device *xe);
> int xe_pm_runtime_get_if_active(struct xe_device *xe);
> +bool xe_pm_runtime_get_if_in_use(struct xe_device *xe);
> void xe_pm_assert_unbounded_bridge(struct xe_device *xe);
> int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold);
> void xe_pm_d3cold_allowed_toggle(struct xe_device *xe);
next prev parent reply other threads:[~2024-03-01 17:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 18:37 [PATCH 1/3] drm/xe: Fix display runtime_pm handling Rodrigo Vivi
2024-02-27 18:37 ` [PATCH 2/3] drm/xe: Create a xe_pm_runtime_resume_and_get variant for display Rodrigo Vivi
2024-03-01 16:09 ` Gupta, Anshuman
2024-02-27 18:37 ` [PATCH 3/3] drm/xe: Prepare display for D3Cold Rodrigo Vivi
2024-02-27 18:50 ` ✓ CI.Patch_applied: success for series starting with [1/3] drm/xe: Fix display runtime_pm handling Patchwork
2024-02-27 18:50 ` ✓ CI.checkpatch: " Patchwork
2024-02-27 18:51 ` ✓ CI.KUnit: " Patchwork
2024-02-27 19:05 ` ✓ CI.Build: " Patchwork
2024-02-27 19:06 ` ✓ CI.Hooks: " Patchwork
2024-02-27 19:07 ` ✓ CI.checksparse: " Patchwork
2024-02-27 19:29 ` ✓ CI.BAT: " Patchwork
2024-03-01 17:47 ` Matthew Auld [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-03-01 18:05 [PATCH 1/3] " Rodrigo Vivi
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=37b53465-2c4b-4099-913d-1cdf6ce3e576@intel.com \
--to=matthew.auld@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=rodrigo.vivi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox