From: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Intel graphics driver community testing & development
<intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: Avoid BIT(max) - 1 and use GENMASK(max, 0)
Date: Tue, 07 Feb 2017 16:38:51 +0200 [thread overview]
Message-ID: <1486478331.3121.123.camel@linux.intel.com> (raw)
In-Reply-To: <20170207140303.GB11545@nuc-i3427.alporthouse.com>
On ti, 2017-02-07 at 14:03 +0000, Chris Wilson wrote:
> On Tue, Feb 07, 2017 at 03:51:41PM +0200, Joonas Lahtinen wrote:
> >
> > "BIT(max) - 1" will overflow when max = 32, and GCC will complain.
> > We already have GENMASK for generating the mask, use it!
> >
> > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> > drivers/gpu/drm/i915/intel_device_info.c | 2 +-
> > drivers/gpu/drm/i915/intel_fbdev.c | 2 +-
> > drivers/gpu/drm/i915/intel_runtime_pm.c | 2 +-
> > 3 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_device_info.c b/drivers/gpu/drm/i915/intel_device_info.c
> > index fcf8181..1c06fbb 100644
> > --- a/drivers/gpu/drm/i915/intel_device_info.c
> > +++ b/drivers/gpu/drm/i915/intel_device_info.c
> > @@ -234,7 +234,7 @@ static void broadwell_sseu_info_init(struct drm_i915_private *dev_priv)
> > > > * The subslice disable field is global, i.e. it applies
> > > > * to each of the enabled slices.
> > > > */
> > > > - sseu->subslice_mask = BIT(ss_max) - 1;
> > > > + sseu->subslice_mask = GENMASK(ss_max, 0);
>
> Too simple!
>
> BUILD_BUG_ON(BIT(ss_max)-1 != GENMASK(ss_max, 0));
>
> Needs to be GENMASK(ss_max - 1, 0); the high bit is inclusive.
>
> Otherwise, the list matches up with a quick grep for BIT*(x)-1.
Whoop, seem to have nucleared my kernel config. I think better check if
the same warning is triggered too, with GENMASK :)
Regards, Joonas
--
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-02-07 14:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 13:51 [PATCH] drm/i915: Avoid BIT(max) - 1 and use GENMASK(max, 0) Joonas Lahtinen
2017-02-07 14:03 ` Chris Wilson
2017-02-07 14:38 ` Joonas Lahtinen [this message]
2017-02-07 16:28 ` ✗ Fi.CI.BAT: failure for " 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=1486478331.3121.123.camel@linux.intel.com \
--to=joonas.lahtinen@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/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.