dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] drm: Restore GNOME monitors.xml support
       [not found] <20170604153445.GA8094@gmail.com>
@ 2017-06-06  9:26 ` Jani Nikula
  2017-06-20  9:15   ` [Intel-gfx] " Daniel Vetter
  0 siblings, 1 reply; 2+ messages in thread
From: Jani Nikula @ 2017-06-06  9:26 UTC (permalink / raw)
  To: H.J. Lu, intel-gfx; +Cc: dri-devel

On Sun, 04 Jun 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> Please CC me since I am not on this mailing list.

Sorry, should've instructed you to send to dri-devel instead of
intel-gfx, because the patch touches drm helpers. Cc'd.

BR,
Jani.

>
> H.J.
> ---
> My ~/.config/monitors.xml swaps primary/secondary displays as well as
> their horizontal positions.  It works fine until:
>
> commit 91eefc05f0ac71902906b2058360e61bd25137fe
> Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> Date:   Wed Dec 14 00:08:10 2016 +0100
>
>     drm: Tighten locking in drm_mode_getconnector
>
> which makes ~/.config/monitors.xml not effective.  This patch reorders
> drm_mode_getconnector and restores monitors.xml support.
>
> This may also fix:
>
> https://bugs.freedesktop.org/show_bug.cgi?id=100576
>
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
> ---
>  drivers/gpu/drm/drm_connector.c | 74 ++++++++++++++++++++---------------------
>  1 file changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 45464c8..4fe8ff3 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -1169,41 +1169,6 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
>  	if (!connector)
>  		return -ENOENT;
>  
> -	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
> -	encoder = drm_connector_get_encoder(connector);
> -	if (encoder)
> -		out_resp->encoder_id = encoder->base.id;
> -	else
> -		out_resp->encoder_id = 0;
> -
> -	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
> -			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
> -			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
> -			&out_resp->count_props);
> -	drm_modeset_unlock(&dev->mode_config.connection_mutex);
> -	if (ret)
> -		goto out_unref;
> -
> -	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
> -		if (connector->encoder_ids[i] != 0)
> -			encoders_count++;
> -
> -	if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
> -		copied = 0;
> -		encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr);
> -		for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
> -			if (connector->encoder_ids[i] != 0) {
> -				if (put_user(connector->encoder_ids[i],
> -					     encoder_ptr + copied)) {
> -					ret = -EFAULT;
> -					goto out_unref;
> -				}
> -				copied++;
> -			}
> -		}
> -	}
> -	out_resp->count_encoders = encoders_count;
> -
>  	out_resp->connector_id = connector->base.id;
>  	out_resp->connector_type = connector->connector_type;
>  	out_resp->connector_type_id = connector->connector_type_id;
> @@ -1240,15 +1205,50 @@ 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;
> -out:
>  	mutex_unlock(&dev->mode_config.mutex);
> -out_unref:
> +
> +	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
> +	encoder = drm_connector_get_encoder(connector);
> +	if (encoder)
> +		out_resp->encoder_id = encoder->base.id;
> +	else
> +		out_resp->encoder_id = 0;
> +
> +	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
> +			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
> +			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
> +			&out_resp->count_props);
> +	drm_modeset_unlock(&dev->mode_config.connection_mutex);
> +	if (ret)
> +		goto out;
> +
> +	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
> +		if (connector->encoder_ids[i] != 0)
> +			encoders_count++;
> +
> +	if ((out_resp->count_encoders >= encoders_count) && encoders_count) {
> +		copied = 0;
> +		encoder_ptr = (uint32_t __user *)(unsigned long)(out_resp->encoders_ptr);
> +		for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
> +			if (connector->encoder_ids[i] != 0) {
> +				if (put_user(connector->encoder_ids[i],
> +					     encoder_ptr + copied)) {
> +					ret = -EFAULT;
> +					goto out;
> +				}
> +				copied++;
> +			}
> +		}
> +	}
> +	out_resp->count_encoders = encoders_count;
> +out:
>  	drm_connector_unreference(connector);
>  
>  	return ret;

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Intel-gfx] [PATCH] drm: Restore GNOME monitors.xml support
  2017-06-06  9:26 ` [PATCH] drm: Restore GNOME monitors.xml support Jani Nikula
@ 2017-06-20  9:15   ` Daniel Vetter
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2017-06-20  9:15 UTC (permalink / raw)
  To: Jani Nikula; +Cc: H.J. Lu, intel-gfx, dri-devel

