All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Use __is_constexpr()
@ 2019-03-20 15:40 Chris Wilson
  2019-03-20 16:05 ` Randy Dunlap
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chris Wilson @ 2019-03-20 15:40 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Randy Dunlap

gcc-4.8 and older dislike the use of __builtin_constant_p() within a
constant expression context, and so we must use the magical
__is_constexpr() instead.

For example, with gcc-4.8.5:
../drivers/gpu/drm/i915/i915_reg.h:167:27: error: first argument to ‘__builtin_choose_expr’ not a constant
../include/linux/build_bug.h:16:45: error: bit-field ‘<anonymous>’ width not an integer constant

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Fixes: baa09e7d2f42 ("drm/i915: use REG_FIELD_PREP() to define register bitfield values")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
---
 drivers/gpu/drm/i915/i915_reg.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 85e8d1a1f70b..50d0b2ae89eb 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -161,10 +161,10 @@
  */
 #define REG_FIELD_PREP(__mask, __val)						\
 	((u32)((((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) +	\
-	       BUILD_BUG_ON_ZERO(!__builtin_constant_p(__mask)) +		\
+	       BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) +		\
 	       BUILD_BUG_ON_ZERO((__mask) == 0 || (__mask) > U32_MAX) +		\
 	       BUILD_BUG_ON_ZERO(!IS_POWER_OF_2((__mask) + (1ULL << __bf_shf(__mask)))) + \
-	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__builtin_constant_p(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
+	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
 
 /**
  * REG_FIELD_GET() - Extract a u32 bitfield value
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Use __is_constexpr()
  2019-03-20 15:40 [PATCH] drm/i915: Use __is_constexpr() Chris Wilson
@ 2019-03-20 16:05 ` Randy Dunlap
  2019-03-20 17:20 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
  2019-03-21  9:50 ` [PATCH] " Jani Nikula
  2 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2019-03-20 16:05 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Jani Nikula

On 3/20/19 8:40 AM, Chris Wilson wrote:
> gcc-4.8 and older dislike the use of __builtin_constant_p() within a
> constant expression context, and so we must use the magical
> __is_constexpr() instead.
> 
> For example, with gcc-4.8.5:
> ../drivers/gpu/drm/i915/i915_reg.h:167:27: error: first argument to ‘__builtin_choose_expr’ not a constant
> ../include/linux/build_bug.h:16:45: error: bit-field ‘<anonymous>’ width not an integer constant
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: baa09e7d2f42 ("drm/i915: use REG_FIELD_PREP() to define register bitfield values")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  drivers/gpu/drm/i915/i915_reg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 85e8d1a1f70b..50d0b2ae89eb 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -161,10 +161,10 @@
>   */
>  #define REG_FIELD_PREP(__mask, __val)						\
>  	((u32)((((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) +	\
> -	       BUILD_BUG_ON_ZERO(!__builtin_constant_p(__mask)) +		\
> +	       BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) +		\
>  	       BUILD_BUG_ON_ZERO((__mask) == 0 || (__mask) > U32_MAX) +		\
>  	       BUILD_BUG_ON_ZERO(!IS_POWER_OF_2((__mask) + (1ULL << __bf_shf(__mask)))) + \
> -	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__builtin_constant_p(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
> +	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
>  
>  /**
>   * REG_FIELD_GET() - Extract a u32 bitfield value
> 


-- 
~Randy
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use __is_constexpr()
  2019-03-20 15:40 [PATCH] drm/i915: Use __is_constexpr() Chris Wilson
  2019-03-20 16:05 ` Randy Dunlap
@ 2019-03-20 17:20 ` Patchwork
  2019-03-21  9:50 ` [PATCH] " Jani Nikula
  2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2019-03-20 17:20 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: Use __is_constexpr()
URL   : https://patchwork.freedesktop.org/series/58278/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
3ae1e5b1f498 drm/i915: Use __is_constexpr()
-:38: WARNING:LONG_LINE: line over 100 characters
#38: FILE: drivers/gpu/drm/i915/i915_reg.h:167:
+	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))

