From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: James Ausmus <james.ausmus@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 09/10] drm/i915: Unify error handling for missing DDI buf trans tables
Date: Wed, 18 Oct 2017 21:15:09 +0300 [thread overview]
Message-ID: <20171018181509.GQ10981@intel.com> (raw)
In-Reply-To: <20171018175240.GO10981@intel.com>
On Wed, Oct 18, 2017 at 08:52:40PM +0300, Ville Syrjälä wrote:
> On Wed, Oct 18, 2017 at 10:41:44AM -0700, James Ausmus wrote:
> > On Mon, Oct 16, 2017 at 05:57:04PM +0300, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Handle missing buf trans tables, or out of bounds buf trans levels
> > > the same way everywhere. These should never be hit under normal
> > > conditions, but let's play it safe for now.
> > >
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > > drivers/gpu/drm/i915/intel_ddi.c | 25 ++++++++++++++++++++-----
> > > 1 file changed, 20 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> > > index f0a709b66e00..5f1c546e5e61 100644
> > > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > > @@ -801,6 +801,9 @@ static int intel_ddi_hdmi_level(struct drm_i915_private *dev_priv, enum port por
> > > hdmi_level >= n_hdmi_entries)
> > > hdmi_level = hdmi_default_entry;
> > >
> > > + if (WARN_ON_ONCE(hdmi_level >= n_hdmi_entries))
> > > + hdmi_level = n_hdmi_entries - 1;
> >
> > intel_ddi_get_buf_trans_* can set n_entries to 0 on failure,
> > which would cause this to return a level of -1 - maybe those functions
> > need to return 1 on failure instead, similar to the cnl_get_buf_trans_*
> > functions?
>
> Hmm. I guess we could just do
>
> if (WARN_ON(hdmi_level == 0))
> return;
>
> before the other check. That would be equivalent to the
> !ddi_translations checks done in the other places.
Hmm. Actually now that I read things again, the -1 shouldn't actually
cause us any problems since all uses of it would do a second
!ddi_translations check before indexing anything with the -1.
-1 and 0 are both wrong indexes when dealing with a zero sized array,
but I suppose in theory 0 is a bit better since it would trip up on
firther level>=n_entries checks. So I guess I could try to avoid
the negative value.
Another way to do that would be just
- return hdmi_level;
+ return max(hdmi_level, 0);
Or your other idea about keeping things unsigned would also take care
of it. Except having a wild UINT_MAX roaming around seems potentially
more dangerous to me.
> >
> > > +
> > > return hdmi_level;
> > > }
> > >
> > > @@ -864,6 +867,11 @@ static void intel_prepare_hdmi_ddi_buffers(struct intel_encoder *encoder,
> > >
> > > ddi_translations_hdmi = intel_ddi_get_buf_trans_hdmi(dev_priv, &n_hdmi_entries);
> > >
> > > + if (WARN_ON_ONCE(!ddi_translations_hdmi))
> > > + return;
> > > + if (WARN_ON_ONCE(hdmi_level >= n_hdmi_entries))
> > > + hdmi_level = n_hdmi_entries - 1;
> > > +
> > > /* If we're boosting the current, set bit 31 of trans1 */
> > > if (IS_GEN9_BC(dev_priv) &&
> > > dev_priv->vbt.ddi_port_info[port].hdmi_boost_level)
> > > @@ -1847,6 +1855,11 @@ static void skl_ddi_set_iboost(struct intel_encoder *encoder,
> > > else
> > > ddi_translations = intel_ddi_get_buf_trans_dp(dev_priv, port, &n_entries);
> > >
> > > + if (WARN_ON_ONCE(!ddi_translations))
> > > + return;
> > > + if (WARN_ON_ONCE(level >= n_entries))
> > > + level = n_entries - 1;
> >
> >
> > > +
> > > iboost = ddi_translations[level].i_boost;
> > > }
> > >
> > > @@ -1877,6 +1890,11 @@ static void bxt_ddi_vswing_sequence(struct intel_encoder *encoder,
> > > else
> > > ddi_translations = bxt_get_buf_trans_dp(dev_priv, &n_entries);
> > >
> > > + if (WARN_ON_ONCE(!ddi_translations))
> > > + return;
> > > + if (WARN_ON_ONCE(level >= n_entries))
> > > + level = n_entries - 1;
> > > +
> > > bxt_ddi_phy_set_signal_level(dev_priv, port,
> > > ddi_translations[level].margin,
> > > ddi_translations[level].scale,
> > > @@ -1932,13 +1950,10 @@ static void cnl_ddi_vswing_program(struct intel_encoder *encoder,
> > > else
> > > ddi_translations = cnl_get_buf_trans_dp(dev_priv, &n_entries);
> > >
> > > - if (WARN_ON(ddi_translations == NULL))
> > > + if (WARN_ON_ONCE(!ddi_translations))
> > > return;
> > > -
> > > - if (level >= n_entries) {
> > > - DRM_DEBUG_KMS("DDI translation not found for level %d. Using %d instead.", level, n_entries - 1);
> > > + if (WARN_ON_ONCE(level >= n_entries))
> > > level = n_entries - 1;
> > > - }
> > >
> > > /* Set PORT_TX_DW5 Scaling Mode Sel to 010b. */
> > > val = I915_READ(CNL_PORT_TX_DW5_LN0(port));
> > > --
> > > 2.13.6
> > >
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
> --
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-10-18 18:15 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 14:56 [PATCH 00/10] DDI buf trans cleanup Ville Syrjala
2017-10-16 14:56 ` [PATCH v2 01/10] drm/i915: Relocate intel_ddi_get_buf_trans_*() functions Ville Syrjala
2017-10-16 23:30 ` Ausmus, James
2017-10-16 14:56 ` [PATCH 02/10] drm/i915: Extract intel_ddi_get_buf_trans_hdmi() Ville Syrjala
2017-10-16 23:41 ` Ausmus, James
2017-10-18 17:09 ` Ville Syrjälä
2017-10-18 17:50 ` James Ausmus
2017-10-18 20:43 ` Manasi Navare
2017-10-16 14:56 ` [PATCH v2 03/10] drm/i915: Pass the encoder type explicitly to skl_set_iboost() Ville Syrjala
2017-10-17 0:02 ` Ausmus, James
2017-10-16 14:56 ` [PATCH 04/10] drm/i915: Pass the level to intel_prepare_hdmi_ddi_buffers() Ville Syrjala
2017-10-17 0:06 ` Ausmus, James
2017-10-16 14:57 ` [PATCH v2 05/10] drm/i915: Integrate BXT into intel_ddi_dp_voltage_max() Ville Syrjala
2017-10-18 16:51 ` James Ausmus
2017-10-16 14:57 ` [PATCH v2 06/10] drm/i915: Pass encoder type to cnl_ddi_vswing_sequence() explicitly Ville Syrjala
2017-10-18 16:59 ` James Ausmus
2017-10-18 21:11 ` Manasi Navare
2017-10-19 10:38 ` Ville Syrjälä
2017-10-19 23:58 ` Manasi Navare
2017-10-16 14:57 ` [PATCH 07/10] drm/i915: Kill off the BXT buf_trans default_index Ville Syrjala
2017-10-18 17:05 ` James Ausmus
2017-10-16 14:57 ` [PATCH 08/10] drm/i915: Centralize the SKL DDI A/E vs. B/C/D buf trans handling Ville Syrjala
2017-10-18 17:21 ` James Ausmus
2017-10-16 14:57 ` [PATCH 09/10] drm/i915: Unify error handling for missing DDI buf trans tables Ville Syrjala
2017-10-18 17:41 ` James Ausmus
2017-10-18 17:52 ` Ville Syrjälä
2017-10-18 18:15 ` Ville Syrjälä [this message]
2017-10-18 18:33 ` James Ausmus
2017-10-18 18:19 ` [PATCH v2 " Ville Syrjala
2017-10-18 19:59 ` James Ausmus
2017-10-16 14:57 ` [PATCH 10/10] drm/i915: Drop the redundant hdmi prefix/suffix from a lot of variables Ville Syrjala
2017-10-18 17:43 ` James Ausmus
2017-10-18 17:54 ` Ville Syrjälä
2017-10-18 19:58 ` James Ausmus
2017-10-18 18:19 ` [PATCH v2 " Ville Syrjala
2017-10-18 19:59 ` James Ausmus
2017-10-19 12:47 ` Ville Syrjälä
2017-10-16 15:43 ` ✓ Fi.CI.BAT: success for DDI buf trans cleanup Patchwork
2017-10-17 3:07 ` ✗ Fi.CI.IGT: warning " Patchwork
2017-10-18 18:38 ` ✓ Fi.CI.BAT: success for DDI buf trans cleanup (rev3) Patchwork
2017-10-19 3:06 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171018181509.GQ10981@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=james.ausmus@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox