[igt-dev] [PATCH 4/7] drm/lease: Check for lessor outside of locks

Boris Brezillon boris.brezillon at collabora.com
Thu Mar 14 08:07:25 UTC 2019


On Thu, 28 Feb 2019 15:49:07 +0100
Daniel Vetter <daniel.vetter at ffwll.ch> wrote:

> The lessor is invariant over a lifetime of a lease, we don't have to
> grab any locks for that. Speeds up the common case of not being a lease.
> 
> Cc: Keith Packard <keithp at keithp.com>
> Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
> ---
>  drivers/gpu/drm/drm_lease.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_lease.c b/drivers/gpu/drm/drm_lease.c
> index cce5d9dd52ff..694ff363a90b 100644
> --- a/drivers/gpu/drm/drm_lease.c
> +++ b/drivers/gpu/drm/drm_lease.c
> @@ -111,7 +111,7 @@ static bool _drm_has_leased(struct drm_master *master, int id)
>   */
>  bool _drm_lease_held(struct drm_file *file_priv, int id)
>  {
> -	if (file_priv == NULL || file_priv->master == NULL)
> +	if (!file_priv || !file_priv->master)

Looks like you're doing unrelated cosmetic changes in the same patch.
Maybe mention that in the commit message, or move that to a separate
patch.

>  		return true;
>  
>  	return _drm_lease_held_master(file_priv->master, id);
> @@ -133,7 +133,7 @@ bool drm_lease_held(struct drm_file *file_priv, int id)
>  	struct drm_master *master;
>  	bool ret;
>  
> -	if (file_priv == NULL || file_priv->master == NULL)
> +	if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>  		return true;
>  
>  	master = file_priv->master;
> @@ -159,7 +159,7 @@ uint32_t drm_lease_filter_crtcs(struct drm_file *file_priv, uint32_t crtcs_in)
>  	int count_in, count_out;
>  	uint32_t crtcs_out = 0;
>  
> -	if (file_priv == NULL || file_priv->master == NULL)
> +	if (!file_priv || !file_priv->master || !file_priv->master->lessor)
>  		return crtcs_in;
>  
>  	master = file_priv->master;

Couldn't we also remove the if (master->lessor) check done in
_drm_lease_held_master()?


More information about the igt-dev mailing list