From: Daniel Vetter <daniel@ffwll.ch>
To: Dave Gordon <david.s.gordon@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/bxt: Fix wrongly placed ')' in I915_READ()
Date: Wed, 14 Oct 2015 15:19:58 +0200 [thread overview]
Message-ID: <20151014131958.GF26718@phenom.ffwll.local> (raw)
In-Reply-To: <561E5193.9070109@intel.com>
On Wed, Oct 14, 2015 at 01:58:59PM +0100, Dave Gordon wrote:
> On 17/09/15 14:20, Damien Lespiau wrote:
> >Not the first time! not the last time?
> >
> >There is a possibility to use gcc 5's -Wbool-compare to try and compare
> >(reg) in those macros to a constant and gcc will warn that the
> >comparison between a boolean expression and a constant is always either
> >true or false. Maybe.
>
> Since boolean true (1) cannot be a valid argument to this macro, it could
> contain a compile-time check that the parameter is not 1; if boolean false
> (0) happens not to be a valid register address (BSpec says MMIO 0 is
> reserved) the macro could check that the argument is neither of these
> values, and the compiler might then detect that all possible paths lead to a
> compile-time error. Something like this?
>
> #define I915_READ(reg) \
> ({ \
> if (__builtin_constant_p(reg)) { \
> BUILD_BUG_ON((reg) == false); \
> BUILD_BUG_ON((reg) == true); \
> } \
> dev_priv->uncore.funcs.mmio_readl(dev_priv, (reg), true); \
> })
I like this.
> Interestingly, that reported three errors, all in intel_dsi.c where the
> port-selection macros use 0s to fill in dummy elements when less than 3
> ports are being used.
>
> In function ‘intel_dsi_get_hw_state’
> In function ‘intel_dsi_port_disable’
> In function ‘intel_dsi_port_enable’
>
> Other than that, there weren't any cases where a bool constant was being
> passed to this specific macro (as of today).
I guess we could fix for_each_dsi_port to only enumerate A and C with
something like
#define for_each_dsi_port(port, mask) \
for (port = PORT_A, port <= PORT_C; port == PORT_A ? PORT_C : port++) \
if (...)
I still think that Ville's approach should catch even more fallout (like
mixing up values and registers for write maybe), but this is a great
interim hack.
Patch wanted ;-)
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-10-14 13:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 13:20 [PATCH] drm/i915/bxt: Fix wrongly placed ')' in I915_READ() Damien Lespiau
2015-09-17 13:42 ` Imre Deak
2015-09-18 11:25 ` Jani Nikula
2015-10-14 12:58 ` Dave Gordon
2015-10-14 13:19 ` Daniel Vetter [this message]
2015-10-14 13:29 ` Jani Nikula
2015-10-14 13:35 ` Jani Nikula
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=20151014131958.GF26718@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=david.s.gordon@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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