On Tue, Jun 06, 2017 at 12:26:57PM +0300, Jani Nikula wrote:
> On Sun, 04 Jun 2017, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> > Please CC me since I am not on this mailing list.
> 
> Sorry, should've instructed you to send to dri-devel instead of
> intel-gfx, because the patch touches drm helpers. Cc'd.
> 
> BR,
> Jani.
> 
> >
> > H.J.
> > ---
> > My ~/.config/monitors.xml swaps primary/secondary displays as well as
> > their horizontal positions.  It works fine until:
> >
> > commit 91eefc05f0ac71902906b2058360e61bd25137fe
> > Author: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Date:   Wed Dec 14 00:08:10 2016 +0100
> >
> >     drm: Tighten locking in drm_mode_getconnector
> >
> > which makes ~/.config/monitors.xml not effective.  This patch reorders
> > drm_mode_getconnector and restores monitors.xml support.

Ok, I think the real bugfix is just getting the properties after probing,
to have the updated EDID. Please test the below more minimal fixup:

commit 4b5d7e764afaf9a2e80e1f78641b5bd17af4692b
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Tue Jun 20 11:13:42 2017 +0200

    drm: Fix GETCONNECTOR regression
    
    In
    
    commit 91eefc05f0ac71902906b2058360e61bd25137fe
    Author: Daniel Vetter <daniel.vetter@ffwll.ch>
    Date:   Wed Dec 14 00:08:10 2016 +0100
    
        drm: Tighten locking in drm_mode_getconnector
    
    I reordered the logic a bit in that IOCTL, but that broke userspace
    since it'll get the new mode list, but not the new property values.
    Fix that again.
    
    Fixes: 91eefc05f0ac ("drm: Tighten locking in drm_mode_getconnector")
    Cc: Sean Paul <seanpaul@chromium.org>
    Cc: Daniel Vetter <daniel.vetter@intel.com>
    Cc: Jani Nikula <jani.nikula@linux.intel.com>
    Cc: David Airlie <airlied@linux.ie>
    Cc: dri-devel@lists.freedesktop.org
    Reported-by: "H.J. Lu" <hjl.tools@gmail.com>
    Cc: "H.J. Lu" <hjl.tools@gmail.com>
    Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 5cd61aff7857..e0fd8168a178 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1293,21 +1293,6 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
 	if (!connector)
 		return -ENOENT;
 
-	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-	encoder = drm_connector_get_encoder(connector);
-	if (encoder)
-		out_resp->encoder_id = encoder->base.id;
-	else
-		out_resp->encoder_id = 0;
-
-	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
-			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
-			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
-			&out_resp->count_props);
-	drm_modeset_unlock(&dev->mode_config.connection_mutex);
-	if (ret)
-		goto out_unref;
-
 	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++)
 		if (connector->encoder_ids[i] != 0)
 			encoders_count++;
@@ -1372,6 +1357,24 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
 	out_resp->count_modes = mode_count;
 out:
 	mutex_unlock(&dev->mode_config.mutex);
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	encoder = drm_connector_get_encoder(connector);
+	if (encoder)
+		out_resp->encoder_id = encoder->base.id;
+	else
+		out_resp->encoder_id = 0;
+
+	/* Only grab properties after probing, to make sure EDID and other
+	 * properties reflect the latest status. */
+	ret = drm_mode_object_get_properties(&connector->base, file_priv->atomic,
+			(uint32_t __user *)(unsigned long)(out_resp->props_ptr),
+			(uint64_t __user *)(unsigned long)(out_resp->prop_values_ptr),
+			&out_resp->count_props);
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+	if (ret)
+		goto out_unref;
+
 out_unref:
 	drm_connector_put(connector);

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-06-20  9:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20170604153445.GA8094@gmail.com>
2017-06-06  9:26 ` [PATCH] drm: Restore GNOME monitors.xml support Jani Nikula
2017-06-20  9:15   ` [Intel-gfx] " Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).