Skip to contentSkip to conversation

drm: Preserve the list head in drm_mode_copy

PATCH In review [email protected] 4 participants 7 messages May 31, 2013 – Jun 11, 2013

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

PATCH 1/3 drm: Preserve the list head in drm_mode_copy

From: Ville Syrjälä <[email protected]>

Preserve the destination mode's list head in drm_mode_copy. Just in case someone decides that it's a good idea to overwrite a mode which happens to be on some list,

---
 drivers/gpu/drm/drm_modes.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_modes.c +4 -3
index a371ff8..ba86316 100644
@@ -787,16 +787,17 @@ EXPORT_SYMBOL(drm_mode_set_crtcinfo);
  * LOCKING:
  * None.
  *
- * Copy an existing mode into another mode, preserving the object id
- * of the destination mode.
+ * Copy an existing mode into another mode, preserving the object id and
+ * list head of the destination mode.
  */
 void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
 {
 	int id = dst->base.id;
+	struct list_head head = dst->head;
 
 	*dst = *src;
 	dst->base.id = id;
-	INIT_LIST_HEAD(&dst->head);
+	dst->head = head;
 }
 EXPORT_SYMBOL(drm_mode_copy);
 
Signature · 6 lines
1.8.1.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/3 drm: Add probed modes in probe order

From: Ville Syrjälä <[email protected]>

Keeping the modes in the same order as we probe them makes it a bit easier to track what's happening.

---
 drivers/gpu/drm/drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_crtc.c +1 -1
index e7e9242..f072ac6 100644
@@ -657,7 +657,7 @@ EXPORT_SYMBOL(drm_crtc_cleanup);
 void drm_mode_probed_add(struct drm_connector *connector,
 			 struct drm_display_mode *mode)
 {
-	list_add(&mode->head, &connector->probed_modes);
+	list_add_tail(&mode->head, &connector->probed_modes);
 }
 EXPORT_SYMBOL(drm_mode_probed_add);
 
Signature · 6 lines
1.8.1.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH 2/3] drm: Add probed modes in probe order

Quoted 6 lines · On Fri, May 31, 2013 at 2:17 PM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Keeping the modes in the same order as we probe them makes it a bit easier to track what's happening.

I've just added a regression fixer to my -fixes queue which depends upon the old behaviour ... I'll make a note to fix this once stuff is merged together again. For reference the patch this will break in -fixes is:

commit c3456fb3e4712d0448592af3c5d644c9472cd3c1

Author: Daniel Vetter <[email protected]>
Date:   Mon Jun 10 09:47:58 2013 +0200

drm/i915: prefer VBT modes for SVDO-LVDS over EDID

Cheers, Daniel

Quoted 20 lines
---
 drivers/gpu/drm/drm_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_crtc.c +1 -2
index e7e9242..f072ac6 100644
@@ -657,7 +657,7 @@ EXPORT_SYMBOL(drm_crtc_cleanup);
 void drm_mode_probed_add(struct drm_connector *connector,
                         struct drm_display_mode *mode)
 {
-       list_add(&mode->head, &connector->probed_modes);
+       list_add_tail(&mode->head, &connector->probed_modes);
 }
 EXPORT_SYMBOL(drm_mode_probed_add);
 
--

1.8.1.5

Quoted 4 lines

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

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#3 lore raw

Re: [PATCH 2/3] drm: Add probed modes in probe order

Quoted 13 lines · Daniel Vetter
Quoted 6 lines · On Fri, May 31, 2013 at 2:17 PM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Keeping the modes in the same order as we probe them makes it a bit easier to track what's happening.

I've just added a regression fixer to my -fixes queue which depends upon the old behaviour ... I'll make a note to fix this once stuff is merged together again. For reference the patch this will break in -fixes is:

Quoted 5 lines

commit c3456fb3e4712d0448592af3c5d644c9472cd3c1

Author: Daniel Vetter <[email protected]>
Date:   Mon Jun 10 09:47:58 2013 +0200

