Skip to content

Commit c7edb7a

Browse files
committed
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 <broonie@kernel.org> Link: https://patch.msgid.link/20240901-regmap-test-fast-io-v1-1-aad83a871bcc@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ae0acef commit c7edb7a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

drivers/base/regmap/regmap-kunit.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct regmap_test_param {
2222
enum regmap_endian val_endian;
2323

2424
unsigned int from_reg;
25+
bool fast_io;
2526
};
2627

2728
static void get_changed_bytes(void *orig, void *new, size_t size)
@@ -80,41 +81,52 @@ static const char *regmap_endian_name(enum regmap_endian endian)
8081

8182
static void param_to_desc(const struct regmap_test_param *param, char *desc)
8283
{
83-
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s-%s @%#x",
84+
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s-%s%s @%#x",
8485
regcache_type_name(param->cache),
8586
regmap_endian_name(param->val_endian),
87+
param->fast_io ? " fast I/O" : "",
8688
param->from_reg);
8789
}
8890

8991
static const struct regmap_test_param regcache_types_list[] = {
9092
{ .cache = REGCACHE_NONE },
93+
{ .cache = REGCACHE_NONE, .fast_io = true },
9194
{ .cache = REGCACHE_FLAT },
95+
{ .cache = REGCACHE_FLAT, .fast_io = true },
9296
{ .cache = REGCACHE_RBTREE },
97+
{ .cache = REGCACHE_RBTREE, .fast_io = true },
9398
{ .cache = REGCACHE_MAPLE },
99+
{ .cache = REGCACHE_MAPLE, .fast_io = true },
94100
};
95101

96102
KUNIT_ARRAY_PARAM(regcache_types, regcache_types_list, param_to_desc);
97103

98104
static const struct regmap_test_param real_cache_types_only_list[] = {
99105
{ .cache = REGCACHE_FLAT },
106+
{ .cache = REGCACHE_FLAT, .fast_io = true },
100107
{ .cache = REGCACHE_RBTREE },
108+
{ .cache = REGCACHE_RBTREE, .fast_io = true },
101109
{ .cache = REGCACHE_MAPLE },
110+
{ .cache = REGCACHE_MAPLE, .fast_io = true },
102111
};
103112

104113
KUNIT_ARRAY_PARAM(real_cache_types_only, real_cache_types_only_list, param_to_desc);
105114

106115
static const struct regmap_test_param real_cache_types_list[] = {
107116
{ .cache = REGCACHE_FLAT, .from_reg = 0 },
117+
{ .cache = REGCACHE_FLAT, .from_reg = 0, .fast_io = true },
108118
{ .cache = REGCACHE_FLAT, .from_reg = 0x2001 },
109119
{ .cache = REGCACHE_FLAT, .from_reg = 0x2002 },
110120
{ .cache = REGCACHE_FLAT, .from_reg = 0x2003 },
111121
{ .cache = REGCACHE_FLAT, .from_reg = 0x2004 },
112122
{ .cache = REGCACHE_RBTREE, .from_reg = 0 },
123+
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
113124
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2001 },
114125
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2002 },
115126
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2003 },
116127
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2004 },
117128
{ .cache = REGCACHE_MAPLE, .from_reg = 0 },
129+
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
118130
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2001 },
119131
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2002 },
120132
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2003 },
@@ -125,11 +137,13 @@ KUNIT_ARRAY_PARAM(real_cache_types, real_cache_types_list, param_to_desc);
125137

126138
static const struct regmap_test_param sparse_cache_types_list[] = {
127139
{ .cache = REGCACHE_RBTREE, .from_reg = 0 },
140+
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
128141
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2001 },
129142
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2002 },
130143
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2003 },
131144
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2004 },
132145
{ .cache = REGCACHE_MAPLE, .from_reg = 0 },
146+
{ .cache = REGCACHE_MAPLE, .from_reg = 0, .fast_io = true },
133147
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2001 },
134148
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2002 },
135149
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2003 },
@@ -151,6 +165,7 @@ static struct regmap *gen_regmap(struct kunit *test,
151165
struct reg_default *defaults;
152166

153167
config->cache_type = param->cache;
168+
config->fast_io = param->fast_io;
154169

155170
if (config->max_register == 0) {
156171
config->max_register = param->from_reg;

0 commit comments

Comments
 (0)