[PATCH 2/3] drm/xe: Create a xe_pm_runtime_resume_and_get variant for display
Gupta, Anshuman
anshuman.gupta at intel.com
Fri Mar 1 16:09:04 UTC 2024
> -----Original Message-----
> From: Vivi, Rodrigo <rodrigo.vivi at intel.com>
> Sent: Wednesday, February 28, 2024 12:07 AM
> To: intel-xe at lists.freedesktop.org
> Cc: Vivi, Rodrigo <rodrigo.vivi at intel.com>; Gupta, Anshuman
> <anshuman.gupta at intel.com>
> Subject: [PATCH 2/3] drm/xe: Create a xe_pm_runtime_resume_and_get
> variant for display
>
> Introduce the resume and get to fulfill the display need for checking if the
> device was actually resumed (or it is awake) and the reference was taken.
>
> Then we can convert the remaining cases to a void function and have individual
> functions for individual cases.
>
> 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.
>
> Cc: Anshuman Gupta <anshuman.gupta at intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
Reviewed-by: Anshuman Gupta <anshuman.gupta at intel.com>
> ---
> .../gpu/drm/xe/compat-i915-headers/i915_drv.h | 6 +-----
> drivers/gpu/drm/xe/xe_pm.c | 17 +++++++++++++++++
> drivers/gpu/drm/xe/xe_pm.h | 1 +
> 3 files changed, 19 insertions(+), 5 deletions(-)
>
> 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 ad5864d1dd74..fef969112b1d 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_drv.h
> @@ -166,11 +166,7 @@ static inline intel_wakeref_t
> intel_runtime_pm_get(struct xe_runtime_pm *pm) {
> struct xe_device *xe = container_of(pm, struct xe_device,
> runtime_pm);
>
> - if (xe_pm_runtime_get(xe) < 0) {
> - xe_pm_runtime_put(xe);
> - return 0;
> - }
> - return 1;
> + return xe_pm_runtime_resume_and_get(xe);
> }
>
> static inline intel_wakeref_t intel_runtime_pm_get_if_in_use(struct
> xe_runtime_pm *pm) diff --git a/drivers/gpu/drm/xe/xe_pm.c
> b/drivers/gpu/drm/xe/xe_pm.c index 7d7df78f3a2f..3e13a666fcc7 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -474,6 +474,23 @@ bool xe_pm_runtime_get_if_in_use(struct xe_device
> *xe)
> return pm_runtime_get_if_in_use(xe->drm.dev) > 0; }
>
> +/**
> + * xe_pm_runtime_resume_and_get - Resume, then get a runtime_pm ref if
> awake.
> + * @xe: xe device instance
> + *
> + * Returns: True if device is awake and the reference was taken, false
> otherwise.
> + */
> +bool xe_pm_runtime_resume_and_get(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_resume_and_get(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
> bb4723a98405..29c20099a3f9 100644
> --- a/drivers/gpu/drm/xe/xe_pm.h
> +++ b/drivers/gpu/drm/xe/xe_pm.h
> @@ -31,6 +31,7 @@ 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);
> +bool xe_pm_runtime_resume_and_get(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);
> --
> 2.43.2
More information about the Intel-xe
mailing list