[Intel-gfx] [PATCH 1/8] drm/i915: Added is_intel_rpm_allowed helper

Gupta, Anshuman anshuman.gupta at intel.com
Thu Aug 4 06:09:42 UTC 2022



> -----Original Message-----
> From: Tangudu, Tilak <tilak.tangudu at intel.com>
> Sent: Thursday, July 21, 2022 3:30 PM
> To: Ewins, Jon <jon.ewins at intel.com>; Belgaumkar, Vinay
> <vinay.belgaumkar at intel.com>; Roper, Matthew D
> <matthew.d.roper at intel.com>; Wilson, Chris P <chris.p.wilson at intel.com>;
> Nikula, Jani <jani.nikula at intel.com>; Gupta, saurabhg
> <saurabhg.gupta at intel.com>; Vivi, Rodrigo <rodrigo.vivi at intel.com>; Gupta,
> Anshuman <anshuman.gupta at intel.com>; Nilawar, Badal
> <badal.nilawar at intel.com>; Tangudu, Tilak <tilak.tangudu at intel.com>; Deak,
> Imre <imre.deak at intel.com>; Iddamsetty, Aravind
> <aravind.iddamsetty at intel.com>; intel-gfx at lists.freedesktop.org
> Subject: [PATCH 1/8] drm/i915: Added is_intel_rpm_allowed helper
> 
> From: Tilak Tangudu <tilak.tangudu at intel.com>
> 
> Added is_intel_rpm_allowed function to query the runtime_pm status and
> disllow during suspending and resuming.
> 
> v2: Return -2 if runtime pm is not allowed in runtime_pm_get and skip wakeref
> release in runtime_pm_put if wakeref value is -2. - Jani N
> Signed-off-by: Tilak Tangudu <tilak.tangudu at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_runtime_pm.c | 23 ++++++++++++++++++++++-
> drivers/gpu/drm/i915/intel_runtime_pm.h |  1 +
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c
> b/drivers/gpu/drm/i915/intel_runtime_pm.c
> index 6ed5786bcd29..704beeeb560b 100644
> --- a/drivers/gpu/drm/i915/intel_runtime_pm.c
> +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
> @@ -113,7 +113,7 @@ static void untrack_intel_runtime_pm_wakeref(struct
> intel_runtime_pm *rpm,
>  	unsigned long flags, n;
>  	bool found = false;
> 
> -	if (unlikely(stack == -1))
> +	if (unlikely(stack == -1) || unlikely(stack == -2))
>  		return;
> 
>  	spin_lock_irqsave(&rpm->debug.lock, flags); @@ -320,6 +320,21 @@
> untrack_all_intel_runtime_pm_wakerefs(struct intel_runtime_pm *rpm)  }
> 
>  #endif
> +static int intel_runtime_pm_status(struct intel_runtime_pm *rpm) {
> +	return rpm->kdev->power.runtime_status; }
> +
> +bool is_intel_rpm_allowed(struct intel_runtime_pm *rpm) {
> +	int rpm_status;
> +
> +	rpm_status = intel_runtime_pm_status(rpm);
> +	if (rpm_status == RPM_RESUMING || rpm_status ==
> RPM_SUSPENDING)
AFAIR I have commented on first patch, we may need dev->power.lock here.
It is racy to test  kdev->power.runtime_status with PM core can change it any time. 
Please check the pm_runtime_status_suspended() kernel doc in include/linux/pm_runtime.h
Thanks,
Anshuman Gupta.
> +		return false;
> +	else
> +		return true;
> +}
> 
>  static void
>  intel_runtime_pm_acquire(struct intel_runtime_pm *rpm, bool wakelock) @@ -
> 354,6 +369,9 @@ static intel_wakeref_t __intel_runtime_pm_get(struct
> intel_runtime_pm *rpm,
>  						     runtime_pm);
>  	int ret;
> 
> +	if (!is_intel_rpm_allowed(rpm))
> +		return -2;
> +
>  	ret = pm_runtime_get_sync(rpm->kdev);
>  	drm_WARN_ONCE(&i915->drm, ret < 0,
>  		      "pm_runtime_get_sync() failed: %d\n", ret); @@ -490,6
> +508,9 @@ static void __intel_runtime_pm_put(struct intel_runtime_pm *rpm,
> 
>  	untrack_intel_runtime_pm_wakeref(rpm, wref);
> 
> +	if (wref == -2)
> +		return;
> +
>  	intel_runtime_pm_release(rpm, wakelock);
> 
>  	pm_runtime_mark_last_busy(kdev);
> diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.h
> b/drivers/gpu/drm/i915/intel_runtime_pm.h
> index d9160e3ff4af..99418c3a934a 100644
> --- a/drivers/gpu/drm/i915/intel_runtime_pm.h
> +++ b/drivers/gpu/drm/i915/intel_runtime_pm.h
> @@ -173,6 +173,7 @@ void intel_runtime_pm_init_early(struct
> intel_runtime_pm *rpm);  void intel_runtime_pm_enable(struct
> intel_runtime_pm *rpm);  void intel_runtime_pm_disable(struct
> intel_runtime_pm *rpm);  void intel_runtime_pm_driver_release(struct
> intel_runtime_pm *rpm);
> +bool is_intel_rpm_allowed(struct intel_runtime_pm *rpm);
> 
>  intel_wakeref_t intel_runtime_pm_get(struct intel_runtime_pm *rpm);
> intel_wakeref_t intel_runtime_pm_get_if_in_use(struct intel_runtime_pm
> *rpm);
> --
> 2.25.1



More information about the Intel-gfx mailing list