Skip to content

Commit 39b1428

Browse files
committed
Merge tag 'regmap-fix-v6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap fixes from Mark Brown: "Three fixes here: - The issues with accounting for register and padding length on raw buses turn out to be quite widespread in custom buses. In order to avoid disturbing anything drop the initial fixes and fall back to a point fix in the SMBus code where the issue was originally noticed, a more substantial refactoring of the API which ensures that all buses make the same assumptions will follow. - The generic regcache code had been forcing on async I/O which did not work with the new maple tree sync code when used with SPI. Since that was mainly for the rbtree cache and the assumptions about hardware that drove the choice are probably not true any more fix this by pushing the enablement of async down into the rbtree code. This probably also makes cache syncs for systems faster though it's not the point. - The test code was triggering use of the rbtree and maple tree caches with dynamic allocation of nodes since all the testing is with RAM backed caches with no I/O performance issues. Just disable the locking in the tests to avoid triggering warnings when allocation debugging is turned on, it's not really what's being tested" * tag 'regmap-fix-v6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: Disable locking for RBTREE and MAPLE unit tests regcache: Push async I/O request down into the rbtree cache regmap: Account for register length in SMBus I/O limits regmap: Drop initial version of maximum transfer length fixes
2 parents c0842db + a9e2616 commit 39b1428

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

drivers/base/regmap/regcache-rbtree.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,8 @@ static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
471471
unsigned int start, end;
472472
int ret;
473473

474+
map->async = true;
475+
474476
rbtree_ctx = map->cache;
475477
for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) {
476478
rbnode = rb_entry(node, struct regcache_rbtree_node, node);
@@ -499,6 +501,8 @@ static int regcache_rbtree_sync(struct regmap *map, unsigned int min,
499501
return ret;
500502
}
501503

504+
map->async = false;
505+
502506
return regmap_async_complete(map);
503507
}
504508

drivers/base/regmap/regcache.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,6 @@ int regcache_sync(struct regmap *map)
368368
if (!map->cache_dirty)
369369
goto out;
370370

371-
map->async = true;
372-
373371
/* Apply any patch first */
374372
map->cache_bypass = true;
375373
for (i = 0; i < map->patch_regs; i++) {
@@ -392,7 +390,6 @@ int regcache_sync(struct regmap *map)
392390

393391
out:
394392
/* Restore the bypass state */
395-
map->async = false;
396393
map->cache_bypass = bypass;
397394
map->no_sync_defaults = false;
398395
map->unlock(map->lock_arg);

drivers/base/regmap/regmap-i2c.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ static int regmap_i2c_smbus_i2c_read(void *context, const void *reg,
242242
static const struct regmap_bus regmap_i2c_smbus_i2c_block = {
243243
.write = regmap_i2c_smbus_i2c_write,
244244
.read = regmap_i2c_smbus_i2c_read,
245-
.max_raw_read = I2C_SMBUS_BLOCK_MAX,
246-
.max_raw_write = I2C_SMBUS_BLOCK_MAX,
245+
.max_raw_read = I2C_SMBUS_BLOCK_MAX - 1,
246+
.max_raw_write = I2C_SMBUS_BLOCK_MAX - 1,
247247
};
248248

249249
static int regmap_i2c_smbus_i2c_write_reg16(void *context, const void *data,
@@ -299,8 +299,8 @@ static int regmap_i2c_smbus_i2c_read_reg16(void *context, const void *reg,
299299
static const struct regmap_bus regmap_i2c_smbus_i2c_block_reg16 = {
300300
.write = regmap_i2c_smbus_i2c_write_reg16,
301301
.read = regmap_i2c_smbus_i2c_read_reg16,
302-
.max_raw_read = I2C_SMBUS_BLOCK_MAX,
303-
.max_raw_write = I2C_SMBUS_BLOCK_MAX,
302+
.max_raw_read = I2C_SMBUS_BLOCK_MAX - 2,
303+
.max_raw_write = I2C_SMBUS_BLOCK_MAX - 2,
304304
};
305305

306306
static const struct regmap_bus *regmap_get_i2c_bus(struct i2c_client *i2c,

drivers/base/regmap/regmap-kunit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ static struct regmap *gen_regmap(struct regmap_config *config,
5858
int i;
5959
struct reg_default *defaults;
6060

61+
config->disable_locking = config->cache_type == REGCACHE_RBTREE ||
62+
config->cache_type == REGCACHE_MAPLE;
63+
6164
buf = kmalloc(size, GFP_KERNEL);
6265
if (!buf)
6366
return ERR_PTR(-ENOMEM);
@@ -889,6 +892,8 @@ static struct regmap *gen_raw_regmap(struct regmap_config *config,
889892

890893
config->cache_type = test_type->cache_type;
891894
config->val_format_endian = test_type->val_endian;
895+
config->disable_locking = config->cache_type == REGCACHE_RBTREE ||
896+
config->cache_type == REGCACHE_MAPLE;
892897

893898
buf = kmalloc(size, GFP_KERNEL);
894899
if (!buf)

drivers/base/regmap/regmap-spi-avmm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ static const struct regmap_bus regmap_spi_avmm_bus = {
660660
.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
661661
.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
662662
.max_raw_read = SPI_AVMM_VAL_SIZE * MAX_READ_CNT,
663-
.max_raw_write = SPI_AVMM_REG_SIZE + SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT,
663+
.max_raw_write = SPI_AVMM_VAL_SIZE * MAX_WRITE_CNT,
664664
.free_context = spi_avmm_bridge_ctx_free,
665665
};
666666

drivers/base/regmap/regmap.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,17 +2082,15 @@ 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;
20872085
int ret, i;
20882086

20892087
if (!val_count)
20902088
return -EINVAL;
20912089

20922090
if (map->use_single_write)
20932091
chunk_regs = 1;
2094-
else if (map->max_raw_write && val_len > max_data)
2095-
chunk_regs = max_data / val_bytes;
2092+
else if (map->max_raw_write && val_len > map->max_raw_write)
2093+
chunk_regs = map->max_raw_write / val_bytes;
20962094

20972095
chunk_count = val_count / chunk_regs;
20982096
chunk_bytes = chunk_regs * val_bytes;

0 commit comments

Comments
 (0)