drm/i915: prefer VBT modes for SVDO-LVDS over EDID

That is not the only place to have a subtle dependence upon the ordering of modes in the list.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw

Re: [PATCH 2/3] drm: Add probed modes in probe order

Quoted 14 lines · Chris Wilson
Quoted 13 lines · Daniel Vetter
Quoted 6 lines · On Fri, May 31, 2013 at 2:17 PM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Keeping the modes in the same order as we probe them makes it a bit easier to track what's happening.

I've just added a regression fixer to my -fixes queue which depends upon the old behaviour ... I'll make a note to fix this once stuff is merged together again. For reference the patch this will break in -fixes is:

Quoted 8 lines
Quoted 5 lines

commit c3456fb3e4712d0448592af3c5d644c9472cd3c1

Author: Daniel Vetter <[email protected]>
Date:   Mon Jun 10 09:47:58 2013 +0200

drm/i915: prefer VBT modes for SVDO-LVDS over EDID

That is not the only place to have a subtle dependence upon the ordering of modes in the list.

I've now included latest drm-next into drm-intel-nightly. I guess we'll find out soon ;-)
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw

PATCH 3/3 drm: Sort connector modes based on vrefresh

In reply to [email protected]

From: Ville Syrjälä <[email protected]>

Keeping the modes sorted by vrefresh before the pixel clock makes the mode list somehow more pleasing to the eye.

---
This is quite a subjective thing, so if no one else wants it, I'm fine with dropping it. More of an RFC really...

 drivers/gpu/drm/drm_crtc_helper.c | 5 +++--
 drivers/gpu/drm/drm_modes.c       | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +3 -2
index ed1334e..f554516 100644
@@ -189,13 +189,14 @@ prune:
 	if (list_empty(&connector->modes))
 		return 0;
 
+	list_for_each_entry(mode, &connector->modes, head)
+		mode->vrefresh = drm_mode_vrefresh(mode);
+
 	drm_mode_sort(&connector->modes);
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id,
 			drm_get_connector_name(connector));
 	list_for_each_entry(mode, &connector->modes, head) {
-		mode->vrefresh = drm_mode_vrefresh(mode);
-
 		drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
 		drm_mode_debug_printmodeline(mode);
 	}
drivers/gpu/drm/drm_modes.c +5 -0
index ba86316..4370fd4 100644
@@ -1018,6 +1018,11 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head
 	diff = b->hdisplay * b->vdisplay - a->hdisplay * a->vdisplay;
 	if (diff)
 		return diff;
+
+	diff = b->vrefresh - a->vrefresh;
+	if (diff)
+		return diff;
+
 	diff = b->clock - a->clock;
 	return diff;
 }
Signature · 6 lines
1.8.1.5

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/3
#6 lore raw
In reply to [email protected]
Quoted 7 lines · On Fri, May 31, 2013 at 8:17 AM, <[email protected]> wrote:

From: Ville Syrjälä <[email protected]>

Preserve the destination mode's list head in drm_mode_copy. Just in case someone decides that it's a good idea to overwrite a mode which happens to be on some list,

For the series:

Quoted 36 lines
---
 drivers/gpu/drm/drm_modes.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_modes.c +4 -4
index a371ff8..ba86316 100644
@@ -787,16 +787,17 @@ EXPORT_SYMBOL(drm_mode_set_crtcinfo);
  * LOCKING:
  * None.
  *
- * Copy an existing mode into another mode, preserving the object id
- * of the destination mode.
+ * Copy an existing mode into another mode, preserving the object id and
+ * list head of the destination mode.
  */
 void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src)
 {
        int id = dst->base.id;
+       struct list_head head = dst->head;
 
        *dst = *src;
        dst->base.id = id;
-       INIT_LIST_HEAD(&dst->head);
+       dst->head = head;
 }
 EXPORT_SYMBOL(drm_mode_copy);
 
--

1.8.1.5

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