FROMGIT: drm/i915: Ensure intel_engine_init_execlist() builds with Clang

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)

Reported-by: Stephen Boyd <>
Cc: Stephen Boyd <>
Cc: Chris Wilson <>
Tested-by: Nathan Chancellor <>
Tested-by: Stephen Boyd <>
Reviewed-by: Chris Wilson <>
Reviewed-by: Nick Desaulniers <>
Signed-off-by: Jani Nikula <>
(cherry picked from commit 410ed5731a6566498a3aa904420aa2e49ba0ba90
 git:// drm-intel-next-queued)

TEST=Build amd64-generic with ubsan use flag

Change-Id: I0a1973f817cb5e5e0fe55a1d1231cb40a34054ad
Signed-off-by: Stephen Boyd <>
Commit-Ready: Douglas Anderson <>
Reviewed-by: Manoj Gupta <>
Reviewed-by: Douglas Anderson <>
diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c
index 5417c59..dd7ce11 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -408,7 +408,7 @@
 	execlists->csb_use_mmio = csb_force_mmio(engine->i915);
 	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 = RB_ROOT;