drm/i915/sdvo: Fully translate sync flags in the dtd->mode conversion
Subsystems (2)
PATCH 1/3 drm/i915/sdvo: Fully translate sync flags in the dtd->mode conversion
Instead of just a flag bit for each of the positive/negative sync modes drm actually uses a separate flag for each ... This upsets the modeset checker since the adjusted mode filled out at modeset time doesn't match the one reconstructed at check time (since the ->get_config callback already gets this right).
References: http://www.gossamer-threads.com/lists/linux/kernel/1778688?do=post_view_threaded
--- drivers/gpu/drm/i915/intel_sdvo.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_sdvo.c +4 -0
@@ -866,8 +866,12 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->flags |=DRM_MODE_FLAG_INTERLACE ;if (dtd->part2.dtd_flags &DTD_FLAG_HSYNC_POSITIVE ) mode->flags |=DRM_MODE_FLAG_PHSYNC ; +else + mode->flags |=DRM_MODE_FLAG_NHSYNC ;if (dtd->part2.dtd_flags &DTD_FLAG_VSYNC_POSITIVE ) mode->flags |=DRM_MODE_FLAG_PVSYNC ; +else + mode->flags |=DRM_MODE_FLAG_NVSYNC ; }static bool intel_sdvo_check_supp_encode (struct intel_sdvo *intel_sdvo)
Signature · 1 line
1.8.4.rc3
PATCH 2/3 drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
We've failed to properly clear out the flags when converting a dtd to a drm mode. For more paranoia just memset the entire structure (and drop the now redundant clears).
Also since
commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64
Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200
drm/i915: clean up crtc timings computation
we don't update the crtc timings any more properly, so do that again.
--- drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +6 -2
@@ -788,6 +788,8 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,uint16_t h_sync_offset, v_sync_offset;int mode_clock; +memset (dtd,0 ,sizeof (*dtd)); + width = mode->hdisplay; height = mode->vdisplay;
@@ -830,14 +832,14 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,if (mode->flags &DRM_MODE_FLAG_PVSYNC ) dtd->part2.dtd_flags |=DTD_FLAG_VSYNC_POSITIVE ; - dtd->part2.sdvo_flags =0 ; dtd->part2.v_sync_off_high = v_sync_offset &0xc0 ; - dtd->part2.reserved =0 ; }static void intel_sdvo_get_mode_from_dtd (struct drm_display_mode * mode,const struct intel_sdvo_dtd *dtd) { +memset (mode,0 ,sizeof (*mode)); + mode->hdisplay = dtd->part1.h_active; mode->hdisplay += ((dtd->part1.h_high >>4 ) &0x0f ) <<8 ; mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;
@@ -872,6 +874,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->flags |=DRM_MODE_FLAG_PVSYNC ; else mode->flags |= DRM_MODE_FLAG_NVSYNC; + +drm_mode_set_crtcinfo (mode); }static bool intel_sdvo_check_supp_encode (struct intel_sdvo *intel_sdvo)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
Quoted 39 lines · Daniel Vetter
We've failed to properly clear out the flags when converting a dtd to a drm mode. For more paranoia just memset the entire structure (and drop the now redundant clears).
Also since
commit
135c81b8c3c9a70d7b55758c9c2a247a4abb7b64Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200drm/i915: clean up crtc timings computation
we don't update the crtc timings any more properly, so do that again.
Cc Rodrigo Vivi <[email protected]>Cc Jesse Barnes <[email protected]>Cc Ville Syrjälä <[email protected]>Reported-by Ville Syrjälä <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_sdvo.c +2
-0@@ -788,6 +788,8 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,uint16_t h_sync_offset, v_sync_offset;int mode_clock; +memset (dtd,0 ,sizeof (*dtd)); + width = mode->hdisplay; height = mode->vdisplay;@@ -830,14 +832,14 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,if (mode->flags &DRM_MODE_FLAG_PVSYNC ) dtd->part2.dtd_flags |=DTD_FLAG_VSYNC_POSITIVE ;
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd, · line 841
Quoted 10 lines
drivers/gpu/drm/i915/intel_sdvo.c +1
-2- dtd->part2.sdvo_flags =0 ; dtd->part2.v_sync_off_high = v_sync_offset &0xc0 ; - dtd->part2.reserved =0 ; }static void intel_sdvo_get_mode_from_dtd (struct drm_display_mode * mode,const struct intel_sdvo_dtd *dtd) { +memset (mode,0 ,sizeof (*mode));
I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here.
To make it totally safe you could populate a pristine mode struct and use drm_mode_copy() to overwrite adjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside the intel_sdvo struct.
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
Quoted 5 lines
drivers/gpu/drm/i915/intel_sdvo.c +1
-0+ mode->hdisplay = dtd->part1.h_active; mode->hdisplay += ((dtd->part1.h_high >>4 ) &0x0f ) <<8 ; mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;@@ -872,6 +874,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
Somewhere around these parts we have:
'mode->flags &= ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);'
It can now be eliminated.
Quoted 10 lines
drivers/gpu/drm/i915/intel_sdvo.c +2
-0mode->flags |=DRM_MODE_FLAG_PVSYNC ; else mode->flags |= DRM_MODE_FLAG_NVSYNC; + +drm_mode_set_crtcinfo (mode); }static bool intel_sdvo_check_supp_encode (struct intel_sdvo *intel_sdvo)Signature · 1 line
1.8.4.rc3
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
Quoted 9 lines · Ville Syrjälä
Quoted 4 lines
static void intel_sdvo_get_mode_from_dtd(struct
drm_display_mode* mode,
const structintel_sdvo_dtd*dtd)
{
+memset(mode, 0, sizeof(*mode));I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here.
Quoted 5 lines
To make it totally safe you could populate a pristine mode struct and use
drm_mode_copy()to overwriteadjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside theintel_sdvostruct.
We can't really check for this since list_empty on stack garbage won't work too well, either. And e.g. ->get_config has the pipe config on the stack. So I think we just need to do review here. I also think the risk is pretty low, this is all used in internal structures around pipe_config, where the mode is never linked.
Quoted 11 lines
drivers/gpu/drm/i915/intel_sdvo.c static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
Quoted 5 lines
drivers/gpu/drm/i915/intel_sdvo.c +1
-0+ mode->hdisplay = dtd->part1.h_active; mode->hdisplay += ((dtd->part1.h_high >>4 ) &0x0f ) <<8 ; mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;@@ -872,6 +874,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,Somewhere around these parts we have:
'
mode->flags&= ~(DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC);'It can now be eliminated.
Will fix and resend.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
Quoted 17 lines · Daniel Vetter
Quoted 9 lines · Ville Syrjälä
Quoted 4 lines
static void intel_sdvo_get_mode_from_dtd(struct
drm_display_mode* mode,
const structintel_sdvo_dtd*dtd)
{
+memset(mode, 0, sizeof(*mode));I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here.
Quoted 5 lines
To make it totally safe you could populate a pristine mode struct and use
drm_mode_copy()to overwriteadjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside theintel_sdvostruct.
Quoted 5 lines
We can't really check for this since
list_emptyon stack garbage won't work too well, either. And e.g. ->get_config has the pipe config on the stack. So I think we just need to do review here. I also think the risk is pretty low, this is all used in internal structures aroundpipe_config, where the mode is never linked.
Well, another idea would be to add drm_mode_clear() what would do the memset() but preserve the id and list head.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
Quoted 18 lines · Ville Syrjälä
Quoted 17 lines · Daniel Vetter
Quoted 14 lines · Ville Syrjälä
Quoted 4 lines
static void intel_sdvo_get_mode_from_dtd(struct
drm_display_mode* mode,
const structintel_sdvo_dtd*dtd)
{
+memset(mode, 0, sizeof(*mode));I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here.
To make it totally safe you could populate a pristine mode struct and use
drm_mode_copy()to overwriteadjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside theintel_sdvostruct.
Quoted 8 lines
Quoted 5 lines
We can't really check for this since
list_emptyon stack garbage won't work too well, either. And e.g. ->get_config has the pipe config on the stack. So I think we just need to do review here. I also think the risk is pretty low, this is all used in internal structures aroundpipe_config, where the mode is never linked.Well, another idea would be to add
drm_mode_clear()what would do thememset()but preserve the id and list head.
At least for the adjusted mode embedded into the pipe config that won't work either since we want to memset the entire thing to not miss any fields ...
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
Quoted 26 lines · Daniel Vetter
Quoted 24 lines · Ville Syrjälä
Quoted 22 lines · Daniel Vetter
Quoted 9 lines · Ville Syrjälä
Quoted 4 lines
static void intel_sdvo_get_mode_from_dtd(struct
drm_display_mode* mode,
const structintel_sdvo_dtd*dtd)
{
+memset(mode, 0, sizeof(*mode));I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here.
Quoted 5 lines
To make it totally safe you could populate a pristine mode struct and use
drm_mode_copy()to overwriteadjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside theintel_sdvostruct.We can't really check for this since
list_emptyon stack garbage won't work too well, either. And e.g. ->get_config has the pipe config on the stack. So I think we just need to do review here. I also think the risk is pretty low, this is all used in internal structures aroundpipe_config, where the mode is never linked.
Quoted 6 lines
Quoted 2 lines
Well, another idea would be to add
drm_mode_clear()what would do thememset()but preserve the id and list head.At least for the adjusted mode embedded into the pipe config that won't work either since we want to memset the entire thing to not miss any fields ...
drm_mode_clear() would skip only the obj id and list head just like drm_mode_copy().
Also isn't the pipe config supposed to be entirely zeroed to start with anyway? And we already use drm_mode_copy() to fill the initial values for adjusted_mode. drm_mode_clear() would overwrite exactly the same fields as drm_mode_copy() filled in.
Signature · 2 lines
Ville Syrjälä Intel OTC
PATCH 1/1 drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
In reply to Ville SyrjäläWe've failed to properly clear out the flags when converting a dtd to a drm mode. For more paranoia just memset the entire structure (and drop the now redundant clears).
Also since
commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64
Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200
drm/i915: clean up crtc timings computation
we don't update the crtc timings any more properly, so do that again.
v2: Remove more redundant clearing, spotted by Ville.
--- drivers/gpu/drm/i915/intel_sdvo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +6 -3
@@ -788,6 +788,8 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,uint16_t h_sync_offset, v_sync_offset;int mode_clock; +memset (dtd,0 ,sizeof (*dtd)); + width = mode->hdisplay; height = mode->vdisplay;
@@ -830,14 +832,14 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,if (mode->flags &DRM_MODE_FLAG_PVSYNC ) dtd->part2.dtd_flags |=DTD_FLAG_VSYNC_POSITIVE ; - dtd->part2.sdvo_flags =0 ; dtd->part2.v_sync_off_high = v_sync_offset &0xc0 ; - dtd->part2.reserved =0 ; }static void intel_sdvo_get_mode_from_dtd (struct drm_display_mode * mode,const struct intel_sdvo_dtd *dtd) { +memset (mode,0 ,sizeof (*mode)); + mode->hdisplay = dtd->part1.h_active; mode->hdisplay += ((dtd->part1.h_high >>4 ) &0x0f ) <<8 ; mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;
@@ -861,7 +863,6 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->clock = dtd->part1.clock *10 ; - mode->flags &= ~(DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC );if (dtd->part2.dtd_flags &DTD_FLAG_INTERLACE ) mode->flags |=DRM_MODE_FLAG_INTERLACE ;if (dtd->part2.dtd_flags &DTD_FLAG_HSYNC_POSITIVE )
@@ -872,6 +873,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->flags |=DRM_MODE_FLAG_PVSYNC ; else mode->flags |= DRM_MODE_FLAG_NVSYNC; + +drm_mode_set_crtcinfo (mode); }static bool intel_sdvo_check_supp_encode (struct intel_sdvo *intel_sdvo)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/2 drm/i915/sdvo: Robustify the dtd<->drm_mode conversions
In reply to Ville SyrjäläWe've failed to properly clear out the flags when converting a dtd to a drm mode. For more paranoia just memset the entire structure (and drop the now redundant clears).
Also since
commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64
Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200
drm/i915: clean up crtc timings computation
we don't update the crtc timings any more properly, so do that again.
v2: Remove more redundant clearing, spotted by Ville.
v3: Actually make it compile. Oops.
--- drivers/gpu/drm/i915/intel_sdvo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_sdvo.c +6 -3
@@ -788,6 +788,8 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,uint16_t h_sync_offset, v_sync_offset;int mode_clock; +memset (dtd,0 ,sizeof (*dtd)); + width = mode->hdisplay; height = mode->vdisplay;
@@ -830,14 +832,14 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,if (mode->flags &DRM_MODE_FLAG_PVSYNC ) dtd->part2.dtd_flags |=DTD_FLAG_VSYNC_POSITIVE ; - dtd->part2.sdvo_flags =0 ; dtd->part2.v_sync_off_high = v_sync_offset &0xc0 ; - dtd->part2.reserved =0 ; }static void intel_sdvo_get_mode_from_dtd (struct drm_display_mode * mode,const struct intel_sdvo_dtd *dtd) { +memset (mode,0 ,sizeof (*mode)); + mode->hdisplay = dtd->part1.h_active; mode->hdisplay += ((dtd->part1.h_high >>4 ) &0x0f ) <<8 ; mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;
@@ -861,7 +863,6 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->clock = dtd->part1.clock *10 ; - mode->flags &= ~(DRM_MODE_FLAG_PHSYNC |DRM_MODE_FLAG_PVSYNC );if (dtd->part2.dtd_flags &DTD_FLAG_INTERLACE ) mode->flags |=DRM_MODE_FLAG_INTERLACE ;if (dtd->part2.dtd_flags &DTD_FLAG_HSYNC_POSITIVE )
@@ -872,6 +873,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, mode->flags |=DRM_MODE_FLAG_PVSYNC ; else mode->flags |= DRM_MODE_FLAG_NVSYNC; + +drm_mode_set_crtcinfo (mode,0 ); }static bool intel_sdvo_check_supp_encode (struct intel_sdvo *intel_sdvo)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915/dvo: set crtc timings again for panel fixed modes
Yet another regression due to
commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64
Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200
drm/i915: clean up crtc timings computation
I'm starting to wonder whether this was worth it ...
v2: Actually make it compile.
--- drivers/gpu/drm/i915/intel_dvo.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_dvo.c +2 -0
@@ -263,6 +263,8 @@ static bool intel_dvo_compute_config(struct intel_encoder *encoder,C (vtotal);C (clock);#undef C + +drm_mode_set_crtcinfo (adjusted_mode,0 ); }if (intel_dvo->dev.dev_ops->mode_fixup)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/3 drm/i915/dvo: set crtc timings again for panel fixed modes
In reply to Daniel VetterYet another regression due to
commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64
Author: Daniel Vetter <[email protected]> Date: Sun Jul 21 21:37:09 2013 +0200
drm/i915: clean up crtc timings computation
I'm starting to wonder whether this was worth it ...
--- drivers/gpu/drm/i915/intel_dvo.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/intel_dvo.c +2 -0
@@ -263,6 +263,8 @@ static bool intel_dvo_compute_config(struct intel_encoder *encoder,C (vtotal);C (clock);#undef C + +drm_mode_set_crtcinfo (adjusted_mode); }if (intel_dvo->dev.dev_ops->mode_fixup)
Signature · 6 lines
1.8.4.rc3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx