Skip to content

Commit 1683c32

Browse files
committed
Merge tag 'regmap-fix-v6.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap fixes from Mark Brown: "The most important fix here is for missing dropping of the RCU read lock when syncing maple tree register caches, the physical devices I have that use the code don't do any syncing so I'd only ever tested this with virtual devices and missed the fact that we need to drop the lock in order to write to buses that need to sleep. Otherwise there's a fix for an edge case when splitting up large batch writes which has been lurking for a long time, a check to make sure nobody writes new drivers with a bug that was found in several SoundWire drivers and a tweak to the way the new kunit tests are enabled to ensure they don't cause regmap to be enabled when it wouldn't otherwise be" * tag 'regmap-fix-v6.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: maple: Drop the RCU read lock while syncing registers regmap: sdw: check for invalid multi-register writes config regmap: Account for register length when chunking regmap: REGMAP_KUNIT should not select REGMAP
2 parents 6d86b56 + 0cc6578 commit 1683c32

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

drivers/base/regmap/Kconfig

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44
# subsystems should select the appropriate symbols.
55

66
config REGMAP
7+
bool "Register Map support" if KUNIT_ALL_TESTS
78
default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO || REGMAP_FSI)
89
select IRQ_DOMAIN if REGMAP_IRQ
910
select MDIO_BUS if REGMAP_MDIO
10-
bool
11+
help
12+
Enable support for the Register Map (regmap) access API.
13+
14+
Usually, this option is automatically selected when needed.
15+
However, you may want to enable it manually for running the regmap
16+
KUnit tests.
17+
18+
If unsure, say N.
1119

1220
config REGMAP_KUNIT
1321
tristate "KUnit tests for regmap"
14-
depends on KUNIT
22+
depends on KUNIT && REGMAP
1523
default KUNIT_ALL_TESTS
16-
select REGMAP
1724
select REGMAP_RAM
1825

1926
config REGMAP_AC97

drivers/base/regmap/regcache-maple.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,18 @@ static int regcache_maple_sync(struct regmap *map, unsigned int min,
203203

204204
mas_for_each(&mas, entry, max) {
205205
for (r = max(mas.index, lmin); r <= min(mas.last, lmax); r++) {
206+
mas_pause(&mas);
207+
rcu_read_unlock();
206208
ret = regcache_sync_val(map, r, entry[r - mas.index]);
207209
if (ret != 0)
208210
goto out;
211+
rcu_read_lock();
209212
}
210213
}
211214

212-
out:
213215
rcu_read_unlock();
214216

217+
out:
215218
map->cache_bypass = false;
216219

217220
return ret;

drivers/base/regmap/regmap-sdw.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ static int regmap_sdw_config_check(const struct regmap_config *config)
5959
if (config->pad_bits != 0)
6060
return -ENOTSUPP;
6161

62+
/* Only bulk writes are supported not multi-register writes */
63+
if (config->can_multi_write)
64+
return -ENOTSUPP;
65+
6266
return 0;
6367
}
6468

drivers/base/regmap/regmap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,15 +2082,17 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
20822082
size_t val_count = val_len / val_bytes;
20832083
size_t chunk_count, chunk_bytes;
20842084
size_t chunk_regs = val_count;
2085+
size_t max_data = map->max_raw_write - map->format.reg_bytes -
2086+
map->format.pad_bytes;
20852087
int ret, i;
20862088

20872089
if (!val_count)
20882090
return -EINVAL;
20892091

20902092
if (map->use_single_write)
20912093
chunk_regs = 1;
2092-
else if (map->max_raw_write && val_len > map->max_raw_write)
2093-
chunk_regs = map->max_raw_write / val_bytes;
2094+
else if (map->max_raw_write && val_len > max_data)
2095+
chunk_regs = max_data / val_bytes;
20942096

20952097
chunk_count = val_count / chunk_regs;
20962098
chunk_bytes = chunk_regs * val_bytes;

0 commit comments

Comments
 (0)