[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a0LWLKs+0quG_OS6EPgg2uSAOM69SKTix47tEUmuZWRdw@mail.gmail.com>
Date: Sat, 2 Jan 2021 12:23:20 +0100
From: Arnd Bergmann <arnd@...nel.org>
To: Chris Wilson <chris@...is-wilson.co.uk>
Cc: Daniel Vetter <daniel@...ll.ch>, David Airlie <airlied@...ux.ie>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Arnd Bergmann <arnd@...db.de>,
Ville Syrjälä <ville.syrjala@...ux.intel.com>,
José Roberto de Souza <jose.souza@...el.com>,
Matt Roper <matthew.d.roper@...el.com>,
Daniele Ceraolo Spurio <daniele.ceraolospurio@...el.com>,
Intel Graphics <intel-gfx@...ts.freedesktop.org>,
dri-devel <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] i915: fix shift warning
On Wed, Dec 30, 2020 at 4:56 PM Chris Wilson <chris@...is-wilson.co.uk> wrote:
>
> Quoting Arnd Bergmann (2020-12-30 15:39:14)
> > From: Arnd Bergmann <arnd@...db.de>
> >
> > Randconfig builds on 32-bit machines show lots of warnings for
> > the i915 driver for incorrect bit masks like:
>
> mask is a u8.
>
> VCS0 is 2, I915_MAX_VCS 4
>
> (u8 & GENMASK(5, 2)) >> 2
Ah right, I misread the warning then.
> > drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c:2584:9: error: shift count >= width of type [-Werror,-Wshift-count-overflow]
> > return hweight64(VDBOX_MASK(&i915->gt));
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64'
> > #define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w))
>
> So it's upset by hweight64() on the unsigned long?
I suspect what is going on is that clang once again warns because it performs
more code checks before dead-code elimination than gcc does. The warning is
for the __const_hweight64() case, which is not actually used here because the
input is not a compile-time constant.
> So hweight_long?
That seems to work, I'll send a new version with that.
> Or use a cast, hweight8((intel_engine_mask_t)VDMASK())?
>
> static __always_inline int engine_count(intel_engine_mask_t mask)
> {
> return sizeof(mask) == 1 ? hweight8(mask) :
> sizeof(mask) == 2 ? hweight16(mask) :
> sizeof(mask) == 4 ? hweight32(mask) :
> hweight64(mask);
> }
Fine with me as well. If you prefer that way, I'll let you handle that.
Arnd
Powered by blists - more mailing lists