From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: Re: [PATCH] drm/i915: make REG_BIT() and REG_GENMASK() work with variables
Date: Fri, 24 May 2019 20:43:42 +0100 [thread overview]
Message-ID: <155872702294.6190.16866375205996135181@skylake-alporthouse-com> (raw)
In-Reply-To: <20190524185253.1088-1-jani.nikula@intel.com>
Quoting Jani Nikula (2019-05-24 19:52:53)
> REG_BIT() and REG_GENMASK() were intended to work with both constant
> expressions and otherwise, with the former having extra compile time
> checks for the bit ranges. Incredibly, the result of
> __builtin_constant_p() is not an integer constant expression when given
> a non-constant expression, leading to errors in BUILD_BUG_ON_ZERO().
>
> Replace __builtin_constant_p() with the __is_constexpr() magic spell.
>
> Reported-by: Ville Syrjala <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/i915_reg.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 49dce04dd688..019c48748dc9 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -126,7 +126,7 @@
> */
> #define REG_BIT(__n) \
> ((u32)(BIT(__n) + \
> - BUILD_BUG_ON_ZERO(__builtin_constant_p(__n) && \
> + BUILD_BUG_ON_ZERO(__is_constexpr(__n) && \
> ((__n) < 0 || (__n) > 31))))
>
> /**
> @@ -140,8 +140,8 @@
> */
> #define REG_GENMASK(__high, __low) \
> ((u32)(GENMASK(__high, __low) + \
> - BUILD_BUG_ON_ZERO(__builtin_constant_p(__high) && \
> - __builtin_constant_p(__low) && \
> + BUILD_BUG_ON_ZERO(__is_constexpr(__high) && \
> + __is_constexpr(__low) && \
> ((__low) < 0 || (__high) > 31 || (__low) > (__high)))))
Ok, one old one remaining in _MASKED_FIELD().
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-05-24 19:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 18:52 [PATCH] drm/i915: make REG_BIT() and REG_GENMASK() work with variables Jani Nikula
2019-05-24 19:43 ` Chris Wilson [this message]
2019-05-27 10:13 ` Jani Nikula
2019-05-26 14:47 ` ✓ Fi.CI.BAT: success for " Patchwork
2019-05-27 8:57 ` ✓ 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=155872702294.6190.16866375205996135181@skylake-alporthouse-com \
--to=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@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 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.