All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Fix wrong number of HDMI translation entries
@ 2014-08-09 15:29 Damien Lespiau
  2014-08-11  8:22 ` Jani Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Lespiau @ 2014-08-09 15:29 UTC (permalink / raw)
  To: intel-gfx; +Cc: Paulo Zanoni

I keep telling myself that those tables aren't great because their size
is the number of dwords we need to program and not the number of entries
(number of dwords = number of entries * 2).

And... I got it wrong when I refactored the code. Fortunately, it was
only wrong when the VBT table (or the code parsing it) is itself
erroneous. Long story short, it shouldn't matter, but still, there's a
potential array overflow and random programming of the DDI translation
tables.

Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index ca1f9a8..02d5584 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -169,14 +169,14 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
 		ddi_translations_dp = bdw_ddi_translations_dp;
 		ddi_translations_edp = bdw_ddi_translations_edp;
 		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
-		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
+		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
 		hdmi_800mV_0dB = 7;
 	} else if (IS_HASWELL(dev)) {
 		ddi_translations_fdi = hsw_ddi_translations_fdi;
 		ddi_translations_dp = hsw_ddi_translations_dp;
 		ddi_translations_edp = hsw_ddi_translations_dp;
 		ddi_translations_hdmi = hsw_ddi_translations_hdmi;
-		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi);
+		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi) / 2;
 		hdmi_800mV_0dB = 6;
 	} else {
 		WARN(1, "ddi translation table missing\n");
@@ -184,7 +184,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
 		ddi_translations_fdi = bdw_ddi_translations_fdi;
 		ddi_translations_dp = bdw_ddi_translations_dp;
 		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
-		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
+		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
 		hdmi_800mV_0dB = 7;
 	}
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/i915: Fix wrong number of HDMI translation entries
  2014-08-09 15:29 [PATCH] drm/i915: Fix wrong number of HDMI translation entries Damien Lespiau
@ 2014-08-11  8:22 ` Jani Nikula
  2014-08-11  9:29   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Jani Nikula @ 2014-08-11  8:22 UTC (permalink / raw)
  To: Damien Lespiau, intel-gfx; +Cc: Paulo Zanoni

On Sat, 09 Aug 2014, Damien Lespiau <damien.lespiau@intel.com> wrote:
> I keep telling myself that those tables aren't great because their size
> is the number of dwords we need to program and not the number of entries
> (number of dwords = number of entries * 2).
>
> And... I got it wrong when I refactored the code. Fortunately, it was
> only wrong when the VBT table (or the code parsing it) is itself
> erroneous. Long story short, it shouldn't matter, but still, there's a
> potential array overflow and random programming of the DDI translation
> tables.

Ugh I looked at the code. I think it would benefit from making the
tables have the right amount of entries, with struct { u32 hi, lo; } for
each element. I also dislike the ARRAY_SIZE(hsw_ddi_translations_fdi) in
the first loop, and magic 2 in the second. But that's for a rainy day.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_ddi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> index ca1f9a8..02d5584 100644
> --- a/drivers/gpu/drm/i915/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/intel_ddi.c
> @@ -169,14 +169,14 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
>  		ddi_translations_dp = bdw_ddi_translations_dp;
>  		ddi_translations_edp = bdw_ddi_translations_edp;
>  		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
> -		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
> +		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
>  		hdmi_800mV_0dB = 7;
>  	} else if (IS_HASWELL(dev)) {
>  		ddi_translations_fdi = hsw_ddi_translations_fdi;
>  		ddi_translations_dp = hsw_ddi_translations_dp;
>  		ddi_translations_edp = hsw_ddi_translations_dp;
>  		ddi_translations_hdmi = hsw_ddi_translations_hdmi;
> -		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi);
> +		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi) / 2;
>  		hdmi_800mV_0dB = 6;
>  	} else {
>  		WARN(1, "ddi translation table missing\n");
> @@ -184,7 +184,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
>  		ddi_translations_fdi = bdw_ddi_translations_fdi;
>  		ddi_translations_dp = bdw_ddi_translations_dp;
>  		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
> -		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
> +		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
>  		hdmi_800mV_0dB = 7;
>  	}
>  
> -- 
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/i915: Fix wrong number of HDMI translation entries
  2014-08-11  8:22 ` Jani Nikula
@ 2014-08-11  9:29   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2014-08-11  9:29 UTC (permalink / raw)
  To: Jani Nikula; +Cc: intel-gfx, Paulo Zanoni

On Mon, Aug 11, 2014 at 11:22:51AM +0300, Jani Nikula wrote:
> On Sat, 09 Aug 2014, Damien Lespiau <damien.lespiau@intel.com> wrote:
> > I keep telling myself that those tables aren't great because their size
> > is the number of dwords we need to program and not the number of entries
> > (number of dwords = number of entries * 2).
> >
> > And... I got it wrong when I refactored the code. Fortunately, it was
> > only wrong when the VBT table (or the code parsing it) is itself
> > erroneous. Long story short, it shouldn't matter, but still, there's a
> > potential array overflow and random programming of the DDI translation
> > tables.
> 
> Ugh I looked at the code. I think it would benefit from making the
> tables have the right amount of entries, with struct { u32 hi, lo; } for
> each element. I also dislike the ARRAY_SIZE(hsw_ddi_translations_fdi) in
> the first loop, and magic 2 in the second. But that's for a rainy day.
> 
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

Queued for -next, thanks for the patch.
-Daniel
> 
> >
> > Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> > Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> > ---
> >  drivers/gpu/drm/i915/intel_ddi.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> > index ca1f9a8..02d5584 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -169,14 +169,14 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
> >  		ddi_translations_dp = bdw_ddi_translations_dp;
> >  		ddi_translations_edp = bdw_ddi_translations_edp;
> >  		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
> > -		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
> > +		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
> >  		hdmi_800mV_0dB = 7;
> >  	} else if (IS_HASWELL(dev)) {
> >  		ddi_translations_fdi = hsw_ddi_translations_fdi;
> >  		ddi_translations_dp = hsw_ddi_translations_dp;
> >  		ddi_translations_edp = hsw_ddi_translations_dp;
> >  		ddi_translations_hdmi = hsw_ddi_translations_hdmi;
> > -		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi);
> > +		n_hdmi_entries = ARRAY_SIZE(hsw_ddi_translations_hdmi) / 2;
> >  		hdmi_800mV_0dB = 6;
> >  	} else {
> >  		WARN(1, "ddi translation table missing\n");
> > @@ -184,7 +184,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
> >  		ddi_translations_fdi = bdw_ddi_translations_fdi;
> >  		ddi_translations_dp = bdw_ddi_translations_dp;
> >  		ddi_translations_hdmi = bdw_ddi_translations_hdmi;
> > -		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi);
> > +		n_hdmi_entries = ARRAY_SIZE(bdw_ddi_translations_hdmi) / 2;
> >  		hdmi_800mV_0dB = 7;
> >  	}
> >  
> > -- 
> > 1.8.3.1
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Jani Nikula, Intel Open Source Technology Center
> _______________________________________________
> 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] 3+ messages in thread

end of thread, other threads:[~2014-08-11  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09 15:29 [PATCH] drm/i915: Fix wrong number of HDMI translation entries Damien Lespiau
2014-08-11  8:22 ` Jani Nikula
2014-08-11  9:29   ` 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.