[Intel-gfx] [PATCH] drm/atomic: Acquire connection_mutex lock in drm_helper_probe_single_connector_modes, v2.

Daniel Vetter daniel at ffwll.ch
Wed Apr 5 06:37:47 UTC 2017


On Tue, Apr 04, 2017 at 12:59:25PM +0200, Maarten Lankhorst wrote:
> mode_valid() called from drm_helper_probe_single_connector_modes()
> may need to look at connector->state because what a valid mode is may
> depend on connector properties being set. For example some HDMI modes
> might be rejected when a connector property forces the connector
> into DVI mode.
> 
> Some implementations of detect() already lock all state,
> so we have to pass an acquire_ctx to them to prevent a deadlock.
> 
> This means changing the function signature of detect() slightly,
> and passing the acquire_ctx for locking multiple crtc's.
> For the callbacks, it will always be non-zero. To allow callers
> not to worry about this, drm_helper_probe_detect_ctx is added
> which might handle -EDEADLK for you.
> 
> Changes since v1:
> - Always set ctx parameter.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Cc: Boris Brezillon <boris.brezillon at free-electrons.com>

>  /**
> + * drm_helper_probe_detect - probe connector status
> + * @connector: connector to probe
> + * @ctx: lock acquire_ctx, or NULL to let this function handle it.
> + * @force: Whether destructive probe operations should be performed.
> + *
> + * This function calls the detect callbacks of the connector.
> + * This function returns drm_connector_status, or
> + * if @ctx is set, it might also return -EDEADLK.
> + */
> +int
> +drm_helper_probe_detect(struct drm_connector *connector,
> +			struct drm_modeset_acquire_ctx *ctx,
> +			bool force)
> +{
> +	const struct drm_connector_helper_funcs *funcs = connector->helper_private;
> +
> +	if (funcs->detect_ctx && ctx)
> +		return funcs->detect_ctx(connector, ctx, force);
> +	else if (funcs->detect_ctx)
> +		return drm_helper_probe_detect_ctx(connector, force);
> +	else if (connector->funcs->detect)
> +		return connector->funcs->detect(connector, force);
> +	else
> +		return connector_status_connected;

On irc we discussed that we need to hold mode_config->connection_mutex
around _all_ types of ->detect. But here you only do that for
->detect_ctx, which defeats the purpose and also runs against your commit
message.

Sent out the wrong version? I can't find v3 anywhere ...
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list