History log of /linux-6.15/drivers/base/regmap/regmap-kunit.c (Results 1 – 25 of 36)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: v6.15, v6.15-rc7, v6.15-rc6, v6.15-rc5, v6.15-rc4, v6.15-rc3, v6.15-rc2, v6.15-rc1, v6.14, v6.14-rc7, v6.14-rc6, v6.14-rc5, v6.14-rc4, v6.14-rc3, v6.14-rc2, v6.14-rc1, v6.13, v6.13-rc7, v6.13-rc6, v6.13-rc5, v6.13-rc4, v6.13-rc3, v6.13-rc2, v6.13-rc1, v6.12, v6.12-rc7, v6.12-rc6
# 96a54082 29-Oct-2024 Cheng-Cheng Lo <[email protected]>

regmap: kunit: Fix repeated test param

There're duplicated elements in the test param real_cache_types_list. The
second one shoulde have cache type REGCACHE_MAPLE.

Signed-off-by: Cheng-Cheng Lo <lo

regmap: kunit: Fix repeated test param

There're duplicated elements in the test param real_cache_types_list. The
second one shoulde have cache type REGCACHE_MAPLE.

Signed-off-by: Cheng-Cheng Lo <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.12-rc5, v6.12-rc4, v6.12-rc3, v6.12-rc2, v6.12-rc1
# 42afe80c 24-Sep-2024 Mark Brown <[email protected]>

regmap: Specifically test writing 0 as a value to sparse caches

Since 0 can look a lot like a NULL pointer when used in a cache some clever
data structures might potentially introduce bugs specific

regmap: Specifically test writing 0 as a value to sparse caches

Since 0 can look a lot like a NULL pointer when used in a cache some clever
data structures might potentially introduce bugs specific to handling it.
Add some explicit testing of storing 0 as a value in a sparse cache, at the
minute there are no issues and this will stop any appearing in the future.

Signed-off-by: Mark Brown <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.11, v6.11-rc7
# c7edb7ac 01-Sep-2024 Mark Brown <[email protected]>

regmap: kunit: Add coverage of spinlocked regmaps

By default regmap uses a mutex to protect the regmap but we also support
other kinds of locking, including spinlocks, which can have an impact
espec

regmap: kunit: Add coverage of spinlocked regmaps

By default regmap uses a mutex to protect the regmap but we also support
other kinds of locking, including spinlocks, which can have an impact
especially around allocations. Ensure that we are covering the spinlock
case by running tests configured using fast I/O, this causes the core to
use a spinlock instead of a mutex. Running every single test would be
redundant but cover most of them.

Signed-off-by: Mark Brown <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.11-rc6, v6.11-rc5
# 290d6e5d 22-Aug-2024 Mark Brown <[email protected]>

regmap: Use locking during kunit tests

There is no reason to bypass the locking when running the kunit tests,
leave it enabled as standard.

Signed-off-by: Mark Brown <[email protected]>
Link: http

regmap: Use locking during kunit tests

There is no reason to bypass the locking when running the kunit tests,
leave it enabled as standard.

Signed-off-by: Mark Brown <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.11-rc4, v6.11-rc3, v6.11-rc2, v6.11-rc1, v6.10
# c2bb8198 11-Jul-2024 Guenter Roeck <[email protected]>

regmap: kunit: Add test cases for regmap_multi_reg_(read,write}()

Add test cases for regmap_multi_reg_read() and regmap_multi_reg_write().

Signed-off-by: Guenter Roeck <[email protected]>
Link: ht

regmap: kunit: Add test cases for regmap_multi_reg_(read,write}()

Add test cases for regmap_multi_reg_read() and regmap_multi_reg_write().

Signed-off-by: Guenter Roeck <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.10-rc7, v6.10-rc6, v6.10-rc5, v6.10-rc4, v6.10-rc3
# f82ecf76 06-Jun-2024 Andy Shevchenko <[email protected]>

regmap: kunit: Use array_size() and sizeof(*ptr) consistently

Some of the allocations use explit sizeof(type) instead of sizeof(*ptr),
which is fragile. In particular, stress_insert() allocates doub

regmap: kunit: Use array_size() and sizeof(*ptr) consistently

Some of the allocations use explit sizeof(type) instead of sizeof(*ptr),
which is fragile. In particular, stress_insert() allocates double
of memory without obvious need for a test. Convert all allocations
to use array_size() and sizeof(*ptr) to eliminate similar mistakes
or wrong memory sizes.

Signed-off-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.10-rc2
# a8bd7789 31-May-2024 Jeff Johnson <[email protected]>

regmap: kunit: add missing MODULE_DESCRIPTION()

make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-kunit.o

Add the missing invoc

regmap: kunit: add missing MODULE_DESCRIPTION()

make allmodconfig && make W=1 C=1 reports:
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-kunit.o

Add the missing invocation of the MODULE_DESCRIPTION() macro.

Signed-off-by: Jeff Johnson <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.10-rc1, v6.9, v6.9-rc7, v6.9-rc6, v6.9-rc5, v6.9-rc4
# c3820641 11-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()

- Use kunit_kcalloc() to allocate the defaults table so that it will be
freed when the test case ends.
- kfree() the buf and *d

regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()

- Use kunit_kcalloc() to allocate the defaults table so that it will be
freed when the test case ends.
- kfree() the buf and *data buffers on the error paths.
- Use kunit_add_action_or_reset() instead of kunit_add_action() so that
if it fails it will call regmap_exit().

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 7ba82218 17-May-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Fix array overflow in stride() test

Force the max_register of the test regmap to be one register longer
than the number of test registers, to prevent an array overflow in
the test loo

regmap: kunit: Fix array overflow in stride() test

Force the max_register of the test regmap to be one register longer
than the number of test registers, to prevent an array overflow in
the test loop.

The test defines num_reg_defaults = 6. With 6 registers and
stride == 2 the valid register addresses would be 0, 2, 4, 6, 8, 10.
However the loop checks attempting to access the odd address, so on
the final register it accesses address 11, and it writes entry [11]
of the read/written arrays.

Originally this worked because the max_register of the regmap was
hardcoded to be BLOCK_TEST_SIZE (== 12).

commit 710915743d53 ("regmap: kunit: Run sparse cache tests at non-zero
register addresses")
introduced the ability to start the test address range from any address,
which means adjusting the max_register. If max_register was not forced,
it was calculated either from num_reg_defaults or BLOCK_TEST_SIZE. This
correctly calculated that with num_reg_defaults == 6 and stride == 2 the
final valid address is 10. So the read/written arrays are allocated to
contain entries [0..10]. When stride attempted to access [11] it was
overflowing the array.

Signed-off-by: Richard Fitzgerald <[email protected]>
Fixes: 710915743d53 ("regmap: kunit: Run sparse cache tests at non-zero register addresses")
Tested-by: Guenter Roeck <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 991b5e2a 15-Apr-2024 Dan Carpenter <[email protected]>

regmap: kunit: Fix an NULL vs IS_ERR() check

The kunit_device_register() function returns error pointers, not NULL.
Passing an error pointer to get_device() will lead to an Oops. Also
get_device()

regmap: kunit: Fix an NULL vs IS_ERR() check

The kunit_device_register() function returns error pointers, not NULL.
Passing an error pointer to get_device() will lead to an Oops. Also
get_device() returns the same device you passed to it. Fix it! ;)

Fixes: 7b7982f14315 ("regmap: kunit: Create a struct device for the regmap")
Signed-off-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# f63eb9ae 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Add test cases for regmap_read_bypassed()

This adds test cases to prove that regmap_read_bypassed() reads
the hardware value while the regmap is in cache-only.

Signed-off-by: Richard

regmap: kunit: Add test cases for regmap_read_bypassed()

This adds test cases to prove that regmap_read_bypassed() reads
the hardware value while the regmap is in cache-only.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 468d277e 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Add cache-drop test with multiple cache blocks

Add a test case for dropping only some cache blocks and leaving others
unchanged.

The regmap is divided into 8 register ranges, and onl

regmap: kunit: Add cache-drop test with multiple cache blocks

Add a test case for dropping only some cache blocks and leaving others
unchanged.

The regmap is divided into 8 register ranges, and only 4 of these are
written with values. This creates 4 non-contiguous ranges of registers
with cached values.

One whole range is then dropped, and part of another range. A cache
sync is then performed to check that the correct registers were written,
and the correct values were written to these registers.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# d6f2fd7a 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc

Replace the kmalloc() and kfree() in raw_read_defaults() with a
kunit_kmalloc() so that KUnit will free it automatically.

Sign

regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc

Replace the kmalloc() and kfree() in raw_read_defaults() with a
kunit_kmalloc() so that KUnit will free it automatically.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# ce75e06e 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Use a KUnit action to call regmap_exit()

Registert a KUnit action handler to call regmap_exit() when a test
terminates. This ensures that regmap_exit() will be called if a test
functi

regmap: kunit: Use a KUnit action to call regmap_exit()

