Skip to content

Commit 72229b8

Browse files
committed
Merge remote-tracking branch 'regmap/for-next' into sound/upstream-20241031
2 parents ea5e2f0 + 96a5408 commit 72229b8

3 files changed

Lines changed: 53 additions & 6 deletions

File tree

drivers/base/regmap/regmap-irq.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,11 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
364364
memset32(data->status_buf, GENMASK(31, 0), chip->num_regs);
365365
} else if (chip->num_main_regs) {
366366
unsigned int max_main_bits;
367-
unsigned long size;
368-
369-
size = chip->num_regs * sizeof(unsigned int);
370367

371368
max_main_bits = (chip->num_main_status_bits) ?
372369
chip->num_main_status_bits : chip->num_regs;
373370
/* Clear the status buf as we don't read all status regs */
374-
memset(data->status_buf, 0, size);
371+
memset32(data->status_buf, 0, chip->num_regs);
375372

376373
/* We could support bulk read for main status registers
377374
* but I don't expect to see devices with really many main

drivers/base/regmap/regmap-kunit.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static const struct regmap_test_param real_cache_types_list[] = {
126126
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2003 },
127127
{ .cache = REGCACHE_RBTREE, .from_reg = 0x2004 },
128128
{ .cache = REGCACHE_MAPLE, .from_reg = 0 },
129-
{ .cache = REGCACHE_RBTREE, .from_reg = 0, .fast_io = true },
129+
{ .cache = REGCACHE_MAPLE, .from_reg = 0, .fast_io = true },
130130
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2001 },
131131
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2002 },
132132
{ .cache = REGCACHE_MAPLE, .from_reg = 0x2003 },
@@ -1499,6 +1499,48 @@ static void cache_present(struct kunit *test)
14991499
KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, param->from_reg + i));
15001500
}
15011501

1502+
static void cache_write_zero(struct kunit *test)
1503+
{
1504+
const struct regmap_test_param *param = test->param_value;
1505+
struct regmap *map;
1506+
struct regmap_config config;
1507+
struct regmap_ram_data *data;
1508+
unsigned int val;
1509+
int i;
1510+
1511+
config = test_regmap_config;
1512+
1513+
map = gen_regmap(test, &config, &data);
1514+
KUNIT_ASSERT_FALSE(test, IS_ERR(map));
1515+
if (IS_ERR(map))
1516+
return;
1517+
1518+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
1519+
data->read[param->from_reg + i] = false;
1520+
1521+
/* No defaults so no registers cached. */
1522+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
1523+
KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, param->from_reg + i));
1524+
1525+
/* We didn't trigger any reads */
1526+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
1527+
KUNIT_ASSERT_FALSE(test, data->read[param->from_reg + i]);
1528+
1529+
/* Write a zero value */
1530+
KUNIT_EXPECT_EQ(test, 0, regmap_write(map, 1, 0));
1531+
1532+
/* Read that zero value back */
1533+
KUNIT_EXPECT_EQ(test, 0, regmap_read(map, 1, &val));
1534+
KUNIT_EXPECT_EQ(test, 0, val);
1535+
1536+
/* From the cache? */
1537+
KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, 1));
1538+
1539+
/* Try to throw it away */
1540+
KUNIT_EXPECT_EQ(test, 0, regcache_drop_region(map, 1, 1));
1541+
KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, 1));
1542+
}
1543+
15021544
/* Check that caching the window register works with sync */
15031545
static void cache_range_window_reg(struct kunit *test)
15041546
{
@@ -2012,6 +2054,7 @@ static struct kunit_case regmap_test_cases[] = {
20122054
KUNIT_CASE_PARAM(cache_drop_all_and_sync_no_defaults, sparse_cache_types_gen_params),
20132055
KUNIT_CASE_PARAM(cache_drop_all_and_sync_has_defaults, sparse_cache_types_gen_params),
20142056
KUNIT_CASE_PARAM(cache_present, sparse_cache_types_gen_params),
2057+
KUNIT_CASE_PARAM(cache_write_zero, sparse_cache_types_gen_params),
20152058
KUNIT_CASE_PARAM(cache_range_window_reg, real_cache_types_only_gen_params),
20162059

20172060
KUNIT_CASE_PARAM(raw_read_defaults_single, raw_test_types_gen_params),

include/linux/regmap.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ struct sdw_slave;
5454
#define REGMAP_UPSHIFT(s) (-(s))
5555
#define REGMAP_DOWNSHIFT(s) (s)
5656

57-
/* An enum of all the supported cache types */
57+
/*
58+
* The supported cache types, the default is no cache. Any new caches
59+
* should usually use the maple tree cache unless they specifically
60+
* require that there are never any allocations at runtime and can't
61+
* provide defaults in which case they should use the flat cache. The
62+
* rbtree cache *may* have some performance advantage for very low end
63+
* systems that make heavy use of cache syncs but is mainly legacy.
64+
*/
5865
enum regcache_type {
5966
REGCACHE_NONE,
6067
REGCACHE_RBTREE,

0 commit comments

Comments
 (0)