total: 0 errors, 1 warnings, 0 checks, 12 lines checked

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Use __is_constexpr()
  2019-03-20 15:40 [PATCH] drm/i915: Use __is_constexpr() Chris Wilson
  2019-03-20 16:05 ` Randy Dunlap
  2019-03-20 17:20 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
@ 2019-03-21  9:50 ` Jani Nikula
  2019-03-21 10:00   ` Chris Wilson
  2 siblings, 1 reply; 5+ messages in thread
From: Jani Nikula @ 2019-03-21  9:50 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx; +Cc: Randy Dunlap

On Wed, 20 Mar 2019, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> gcc-4.8 and older dislike the use of __builtin_constant_p() within a
> constant expression context, and so we must use the magical
> __is_constexpr() instead.
>
> For example, with gcc-4.8.5:
> ../drivers/gpu/drm/i915/i915_reg.h:167:27: error: first argument to ‘__builtin_choose_expr’ not a constant
> ../include/linux/build_bug.h:16:45: error: bit-field ‘<anonymous>’ width not an integer constant
>
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: baa09e7d2f42 ("drm/i915: use REG_FIELD_PREP() to define register bitfield values")
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Randy Dunlap <rdunlap@infradead.org>

Thanks, Uma reported this too and confirmed __is_constexpr works.

Reported-by: Uma Shankar <uma.shankar@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_reg.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 85e8d1a1f70b..50d0b2ae89eb 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -161,10 +161,10 @@
>   */
>  #define REG_FIELD_PREP(__mask, __val)						\
>  	((u32)((((typeof(__mask))(__val) << __bf_shf(__mask)) & (__mask)) +	\
> -	       BUILD_BUG_ON_ZERO(!__builtin_constant_p(__mask)) +		\
> +	       BUILD_BUG_ON_ZERO(!__is_constexpr(__mask)) +		\
>  	       BUILD_BUG_ON_ZERO((__mask) == 0 || (__mask) > U32_MAX) +		\
>  	       BUILD_BUG_ON_ZERO(!IS_POWER_OF_2((__mask) + (1ULL << __bf_shf(__mask)))) + \
> -	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__builtin_constant_p(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
> +	       BUILD_BUG_ON_ZERO(__builtin_choose_expr(__is_constexpr(__val), (~((__mask) >> __bf_shf(__mask)) & (__val)), 0))))
>  
>  /**
>   * REG_FIELD_GET() - Extract a u32 bitfield value

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH] drm/i915: Use __is_constexpr()
  2019-03-21  9:50 ` [PATCH] " Jani Nikula
@ 2019-03-21 10:00   ` Chris Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2019-03-21 10:00 UTC (permalink / raw)
  To: Jani Nikula, intel-gfx; +Cc: Randy Dunlap

Quoting Jani Nikula (2019-03-21 09:50:25)
> On Wed, 20 Mar 2019, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > gcc-4.8 and older dislike the use of __builtin_constant_p() within a
> > constant expression context, and so we must use the magical
> > __is_constexpr() instead.
> >
> > For example, with gcc-4.8.5:
> > ../drivers/gpu/drm/i915/i915_reg.h:167:27: error: first argument to ‘__builtin_choose_expr’ not a constant
> > ../include/linux/build_bug.h:16:45: error: bit-field ‘<anonymous>’ width not an integer constant
> >
> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
> > Fixes: baa09e7d2f42 ("drm/i915: use REG_FIELD_PREP() to define register bitfield values")
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Jani Nikula <jani.nikula@intel.com>
> > Cc: Imre Deak <imre.deak@intel.com>
> > Cc: Randy Dunlap <rdunlap@infradead.org>
> 
> Thanks, Uma reported this too and confirmed __is_constexpr works.
> 
> Reported-by: Uma Shankar <uma.shankar@intel.com>
> Reviewed-by: Jani Nikula <jani.nikula@intel.com>

And pushed for a quieter tomorrow. Thanks everyone for reporting!
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2019-03-21 10:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 15:40 [PATCH] drm/i915: Use __is_constexpr() Chris Wilson
2019-03-20 16:05 ` Randy Dunlap
2019-03-20 17:20 ` ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2019-03-21  9:50 ` [PATCH] " Jani Nikula
2019-03-21 10:00   ` Chris Wilson

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.