[RFC 10/20] drm/xe: Sort some xe_pm_runtime related functions

Matthew Auld matthew.auld at intel.com
Tue Jan 9 11:26:22 UTC 2024


On 28/12/2023 02:12, Rodrigo Vivi wrote:
> No functional change. Just organizing the file a bit better
> 
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi at intel.com>
> ---
>   drivers/gpu/drm/xe/xe_pm.c | 42 +++++++++++++++++++-------------------
>   drivers/gpu/drm/xe/xe_pm.h |  4 ++--
>   2 files changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
> index f599707413f18..3594e707606ce 100644
> --- a/drivers/gpu/drm/xe/xe_pm.c
> +++ b/drivers/gpu/drm/xe/xe_pm.c
> @@ -387,6 +387,23 @@ int xe_pm_runtime_resume(struct xe_device *xe)
>   	return err;
>   }
>   
> +/**
> + * 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 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;

Nit: Formatting looks off here.

> +}
> +
>   /**
>    * xe_pm_runtime_get - Get a runtime_pm reference and resume synchronously
>    * @xe: xe device instance
> @@ -401,16 +418,6 @@ void xe_pm_runtime_get(struct xe_device *xe)
>   	pm_runtime_resume(xe->drm.dev);
>   }
>   
> -/**
> - * xe_pm_runtime_put - Put the runtime_pm reference back and mark as idle
> - * @xe: xe device instance
> - */
> -void xe_pm_runtime_put(struct xe_device *xe)
> -{
> -	pm_runtime_mark_last_busy(xe->drm.dev);
> -	pm_runtime_put(xe->drm.dev);
> -}
> -
>   /**
>    * xe_pm_runtime_get_sync - Get a runtime_pm reference and resume synchronously
>    * @xe: xe device instance
> @@ -456,20 +463,13 @@ bool xe_pm_runtime_get_if_in_use(struct xe_device *xe)
>   }
>   
>   /**
> - * xe_pm_runtime_resume_and_get - Resume, then get a runtime_pm ref if awake.
> + * xe_pm_runtime_put - Put the runtime_pm reference back and mark as idle
>    * @xe: xe device instance
> - *
> - * Returns: True if device is awake and the the reference was taken, false otherwise.
>    */
> -bool xe_pm_runtime_resume_and_get(struct xe_device *xe)
> +void xe_pm_runtime_put(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;
> +	pm_runtime_mark_last_busy(xe->drm.dev);
> +	pm_runtime_put(xe->drm.dev);
>   }
>   
>   /**
> diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h
> index d0e6011a80688..fc82a1466453b 100644
> --- a/drivers/gpu/drm/xe/xe_pm.h
> +++ b/drivers/gpu/drm/xe/xe_pm.h
> @@ -25,12 +25,12 @@ void xe_pm_runtime_fini(struct xe_device *xe);
>   bool xe_pm_runtime_suspended(struct xe_device *xe);
>   int xe_pm_runtime_suspend(struct xe_device *xe);
>   int xe_pm_runtime_resume(struct xe_device *xe);
> +bool xe_pm_runtime_resume_and_get(struct xe_device *xe);
>   void xe_pm_runtime_get(struct xe_device *xe);
>   int xe_pm_runtime_get_sync(struct xe_device *xe);
> -void 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_runtime_put(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);


More information about the Intel-xe mailing list