2024-04-08 15:15:37

by Richard Fitzgerald

[permalink] [raw]
Subject: [PATCH 00/11] regmap: kunit: Add some test cases and a few small improvements

This series adds some more test cases, mainly for testing:

commit eaa03486d932 ("regmap: maple: Fix uninitialized symbol 'ret' warnings")
commit 00bb549d7d63 ("regmap: maple: Fix cache corruption in regcache_maple_drop()")

And the pending patch ("regmap: Add regmap_read_bypassed()")
https://lore.kernel.org/linux-sound/[email protected]/T/#m2b99b1e01872bfc3597e89dee57dcdd5dbaf1b55

There are also a few small improvements to the KUnit implementation.

Richard Fitzgerald (11):
regmap: kunit: Fix warnings of implicit casts to __le16 and __be16
regmap: kunit: Create a struct device for the regmap
regmap: kunit: Introduce struct for test case parameters
regmap: kunit: Run sparse cache tests at non-zero register addresses
regmap: kunit: Run non-sparse cache tests at non-zero register
addresses
regmap: kunit: Add more cache-drop tests
regmap: kunit: Add more cache-sync tests
regmap: kunit: Use a KUnit action to call regmap_exit()
regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc
regmap: kunit: Add cache-drop test with multiple cache blocks
regmap: kunit: Add test cases for regmap_read_bypassed()

drivers/base/regmap/internal.h | 14 +-
drivers/base/regmap/regmap-kunit.c | 994 ++++++++++++++++++++-------
drivers/base/regmap/regmap-ram.c | 5 +-
drivers/base/regmap/regmap-raw-ram.c | 5 +-
4 files changed, 765 insertions(+), 253 deletions(-)

--
2.39.2



2024-04-08 15:16:00

by Richard Fitzgerald

[permalink] [raw]
Subject: [PATCH 01/11] 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]>
---
drivers/base/regmap/regmap-kunit.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c
index bb2ab6129f38..b46a4f28c1a1 100644
--- a/drivers/base/regmap/regmap-kunit.c
+++ b/drivers/base/regmap/regmap-kunit.c
@@ -1115,12 +1115,12 @@ static void raw_read_defaults(struct kunit *test)
for (i = 0; i < config.max_register + 1; i++) {
def = config.reg_defaults[i].def;
if (config.val_format_endian == REGMAP_ENDIAN_BIG) {
- KUNIT_EXPECT_EQ(test, def, be16_to_cpu(rval[i]));
+ KUNIT_EXPECT_EQ(test, def, be16_to_cpu((__force __be16)rval[i]));
} else {
- KUNIT_EXPECT_EQ(test, def, le16_to_cpu(rval[i]));
+ KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i]));
}
}
-
+
kfree(rval);
regmap_exit(map);
}
@@ -1185,10 +1185,10 @@ static void raw_write(struct kunit *test)
case 3:
if (config.val_format_endian == REGMAP_ENDIAN_BIG) {
KUNIT_EXPECT_EQ(test, rval,
- be16_to_cpu(val[i % 2]));
+ be16_to_cpu((__force __be16)val[i % 2]));
} else {
KUNIT_EXPECT_EQ(test, rval,
- le16_to_cpu(val[i % 2]));
+ le16_to_cpu((__force __le16)val[i % 2]));
}
break;
default:
@@ -1300,10 +1300,10 @@ static void raw_sync(struct kunit *test)
case 3:
if (config.val_format_endian == REGMAP_ENDIAN_BIG) {
KUNIT_EXPECT_EQ(test, rval,
- be16_to_cpu(val[i - 2]));
+ be16_to_cpu((__force __be16)val[i - 2]));
} else {
KUNIT_EXPECT_EQ(test, rval,
- le16_to_cpu(val[i - 2]));
+ le16_to_cpu((__force __le16)val[i - 2]));
}
break;
case 4:
--
2.39.2


2024-04-08 15:16:42

by Richard Fitzgerald

[permalink] [raw]
Subject: [PATCH 09/11] 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]>
---
drivers/base/regmap/regmap-kunit.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c
index e21028cbddc3..4c29d2db4d20 100644
--- a/drivers/base/regmap/regmap-kunit.c
+++ b/drivers/base/regmap/regmap-kunit.c
@@ -1360,7 +1360,7 @@ static void raw_read_defaults(struct kunit *test)
return;

val_len = sizeof(*rval) * (config.max_register + 1);
- rval = kmalloc(val_len, GFP_KERNEL);
+ rval = kunit_kmalloc(test, val_len, GFP_KERNEL);
KUNIT_ASSERT_TRUE(test, rval != NULL);
if (!rval)
return;
@@ -1375,8 +1375,6 @@ static void raw_read_defaults(struct kunit *test)
KUNIT_EXPECT_EQ(test, def, le16_to_cpu((__force __le16)rval[i]));
}
}
-
- kfree(rval);
}

static void raw_write_read_single(struct kunit *test)
--
2.39.2


2024-04-09 23:34:56

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 00/11] regmap: kunit: Add some test cases and a few small improvements

On Mon, 08 Apr 2024 15:45:49 +0100, Richard Fitzgerald wrote:
> This series adds some more test cases, mainly for testing:
>
> commit eaa03486d932 ("regmap: maple: Fix uninitialized symbol 'ret' warnings")
> commit 00bb549d7d63 ("regmap: maple: Fix cache corruption in regcache_maple_drop()")
>
> And the pending patch ("regmap: Add regmap_read_bypassed()")
> https://lore.kernel.org/linux-sound/[email protected]/T/#m2b99b1e01872bfc3597e89dee57dcdd5dbaf1b55
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[01/11] regmap: kunit: Fix warnings of implicit casts to __le16 and __be16
commit: 866f70211bf43927ca44d8e98b5266926fd51315
[02/11] regmap: kunit: Create a struct device for the regmap
commit: 7b7982f14315e0f6910e13b22ed38a47144a83ec
[03/11] regmap: kunit: Introduce struct for test case parameters
commit: 48bccea96fead1b212e19e38e50bf8e69287c45d
[04/11] regmap: kunit: Run sparse cache tests at non-zero register addresses
commit: 710915743d53d19a1baf0326302aa1f743ab018e
[05/11] regmap: kunit: Run non-sparse cache tests at non-zero register addresses
commit: ac4394bf9c5e065919a0e491bfd95e2106b1b9b2
[06/11] regmap: kunit: Add more cache-drop tests
commit: 7dd52d301cfcff9a67be19d00289e03d80d05e46
[07/11] regmap: kunit: Add more cache-sync tests
commit: 7903d15f008056c8c152f2aa3b36217917853264
[08/11] regmap: kunit: Use a KUnit action to call regmap_exit()
commit: ce75e06eea9cfdddaa0082cef663cf2d4aa5ed1d
[09/11] regmap: kunit: Replace a kmalloc/kfree() pair with KUnit-managed alloc
commit: d6f2fd7adcb5f25ac661808be9409f846b1de6fe
[10/11] regmap: kunit: Add cache-drop test with multiple cache blocks
commit: 468d277e6fb112e7a5e816ef5f1f6bd86c29bea6
[11/11] regmap: kunit: Add test cases for regmap_read_bypassed()
commit: f63eb9ae085dc6da27eebfe35317e07a6a02a160

All 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