Re: Re: [PATCH v3 1/3] bits: introduce fixed-type genmasks

2024-02-22 Thread Yury Norov
On Thu, Feb 22, 2024 at 05:04:10PM +0200, Andy Shevchenko wrote: > On Thu, Feb 22, 2024 at 06:49:59AM -0800, Yury Norov wrote: > > On Wed, Feb 21, 2024 at 03:59:06PM -0600, Lucas De Marchi wrote: > > ... > > > +#define __GENMASK(t, h, l) \ > > + ((~0 - (1 <&l

Re: Re: [PATCH v3 2/3] bits: Introduce fixed-type BIT

2024-02-22 Thread Yury Norov
On Mon, Feb 19, 2024 at 11:13:57PM -0600, Lucas De Marchi wrote: > On Fri, Feb 09, 2024 at 08:53:25AM -0800, Yury Norov wrote: > > On Wed, Feb 07, 2024 at 11:45:20PM -0800, Lucas De Marchi wrote: > > > Implement fixed-type BIT() to help drivers add stricter checks, like was >

Re: Re: [PATCH v3 1/3] bits: introduce fixed-type genmasks

2024-02-22 Thread Yury Norov
; > > -#define GENMASK_ULL(h, l) \ > > > > - (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l)) > > > > Ditto. > > problem here seems actually because of the cast to the final type. My > previous impl was avoiding that, but was too verbose compare

Re: [PATCH v3 2/3] bits: Introduce fixed-type BIT

2024-02-09 Thread Yury Norov
On Wed, Feb 07, 2024 at 11:45:20PM -0800, Lucas De Marchi wrote: > Implement fixed-type BIT() to help drivers add stricter checks, like was > done for GENMASK. > > Signed-off-by: Lucas De Marchi > Acked-by: Jani Nikula So I get v1 from Jan.23 in my mailbox, and this one is v3. Did I miss a v2?

Re: [PATCH 2/3] bits: Introduce fixed-type BIT

2024-02-09 Thread Yury Norov
On Tue, Jan 23, 2024 at 09:02:04PM -0800, Lucas De Marchi wrote: > Implement fixed-type BIT() to help drivers add stricter checks, like was > done for GENMASK. > > Signed-off-by: Lucas De Marchi Reviewed-by: Yury Norov > --- > include/linux/bits.h | 9 + &g

Re: Re: Re: [PATCH 1/3] bits: introduce fixed-type genmasks

2024-01-29 Thread Yury Norov
On Mon, Jan 29, 2024 at 08:49:35AM -0600, Lucas De Marchi wrote: > On Wed, Jan 24, 2024 at 07:27:58AM -0800, Yury Norov wrote: > > On Wed, Jan 24, 2024 at 08:03:53AM -0600, Lucas De Marchi wrote: > > > On Wed, Jan 24, 2024 at 09:58:26AM +0200, Jani Nikula wrote: > > > &

Re: Re: [PATCH 1/3] bits: introduce fixed-type genmasks

2024-01-24 Thread Yury Norov
On Wed, Jan 24, 2024 at 08:03:53AM -0600, Lucas De Marchi wrote: > On Wed, Jan 24, 2024 at 09:58:26AM +0200, Jani Nikula wrote: > > On Tue, 23 Jan 2024, Lucas De Marchi wrote: > > > From: Yury Norov > > > > > > Generalize __GENMASK() to support different ty

