Skip to contentSkip to conversation

drm: fixes crct set_mode when encoder mode_fixup is null.

PATCH In review Carlos Palminha 2 participants 4 messages Feb 10, 2016

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

PATCH 1/1 drm: fixes crct set_mode when encoder mode_fixup is null.

Avoids null crash when encoders don't implement mode_fixup.

---
 drivers/gpu/drm/drm_crtc_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +6 -4
index a02a7f9..ef3def7 100644
@@ -328,10 +328,12 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		}
 
 		encoder_funcs = encoder->helper_private;
-		if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
-						      adjusted_mode))) {
-			DRM_DEBUG_KMS("Encoder fixup failed\n");
-			goto done;
+		if (encoder_funcs->mode_fixup) {
+			if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
+							      adjusted_mode))) {
+				DRM_DEBUG_KMS("Encoder fixup failed\n");
+				goto done;
+			}
 		}
 	}
 
Signature · 6 lines
2.5.0

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

Avoids null crash when encoders don't implement mode_fixup.

---
 drivers/gpu/drm/drm_crtc_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +0 -0
index a02a7f9..ef3def7 100644
@@ -328,10 +328,12 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		}
 
 		encoder_funcs = encoder->helper_private;

drivers/gpu/drm/drm_crtc_helper.c bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, · line 336

Quoted 10 lines
drivers/gpu/drm/drm_crtc_helper.c +6 -4
-		if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
-						      adjusted_mode))) {
-			DRM_DEBUG_KMS("Encoder fixup failed\n");
-			goto done;
+		if (encoder_funcs->mode_fixup) {
+			if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
+							      adjusted_mode))) {
+				DRM_DEBUG_KMS("Encoder fixup failed\n");
+				goto done;
+			}

At first I thought this isn't useful since it's the old legacy helper code that no new driver should use. But from a quick

$ git grep mode_fixup.*encoder

it looks like there's piles of existing drivers that could benefit from this with a small cleanup. So applied it, but can you pls follow up with patches to get rid of the now unecessary dummy functions?

Thanks, Daniel

Quoted 6 lines
drivers/gpu/drm/drm_crtc_helper.c +0 -0
 		}
 	}
 
Signature · 1 line
2.5.0
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Carlos Palminha
Quoted 3 lines · Carlos Palminha

Avoids null crash when encoders don't implement mode_fixup.

btw we could do the same game for drm_crtc_helper_funcs->mode_fixup. More dummy functions to nuke!
-Daniel

Quoted 28 lines
---
 drivers/gpu/drm/drm_crtc_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +6 -4
index a02a7f9..ef3def7 100644
@@ -328,10 +328,12 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		}
 
 		encoder_funcs = encoder->helper_private;
-		if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
-						      adjusted_mode))) {
-			DRM_DEBUG_KMS("Encoder fixup failed\n");
-			goto done;
+		if (encoder_funcs->mode_fixup) {
+			if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
+							      adjusted_mode))) {
+				DRM_DEBUG_KMS("Encoder fixup failed\n");
+				goto done;
+			}
 		}
 	}
 
Signature · 1 line
2.5.0
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Carlos Palminha
Quoted 3 lines · Carlos Palminha

Avoids null crash when encoders don't implement mode_fixup.

One more thing I've forgotten: With these changes the kerneldoc in include/drm/drm_modeset_helper_vtables.h is now no longer accurate. It needs to be updated to explain that this hook is optional for both helpers.
-Daniel

Quoted 28 lines
---
 drivers/gpu/drm/drm_crtc_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_crtc_helper.c +6 -4
index a02a7f9..ef3def7 100644
@@ -328,10 +328,12 @@ bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
 		}
 
 		encoder_funcs = encoder->helper_private;
-		if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
-						      adjusted_mode))) {
-			DRM_DEBUG_KMS("Encoder fixup failed\n");
-			goto done;
+		if (encoder_funcs->mode_fixup) {
+			if (!(ret = encoder_funcs->mode_fixup(encoder, mode,
+							      adjusted_mode))) {
+				DRM_DEBUG_KMS("Encoder fixup failed\n");
+				goto done;
+			}
 		}
 	}
 
Signature · 1 line
2.5.0
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel