regmap: Initial KUnit coverage
Subsystems (3)
Mark Brown
maintainercover regmap: Initial KUnit coverage
This series provides some initial KUnit coverage for regmap, covering most of the interfaces that operate at the register level using an instrumented RAM backed bus type.
---
Mark Brown (2):
regmap: Add RAM backed register map
regmap: Add some basic kunit tests
drivers/base/regmap/Kconfig | 10 + drivers/base/regmap/Makefile | 2 + drivers/base/regmap/internal.h | 19 ++ drivers/base/regmap/regmap-kunit.c | 631 +++++++++++++++++++++++++++++++++++++ drivers/base/regmap/regmap-ram.c | 85 +++++ 5 files changed, 747 insertions(+)
---
base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65
change-id: 20230324-regmap-kunit-bb3c3e81e35c
Best regards,
Signature · 1 line
Mark Brown <[email protected]>
Mark Brown
maintainerPATCH 1/2 regmap: Add RAM backed register map
Add a register map that is a simple array of memory, for use in KUnit testing of the framework. This is not exposed in regmap.h since I can't think of a non-test use case, it is purely for use internally. To facilitate testing we track if registers have been read or written to.
--- drivers/base/regmap/Kconfig | 3 ++ drivers/base/regmap/Makefile | 1 + drivers/base/regmap/internal.h | 19 +++++++++ drivers/base/regmap/regmap-ram.c | 85 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+)
drivers/base/regmap/Kconfig +3 -0
@@ -46,6 +46,9 @@ config REGMAP_MMIO config REGMAP_IRQ bool +config REGMAP_RAM + tristate + config REGMAP_SOUNDWIRE tristate depends on SOUNDWIRE
drivers/base/regmap/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o +obj-$(CONFIG_REGMAP_RAM) += regmap-ram.o obj-$(CONFIG_REGMAP_SLIMBUS) += regmap-slimbus.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o obj-$(CONFIG_REGMAP_SPMI) += regmap-spmi.o
drivers/base/regmap/internal.h +19 -0
@@ -307,4 +307,23 @@ static inline unsigned int regcache_get_index_by_order(const struct regmap *map, return reg >> map->reg_stride_order; } +struct regmap_ram_data { +unsigned int *vals;/* Allocatd by caller */ +bool *read; +bool *written; +}; + +/* +* Create a test register map with data stored in RAM, not intended +* for practical use. +*/ +struct regmap *__regmap_init_ram (const struct regmap_config *config, +struct regmap_ram_data *data, +struct lock_class_key *lock_key, +const char *lock_name); + +#define regmap_init_ram (config, data) \ + __regmap_lockdep_wrapper(__regmap_init_ram, #config, config, data) + +#endif
drivers/base/regmap/regmap-ram.c new file +85 -0
85 lines not on this page · raw message
Signature · 1 line
2.34.1
Mark Brown
maintainerPATCH 2/2 regmap: Add some basic kunit tests
In reply to Mark BrownOn the theory that it's better to make a start let's add some KUnit tests for regmap. Currently this is a bit of a mess but it passes and hopefully will at some point help catch problems. We provide very basic cover for most of the core functionality that operates at the register level, repeating each test for each cache type in order to exercise the caches. There is no coverage of anything to do with the bulk operations at the bus level or formatting for byte stream buses yet.
Each test creates it's own regmap since the cache structures are built incrementally, meaning we gain coverage from the different access patterns, and some of the tests cover different init scenarios.
--- drivers/base/regmap/Kconfig | 7 + drivers/base/regmap/Makefile | 1 + drivers/base/regmap/regmap-kunit.c | 631 +++++++++++++++++++++++++++++++++++++ 3 files changed, 639 insertions(+)
drivers/base/regmap/Kconfig +7 -0
@@ -14,6 +14,13 @@ config REGCACHE_COMPRESSED select LZO_DECOMPRESS bool +config REGMAP_KUNIT + tristate "KUnit tests for regmap" + depends on KUNIT + default KUNIT_ALL_TESTS + select REGMAP + select REGMAP_RAM + config REGMAP_AC97 tristate
drivers/base/regmap/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_REGMAP) += regmap.o regcache.o obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o +obj-$(CONFIG_REGMAP_KUNIT) += regmap-kunit.o obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_RAM) += regmap-ram.o
drivers/base/regmap/regmap-kunit.c new file +631 -0
631 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 2/2] regmap: Add some basic kunit tests
Quoted 9 lines · Mark Brown
On the theory that it's better to make a start let's add some KUnit tests for regmap. Currently this is a bit of a mess but it passes and hopefully will at some point help catch problems. We provide very basic cover for most of the core functionality that operates at the register level, repeating each test for each cache type in order to exercise the caches. There is no coverage of anything to do with the bulk operations at the bus level or formatting for byte stream buses yet.
Quoted 6 lines
Each test creates it's own regmap since the cache structures are built incrementally, meaning we gain coverage from the different access patterns, and some of the tests cover different init scenarios.
Signed-off-by Mark Brown <[email protected]>---
It looks like regmap.basic_ranges is broken here (um, i386, arm64):
KTAP version 1
1..1
KTAP version 1
# Subtest: regmap
1..1
KTAP version 1
# Subtest: basic_ranges
# basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:399 Expected data->written[test_range.selector_reg] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:400 Expected data->written[test_range.window_start] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:408 Expected data->written[test_range.selector_reg] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:409 Expected data->written[test_range.window_start] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:415 Expected data->written[test_range.selector_reg] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:416 Expected data->read[test_range.window_start] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:424 Expected data->written[test_range.selector_reg] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:425 Expected data->read[test_range.window_start] to be true, but is false # basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:429 Expected data->read[i] to be false, but is true
# basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:430 Expected data->written[i] to be false, but is true
# basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:429 Expected data->read[i] to be false, but is true
# basic_ranges: EXPECTATION FAILED at drivers/base/regmap/regmap-kunit.c:430 Expected data->written[i] to be false, but is true
not ok 1 none
<same for flat, rbtree>
The other tests all pass fine.
Am I missing a prerequisite?
Cheers,
-- David
Mark Brown
maintainerRe: [PATCH 2/2] regmap: Add some basic kunit tests
Quoted 3 lines · David Gow
It looks like regmap.basic_ranges is broken here (um, i386, arm64):
Am I missing a prerequisite?
Yes, there's a missing feature there which means that ranges don't do anything with the specific interface regmap-ram uses - I already posted a patch for it, should appear in -next next week.
Mark Brown
maintainerQuoted 5 lines · Mark Brown
This series provides some initial KUnit coverage for regmap, covering most of the interfaces that operate at the register level using an instrumented RAM backed bus type.
Applied to
broonie/regmap.git for-next
Thanks!
[1/2] regmap: Add RAM backed register map
commit: f6352424e37e7bf72291ceab87dc620172be0999
[2/2] regmap: Add some basic kunit tests
commit: 2238959b6ad27040275439edd6893e309bc729a3All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark