Skip to contentSkip to conversation

drm: Fix GETCONNECTOR regression

PATCH In review Daniel Vetter 5 participants 7 messages Jun 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Fix GETCONNECTOR regression

In

commit 91eefc05f0ac71902906b2058360e61bd25137fe

Author: Daniel Vetter <[email protected]>
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 <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Cc "H.J. Lu" <[email protected]>
---
 drivers/gpu/drm/drm_connector.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_connector.c +18 -15
index 5cd61aff7857..e0fd8168a178 100644
@@ -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);
 
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 12 lines · Daniel Vetter

In

commit 91eefc05f0ac71902906b2058360e61bd25137fe

Author: Daniel Vetter <[email protected]>
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.

Quoted 9 lines
Fixes 91eefc05f0ac ("drm: Tighten locking in drm_mode_getconnector")
Cc Sean Paul <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Cc "H.J. Lu" <[email protected]>

Possibly

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100576

Quoted 54 lines
---
 drivers/gpu/drm/drm_connector.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_connector.c +18 -15
index 5cd61aff7857..e0fd8168a178 100644
@@ -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);
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 73 lines · Jani Nikula
Quoted 12 lines · Daniel Vetter

In

commit 91eefc05f0ac71902906b2058360e61bd25137fe

Author: Daniel Vetter <[email protected]>
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.

Quoted 9 lines
Fixes 91eefc05f0ac ("drm: Tighten locking in drm_mode_getconnector")
Cc Sean Paul <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Cc "H.J. Lu" <[email protected]>

Possibly

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100576

Quoted 46 lines
---
 drivers/gpu/drm/drm_connector.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_connector.c +12 -15
index 5cd61aff7857..e0fd8168a178 100644
@@ -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),
Quoted 9 lines

drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1379

Quoted 8 lines
drivers/gpu/drm/drm_connector.c +6 -0
+                     (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);

Yes, it fixed my issue.

Thanks.

Signature · 5 lines
H.J.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

✓ Fi.CI.BAT: success for drm: Fix GETCONNECTOR regression

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: drm: Fix GETCONNECTOR regression
URL : https://patchwork.freedesktop.org/series/26034/
State : success

== Summary ==

Series 26034v1 drm: Fix GETCONNECTOR regression
https://patchwork.freedesktop.org/api/1.0/series/26034/revisions/1/mbox/

Test gem_exec_suspend:

        Subgroup basic-s4-devices:
                dmesg-warn -> PASS       (fi-kbl-r) fdo#100125
Test kms_cursor_legacy:
        Subgroup basic-busy-flip-before-cursor-atomic:
                pass       -> FAIL       (fi-snb-2600) fdo#100215

fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fdo#100215 https://bugs.freedesktop.org/show_bug.cgi?id=100215

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:462s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:494s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:587s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:553s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:494s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:486s
fi-glk-2a        total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:582s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:436s
fi-hsw-4770r     total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:16  time:418s
fi-ilk-650       total:278  pass:227  dwarn:0   dfail:0   fail:0   skip:50  time:463s
fi-ivb-3520m     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:18  time:497s
fi-ivb-3770      total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:18  time:518s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:477s
fi-kbl-7560u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:571s
fi-kbl-r         total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:574s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:474s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:518s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:497s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:506s
fi-snb-2520m     total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:28  time:625s
fi-snb-2600      total:278  pass:246  dwarn:0   dfail:0   fail:2   skip:29  time:410s

fi-skl-6700hq failed to connect after reboot

7fd750f0441e3445a3d783b3bb6b4d92be20780c drm-tip: 2017y-06m-20d-08h-32m-41s UTC integration manifest 60e2f01 drm: Fix GETCONNECTOR regression

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4992/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Daniel Vetter
Quoted 12 lines · Daniel Vetter

In

commit 91eefc05f0ac71902906b2058360e61bd25137fe

Author: Daniel Vetter <[email protected]>
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.

Quoted 9 lines
Fixes 91eefc05f0ac ("drm: Tighten locking in drm_mode_getconnector")
Cc Sean Paul <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Cc "H.J. Lu" <[email protected]>

Some dim fixes failed me, also needs:

Cc <[email protected]> # v4.11+
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
In reply to Daniel Vetter
Quoted 59 lines · Daniel Vetter

In

commit 91eefc05f0ac71902906b2058360e61bd25137fe

Author: Daniel Vetter <[email protected]>
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 <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Jani Nikula <[email protected]>
Cc David Airlie <[email protected]>
Cc "H.J. Lu" <[email protected]>
---
 drivers/gpu/drm/drm_connector.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/drm_connector.c +4 -15
index 5cd61aff7857..e0fd8168a178 100644
@@ -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)

drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1373

Quoted 10 lines
drivers/gpu/drm/drm_connector.c +10 -0
+		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);

Isn't this overwriting the -EFAULT return in case copy_to_user() failed while copying the modes ?

drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1380

Quoted 7 lines
drivers/gpu/drm/drm_connector.c +4 -0
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+	if (ret)
+		goto out_unref;
+
 out_unref:
 	drm_connector_put(connector);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 2 lines · Dhinakaran

Isn't this overwriting the -EFAULT return in case copy_to_user() failed while copying the modes ?

Indeed, thanks for spotting this. New patch in-flight. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel