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 the
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 TEST_GENMA
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
---
Changelog:
v1 -> v2:
- No changes
---
incl
This is a subset of below series:
bits: Fixed-type GENMASK_U*() and BIT_U*()
Link:
https://lore.kernel.org/r/20250308-fixed-type-genmasks-v6-0-f59315e73...@wanadoo.fr
Yury suggested to split the above series in two steps:
#1 Introduce the new fixed type GENMASK_U*() (already merged upstre
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 we
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 into tests/
From: Lucas De Marchi
Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
them to implement the i915/xe specific macros. Converting each driver
to use the generic macros are left for later, when/if other
driver-specific macros are also generalized.
Signed-off-by: Lucas De Marc
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
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-count-ov
Introduce some fixed width variant of the GENMASK() and the BIT()
macros in bits.h. For example:
GENMASK_U16(16, 0)
will raise a build bug.
This series is a continuation of:
https://lore.kernel.org/intel-xe/20240208074521.577076-1-lucas.demar...@intel.com
from Lucas De Marchi. Above serie
From: Lucas De Marchi
Add some additional tests in lib/tests/test_bits.c to cover the
expected/non-expected values of the fixed-type GENMASK_U*() macros.
Also check that the result value matches the expected type. Since
those are known at build time, use static_assert() instead of normal
kunit t
From: Lucas De Marchi
Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
them to implement the i915/xe specific macros. Converting each driver
to use the generic macros are left for later, when/if other
driver-specific macros are also generalized.
Signed-off-by: Lucas De Marc
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
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 TEST_GENMA
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 the
This is a subset of below series:
bits: Fixed-type GENMASK_U*() and BIT_U*()
Link:
https://lore.kernel.org/r/20250308-fixed-type-genmasks-v6-0-f59315e73...@wanadoo.fr
Yury suggested to split the above series in two steps:
#1 Introduce the new fixed type GENMASK_U*()
#2 Consolidate the e
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:
- No c
From: Lucas De Marchi
Add some additional tests in lib/test_bits.c to cover the
expected/non-expected values of the fixed-type GENMASK_U*() macros.
Also check that the result value matches the expected type. Since
those are known at build time, use static_assert() instead of normal
kunit tests.
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
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 changes.
v4
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 rather to enforce more checks at compile time. For example:
GENMASK_U16(16, 0)
will raise a build bug.
This series is a continuation of:
https://l
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: Vi
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_bits.c | 1
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: Vi
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 -> v4:
- Ne
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 changes.
v
From: Lucas De Marchi
Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
them to implement the i915/xe specific macros. Converting each driver
to use the generic macros are left for later, when/if other
driver-specific macros are also generalized.
Signed-off-by: Lucas De Marc
From: Lucas De Marchi
Add some additional tests in lib/test_bits.c to cover the
expected/non-expected values of the fixed-type GENMASK_U*() macros.
Also check that the result value matches the expected type. Since
those are known at build time, use static_assert() instead of normal
kunit tests.
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 rather to enforce more checks at compile time. For example:
GENMASK_U16(16, 0)
will raise a build bug.
This series is a continuation of:
https://l
From: Yury Norov
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 by
i9
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 decide
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 rather to enforce more checks at compile time. For example:
GENMASK_U16(16, 0)
will raise a build bug.
This series is a continuation of:
https://l
From: Lucas De Marchi
Add some additional tests in lib/test_bits.c to cover the
expected/non-expected values of the fixed-type GENMASK_U*() macros.
Also check that the result value matches the expected type. Since
those are known at build time, use static_assert() instead of normal
kunit tests.
From: Lucas De Marchi
Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
them to implement the i915/xe specific macros. Converting each driver
to use the generic macros are left for later, when/if other
driver-specific macros are also generalized.
Signed-off-by: Lucas De Marc
From: Yury Norov
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 by
i9
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 chang
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 GENMASK_t()
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().
- Make B
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 rather to enforce more checks at compile time. For example:
GENMASK_U16(16, 0)
will raise a build bug.
This series is a continuation of:
https://l
From: Lucas De Marchi
Now that include/linux/bits.h implements fixed-width GENMASK_*, use them
to implement the i915/xe specific macros. Converting each driver to use
the generic macros are left for later, when/if other driver-specific
macros are also generalized.
Signed-off-by: Lucas De Marchi
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 chang
From: Lucas De Marchi
Add some additional tests in lib/test_bits.c to cover the
expected/non-expected values of the fixed-type genmasks.
Also check that the result value matches the expected type. Since
those are known at build time, use static_assert() instead of normal
kunit tests.
Signed-off
From: Yury Norov
Add __GENMASK_t() 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 by
i91
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
c3a40995a25773222
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: Vi
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/include/linux/bits.h
index
61a75d3f294bfa96267383b5
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 +--
1 file c
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: avoid b
This series is the spiritual successor of [1] which introduced
const_true(). In [1], following a comment from David Laight, Linus
came with a suggestion to simplify __is_constexpr() and its derived
macros using a _Generic() selection. Because of the total change of
scope, I am starting a new series
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
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:
- __is_
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 tests from CO
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 is
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(
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/ov
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 | 47 ---
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/fortify-string.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/
57 matches
Mail list logo