Commit c7edb7ac authored by Mark Brown's avatar Mark Brown

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: default avatarMark Brown <broonie@kernel.org>
Link: https://patch.msgid.link/20240901-regmap-test-fast-io-v1-1-aad83a871bcc@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent ae0acef3
...@@ -22,6 +22,7 @@ struct regmap_test_param { ...@@ -22,6 +22,7 @@ struct regmap_test_param {
enum regmap_endian val_endian; enum regmap_endian val_endian;
unsigned int from_reg; unsigned int from_reg;
bool fast_io;
}; };
static void get_changed_bytes(void *orig, void *new, size_t size) 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) ...@@ -80,41 +81,52 @@ static const char *regmap_endian_name(enum regmap_endian endian)
static void param_to_desc(const struct regmap_test_param *param, char *desc) static void param_to_desc(const struct regmap_test_param *param, char *desc)
{ {
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s-%s @%#x", snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s-%s%s @%#x",
regcache_type_name(param->cache), regcache_type_name(param->cache),
regmap_endian_name(param->val_endian), regmap_endian_name(param->val_endian),
param->fast_io ? " fast I/O" : "",
param->from_reg); param->from_reg);
} }
static const struct regmap_test_param regcache_types_list[] = { static const struct regmap_test_param regcache_types_list[] = {
{ .cache = REGCACHE_NONE }, { .cache = REGCACHE_NONE },
{ .cache = REGCACHE_NONE, .fast_io = true },
{ .cache = REGCACHE_FLAT }, { .cache = REGCACHE_FLAT },
{ .cache = REGCACHE_FLAT, .fast_io = true },
{ .cache = REGCACHE_RBTREE }, { .cache = REGCACHE_RBTREE },
{ .cache = REGCACHE_RBTREE, .fast_io = true },
{ .cache = REGCACHE_MAPLE }, { .cache = REGCACHE_MAPLE },
{ .cache = REGCACHE_MAPLE, .fast_io = true },
}; };
KUNIT_ARRAY_PARAM(regcache_types, regcache_types_list, param_to_desc); KUNIT_ARRAY_PARAM(regcache_types, regcache_types_list, param_to_desc);
static const struct regmap_test_param real_cache_types_only_list[] = { static const struct regmap_test_param real_cache_types_only_list[] = {
{ .cache = REGCACHE_FLAT }, { .cache = REGCACHE_FLAT },
{ .cache = REGCACHE_FLAT, .fast_io = true },
{ .cache = REGCACHE_RBTREE }, { .cache = REGCACHE_RBTREE },
{ .cache = REGCACHE_RBTREE, .fast_io = true },
{ .cache = REGCACHE_MAPLE }, { .cache = REGCACHE_MAPLE },
{ .cache = REGCACHE_MAPLE, .fast_io = true },
}; };
KUNIT_ARRAY_PARAM(real_cache_types_only, real_cache_types_only_list, param_to_desc); KUNIT_ARRAY_PARAM(real_cache_types_only, real_cache_types_only_list, param_to_desc);
static const struct regmap_test_param real_cache_types_list[] = { static const struct regmap_test_param real_cache_types_list[] = {
{ .cache = REGCACHE_FLAT, .from_reg = 0 }, { .cache = REGCACHE_FLAT, .from_reg = 0 },
{ .cache = REGCACHE_FLAT, .from_reg = 0, .fast_io = true },
{ .cache = REGCACHE_FLAT, .from_reg = 0x2001 }, { .cache = REGCACHE_FLAT, .from_reg = 0x2001 },
{ .cache = REGCACHE_FLAT, .from_reg = 0x2002 }, { .cache = REGCACHE_FLAT, .from_reg = 0x2002 },
{ .cache = REGCACHE_FLAT, .from_reg = 0x2003 }, { .cache = REGCACHE_FLAT, .from_reg = 0x2003 },
{ .cache = REGCACHE_FLAT, .from_reg = 0x2004 }, { .cache = REGCACHE_FLAT, .from_reg = 0x2004 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0 }, { .cache = REGCACHE_RBTREE, .from_reg = 0 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2001 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2001 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2002 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2002 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2003 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2003 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2004 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2004 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0 }, { .cache = REGCACHE_MAPLE, .from_reg = 0 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2001 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2001 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2002 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2002 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2003 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2003 },
...@@ -125,11 +137,13 @@ KUNIT_ARRAY_PARAM(real_cache_types, real_cache_types_list, param_to_desc); ...@@ -125,11 +137,13 @@ KUNIT_ARRAY_PARAM(real_cache_types, real_cache_types_list, param_to_desc);
static const struct regmap_test_param sparse_cache_types_list[] = { static const struct regmap_test_param sparse_cache_types_list[] = {
{ .cache = REGCACHE_RBTREE, .from_reg = 0 }, { .cache = REGCACHE_RBTREE, .from_reg = 0 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2001 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2001 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2002 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2002 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2003 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2003 },
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2004 }, { .cache = REGCACHE_RBTREE, .from_reg = 0x2004 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0 }, { .cache = REGCACHE_MAPLE, .from_reg = 0 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0, .fast_io = true },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2001 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2001 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2002 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2002 },
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2003 }, { .cache = REGCACHE_MAPLE, .from_reg = 0x2003 },
...@@ -151,6 +165,7 @@ static struct regmap *gen_regmap(struct kunit *test, ...@@ -151,6 +165,7 @@ static struct regmap *gen_regmap(struct kunit *test,
struct reg_default *defaults; struct reg_default *defaults;
config->cache_type = param->cache; config->cache_type = param->cache;
config->fast_io = param->fast_io;
if (config->max_register == 0) { if (config->max_register == 0) {
config->max_register = param->from_reg; config->max_register = param->from_reg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment