drm/i915: Avoid div-by-zero when pixel_multiplier is zero
Subsystems (2)
PATCH 1/1 drm/i915: Avoid div-by-zero when pixel_multiplier is zero
From: Ville Syrjälä <[email protected]>
On certain platforms pixel_multiplier is read out in .get_pipe_config(), but it also gets used to calculate the pixel clock in intel_sdvo_get_config(). If the pipe is disable but some SDVO outputs are active, we may end up dividing by zero in intel_sdvo_get_config().
To avoid the problem simply check for zero pixel_multiplier and skip the division. Another attempt at fixing this involved populating pixel_multiplier to 1 even for disabled pipes, but that triggered a WARN because SDVO_CMD_GET_CLOCK_RATE_MULT command failed and thus encoder_pixel_multiplier was left at zero and didn't match pipe_config->pixel_multiplier.
The "divide by pixel_multiplier" operation got introduced here:
commit 18442d08786472c63a0a80c27f92b033dffc26de
Author: Ville Syrjälä <[email protected]>
Date: Fri Sep 13 16:00:08 2013 +0300
drm/i915: Fix port_clock and adjusted_mode.clock readout all over
and it has caused a regression on certain machines since they would hit the div-by-zero during resume.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76520
--- drivers/gpu/drm/i915/intel_sdvo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_sdvo.c +3 -1
@@ -1385,7 +1385,9 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, >> SDVO_PORT_MULTIPLY_SHIFT) + 1; } - dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier; + dotclock = pipe_config->port_clock; +if (pipe_config->pixel_multiplier) + dotclock /= pipe_config->pixel_multiplier;if (HAS_PCH_SPLIT (dev))ironlake_check_encoder_dotclock (pipe_config, dotclock);
Signature · 6 lines
1.8.5.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 22 lines · On Mon, Jun 09, 2014 at 04:20:46PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
On certain platforms
pixel_multiplieris read out in .get_pipe_config(), but it also gets used to calculate the pixel clock inintel_sdvo_get_config(). If the pipe is disable but some SDVO outputs are active, we may end up dividing by zero inintel_sdvo_get_config().To avoid the problem simply check for zero
pixel_multiplierand skip the division. Another attempt at fixing this involved populatingpixel_multiplierto 1 even for disabled pipes, but that triggered a WARN becauseSDVO_CMD_GET_CLOCK_RATE_MULTcommand failed and thusencoder_pixel_multiplierwas left at zero and didn't matchpipe_config->pixel_multiplier.The "divide by
pixel_multiplier" operation got introduced here:
commit18442d08786472c63a0a80c27f92b033dffc26de
Author: Ville Syrjälä <[email protected]>
Date: Fri Sep 13 16:00:08 2013 +0300drm/i915: Fix
port_clockand adjusted_mode.clock readout all over
Quoted 7 lines
and it has caused a regression on certain machines since they would hit the div-by-zero during resume.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76520
Cc <[email protected]> # 3.13+Tested-by Tim Richardson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 26 lines
--- drivers/gpu/drm/i915/intel_sdvo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_sdvo.c +3
-1@@ -1385,7 +1385,9 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, >> SDVO_PORT_MULTIPLY_SHIFT) + 1; } - dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier; + dotclock = pipe_config->port_clock; +if (pipe_config->pixel_multiplier) + dotclock /= pipe_config->pixel_multiplier;if (HAS_PCH_SPLIT (dev))ironlake_check_encoder_dotclock (pipe_config, dotclock);Signature · 6 lines
1.8.5.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 26 lines · Daniel Vetter
Quoted 25 lines · On Mon, Jun 09, 2014 at 04:20:46PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
On certain platforms
pixel_multiplieris read out in .get_pipe_config(), but it also gets used to calculate the pixel clock inintel_sdvo_get_config(). If the pipe is disable but some SDVO outputs are active, we may end up dividing by zero inintel_sdvo_get_config().To avoid the problem simply check for zero
pixel_multiplierand skip the division. Another attempt at fixing this involved populatingpixel_multiplierto 1 even for disabled pipes, but that triggered a WARN becauseSDVO_CMD_GET_CLOCK_RATE_MULTcommand failed and thusencoder_pixel_multiplierwas left at zero and didn't matchpipe_config->pixel_multiplier.The "divide by
pixel_multiplier" operation got introduced here:
commit18442d08786472c63a0a80c27f92b033dffc26de
Author: Ville Syrjälä <[email protected]>
Date: Fri Sep 13 16:00:08 2013 +0300drm/i915: Fix
port_clockand adjusted_mode.clock readout all overand it has caused a regression on certain machines since they would hit the div-by-zero during resume.
Quoted 6 lines
Quoted 4 lines
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76520
Cc <[email protected]> # 3.13+Tested-by Tim Richardson <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Reviewed-by Daniel Vetter <[email protected]>
Pushed to -fixes, thanks for the patch and review.
BR,
Jani.
Quoted 36 lines
Quoted 27 lines
--- drivers/gpu/drm/i915/intel_sdvo.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_sdvo.c +3
-1@@ -1385,7 +1385,9 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder, >> SDVO_PORT_MULTIPLY_SHIFT) + 1; } - dotclock = pipe_config->port_clock / pipe_config->pixel_multiplier; + dotclock = pipe_config->port_clock; +if (pipe_config->pixel_multiplier) + dotclock /= pipe_config->pixel_multiplier;if (HAS_PCH_SPLIT (dev))ironlake_check_encoder_dotclock (pipe_config, dotclock);Signature · 6 lines
1.8.5.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center