Registert a KUnit action handler to call regmap_exit() when a test
terminates. This ensures that regmap_exit() will be called if a test
function returns early or aborts.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 7903d15f 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Add more cache-sync tests

Extend the testing of cache-sync.

- cache_sync() renamed cache_sync_marked_dirty() for clarity of
what conditions it is testing.

- cache_sync_defaults()

regmap: kunit: Add more cache-sync tests

Extend the testing of cache-sync.

- cache_sync() renamed cache_sync_marked_dirty() for clarity of
what conditions it is testing.

- cache_sync_defaults() renamed cache_sync_defaults_marked_dirty()
for clarity. Added code to write the register back to its default
value to check that a dirty sync doesn't write out the default value.

- Added cache_sync_after_cache_only(). Tests syncing the cache without
calling regcache_mark_dirty(). A register written while in cache-only
should be written out by regcache_sync().

- Added cache_sync_default_after_cache_only. This is similar to
cache_sync_after_cache_only(), but the register is changed to its
default value while in cache-only. Because regcache_mark_dirty() was
NOT called, regacache_sync() should write out the register.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 7dd52d30 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Add more cache-drop tests

Extend the testing of cache-drop.

- Added cache_drop_all_and_sync_marked_dirty(). If all registers are
dropped from the cache a regcache_mark_dirty() foll

regmap: kunit: Add more cache-drop tests

Extend the testing of cache-drop.

- Added cache_drop_all_and_sync_marked_dirty(). If all registers are
dropped from the cache a regcache_mark_dirty() followed by
regcache_sync() should not write anything because the cache is empty.

- Added cache_drop_all_and_sync_no_defaults(). This is similar to
cache_drop_all_and_sync_marked_dirty() except that regcache_mark_dirty()
is NOT called. All registers were dropped so regcache_sync() should not
write anything.

- Added cache_drop_all_and_sync_has_defaults(). This is the same as
cache_drop_all_and_sync_no_defaults() except that the regmap has a
table of default values.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# ac4394bf 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Run non-sparse cache tests at non-zero register addresses

Change the tests parameterized by real_cache_types_list[] to test at some
register addresses that are not 0.

The cache_range

regmap: kunit: Run non-sparse cache tests at non-zero register addresses

Change the tests parameterized by real_cache_types_list[] to test at some
register addresses that are not 0.

The cache_range_window_reg() test has hardcoded address assumptions that
are not present in any other tests using real_cache_types_list[] table. So
it has been given a separate parameter table, real_cache_types_only_list[],
that preserves the original parameterization.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 71091574 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Run sparse cache tests at non-zero register addresses

Run the cache_drop() and cache_present() tests at blocks of addresses
that don't start at zero.

This adds a from_reg parameter t

regmap: kunit: Run sparse cache tests at non-zero register addresses

Run the cache_drop() and cache_present() tests at blocks of addresses
that don't start at zero.

This adds a from_reg parameter to struct regmap_test_param. This is
used to set the base address of the register defaults created by
gen_regmap().

Extra entries are added to sparse_cache_types_list[] to test at non-zero
from_reg values. The cache_drop() and cache_present() tests are updated
to test at the given offset.

