Message ID | 20170908092935.1278-1-joonas.lahtinen@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, 08 Sep 2017, Joonas Lahtinen <joonas.lahtinen@linux.intel.com> wrote: > Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable > within static declarations (unlike combound statements). > > Cc: Jani Nikula <jani.nikula@intel.com> > Cc: Chris Wilson <chris@chris-wilson.co.uk> > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > --- > drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > index 63ca2ffcafef..c3f9d7d7b146 100644 > --- a/drivers/gpu/drm/i915/i915_drv.h > +++ b/drivers/gpu/drm/i915/i915_drv.h > @@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv) > #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) > > #define GEN_FOREVER (0) > + > +#define INTEL_GEN_MASK(s, e) ( \ > + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ > + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ > + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ > + (s) != GEN_FOREVER ? (s) - 1 : 0) \ Reviewed-by: Jani Nikula <jani.nikula@intel.com> but I'd really like a patch on top to remove the -1 from here and info->gen_mask. > +) > + > /* > * Returns true if Gen is in inclusive range [Start, End]. > * > * Use GEN_FOREVER for unbound start and or end. > */ > -#define IS_GEN(dev_priv, s, e) ({ \ > - unsigned int __s = (s), __e = (e); \ > - BUILD_BUG_ON(!__builtin_constant_p(s)); \ > - BUILD_BUG_ON(!__builtin_constant_p(e)); \ > - if ((__s) != GEN_FOREVER) \ > - __s = (s) - 1; \ > - if ((__e) == GEN_FOREVER) \ > - __e = BITS_PER_LONG - 1; \ > - else \ > - __e = (e) - 1; \ > - !!((dev_priv)->info.gen_mask & GENMASK((__e), (__s))); \ > -}) > +#define IS_GEN(dev_priv, s, e) \ > + (!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e)))) Actually, why do we even have info->gen_mask? It'll only ever have one bit set, and it's duplication of information. Why don't we use BIT((dev_priv)->info.gen) here? BR, Jani. > > /* > * Return true if revision is in range [since,until] inclusive.
On Fri, 2017-09-08 at 12:39 +0300, Jani Nikula wrote: > On Fri, 08 Sep 2017, Joonas Lahtinen <joonas.lahtinen@linux.intel.com> wrote: > > Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable > > within static declarations (unlike combound statements). > > > > Cc: Jani Nikula <jani.nikula@intel.com> > > Cc: Chris Wilson <chris@chris-wilson.co.uk> > > Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> > > --- > > drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ > > 1 file changed, 10 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h > > index 63ca2ffcafef..c3f9d7d7b146 100644 > > --- a/drivers/gpu/drm/i915/i915_drv.h > > +++ b/drivers/gpu/drm/i915/i915_drv.h > > @@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv) > > #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) > > > > #define GEN_FOREVER (0) > > + > > +#define INTEL_GEN_MASK(s, e) ( \ > > + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ > > + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ > > + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ > > + (s) != GEN_FOREVER ? (s) - 1 : 0) \ > > Reviewed-by: Jani Nikula <jani.nikula@intel.com> > > but I'd really like a patch on top to remove the -1 from here and > info->gen_mask. I'll add it. Regards, Joonas
On 08/09/2017 10:39, Jani Nikula wrote: > On Fri, 08 Sep 2017, Joonas Lahtinen <joonas.lahtinen@linux.intel.com> wrote: >> Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable >> within static declarations (unlike combound statements). >> >> Cc: Jani Nikula <jani.nikula@intel.com> >> Cc: Chris Wilson <chris@chris-wilson.co.uk> >> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> >> --- >> drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ >> 1 file changed, 10 insertions(+), 12 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h >> index 63ca2ffcafef..c3f9d7d7b146 100644 >> --- a/drivers/gpu/drm/i915/i915_drv.h >> +++ b/drivers/gpu/drm/i915/i915_drv.h >> @@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv) >> #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) >> >> #define GEN_FOREVER (0) >> + >> +#define INTEL_GEN_MASK(s, e) ( \ >> + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ >> + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ >> + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ >> + (s) != GEN_FOREVER ? (s) - 1 : 0) \ > > Reviewed-by: Jani Nikula <jani.nikula@intel.com> > > but I'd really like a patch on top to remove the -1 from here and > info->gen_mask. What is the objection on -1? It is hidden in the macros so you can only see it if looking at disassembly or even lower level. We could even make it -2, but AFAIR Chris wanted to keep the option for supporting gen1 open. :) Regards, Tvrtko
On Fri, 08 Sep 2017, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> wrote: > On 08/09/2017 10:39, Jani Nikula wrote: >> On Fri, 08 Sep 2017, Joonas Lahtinen <joonas.lahtinen@linux.intel.com> wrote: >>> Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable >>> within static declarations (unlike combound statements). >>> >>> Cc: Jani Nikula <jani.nikula@intel.com> >>> Cc: Chris Wilson <chris@chris-wilson.co.uk> >>> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> >>> --- >>> drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ >>> 1 file changed, 10 insertions(+), 12 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h >>> index 63ca2ffcafef..c3f9d7d7b146 100644 >>> --- a/drivers/gpu/drm/i915/i915_drv.h >>> +++ b/drivers/gpu/drm/i915/i915_drv.h >>> @@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv) >>> #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) >>> >>> #define GEN_FOREVER (0) >>> + >>> +#define INTEL_GEN_MASK(s, e) ( \ >>> + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ >>> + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ >>> + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ >>> + (s) != GEN_FOREVER ? (s) - 1 : 0) \ >> >> Reviewed-by: Jani Nikula <jani.nikula@intel.com> >> >> but I'd really like a patch on top to remove the -1 from here and >> info->gen_mask. > > What is the objection on -1? It is hidden in the macros so you can only > see it if looking at disassembly or even lower level. IMO it's unnecessary optimization that makes reviewing the patches at hand a tiny bit harder. Multiply that by everyone who ever looks at the guts of the macros, and wonders why gen_mask is really gen_off_by_one_mask, and for what reason. Indeed I thought there must be a reason, until I realized that in reality, there is none. BR, Jani. > > We could even make it -2, but AFAIR Chris wanted to keep the option for > supporting gen1 open. :) > > Regards, > > Tvrtko
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 63ca2ffcafef..c3f9d7d7b146 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2873,23 +2873,21 @@ intel_info(const struct drm_i915_private *dev_priv) #define INTEL_REVID(dev_priv) ((dev_priv)->drm.pdev->revision) #define GEN_FOREVER (0) + +#define INTEL_GEN_MASK(s, e) ( \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(s)) + \ + BUILD_BUG_ON_ZERO(!__builtin_constant_p(e)) + \ + GENMASK((e) != GEN_FOREVER ? (e) - 1 : BITS_PER_LONG - 1, \ + (s) != GEN_FOREVER ? (s) - 1 : 0) \ +) + /* * Returns true if Gen is in inclusive range [Start, End]. * * Use GEN_FOREVER for unbound start and or end. */ -#define IS_GEN(dev_priv, s, e) ({ \ - unsigned int __s = (s), __e = (e); \ - BUILD_BUG_ON(!__builtin_constant_p(s)); \ - BUILD_BUG_ON(!__builtin_constant_p(e)); \ - if ((__s) != GEN_FOREVER) \ - __s = (s) - 1; \ - if ((__e) == GEN_FOREVER) \ - __e = BITS_PER_LONG - 1; \ - else \ - __e = (e) - 1; \ - !!((dev_priv)->info.gen_mask & GENMASK((__e), (__s))); \ -}) +#define IS_GEN(dev_priv, s, e) \ + (!!((dev_priv)->info.gen_mask & INTEL_GEN_MASK((s), (e)))) /* * Return true if revision is in range [since,until] inclusive.
Split INTEL_GEN_MASK out of IS_GEN macro, and make it usable within static declarations (unlike combound statements). Cc: Jani Nikula <jani.nikula@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> --- drivers/gpu/drm/i915/i915_drv.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)