All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>
Subject: [PATCH] drm/i915: Silence build error with UBSAN
Date: Mon, 15 Oct 2018 13:34:10 -0700	[thread overview]
Message-ID: <20181015203410.155997-1-swboyd@chromium.org> (raw)

When I enable UBSAN and compile this driver with clang I get 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'

from what I can figure out, the compiler can't optimize
execlists_num_ports() sufficiently enough at compile time to figure out
that the 'execlists->port_mask = 1' assignment one line above the
BUILD_BUG_ON_NOT_POWER_OF_2 check will make execlists_num_ports() return
2. Most likely that's because UBSAN is going to check the load inside
execlists_num_ports() and that check isn't omitted so the optimizer
can't optimize away the whole function.

So let's just change this check to cause a build error when the maximum
number of ports isn't a power of two. It looks like this is similar to
what's being checked here so this might work well enough.

Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 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 217ed3ee1cab..bdf75628ed83 100644
--- a/drivers/gpu/drm/i915/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/intel_engine_cs.c
@@ -463,7 +463,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));
+	BUILD_BUG_ON_NOT_POWER_OF_2(EXECLIST_MAX_PORTS);
 	GEM_BUG_ON(execlists_num_ports(execlists) > EXECLIST_MAX_PORTS);
 
 	execlists->queue_priority = INT_MIN;
-- 
Sent by a computer through tubes


             reply	other threads:[~2018-10-15 20:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-15 20:34 Stephen Boyd [this message]
2018-10-15 21:05 ` ✓ Fi.CI.BAT: success for drm/i915: Silence build error with UBSAN Patchwork
2018-10-16  1:25 ` ✓ Fi.CI.IGT: " Patchwork
2018-10-16  9:59 ` [PATCH] " Jani Nikula
2018-10-16 10:07   ` Chris Wilson
2018-10-16 10:07     ` Chris Wilson
2018-10-16 11:48     ` Jani Nikula
2018-10-16 10:33 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Silence build error with UBSAN (rev2) Patchwork
2018-10-16 10:50 ` ✓ Fi.CI.BAT: success " Patchwork
2018-10-16 11:43 ` ✓ 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=20181015203410.155997-1-swboyd@chromium.org \
    --to=swboyd@chromium.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=rodrigo.vivi@intel.com \
    --cc=yamada.masahiro@socionext.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.