The aim here is to add test cases to cache_drop() for the bug fixed by
commit 00bb549d7d63 ("regmap: maple: Fix cache corruption in
regcache_maple_drop()")

But the same parameter table is used by the cache_present() test so
let's also update that to use from_reg.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 48bccea9 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Introduce struct for test case parameters

Add a struct regmap_test_param and use it for all test cases
instead of passing various different types of param object
depending on the test

regmap: kunit: Introduce struct for test case parameters

Add a struct regmap_test_param and use it for all test cases
instead of passing various different types of param object
depending on the test case.

This makes it much easier and cleaner to expand what can be
parameterized.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 7b7982f1 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Create a struct device for the regmap

Use kunit_device_register() to create a real struct device for the
regmap instead of leaving it at NULL.

The main reason for this is that it all

regmap: kunit: Create a struct device for the regmap

Use kunit_device_register() to create a real struct device for the
regmap instead of leaving it at NULL.

The main reason for this is that it allows context data to be passed
into the readable_reg/writable_reg/volatile_reg functions by attaching
it to the struct device with dev_set_drvdata().

The gen_regmap() and gen_raw_regmap() functions are updated to take a
struct kunit * argument.

A new struct regmap_test_priv has been created to hold the struct device
created by kunit_device_register(). This allows the struct to be
extended in the future to hold more private data for the test suite.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 866f7021 08-Apr-2024 Richard Fitzgerald <[email protected]>

regmap: kunit: Fix warnings of implicit casts to __le16 and __be16

Fix warnings about implicit casts to __le16 and __be16 types reported
by smatch:

drivers/base/regmap/regmap-kunit.c:1118:25:
warni

regmap: kunit: Fix warnings of implicit casts to __le16 and __be16

Fix warnings about implicit casts to __le16 and __be16 types reported
by smatch:

drivers/base/regmap/regmap-kunit.c:1118:25:
warning: cast to restricted __be16
drivers/base/regmap/regmap-kunit.c:1120:25:
warning: cast to restricted __le16
drivers/base/regmap/regmap-kunit.c:1187:33:
warning: cast to restricted __be16
drivers/base/regmap/regmap-kunit.c:1190:33:
warning: cast to restricted __le16
drivers/base/regmap/regmap-kunit.c:1302:33:
warning: cast to restricted __be16
drivers/base/regmap/regmap-kunit.c:1305:33:
warning: cast to restricted __le16

Perform a __force cast for all these.

Signed-off-by: Richard Fitzgerald <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.9-rc3, v6.9-rc2, v6.9-rc1, v6.8, v6.8-rc7, v6.8-rc6
# bb92804b 25-Feb-2024 Mark Brown <[email protected]>

regmap: kunit: Add a test for ranges in combination with windows

In preparation for taking advantage of the SPI support for pre-coooked
messages add a test case covering the use of windows on a raw

regmap: kunit: Add a test for ranges in combination with windows

In preparation for taking advantage of the SPI support for pre-coooked
messages add a test case covering the use of windows on a raw regmap,
unfortunately the parameterisation prevents direct reuse and we will
want to add some raw specific coverage anyway.

Signed-off-by: Mark Brown <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.8-rc5, v6.8-rc4
# 2f0dbb24 11-Feb-2024 Mark Brown <[email protected]>

regmap: kunit: Ensure that changed bytes are actually different

During the cache sync test we verify that values we expect to have been
written only to the cache do not appear in the hardware. This

regmap: kunit: Ensure that changed bytes are actually different

During the cache sync test we verify that values we expect to have been
written only to the cache do not appear in the hardware. This works most
of the time but since we randomly generate both the original and new values
there is a low probability that these values may actually be the same.
Wrap get_random_bytes() to ensure that the values are different, there
are other tests which should have similar verification that we actually
changed something.

While we're at it refactor the test to use three changed values rather
than attempting to use one of them twice, that just complicates checking
that our new values are actually new.

We use random generation to try to avoid data dependencies in the tests.

Reported-by: Guenter Roeck <[email protected]>
Reviewed-by: Guenter Roeck <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
Link: https://msgid.link/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


# 7011b51f 06-Feb-2024 Ben Wolsieffer <[email protected]>

regmap: kunit: fix raw noinc write test wrapping

The raw noinc write test places a known value in the register following
the noinc register to verify that it is not disturbed by the noinc
write. Thi

regmap: kunit: fix raw noinc write test wrapping

The raw noinc write test places a known value in the register following
the noinc register to verify that it is not disturbed by the noinc
write. This test ensures this value is distinct by adding 100 to the
second element of the noinc write data.

The regmap registers are 16-bit, while the test value is stored in an
unsigned int. Therefore, adding 100 may cause the register to wrap while
the test value does not, causing the test to fail. This patch fixes this
by changing val_test and val_last from unsigned int to u16.

Signed-off-by: Ben Wolsieffer <[email protected]>
Reported-by: Guenter Roeck <[email protected]>
Closes: https://lore.kernel.org/linux-kernel/[email protected]/T/
Tested-by: Guenter Roeck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


Revision tags: v6.8-rc3, v6.8-rc2, v6.8-rc1, v6.7, v6.7-rc8, v6.7-rc7, v6.7-rc6, v6.7-rc5, v6.7-rc4, v6.7-rc3, v6.7-rc2, v6.7-rc1
# d958d978 02-Nov-2023 Ben Wolsieffer <[email protected]>

regmap: kunit: add noinc write test

Add a test for writing to a noinc register, which verifies that the
write does not touch adjacent registers. This test succeeds with [1]
applied and fails without

regmap: kunit: add noinc write test

Add a test for writing to a noinc register, which verifies that the
write does not touch adjacent registers. This test succeeds with [1]
applied and fails without it.

[1] 984a4afdc87a ("regmap: prevent noinc writes from clobbering cache")

Signed-off-by: Ben Wolsieffer <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>

show more ...


12