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

2025-04-04 Thread Vincent Mailhol
the other variants. If doing: #define GENMASK_TYPE(t, h, l) \ ((t)(GENMASK_INPUT_CHECK(h, l) +\ (((t)1 << (h) << 1) - ((t)1 << (l))))) The unit tests pass for everything and you even still get the warning if h is out of bound. But then, bloat-o-meter (x86_64, defconfig, GCC 12.4.1) shows a small increase: Total: Before=22723482, After=22724586, chg +0.00% So, probably not worth the change anyway. I am keeping the current version. Yours sincerely, Vincent Mailhol

[PATCH v8 1/6] bits: add comments and newlines to #if, #else and #endif directives

2025-03-25 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol This is a preparation for the upcoming GENMASK_U*() and BIT_U*() changes. After introducing those new macros, there will be a lot of scrolling between the #if, #else and #endif. Add a comment to the #else and #endif preprocessor macros to help keep track of which context

[PATCH v8 6/6] test_bits: add tests for BIT_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add some additional tests in lib/tests/test_bits.c to cover the expected results of the fixed type BIT_U*() macros. Signed-off-by: Vincent Mailhol Reviewed-by: Lucas De Marchi --- Changelog: v7 -> v8: - In commit db6fe4d61ece ("lib: Move KUnit tests in

[PATCH v7 3/5] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
Marchi Acked-by: Jani Nikula Signed-off-by: Vincent Mailhol --- Changelog: v6 -> v7: - Replace BIT_* and GENMASK_* by BIT_U*() and GENMASK_U*() in the description. - Add the information in the description that BIT_U*() and GENMASK_U*() are fixed width. v5 -> v6:

Re: [PATCH v7 0/5] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-25 Thread Vincent Mailhol
On 26/03/2025 at 00:23, Yury Norov wrote: > On Tue, Mar 25, 2025 at 01:23:22AM +0900, Vincent Mailhol wrote: (...) > This series doesn't apply on 6.15-rc1 because test_bits.c has moved to > lib/tests. Can you please rebase your v8 and submit? I see no other > issues to merge

[PATCH v8 2/6] bits: introduce fixed-type GENMASK_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add GENMASK_TYPE() which generalizes __GENMASK() to support different types, and implement fixed-types versions of GENMASK() based on it. The fixed-type version allows more strict checks to the min/max values accepted, which is useful for defining registers like implemented

[PATCH v8 3/6] bits: introduce fixed-type BIT_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
From: Lucas De Marchi Implement fixed-type BIT_U*() to help drivers add stricter checks, like it was done for GENMASK_U*(). Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincent Mailhol Signed-off-by: Vincent Mailhol --- Changelog: v7 -> v8: - s/shift-co

[PATCH v8 0/6] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
REG_GENMASK*() to fixed-width GENMASK_U*() test_bits: add tests for GENMASK_U*() Vincent Mailhol (3): bits: add comments and newlines to #if, #else and #endif directives bits: introduce fixed-type GENMASK_U*() test_bits: add tests for BIT_U*() drivers/gpu/drm/i915/i915_reg

[PATCH v8 5/6] test_bits: add tests for GENMASK_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
tests. Signed-off-by: Lucas De Marchi Signed-off-by: Vincent Mailhol --- Changelog: v7 -> v8: - In commit db6fe4d61ece ("lib: Move KUnit tests into tests/ subdirectory"), lib/test_bits.c was moved to lib/tests/test_bits.c. Adjust the patch descrption accordingly

[PATCH v8 4/6] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-25 Thread Vincent Mailhol via B4 Relay
Marchi Acked-by: Jani Nikula Signed-off-by: Vincent Mailhol --- Changelog: v7 -> v8: - No changes. v6 -> v7: - Replace BIT_* and GENMASK_* by BIT_U*() and GENMASK_U*() in the description. - Add the information in the description that BIT_U*() and GENMASK_U*

Re: [PATCH v7 0/5] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-24 Thread Vincent Mailhol
On 24/03/2025 at 23:28, Yury Norov wrote: > On Sat, Mar 22, 2025 at 06:23:11PM +0900, Vincent Mailhol via B4 Relay wrote: >> Introduce some fixed width variant of the GENMASK() and the BIT() >> macros in bits.h. Note that the main goal is not to get the correct >> type, but r

Re: [PATCH 0/3] bits: Split asm and non-asm GENMASK*() and unify definitions

2025-03-24 Thread Vincent Mailhol
_U128() from __GENMASK_U128(), but I did not touch the uapi. After this series, __GENMASK_U128() is not used anymore in the kernel, but I am not brave enough to remove it myself because there is always a risk that some userland code somewhere is relying on it… (...) Yours sincerely, Vincent Mailhol

Re: [PATCH v7 2/5] bits: introduce fixed-type BIT_U*()

2025-03-24 Thread Vincent Mailhol
On 24/03/2025 at 22:41, Andy Shevchenko wrote: > On Sat, Mar 22, 2025 at 06:23:13PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Lucas De Marchi >> >> Implement fixed-type BIT_U*() to help drivers add stricter checks, >> like it was done for GENMASK_U*(). >

Re: [PATCH v7 1/5] bits: introduce fixed-type GENMASK_U*()

2025-03-24 Thread Vincent Mailhol
On 24/03/2025 at 16:22, Andy Shevchenko wrote: > On Sat, Mar 22, 2025 at 06:23:12PM +0900, Vincent Mailhol via B4 Relay wrote: >> >> Add GENMASK_TYPE() which generalizes __GENMASK() to support different >> types, and implement fixed-types versions of GENMASK() based on

[PATCH 2/3] bits: unify the non-asm GENMASK*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol The newly introduced GENMASK_TYPE() macro can also be used to generate the pre-existing non-asm GENMASK*() variants. Apply GENMASK_TYPE() to GENMASK(), GENMASK_ULL() and GENMASK_U128(). Signed-off-by: Vincent Mailhol --- include/linux/bits.h | 26

[PATCH 3/3] test_bits: add tests for __GENMASK() and __GENMASK_ULL()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol The definitions of GENMASK() and GENMASK_ULL() do not depend any more on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests so that __GENMASK{,ULL}() are still covered. Because __GENMASK() and __GENMASK_ULL() do use GENMASK_INPUT_CHECK(), drop the

[PATCH 1/3] bits: split the definition of the asm and non-asm GENMASK*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In an upcoming change, the non-asm GENMASK*() will all be unified to depend on GENMASK_TYPE() which indirectly depend on sizeof(), something not available in asm. Instead of adding further complexity to GENMASK_TYPE() to make it work for both asm and non asm, just split

[PATCH 0/3] bits: Split asm and non-asm GENMASK*() and unify definitions

2025-03-22 Thread Vincent Mailhol via B4 Relay
13271328 +1 cfg80211_inform_bss_data51095108 -1 intel_drrs_activate 379 376 -3 Total: Before=22723481, After=22723482, chg +0.00% (done with GCC 12.4.1 on an x86_64 defconfig) -- 2.43.0 Signed-off-by: Vincent

[PATCH v7 2/5] bits: introduce fixed-type BIT_U*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Lucas De Marchi Implement fixed-type BIT_U*() to help drivers add stricter checks, like it was done for GENMASK_U*(). Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincent Mailhol Signed-off-by: Vincent Mailhol --- Changelog: v6 -> v7: v5 -> v6:

[PATCH v7 4/5] test_bits: add tests for GENMASK_U*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
. Signed-off-by: Lucas De Marchi Signed-off-by: Vincent Mailhol --- Changelog: v6 -> v7: v5 -> v6: - No changes. v4 -> v5: - Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to u8/u16. v3 -> v4: - Adjust the type of GENMASK_U8()/GENMASK_U16() fr

[PATCH v7 1/5] bits: introduce fixed-type GENMASK_U*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add GENMASK_TYPE() which generalizes __GENMASK() to support different types, and implement fixed-types versions of GENMASK() based on it. The fixed-type version allows more strict checks to the min/max values accepted, which is useful for defining registers like implemented

[PATCH v7 5/5] test_bits: add tests for BIT_U*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add some additional tests in lib/test_bits.c to cover the expected results of the fixed type BIT_U*() macros. Signed-off-by: Vincent Mailhol Reviewed-by: Lucas De Marchi --- Changelog: v6 -> v7: - Add Lucas's Reviewed-by tag. v5 -> v6: - No cha

[PATCH v7 0/5] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-22 Thread Vincent Mailhol via B4 Relay
30509051403.2748545-1-lucas.demar...@intel.com --- Lucas De Marchi (3): bits: introduce fixed-type BIT_U*() drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*() test_bits: add tests for GENMASK_U*() Vincent Mailhol (2): bits: introduce fixed-type GENMASK_U*()

Re: [PATCH v6 2/7] bits: introduce fixed-type genmasks

2025-03-18 Thread Vincent Mailhol
On 19/03/2025 at 01:45, Yury Norov wrote: > On Sat, Mar 08, 2025 at 01:48:49AM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Yury Norov (...) >> +#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l) >> +#define GENMASK_ULL(h, l) GENMASK_TYPE(uns

Re: [PATCH v6 4/7] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-18 Thread Vincent Mailhol
On 19/03/2025 at 07:32, Jani Nikula wrote: > On Tue, 18 Mar 2025, Yury Norov wrote: >> On Sat, Mar 08, 2025 at 01:48:51AM +0900, Vincent Mailhol via B4 Relay wrote: >>> From: Lucas De Marchi >>> >>> Now that include/linux/bits.h implements fixed-width GENMASK

Re: [PATCH v6 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-18 Thread Vincent Mailhol
On 19/03/2025 at 01:06, Yury Norov wrote: > On Sat, Mar 08, 2025 at 06:10:25PM +0900, Vincent Mailhol wrote: >> On 08/03/2025 at 02:42, Andy Shevchenko wrote: >>> On Sat, Mar 08, 2025 at 01:48:48AM +0900, Vincent Mailhol via B4 Relay >>> wrote: >>>> From: Vi

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-12 Thread Vincent Mailhol
On 13/03/2025 at 13:16, Lucas De Marchi wrote: > On Fri, Mar 07, 2025 at 02:10:28AM +0900, Vincent Mailhol wrote: >> On 06/03/2025 at 23:34, Lucas De Marchi wrote: >>> On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay >>> wrote: >> >&

Re: [PATCH v5 5/7] test_bits: add tests for __GENMASK() and __GENMASK_ULL()

2025-03-12 Thread Vincent Mailhol
On 13/03/2025 at 13:13, Lucas De Marchi wrote: > On Thu, Mar 06, 2025 at 08:29:56PM +0900, Vincent Mailhol via B4 Relay > wrote: >> From: Vincent Mailhol >> >> The definitions of GENMASK() and GENMASK_ULL() do not depend any more >> on __GENMASK() and __GENMASK_ULL(

[PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-11 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In an upcoming change, GENMASK() and its friends will indirectly depend on sizeof() which is not available in asm. Instead of adding further complexity to __GENMASK() to make it work for both asm and non asm, just split the definition of the two variants. Signed-off-by

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-11 Thread Vincent Mailhol
On 07/03/2025 at 04:23, David Laight wrote: > On Thu, 06 Mar 2025 20:29:52 +0900 > Vincent Mailhol via B4 Relay > wrote: > >> From: Vincent Mailhol >> >> In an upcoming change, GENMASK() and its friends will indirectly >> depend on sizeof() which is no

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-10 Thread Vincent Mailhol
On 09/03/2025 at 19:23, David Laight wrote: > On Sun, 9 Mar 2025 01:58:53 + > David Laight wrote: > >> On Fri, 7 Mar 2025 18:58:08 +0900 >> Vincent Mailhol wrote: >> >>> On 07/03/2025 at 04:23, David Laight wrote: >>>> On Thu, 06 Mar 2025

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-08 Thread Vincent Mailhol
On 06/03/2025 at 23:34, Lucas De Marchi wrote: > On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay > wrote: (...) > it seems we now have 1 inconsistency that we comment why > GENMASK_U128() is not available in asm, but we don't comment why > GENMASK_

Re: [PATCH v6 0/7] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-08 Thread Vincent Mailhol
sions. If you know >> anyone relevant in ARM or everywhere else, feel free to loop them. > > I see, yep, we still have time for that, let's wait a bit. Ack. Andy, I already addressed your last comments in my local tree. I will now wait for others' feedback. Yours sincerely, Vincent Mailhol

Re: [PATCH v6 4/7] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-08 Thread Vincent Mailhol
On 08/03/2025 at 02:54, Andy Shevchenko wrote: > On Sat, Mar 08, 2025 at 01:48:51AM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Lucas De Marchi >> >> Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use >> them to implement the i915/xe speci

[PATCH v5 7/7] test_bits: add tests for BIT_U*()

2025-03-08 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add some additional tests in lib/test_bits.c to cover the expected results of the fixed type BIT_U*() macros. Signed-off-by: Vincent Mailhol --- Changelog v4 -> v5: - BIT_U8()/BIT_U16() are now back to u8/u16. v3 -> v4: - New patch. --- lib/test_

Re: [PATCH v6 3/7] bits: introduce fixed-type BIT_U*()

2025-03-08 Thread Vincent Mailhol
On 08/03/2025 at 02:49, Andy Shevchenko wrote: > On Fri, Mar 07, 2025 at 07:48:01PM +0200, Andy Shevchenko wrote: >> On Sat, Mar 08, 2025 at 01:48:50AM +0900, Vincent Mailhol via B4 Relay wrote: > > ... > >>> /* >>> * Missing asm support >>> *

Re: [PATCH v6 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-08 Thread Vincent Mailhol
On 08/03/2025 at 02:42, Andy Shevchenko wrote: > On Sat, Mar 08, 2025 at 01:48:48AM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Vincent Mailhol >> >> In an upcoming change, GENMASK() and its friends will indirectly >> depend on sizeof() which is not availab

[PATCH v6 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-07 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In an upcoming change, GENMASK() and its friends will indirectly depend on sizeof() which is not available in asm. Instead of adding further complexity to __GENMASK() to make it work for both asm and non asm, just split the definition of the two variants. Signed-off-by

[PATCH v6 7/7] test_bits: add tests for BIT_U*()

2025-03-07 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add some additional tests in lib/test_bits.c to cover the expected results of the fixed type BIT_U*() macros. Signed-off-by: Vincent Mailhol --- Changelog: v5 -> v6: - No changes. v4 -> v5: - BIT_U8()/BIT_U16() are now back to u8/u16. v3

[PATCH v6 3/7] bits: introduce fixed-type BIT_U*()

2025-03-07 Thread Vincent Mailhol via B4 Relay
From: Lucas De Marchi Implement fixed-type BIT_U*() to help drivers add stricter checks, like it was done for GENMASK_U*(). Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincent Mailhol Signed-off-by: Vincent Mailhol --- Changelog: v5 -> v6: - No chan

[PATCH v6 4/7] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-07 Thread Vincent Mailhol via B4 Relay
Marchi Acked-by: Jani Nikula Signed-off-by: Vincent Mailhol --- Changelog: v5 -> v6: - No changes. v4 -> v5: - Add braket to macro names in patch description, e.g. 'REG_GENMASK*' -> 'REG_GENMASK*()' v3 -> v4: - Remove the prefixe

Re: [PATCH v5 7/7] test_bits: add tests for BIT_U*()

2025-03-07 Thread Vincent Mailhol
On 08/03/2025 at 01:07, Andy Shevchenko wrote: > On Fri, Mar 07, 2025 at 07:11:42PM +0900, Vincent Mailhol wrote: >> On 07/03/2025 at 02:55, Andy Shevchenko wrote: >>> On Fri, Mar 07, 2025 at 01:08:15AM +0900, Vincent Mailhol wrote: >>>> On 06/03/2025 at 22:11, Andy

[PATCH v6 6/7] test_bits: add tests for GENMASK_U*()

2025-03-07 Thread Vincent Mailhol via B4 Relay
. Signed-off-by: Lucas De Marchi Signed-off-by: Vincent Mailhol --- Changelog: v5 -> v6: - No changes. v4 -> v5: - Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to u8/u16. v3 -> v4: - Adjust the type of GENMASK_U8()/GENMASK_U16() from

[PATCH v6 0/7] bits: Fixed-type GENMASK_U*() and BIT_U*()

2025-03-07 Thread Vincent Mailhol via B4 Relay
20230509051403.2748545-1-lucas.demar...@intel.com --- Lucas De Marchi (3): bits: introduce fixed-type BIT_U*() drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*() test_bits: add tests for GENMASK_U*() Vincent Mailhol (3): bits: split the definition of the asm and

[PATCH v6 2/7] bits: introduce fixed-type genmasks

2025-03-07 Thread Vincent Mailhol via B4 Relay
: error: right shift count >= width of type [-Werror=shift-count-overflow] 51 | type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h) | ^~ Signed-off-by: Yury Norov Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincen

[PATCH v6 5/7] test_bits: add tests for __GENMASK() and __GENMASK_ULL()

2025-03-07 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol The definitions of GENMASK() and GENMASK_ULL() do not depend any more on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests so that __GENMASK{,ULL}() is still covered. It would be good to have a small assembly test case for GENMASK*() in case somebody

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-07 Thread Vincent Mailhol
On 07/03/2025 at 22:27, David Laight wrote: > On Fri, 7 Mar 2025 18:58:08 +0900 > Vincent Mailhol wrote: > >> On 07/03/2025 at 04:23, David Laight wrote: >>> On Thu, 06 Mar 2025 20:29:52 +0900 >>> Vincent Mailhol via B4 Relay >>> wrote: >>>

Re: [PATCH v5 7/7] test_bits: add tests for BIT_U*()

2025-03-07 Thread Vincent Mailhol
On 07/03/2025 at 02:55, Andy Shevchenko wrote: > On Fri, Mar 07, 2025 at 01:08:15AM +0900, Vincent Mailhol wrote: >> On 06/03/2025 at 22:11, Andy Shevchenko wrote: >>> On Thu, Mar 06, 2025 at 08:29:58PM +0900, Vincent Mailhol via B4 Relay >>> wrote: >>>> Fr

Re: [PATCH v5 2/7] bits: introduce fixed-type genmasks

2025-03-06 Thread Vincent Mailhol
On 06/03/2025 à 22:08, Andy Shevchenko wrote: > On Thu, Mar 06, 2025 at 08:29:53PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Yury Norov >> >> Add GENMASK_TYPE() which generalizes __GENMASK() to support different >> types, and implement fixed-types versio

Re: [PATCH v5 0/7] bits: Fixed-type GENMASK()/BIT()

2025-03-06 Thread Vincent Mailhol
On 06/03/2025 at 22:02, Andy Shevchenko wrote: > On Thu, Mar 06, 2025 at 08:29:51PM +0900, Vincent Mailhol via B4 Relay wrote: >> Introduce some fixed width variant of the GENMASK() and the BIT() >> macros in bits.h. Note that the main goal is not to get the correct >> type,

Re: [PATCH v5 7/7] test_bits: add tests for BIT_U*()

2025-03-06 Thread Vincent Mailhol
On 06/03/2025 at 22:11, Andy Shevchenko wrote: > On Thu, Mar 06, 2025 at 08:29:58PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Vincent Mailhol >> >> Add some additional tests in lib/test_bits.c to cover the expected >> results of the fixed type BIT_U*() macro

Re: [PATCH v5 1/7] bits: split the definition of the asm and non-asm GENMASK()

2025-03-06 Thread Vincent Mailhol
On 06/03/2025 at 22:05, Andy Shevchenko wrote: > On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Vincent Mailhol >> >> In an upcoming change, GENMASK() and its friends will indirectly >> depend on sizeof() which is not availab

[PATCH v5 0/7] bits: Fixed-type GENMASK()/BIT()

2025-03-06 Thread Vincent Mailhol via B4 Relay
*() drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*() test_bits: add tests for GENMASK_U*() Vincent Mailhol (3): bits: split the definition of the asm and non-asm GENMASK() test_bits: add tests for __GENMASK() and __GENMASK_ULL() test_bits: add tests f

[PATCH v5 6/7] test_bits: add tests for GENMASK_U*()

2025-03-06 Thread Vincent Mailhol via B4 Relay
. Signed-off-by: Lucas De Marchi Signed-off-by: Vincent Mailhol --- Changelog: v4 -> v5: - Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to u8/u16. v3 -> v4: - Adjust the type of GENMASK_U8()/GENMASK_U16() from u8/u16 to unsigned int. - Reord

[PATCH v5 4/7] drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()

2025-03-06 Thread Vincent Mailhol via B4 Relay
Marchi Acked-by: Jani Nikula Signed-off-by: Vincent Mailhol --- Changelog: v4 -> v5: - Add braket to macro names in patch description, e.g. 'REG_GENMASK*' -> 'REG_GENMASK*()' v3 -> v4: - Remove the prefixes in macro parameters, e.

[PATCH v5 2/7] bits: introduce fixed-type genmasks

2025-03-06 Thread Vincent Mailhol via B4 Relay
: error: right shift count >= width of type [-Werror=shift-count-overflow] 51 | type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h) | ^~ Signed-off-by: Yury Norov Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincen

[PATCH v5 5/7] test_bits: add tests for __GENMASK() and __GENMASK_ULL()

2025-03-06 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol The definitions of GENMASK() and GENMASK_ULL() do not depend any more on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests so that __GENMASK{,ULL}() is still covered. Signed-off-by: Vincent Mailhol --- lib/test_bits.c | 18 ++ 1 file

[PATCH v5 3/7] bits: introduce fixed-type BIT_U*()

2025-03-06 Thread Vincent Mailhol via B4 Relay
From: Lucas De Marchi Implement fixed-type BIT_U*() to help drivers add stricter checks, like was done for GENMASK_U*(). Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Co-developed-by: Vincent Mailhol Signed-off-by: Vincent Mailhol --- Changelog: v4 -> v5: - Rename GENMAS

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

2025-03-06 Thread Vincent Mailhol
The question raised by Yury on whether or not we should keep __GENMASK_U128() in the uapi still remains. And in full honesty, I will not touch that one. This is not in the scope of this series. Yours sincerely, Vincent Mailhol

Re: [PATCH v4 4/8] bits: introduce fixed-type BIT

2025-03-06 Thread Vincent Mailhol
On 06/03/2025 at 18:12, Andy Shevchenko wrote: > On Wed, Mar 05, 2025 at 09:50:27PM +, David Laight wrote: >> On Wed, 5 Mar 2025 21:56:22 +0200 >> Andy Shevchenko wrote: >>> On Thu, Mar 06, 2025 at 02:17:18AM +0900, Vincent Mailhol wrote: >>>> On 06/03/

Re: [PATCH v4 4/8] bits: introduce fixed-type BIT

2025-03-05 Thread Vincent Mailhol
On 06/03/2025 at 00:48, Andy Shevchenko wrote: > On Wed, Mar 05, 2025 at 11:48:10PM +0900, Vincent Mailhol wrote: >> On 05/03/2025 at 23:33, Andy Shevchenko wrote: >>> On Wed, Mar 05, 2025 at 10:00:16PM +0900, Vincent Mailhol via B4 Relay >>> wrote: > &

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

2025-03-05 Thread Vincent Mailhol
On 06/03/2025 at 00:47, Yury Norov wrote: > On Wed, Mar 05, 2025 at 10:00:15PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Yury Norov >> >> Add __GENMASK_t() which generalizes __GENMASK() to support different >> types, and implement fixed-types versions of GE

Re: [PATCH v4 1/8] bits: fix typo 'unsigned __init128' -> 'unsigned __int128'

2025-03-05 Thread Vincent Mailhol
On 05/03/2025 at 23:38, Yury Norov wrote: > On Wed, Mar 05, 2025 at 04:36:12PM +0200, Andy Shevchenko wrote: >> On Wed, Mar 05, 2025 at 09:30:20AM -0500, Yury Norov wrote: >>> On Wed, Mar 05, 2025 at 10:00:13PM +0900, Vincent Mailhol via B4 Relay >>> wrote:

Re: [PATCH v4 4/8] bits: introduce fixed-type BIT

2025-03-05 Thread Vincent Mailhol
On 05/03/2025 at 23:33, Andy Shevchenko wrote: > On Wed, Mar 05, 2025 at 10:00:16PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Lucas De Marchi >> >> Implement fixed-type BIT to help drivers add stricter checks, like was > > Here and in the Subject I would us

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

2025-03-05 Thread Vincent Mailhol
On 05/03/2025 at 23:30, Andy Shevchenko wrote: > On Wed, Mar 05, 2025 at 10:00:15PM +0900, Vincent Mailhol via B4 Relay wrote: >> From: Yury Norov >> >> Add __GENMASK_t() which generalizes __GENMASK() to support different > > Is it with double underscore? I do not see

[PATCH v4 4/8] bits: introduce fixed-type BIT

2025-03-05 Thread Vincent Mailhol via B4 Relay
From: Lucas De Marchi 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 Signed-off-by: Vincent Mailhol --- Changelog: v3 -> v4: - Use const_true() to simplify BIT_INPUT_CHECK(). - M

[PATCH v4 0/8] bits: Fixed-type GENMASK()/BIT()

2025-03-05 Thread Vincent Mailhol via B4 Relay
45-1-lucas.demar...@intel.com -- 2.43.0 --- Lucas De Marchi (3): bits: introduce fixed-type BIT drm/i915: Convert REG_GENMASK* to fixed-width GENMASK_* test_bits: add tests for fixed-type genmasks Vincent Mailhol (4): bits: fix typo 'unsigned __init128' -> &

[PATCH v4 5/8] drm/i915: Convert REG_GENMASK* to fixed-width GENMASK_*

2025-03-05 Thread Vincent Mailhol via B4 Relay
Acked-by: Jani Nikula Signed-off-by: Vincent Mailhol --- Changelog: v3 -> v4: - Remove the prefixes in macro parameters, e.g. 'REG_GENMASK(__high, __low)' -> 'REG_GENMASK(high, low)' --- drivers/gpu/drm/i915/i915_reg_defs.h | 108 -

[PATCH v4 6/8] test_bits: add tests for __GENMASK() and __GENMASK_ULL()

2025-03-05 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol The definitions of GENMASK() and GENMASK_ULL() do not depend any more on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests so that __GENMASK{,ULL}() is still covered. Signed-off-by: Vincent Mailhol --- lib/test_bits.c | 18 ++ 1 file

[PATCH v4 7/8] test_bits: add tests for fixed-type genmasks

2025-03-05 Thread Vincent Mailhol via B4 Relay
-off-by: Lucas De Marchi Signed-off-by: Vincent Mailhol --- Changelog: v3 -> v4: - Adjust the type of GENMASK_U8()/GENMASK_U16() from u8/u16 to unsigned int. - Reorder the tests to match the order in which the macros are declared in bits.h. --- lib/test_bits.c |

[PATCH v4 3/8] bits: introduce fixed-type genmasks

2025-03-05 Thread Vincent Mailhol via B4 Relay
/bits.h:41:31: error: left shift count >= width of type [-Werror=shift-count-overflow] 41 | (((t)~0ULL - ((t)(1) << (l)) + 1) & \ | ^~ Signed-off-by: Yury Norov Signed-off-by: Lucas De Marchi Acked-by: Jani Nikula Signed-of

[PATCH v4 8/8] test_bits: add tests for fixed-type BIT

2025-03-05 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Add some additional tests in lib/test_bits.c to cover the expected results of the BIT_U*() macros. Signed-off-by: Vincent Mailhol --- lib/test_bits.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/lib/test_bits.c b/lib/test_bits.c index

[PATCH v4 2/8] bits: split the definition of the asm and non-asm GENMASK()

2025-03-05 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In an upcoming change, GENMASK() and its friends will indirectly depend on sizeof() which is not available in asm. Instead of adding further complexity to __GENMASK() to make it work for both asm and non asm, just split the definition of the two variants. Signed-off-by

[PATCH v4 1/8] bits: fix typo 'unsigned __init128' -> 'unsigned __int128'

2025-03-05 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol "int" was misspelled as "init" in GENMASK_U128() comments. Fix the typo. Signed-off-by: Vincent Mailhol --- include/linux/bits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bits.h b/includ

Re: [PATCH v3 0/3] Fixed-type GENMASK/BIT

2025-02-02 Thread Vincent Mailhol
. With the -next development windows opening very soon, wouldn't it be a good idea to revive this topic? Yours sincerely, Vincent Mailhol

Re: [PATCH 05/10] minmax: simplify __clamp_once() by using is_const_false()

2024-12-09 Thread Vincent Mailhol
On Fri. 6 Dec. 2024 at 00:52, Vincent Mailhol wrote: > On Thu. 5 Dec. 2024 at 03:54, David Laight wrote: > > From: Vincent Mailhol > > > Sent: 02 December 2024 17:33 > > > > > > In __clamp_once(), > > > > > > __builtin_choose_expr(__is_cons

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
tps://godbolt.org/z/xer4aMees And can we ignore the case (!(var << 2))? This is not a warning because of the macro, but because of the caller! If I do any of: if (!(var << 2)) {} (void)__builtin_constant_p(!(var << 2)); I also got the warning. The point is that the macro should not generate *new* warnings. If the given argument already raises a warning, it is the caller's responsibility to fix. Yours sincerely, Vincent Mailhol

Re: [PATCH 03/10] compiler.h: add is_const_true() and is_const_false()

2024-12-07 Thread Vincent Mailhol
On Thu. 5 Dec 2024 at 03:48, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > __builtin_constant_p() is known for not always being able to produce > > constant expression [1] which led to the introduction of > > __is_constexpr

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
On Fri. 6 Dec. 2024 at 15:40, Martin Uecker wrote: > Am Freitag, dem 06.12.2024 um 02:25 + schrieb David Laight: > > From: Vincent Mailhol > > > Sent: 05 December 2024 15:31 > > > > > > -CC: Martin Uecker > > > +CC: Martin Uecker > > >

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
On Sun. 8 Dec. 2024 at 00:10, Martin Uecker wrote: > Am Samstag, dem 07.12.2024 um 22:50 +0900 schrieb Vincent Mailhol: > > On Sat. 7 Dec. 2024 à 22:19, Martin Uecker wrote: > > > > ... > > > > > I was invited to WG14 this September. For now, I am only lurking

Re: [PATCH 05/10] minmax: simplify __clamp_once() by using is_const_false()

2024-12-07 Thread Vincent Mailhol
On Thu. 5 Dec. 2024 at 03:54, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > In __clamp_once(), > > > > __builtin_choose_expr(__is_constexpr((lo) > (hi)), (lo) <= (hi), true) > > > > is equivalent to: &g

Re: [PATCH 04/10] linux/bits.h: simplify GENMASK_INPUT_CHECK() by using is_const_true()

2024-12-07 Thread Vincent Mailhol
On Thu. 5 Dec 2024 at 03:52, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > __builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0) > > > > is equivalent to: > > > > is_const_true((l) > (h)

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
-CC: Martin Uecker +CC: Martin Uecker (seems that Martin changed his address) On Thu. 5 Dec. 2024 at 03:39, David Laight wrote: > > Sent: 02 December 2024 17:33 > > > > From: Vincent Mailhol > > > > __is_constexpr(), while being one of the most glorious one li

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
On Sat. 7 Dec. 2024 at 20:19, David Laight wrote: > From: Vincent Mailhol > > Sent: 07 December 2024 07:43 > ... > > > So maybe the slightly long lines: > > > #define const_true(x) _Generic(0 ? (void *)((x) + 0 ? 0L : 1L) : (char > > > *)0, char *: 1

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
On Sat. 7 Dec. 2024 at 17:39, Martin Uecker wrote: > Am Freitag, dem 06.12.2024 um 16:26 +0900 schrieb Vincent Mailhol: > > > On Fri. 6 Dec. 2024 at 15:40, Martin Uecker wrote: > > > > > Am Freitag, dem 06.12.2024 um 02:25 + schrieb David Laight: > >

Re: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-07 Thread Vincent Mailhol
On Sat. 7 Dec. 2024 à 22:19, Martin Uecker wrote: > Am Samstag, dem 07.12.2024 um 21:45 +0900 schrieb Vincent Mailhol: > > On Sat. 7 Dec. 2024 at 17:39, Martin Uecker wrote: > > > Am Freitag, dem 06.12.2024 um 16:26 +0900 schrieb Vincent Mailhol: > > ... > > >

Re: [PATCH 06/10] fortify: replace __is_constexpr() by is_const() in strlen()

2024-12-06 Thread Vincent Mailhol
On Thu. 5 Dec. 2024 at 03:58, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > From: Vincent Mailhol > > > > is_const() is a one to one replacement of __is_constexpr(). Do the > > replacement so that __is_constexpr(

Re: [PATCH 00/10] compiler.h: refactor __is_constexpr() into is_const{, _true, _false}()

2024-12-06 Thread Vincent Mailhol
On Thu. 5 Dec. 2024 at 08:58, Kees Cook wrote: > On December 3, 2024 3:33:22 AM GMT+10:00, Vincent Mailhol via B4 Relay > wrote: > >This series is the spiritual successor of [1] which introduced > >const_true(). In [1], following a comment from David Laight, Linus > >c

Re: [PATCH 01/10] compiler.h: add statically_false()

2024-12-06 Thread Vincent Mailhol
On Thu. 5 Dec 2024 at 03:30, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:33 > > > > From: Vincent Mailhol > > > > For completion, add statically_false() which is the equivalent of > > statically_true() except that it will ret

Re: [PATCH 08/10] drm/i915/reg: replace __is_const_expr() by is_const_true() or is_const()

2024-12-06 Thread Vincent Mailhol
On Thu. 5 Dec 2024 at 04:00, David Laight wrote: > From: Vincent Mailhol > > Sent: 02 December 2024 17:34 > > > > Most of the use of __is_const_expr() in i915_reg_defs.h are just to > > test whether an expression is known to be true. Because those checks > > ar

[PATCH 05/10] minmax: simplify __clamp_once() by using is_const_false()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In __clamp_once(), __builtin_choose_expr(__is_constexpr((lo) > (hi)), (lo) <= (hi), true) is equivalent to: !is_const_false((lo) <= (hi)) Apply is_const_false() to simplify __clamp_once(). Signed-off-by: Vincent Mailhol --- include/linux/minmax.h | 3 +-

[PATCH 09/10] coresight: etm4x: replace __is_const_expr() by is_const()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol is_const() is a one to one replacement of __is_constexpr(). Do the replacement so that __is_constexpr() can be removed. Refer to [1] for an explaination of why __builtin_constant_p() can not be used as a replacement here. [1] commit 4d45bc82df66 ("coresight: etm4x:

[PATCH 00/10] compiler.h: refactor __is_constexpr() into is_const{,_true,_false}()

2024-12-02 Thread Vincent Mailhol via B4 Relay
is_const_false() whenever feasible, or by is_const() otherwise. Patch 10 finally remove __is_constexpr(). RIP! [1] add const_true() to simplify GENMASK_INPUT_CHECK() Link: https://lore.kernel.org/all/20241113172939.747686-4-mailhol.vinc...@wanadoo.fr/ Signed-off-by: Vincent Mailhol --- Vincent

[PATCH 01/10] compiler.h: add statically_false()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol For completion, add statically_false() which is the equivalent of statically_true() except that it will return true only if the input is known to be false at compile time. The == operator is used instead of the ! negation to prevent a -Wint-in-bool-context compiler warning

[PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol __is_constexpr(), while being one of the most glorious one liner hack ever witnessed by mankind, is overly complex. Following the adoption of C11 in the kernel, this macro can be simplified through the use of a _Generic() selection. First, split the macro in two

[PATCH 04/10] linux/bits.h: simplify GENMASK_INPUT_CHECK() by using is_const_true()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol In GENMASK_INPUT_CHECK(), __builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0) is equivalent to: is_const_true((l) > (h)) Apply is_const_true() to simplify GENMASK_INPUT_CHECK(). Signed-off-by: Vincent Mailhol --- This change passes the unit t

[PATCH 08/10] drm/i915/reg: replace __is_const_expr() by is_const_true() or is_const()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Most of the use of __is_const_expr() in i915_reg_defs.h are just to test whether an expression is known to be true. Because those checks are all done in a BUILD_BUG_ON_ZERO(), replace those with is_const_true(). Replace the few other occurrences of __is_const_expr() with

[PATCH 03/10] compiler.h: add is_const_true() and is_const_false()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol __builtin_constant_p() is known for not always being able to produce constant expression [1] which led to the introduction of __is_constexpr() [2]. Because of its dependency on __builtin_constant_p(), statically_true() suffers from the same issues. For example: void foo

[PATCH 07/10] overflow: replace __is_constexpr() by is_const()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol is_const() is a one to one replacement of __is_constexpr(). Do the replacement so that __is_constexpr() can be removed. Signed-off-by: Vincent Mailhol --- include/linux/overflow.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux

[PATCH 10/10] compiler.h: remove __is_constexpr()

2024-12-02 Thread Vincent Mailhol via B4 Relay
From: Vincent Mailhol Now that all the users of __is_constexpr() have been migrated to is_const() or one of its friends, remove it. The homage to Martin Uecker's genius hack remains in the documentation of __is_const_zero(). Signed-off-by: Vincent Mailhol --- include/linux/compiler.h

  1   2   >