* [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command
@ 2013-07-11 18:46 Damien Lespiau
2013-07-11 19:52 ` Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Damien Lespiau @ 2013-07-11 18:46 UTC (permalink / raw)
To: intel-gfx
If intel_sdvo_get_value() fails here, val is unitialized and the cross
check won't check anything.
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index b8e1623..4481f6a 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
}
/* Cross check the port pixel multiplier with the sdvo encoder state. */
- intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
+ if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
+ &val, 1))
+ return;
+
switch (val) {
case SDVO_CLOCK_RATE_MULT_1X:
encoder_pixel_multiplier = 1;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command
2013-07-11 18:46 [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command Damien Lespiau
@ 2013-07-11 19:52 ` Daniel Vetter
2013-07-11 20:35 ` Damien Lespiau
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2013-07-11 19:52 UTC (permalink / raw)
To: Damien Lespiau; +Cc: intel-gfx
On Thu, Jul 11, 2013 at 07:46:00PM +0100, Damien Lespiau wrote:
> If intel_sdvo_get_value() fails here, val is unitialized and the cross
> check won't check anything.
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
> drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index b8e1623..4481f6a 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
> }
>
> /* Cross check the port pixel multiplier with the sdvo encoder state. */
> - intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
> + if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
> + &val, 1))
> + return;
But now it fails silently instead of being paranoid ... Can we just shut
up the tool instead?
-Daniel
> +
> switch (val) {
> case SDVO_CLOCK_RATE_MULT_1X:
> encoder_pixel_multiplier = 1;
> --
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command
2013-07-11 19:52 ` Daniel Vetter
@ 2013-07-11 20:35 ` Damien Lespiau
2013-07-12 12:11 ` Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Damien Lespiau @ 2013-07-11 20:35 UTC (permalink / raw)
To: Daniel Vetter; +Cc: intel-gfx
On Thu, Jul 11, 2013 at 09:52:33PM +0200, Daniel Vetter wrote:
> On Thu, Jul 11, 2013 at 07:46:00PM +0100, Damien Lespiau wrote:
> > If intel_sdvo_get_value() fails here, val is unitialized and the cross
> > check won't check anything.
> >
> > Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> > ---
> > drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> > index b8e1623..4481f6a 100644
> > --- a/drivers/gpu/drm/i915/intel_sdvo.c
> > +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> > @@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
> > }
> >
> > /* Cross check the port pixel multiplier with the sdvo encoder state. */
> > - intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
> > + if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
> > + &val, 1))
> > + return;
>
> But now it fails silently instead of being paranoid ... Can we just shut
> up the tool instead?
We absolutely can! (and it's done).
--
Damien
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command
2013-07-11 20:35 ` Damien Lespiau
@ 2013-07-12 12:11 ` Daniel Vetter
2013-07-12 15:24 ` [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value Damien Lespiau
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Vetter @ 2013-07-12 12:11 UTC (permalink / raw)
To: Damien Lespiau; +Cc: intel-gfx
On Thu, Jul 11, 2013 at 09:35:17PM +0100, Damien Lespiau wrote:
> On Thu, Jul 11, 2013 at 09:52:33PM +0200, Daniel Vetter wrote:
> > On Thu, Jul 11, 2013 at 07:46:00PM +0100, Damien Lespiau wrote:
> > > If intel_sdvo_get_value() fails here, val is unitialized and the cross
> > > check won't check anything.
> > >
> > > Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> > > ---
> > > drivers/gpu/drm/i915/intel_sdvo.c | 5 ++++-
> > > 1 file changed, 4 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> > > index b8e1623..4481f6a 100644
> > > --- a/drivers/gpu/drm/i915/intel_sdvo.c
> > > +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> > > @@ -1357,7 +1357,10 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
> > > }
> > >
> > > /* Cross check the port pixel multiplier with the sdvo encoder state. */
> > > - intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
> > > + if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
> > > + &val, 1))
> > > + return;
> >
> > But now it fails silently instead of being paranoid ... Can we just shut
> > up the tool instead?
>
> We absolutely can! (and it's done).
On second thought we could shovel the switch into an if block so that val
is only read when written. Since pixel_multiplier is already set to 0 (in
case the sdvo device returns garbage) we'll correctly WARN even when
get_value fails (and per chance the stack garbage in val is the right
value for the pixel multiplier).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value
2013-07-12 12:11 ` Daniel Vetter
@ 2013-07-12 15:24 ` Damien Lespiau
2013-07-12 15:33 ` Daniel Vetter
0 siblings, 1 reply; 6+ messages in thread
From: Damien Lespiau @ 2013-07-12 15:24 UTC (permalink / raw)
To: intel-gfx
If intel_sdvo_get_value() fails here, val is unitialized and the cross
check will compare the pipe config multiplier with a bogus value.
Instead, only set encoder_pixel_multiplier when the sdvo command has
been successful. The cross check will compare the pipe config value with
0 otherwise.
v2: Do the cross check with the initial value of encoder_pixel_multiplier (0)
if the sdvo command fails (and thus keep the warning) (Daniel Vetter)
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
drivers/gpu/drm/i915/intel_sdvo.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index b8e1623..eb2a603 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -1357,17 +1357,19 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
}
/* Cross check the port pixel multiplier with the sdvo encoder state. */
- intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
- switch (val) {
- case SDVO_CLOCK_RATE_MULT_1X:
- encoder_pixel_multiplier = 1;
- break;
- case SDVO_CLOCK_RATE_MULT_2X:
- encoder_pixel_multiplier = 2;
- break;
- case SDVO_CLOCK_RATE_MULT_4X:
- encoder_pixel_multiplier = 4;
- break;
+ if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
+ &val, 1)) {
+ switch (val) {
+ case SDVO_CLOCK_RATE_MULT_1X:
+ encoder_pixel_multiplier = 1;
+ break;
+ case SDVO_CLOCK_RATE_MULT_2X:
+ encoder_pixel_multiplier = 2;
+ break;
+ case SDVO_CLOCK_RATE_MULT_4X:
+ encoder_pixel_multiplier = 4;
+ break;
+ }
}
if(HAS_PCH_SPLIT(dev))
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value
2013-07-12 15:24 ` [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value Damien Lespiau
@ 2013-07-12 15:33 ` Daniel Vetter
0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2013-07-12 15:33 UTC (permalink / raw)
To: Damien Lespiau; +Cc: intel-gfx
On Fri, Jul 12, 2013 at 04:24:40PM +0100, Damien Lespiau wrote:
> If intel_sdvo_get_value() fails here, val is unitialized and the cross
> check will compare the pipe config multiplier with a bogus value.
>
> Instead, only set encoder_pixel_multiplier when the sdvo command has
> been successful. The cross check will compare the pipe config value with
> 0 otherwise.
>
> v2: Do the cross check with the initial value of encoder_pixel_multiplier (0)
> if the sdvo command fails (and thus keep the warning) (Daniel Vetter)
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Queued for -next, thanks for the patch.
-Daniel
> ---
> drivers/gpu/drm/i915/intel_sdvo.c | 24 +++++++++++++-----------
> 1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
> index b8e1623..eb2a603 100644
> --- a/drivers/gpu/drm/i915/intel_sdvo.c
> +++ b/drivers/gpu/drm/i915/intel_sdvo.c
> @@ -1357,17 +1357,19 @@ static void intel_sdvo_get_config(struct intel_encoder *encoder,
> }
>
> /* Cross check the port pixel multiplier with the sdvo encoder state. */
> - intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT, &val, 1);
> - switch (val) {
> - case SDVO_CLOCK_RATE_MULT_1X:
> - encoder_pixel_multiplier = 1;
> - break;
> - case SDVO_CLOCK_RATE_MULT_2X:
> - encoder_pixel_multiplier = 2;
> - break;
> - case SDVO_CLOCK_RATE_MULT_4X:
> - encoder_pixel_multiplier = 4;
> - break;
> + if (intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_CLOCK_RATE_MULT,
> + &val, 1)) {
> + switch (val) {
> + case SDVO_CLOCK_RATE_MULT_1X:
> + encoder_pixel_multiplier = 1;
> + break;
> + case SDVO_CLOCK_RATE_MULT_2X:
> + encoder_pixel_multiplier = 2;
> + break;
> + case SDVO_CLOCK_RATE_MULT_4X:
> + encoder_pixel_multiplier = 4;
> + break;
> + }
> }
>
> if(HAS_PCH_SPLIT(dev))
> --
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-07-12 15:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-11 18:46 [PATCH] drm/i915: Skip pixel multiplier x-check if we fail to send the command Damien Lespiau
2013-07-11 19:52 ` Daniel Vetter
2013-07-11 20:35 ` Damien Lespiau
2013-07-12 12:11 ` Daniel Vetter
2013-07-12 15:24 ` [PATCH 1/2] drm/i915: Don't attempt to read an unitialized stack value Damien Lespiau
2013-07-12 15:33 ` Daniel Vetter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.