Re: Re: Re: [Intel-xe] [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros

2024-01-18 Thread Yury Norov
On Thu, Jan 18, 2024 at 05:25:00PM -0600, Lucas De Marchi wrote: > SA2PR11MB4874 > X-OriginatorOrg: intel.com > Status: RO > Content-Length: 6257 > Lines: 150 > > On Thu, Jan 18, 2024 at 01:48:43PM -0800, Yury Norov wrote: > > On Thu, Jan 18, 2024 at 02:42:12PM -

Re: Re: [Intel-xe] [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros

2024-01-18 Thread Yury Norov
On Thu, Jan 18, 2024 at 02:42:12PM -0600, Lucas De Marchi wrote: > Hi, > > Reviving this thread as now with xe driver merged we have 2 users for > a fixed-width BIT/GENMASK. Can you point where and why? > On Wed, Jun 21, 2023 at 07:20:59PM -0700, Yury Norov wrote: &g

Re: [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros

2023-06-22 Thread Yury Norov
+ Rasmus Villemoes > > -#define __GENMASK(h, l) \ > > - (((~UL(0)) - (UL(1) << (l)) + 1) & \ > > -(~UL(0) >> (BITS_PER_LONG - 1 - (h > > -#define GENMASK(h, l) \ > > - (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) > > +#define __GENMASK(t, h, l) \ > > + (GENMASK_INPUT_CHECK(h, l) +

Re: [PATCH 2/3] linux/bits.h: Add fixed-width GENMASK and BIT macros

2023-06-21 Thread Yury Norov
on the exact patch(es) that added a bug related to GENMASK() misuse? It would be easier to advocate the purpose of new API with that in mind. Regarding implementation - we should avoid copy-pasting in cases like this. Below is the patch that I boot-tested for x86_64 and compile-tested for arm64. It look

Re: [PATCH v5 0/7] treewide cleanup of random integer usage

2022-10-08 Thread Yury Norov
reewide-cleanup > experience might share some wisdom about what the best timing usually > winds up being, I'm all ears. > > Please take a look! The number of lines touched is quite small, so this > should be reviewable, and as much as is possible has been pushed into > Coccinelle

[PATCH 4/4] drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate

2022-04-20 Thread Yury Norov
The smu_v1X_0_set_allowed_mask() uses bitmap_copy() to convert bitmap to 32-bit array. This may be wrong due to endianness issues. Fix it by switching to bitmap_{from,to}_arr32. Signed-off-by: Yury Norov --- drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +- drivers/gpu/drm/amd/pm/swsmu

[PATCH 18/49] drm/i915/pmu: replace cpumask_weight with cpumask_empty where appropriate

2022-02-10 Thread Yury Norov
-by: Yury Norov Reviewed-by: Tvrtko Ursulin --- drivers/gpu/drm/i915/i915_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index cfc21042499d..7299ed9937dd 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b

[PATCH 08/49] drm: replace bitmap_weight with bitmap_empty where appropriate

2022-02-10 Thread Yury Norov
bits unconditionally. Signed-off-by: Yury Norov --- drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c index d7fa2c49e741..56a3063545ec 100644

Re: [PATCH 17/54] gpu: drm: replace cpumask_weight with cpumask_empty where appropriate

2022-01-25 Thread Yury Norov
On Tue, Jan 25, 2022 at 1:28 AM Tvrtko Ursulin wrote: > > > On 23/01/2022 18:38, Yury Norov wrote: > > i915_pmu_cpu_online() calls cpumask_weight() to check if any bit of a > > given cpumask is set. We can do it more efficiently with cpumask_empty() > > because cpuma

[PATCH 17/54] gpu: drm: replace cpumask_weight with cpumask_empty where appropriate

2022-01-23 Thread Yury Norov
-by: Yury Norov --- drivers/gpu/drm/i915/i915_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index ea655161793e..1894c876b31d 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915

[PATCH 07/54] gpu: drm: replace bitmap_weight with bitmap_empty where appropriate

2022-01-23 Thread Yury Norov
bits unconditionally. Signed-off-by: Yury Norov --- drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c index d7fa2c49e741..56a3063545ec 100644

Re: [PATCH 0/3] for_each_*_bit: move to find.h and reconsider

2021-07-28 Thread Yury Norov
Ping? On Fri, Jun 18, 2021 at 12:57:32PM -0700, Yury Norov wrote: > for_each_bit() macro family uses find_bit() functions, so it's better > to have for_each_bit() and find_bit() functions in the same header. > > This series puts for_each_bit() to a proper place and optimizes its

Re: [PATCH 2/3] find: micro-optimize for_each_{set,clear}_bit()

2021-06-27 Thread Yury Norov
On Sat, Jun 19, 2021 at 10:28:07AM -0700, Yury Norov wrote: > On Sat, Jun 19, 2021 at 05:24:15PM +0100, Marc Zyngier wrote: > > On Fri, 18 Jun 2021 20:57:34 +0100, > > Yury Norov wrote: > > > > > > The macros iterate thru all set/clear bits in a bitmap. Th

Re: [PATCH 3/3] Replace for_each_*_bit_from() with for_each_*_bit() where appropriate

2021-06-21 Thread Yury Norov
On Mon, Jun 21, 2021 at 01:17:11PM -0700, Guenter Roeck wrote: > On Fri, Jun 18, 2021 at 12:57:35PM -0700, Yury Norov wrote: > > A couple of kernel functions call for_each_*_bit_from() with start > > bit equal to 0. Replace them with for_each_*_bit(). > > > > No fu

Re: [PATCH 2/3] find: micro-optimize for_each_{set,clear}_bit()

2021-06-19 Thread Yury Norov
On Sat, Jun 19, 2021 at 05:24:15PM +0100, Marc Zyngier wrote: > On Fri, 18 Jun 2021 20:57:34 +0100, > Yury Norov wrote: > > > > The macros iterate thru all set/clear bits in a bitmap. They search a > > first bit using find_first_bit(), and the rest bits using find_ne

[PATCH 3/3] Replace for_each_*_bit_from() with for_each_*_bit() where appropriate

2021-06-19 Thread Yury Norov
A couple of kernel functions call for_each_*_bit_from() with start bit equal to 0. Replace them with for_each_*_bit(). No functional changes, but might improve on readability. Signed-off-by: Yury Norov --- arch/x86/kernel/apic/vector.c | 4 ++-- drivers/gpu/drm/etnaviv/etnaviv_gpu.c

[PATCH 2/3] find: micro-optimize for_each_{set,clear}_bit()

2021-06-19 Thread Yury Norov
The macros iterate thru all set/clear bits in a bitmap. They search a first bit using find_first_bit(), and the rest bits using find_next_bit(). Since find_next_bit() is called shortly after find_first_bit(), we can save few lines of I-cache by not using find_first_bit(). Signed-off-by: Yury

[PATCH 1/3] include/linux: move for_each_bit() macros from bitops.h to find.h

2021-06-19 Thread Yury Norov
for_each_bit() macros depend on find_bit() machinery, and so the proper place for them is the find.h header. Signed-off-by: Yury Norov --- include/linux/bitops.h | 34 -- include/linux/find.h | 34 ++ 2 files changed, 34

[PATCH 0/3] for_each_*_bit: move to find.h and reconsider

2021-06-19 Thread Yury Norov
/20210612123639.329047-1-yury.no...@gmail.com/ The full series can be found here: https://github.com/norov/linux/commits/bm-final Yury Norov (3): include/linux: move for_each_bit() macros from bitops.h to find.h find: micro-optimize for_each_{set,clear}_bit() Replace for_each_*_bit_from