[RFC][PATCH 09/11] drm: Fix getconnector locking

Daniel Vetter daniel at ffwll.ch
Tue Mar 6 09:55:19 UTC 2018


On Tue, Feb 27, 2018 at 02:56:58PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> The edid is protected by mode_config.mutex so extend the locking to
> protect the property readout part as well.
> 
> Cc: Keith Packard <keithp at keithp.com>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Ehrm no, properties have their own locking and are safe.
drm_connector->edid is indeed protected by the mode_config.mutex, but
that's not the thing we're looking at here. Maybe we need to patch up the
struct drm_connector locking comments a bit to clarify this more?
-Daniel

> ---
>  drivers/gpu/drm/drm_connector.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 2bf19a37dbac..122060792b6f 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1624,15 +1624,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  			if (copy_to_user(mode_ptr + copied,
>  					 &u_mode, sizeof(u_mode))) {
>  				ret = -EFAULT;
> -				mutex_unlock(&dev->mode_config.mutex);
> -
>  				goto out;
>  			}
>  			copied++;
>  		}
>  	}
>  	out_resp->count_modes = mode_count;
> -	mutex_unlock(&dev->mode_config.mutex);
>  
>  	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
>  	encoder = drm_connector_get_encoder(connector);
> @@ -1650,6 +1647,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  	drm_modeset_unlock(&dev->mode_config.connection_mutex);
>  
>  out:
> +	mutex_unlock(&dev->mode_config.mutex);
> +
>  	drm_connector_put(connector);
>  
>  	return ret;
> -- 
> 2.13.6
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list