[Intel-gfx] [PATCH 2/2] drm/i915: Ensure intel_engine_init_execlist() builds with Clang
Nathan Chancellor
natechancellor at gmail.com
Tue Oct 16 15:11:00 UTC 2018
On Tue, Oct 16, 2018 at 03:29:38PM +0300, Jani Nikula wrote:
> Clang build with UBSAN enabled leads to the following build error:
>
> drivers/gpu/drm/i915/intel_engine_cs.o: In function `intel_engine_init_execlist':
> drivers/gpu/drm/i915/intel_engine_cs.c:411: undefined reference to `__compiletime_assert_411'
>
> Again, for this to work the code would first need to be inlined and then
> constant folded, which doesn't work for Clang because semantic analysis
> happens before optimization/inlining.
>
> Use GEM_BUG_ON() instead of BUILD_BUG_ON().
>
> v2: Use is_power_of_2() from log2.h (Chris)
>
> References: http://mid.mail-archive.com/20181015203410.155997-1-swboyd@chromium.org
> Reported-by: Stephen Boyd <swboyd at chromium.org>
> Cc: Stephen Boyd <swboyd at chromium.org>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> Signed-off-by: Jani Nikula <jani.nikula at intel.com>
> ---
Tested-by: Nathan Chancellor <natechancellor at gmail.com>
> drivers/gpu/drm/i915/intel_engine_cs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
> index f27dbe26bcc1..bc793b0c8806 100644
> --- a/drivers/gpu/drm/i915/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/intel_engine_cs.c
> @@ -466,7 +466,7 @@ static void intel_engine_init_execlist(struct intel_engine_cs *engine)
> struct intel_engine_execlists * const execlists = &engine->execlists;
>
> execlists->port_mask = 1;
> - BUILD_BUG_ON_NOT_POWER_OF_2(execlists_num_ports(execlists));
> + GEM_BUG_ON(!is_power_of_2(execlists_num_ports(execlists)));
> GEM_BUG_ON(execlists_num_ports(execlists) > EXECLIST_MAX_PORTS);
>
> execlists->queue_priority = INT_MIN;
> --
> 2.11.0
>
More information about the Intel-gfx
mailing list