Skip to content

Commit 9179b73

Browse files
committed
Merge tag 'regmap-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap updates from Mark Brown: "The main update here is Matti's work allowing regmap irqdomains to be given custom names (allowing multiple interrupt controllers associatd with a single struct device), this pulls in some commits from Thomas' tree which it depends on. Otherwise there's a bit of work on improving handling of regmaps protected with spinlocks when used with complex cache types, fixing some valid but harmless lockdep reports seen with some new driver work" * tag 'regmap-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: kunit: Add coverage of spinlocked regmaps regcache: use map->alloc_flags also for allocating cache regmap: Use locking during kunit tests regmap: Hold the regmap lock when allocating and freeing the cache regmap: Allow setting IRQ domain name suffix
2 parents c903327 + c7edb7a commit 9179b73

8 files changed

Lines changed: 54 additions & 17 deletions

File tree

drivers/base/regmap/regcache-flat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static int regcache_flat_init(struct regmap *map)
2727
return -EINVAL;
2828

2929
map->cache = kcalloc(regcache_flat_get_index(map, map->max_register)
30-
+ 1, sizeof(unsigned int), GFP_KERNEL);
30+
+ 1, sizeof(unsigned int), map->alloc_flags);
3131
if (!map->cache)
3232
return -ENOMEM;
3333

drivers/base/regmap/regcache-maple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int regcache_maple_init(struct regmap *map)
348348
int ret;
349349
int range_start;
350350

351-
mt = kmalloc(sizeof(*mt), GFP_KERNEL);
351+
mt = kmalloc(sizeof(*mt), map->alloc_flags);
352352
if (!mt)
353353
return -ENOMEM;
354354
map->cache = mt;

drivers/base/regmap/regcache-rbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int regcache_rbtree_init(struct regmap *map)
187187
int i;
188188
int ret;
189189

190-
map->cache = kmalloc(sizeof *rbtree_ctx, GFP_KERNEL);
190+
map->cache = kmalloc(sizeof *rbtree_ctx, map->alloc_flags);
191191
if (!map->cache)
192192
return -ENOMEM;
193193

drivers/base/regmap/regcache.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
195195
if (map->cache_ops->init) {
196196
dev_dbg(map->dev, "Initializing %s cache\n",
197197
map->cache_ops->name);
198+
map->lock(map->lock_arg);
198199
ret = map->cache_ops->init(map);
200+
map->unlock(map->lock_arg);
199201
if (ret)
200202
goto err_free;
201203
}
@@ -223,7 +225,9 @@ void regcache_exit(struct regmap *map)
223225
if (map->cache_ops->exit) {
224226
dev_dbg(map->dev, "Destroying %s cache\n",
225227
map->cache_ops->name);
228+
map->lock(map->lock_arg);
226229
map->cache_ops->exit(map);
230+
map->unlock(map->lock_arg);
227231
}
228232
}
229233

drivers/base/regmap/regmap-irq.c

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,30 @@ int regmap_irq_set_type_config_simple(unsigned int **buf, unsigned int type,
608608
}
609609
EXPORT_SYMBOL_GPL(regmap_irq_set_type_config_simple);
610610

611+
static int regmap_irq_create_domain(struct fwnode_handle *fwnode, int irq_base,
612+
const struct regmap_irq_chip *chip,
613+
struct regmap_irq_chip_data *d)
614+
{
615+
struct irq_domain_info info = {
616+
.fwnode = fwnode,
617+
.size = chip->num_irqs,
618+
.hwirq_max = chip->num_irqs,
619+
.virq_base = irq_base,
620+
.ops = &regmap_domain_ops,
621+
.host_data = d,
622+
.name_suffix = chip->domain_suffix,
623+
};
624+
625+
d->domain = irq_domain_instantiate(&info);
626+
if (IS_ERR(d->domain)) {
627+
dev_err(d->map->dev, "Failed to create IRQ domain\n");
628+
return PTR_ERR(d->domain);
629+
}
630+
631+
return 0;
632+
}
633+
634+
611635
/**
612636
* regmap_add_irq_chip_fwnode() - Use standard regmap IRQ controller handling
613637
*
@@ -856,18 +880,9 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
856880
}
857881
}
858882

859-
if (irq_base)
860-
d->domain = irq_domain_create_legacy(fwnode, chip->num_irqs,
861-
irq_base, 0,
862-
&regmap_domain_ops, d);
863-
else
864-
d->domain = irq_domain_create_linear(fwnode, chip->num_irqs,
865-
&regmap_domain_ops, d);
866-
if (!d->domain) {
867-
dev_err(map->dev, "Failed to create IRQ domain\n");
868-
ret = -ENOMEM;
883+
ret = regmap_irq_create_domain(fwnode, irq_base, chip, d);
884+
if (ret)
869885
goto err_alloc;
870-
}
871886

872887
ret = request_threaded_irq(irq, NULL, regmap_irq_thread,
873888
irq_flags | IRQF_ONESHOT,

drivers/base/regmap/regmap-kunit.c

Lines changed: 16 additions & 3 deletions
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,8 +165,7 @@ static struct regmap *gen_regmap(struct kunit *test,
151165
struct reg_default *defaults;
152166

153167
config->cache_type = param->cache;
154-
config->disable_locking = config->cache_type == REGCACHE_RBTREE ||
155-
config->cache_type == REGCACHE_MAPLE;
168+
config->fast_io = param->fast_io;
156169

157170
if (config->max_register == 0) {
158171
config->max_register = param->from_reg;

drivers/base/regmap/regmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ void regmap_exit(struct regmap *map)
14451445
struct regmap_async *async;
14461446

14471447
regcache_exit(map);
1448+
14481449
regmap_debugfs_exit(map);
14491450
regmap_range_exit(map);
14501451
if (map->bus && map->bus->free_context)

include/linux/regmap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,9 @@ struct regmap_irq_chip_data;
15211521
* struct regmap_irq_chip - Description of a generic regmap irq_chip.
15221522
*
15231523
* @name: Descriptive name for IRQ controller.
1524+
* @domain_suffix: Name suffix to be appended to end of IRQ domain name. Needed
1525+
* when multiple regmap-IRQ controllers are created from same
1526+
* device.
15241527
*
15251528
* @main_status: Base main status register address. For chips which have
15261529
* interrupts arranged in separate sub-irq blocks with own IRQ
@@ -1606,6 +1609,7 @@ struct regmap_irq_chip_data;
16061609
*/
16071610
struct regmap_irq_chip {
16081611
const char *name;
1612+
const char *domain_suffix;
16091613

16101614
unsigned int main_status;
16111615
unsigned int num_main_status_bits;

0 commit comments

Comments
 (0)