From: Damien Lespiau <damien.lespiau@intel.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: Check mask/bit helper functions
Date: Mon, 8 Dec 2014 15:14:41 +0000 [thread overview]
Message-ID: <20141208151441.GD4337@strange.ger.corp.intel.com> (raw)
In-Reply-To: <1418050829-5493-1-git-send-email-daniel.vetter@ffwll.ch>
On Mon, Dec 08, 2014 at 04:00:29PM +0100, Daniel Vetter wrote:
> After a bit of irc discussion we've concluded that it would be prudent
> to check that callers use the mask/enable paramters correctly. So add
> a WARN_ON.
>
> Now most callers have static parameters, so even better would be if we
> could bug at compile-time. Hence improve the i915 WARN_ON to
> BUILD_BUG_ON if the condition can be statically determined. Thanks to
> Chris for this suggestion.
>
> All this spurred by Damien's bugfix which added _MASKED_FIELD.
>
> Cc: Damien Lespiau <damien.lespiau@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 9 ++++++++-
> drivers/gpu/drm/i915/i915_irq.c | 6 ++++++
> 2 files changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 95dfa2dd35b9..e5d9d6642b09 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -57,8 +57,15 @@
> #define DRIVER_DESC "Intel Graphics"
> #define DRIVER_DATE "20141205"
>
> +static inline bool __i915_warn_on(bool cond, const char *str)
> +{
> + if (__builtin_constant_p(cond))
> + BUILD_BUG_ON(cond);
> + return WARN(cond, str);
> +}
- Can we have BUILD_BUG_ON_MSG()?
- We could avoid emitting the WARN() part if __builtin_constant_p() is
true, we don't really need to run-time code in there in that case.
> #undef WARN_ON
> -#define WARN_ON(x) WARN(x, "WARN_ON(" #x ")")
> +#define WARN_ON(x) __i915_warn_on((x), "WARN_ON(" #x ")")
>
> enum pipe {
> INVALID_PIPE = -1,
> diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
> index 08a5a4ba52ac..e6a1db36928e 100644
> --- a/drivers/gpu/drm/i915/i915_irq.c
> +++ b/drivers/gpu/drm/i915/i915_irq.c
> @@ -183,6 +183,8 @@ static void ilk_update_gt_irq(struct drm_i915_private *dev_priv,
> {
> assert_spin_locked(&dev_priv->irq_lock);
>
> + WARN_ON(enabled_irq_mask & ~interrupt_mask);
> +
> if (WARN_ON(!intel_irqs_enabled(dev_priv)))
> return;
>
> @@ -229,6 +231,8 @@ static void snb_update_pm_irq(struct drm_i915_private *dev_priv,
> {
> uint32_t new_val;
>
> + WARN_ON(enabled_irq_mask & ~interrupt_mask);
> +
> assert_spin_locked(&dev_priv->irq_lock);
>
> new_val = dev_priv->pm_irq_mask;
> @@ -328,6 +332,8 @@ void ibx_display_interrupt_update(struct drm_i915_private *dev_priv,
> sdeimr &= ~interrupt_mask;
> sdeimr |= (~enabled_irq_mask & interrupt_mask);
>
> + WARN_ON(enabled_irq_mask & ~interrupt_mask);
> +
> assert_spin_locked(&dev_priv->irq_lock);
>
> if (WARN_ON(!intel_irqs_enabled(dev_priv)))
> --
> 2.1.1
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2014-12-08 15:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-08 15:00 [PATCH] drm/i915: Check mask/bit helper functions Daniel Vetter
2014-12-08 15:14 ` Damien Lespiau [this message]
2014-12-08 15:19 ` Daniel Vetter
2014-12-08 15:18 ` Jani Nikula
2014-12-08 15:20 ` Daniel Vetter
2014-12-08 15:30 ` Daniel Vetter
2014-12-08 15:44 ` Jani Nikula
2014-12-08 16:23 ` Jani Nikula
2014-12-09 12:57 ` shuang.he
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=20141208151441.GD4337@strange.ger.corp.intel.com \
--to=damien.lespiau@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=daniel.vetter@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