Skip to content

Commit 0fc81f3

Browse files
committed
Merge tag 'regmap-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap
Pull regmap updates from Mark Brown: "This is a much quieter release than the past few, there's one small API addition that I noticed a user for in ALSA and a bunch of cleanups: - Provide an interface for determining if a register is present in the cache and add a user of it in ALSA. - Full support for dynamic allocations, following the temporary bodges that were done as fixes in the previous release. - Remove the unused and questionably working 64 bit support" * tag 'regmap-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: regmap: Fix the type used for a bitmap pointer regmap: Remove dynamic allocation warnings for rbtree and maple regmap: rbtree: Use alloc_flags for memory allocations regmap: maple: Use alloc_flags for memory allocations regmap: Reject fast_io regmap configurations with RBTREE and MAPLE caches ALSA: hda: Use regcache_reg_cached() rather than open coding regmap: Provide test for regcache_reg_present() regmap: Let users check if a register is cached regmap: Provide user selectable option to enable regmap regmap: mmio: Remove unused 64-bit support code regmap: cache: Revert "Add 64-bit mode support" regmap: Revert "add 64-bit mode support" and Co.
2 parents c35c486 + 5d481dd commit 0fc81f3

File tree

10 files changed

+94
-182
lines changed

10 files changed

+94
-182
lines changed

drivers/base/regmap/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# subsystems should select the appropriate symbols.
55

66
config REGMAP
7-
bool "Register Map support" if KUNIT_ALL_TESTS
7+
bool
88
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)
99
select IRQ_DOMAIN if REGMAP_IRQ
1010
select MDIO_BUS if REGMAP_MDIO
@@ -23,6 +23,16 @@ config REGMAP_KUNIT
2323
default KUNIT_ALL_TESTS
2424
select REGMAP_RAM
2525

26+
config REGMAP_BUILD
27+
bool "Enable regmap build"
28+
depends on KUNIT
29+
select REGMAP
30+
help
31+
This option exists purely to allow the regmap KUnit tests to
32+
be enabled without having to enable some driver that uses
33+
regmap due to unfortunate issues with how KUnit tests are
34+
normally enabled.
35+
2636
config REGMAP_AC97
2737
tristate
2838

drivers/base/regmap/regcache-maple.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
7474
rcu_read_unlock();
7575

7676
entry = kmalloc((last - index + 1) * sizeof(unsigned long),
77-
GFP_KERNEL);
77+
map->alloc_flags);
7878
if (!entry)
7979
return -ENOMEM;
8080

@@ -92,7 +92,7 @@ static int regcache_maple_write(struct regmap *map, unsigned int reg,
9292
mas_lock(&mas);
9393

9494
mas_set_range(&mas, index, last);
95-
ret = mas_store_gfp(&mas, entry, GFP_KERNEL);
95+
ret = mas_store_gfp(&mas, entry, map->alloc_flags);
9696

9797
mas_unlock(&mas);
9898

@@ -134,7 +134,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
134134

135135
lower = kmemdup(entry, ((min - mas.index) *
136136
sizeof(unsigned long)),
137-
GFP_KERNEL);
137+
map->alloc_flags);
138138
if (!lower) {
139139
ret = -ENOMEM;
140140
goto out_unlocked;
@@ -148,7 +148,7 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
148148
upper = kmemdup(&entry[max + 1],
149149
((mas.last - max) *
150150
sizeof(unsigned long)),
151-
GFP_KERNEL);
151+
map->alloc_flags);
152152
if (!upper) {
153153
ret = -ENOMEM;
154154
goto out_unlocked;
@@ -162,15 +162,15 @@ static int regcache_maple_drop(struct regmap *map, unsigned int min,
162162
/* Insert new nodes with the saved data */
163163
if (lower) {
164164
mas_set_range(&mas, lower_index, lower_last);
165-
ret = mas_store_gfp(&mas, lower, GFP_KERNEL);
165+
ret = mas_store_gfp(&mas, lower, map->alloc_flags);
166166
if (ret != 0)
167167
goto out;
168168
lower = NULL;
169169
}
170170

171171
if (upper) {
172172
mas_set_range(&mas, upper_index, upper_last);
173-
ret = mas_store_gfp(&mas, upper, GFP_KERNEL);
173+
ret = mas_store_gfp(&mas, upper, map->alloc_flags);
174174
if (ret != 0)
175175
goto out;
176176
upper = NULL;
@@ -320,7 +320,7 @@ static int regcache_maple_insert_block(struct regmap *map, int first,
320320
unsigned long *entry;
321321
int i, ret;
322322

323-
entry = kcalloc(last - first + 1, sizeof(unsigned long), GFP_KERNEL);
323+
entry = kcalloc(last - first + 1, sizeof(unsigned long), map->alloc_flags);
324324
if (!entry)
325325
return -ENOMEM;
326326

@@ -331,7 +331,7 @@ static int regcache_maple_insert_block(struct regmap *map, int first,
331331

332332
mas_set_range(&mas, map->reg_defaults[first].reg,
333333
map->reg_defaults[last].reg);
334-
ret = mas_store_gfp(&mas, entry, GFP_KERNEL);
334+
ret = mas_store_gfp(&mas, entry, map->alloc_flags);
335335

336336
mas_unlock(&mas);
337337

drivers/base/regmap/regcache-rbtree.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct regcache_rbtree_node {
2222
/* block of adjacent registers */
2323
void *block;
2424
/* Which registers are present */
25-
long *cache_present;
25+
unsigned long *cache_present;
2626
/* base register handled by this block */
2727
unsigned int base_reg;
2828
/* number of registers available in the block */
@@ -277,7 +277,7 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
277277

278278
blk = krealloc(rbnode->block,
279279
blklen * map->cache_word_size,
280-
GFP_KERNEL);
280+
map->alloc_flags);
281281
if (!blk)
282282
return -ENOMEM;
283283

@@ -286,7 +286,7 @@ static int regcache_rbtree_insert_to_block(struct regmap *map,
286286
if (BITS_TO_LONGS(blklen) > BITS_TO_LONGS(rbnode->blklen)) {
287287
present = krealloc(rbnode->cache_present,
288288
BITS_TO_LONGS(blklen) * sizeof(*present),
289-
GFP_KERNEL);
289+
map->alloc_flags);
290290
if (!present)
291291
return -ENOMEM;
292292

@@ -320,7 +320,7 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
320320
const struct regmap_range *range;
321321
int i;
322322

323-
rbnode = kzalloc(sizeof(*rbnode), GFP_KERNEL);
323+
rbnode = kzalloc(sizeof(*rbnode), map->alloc_flags);
324324
if (!rbnode)
325325
return NULL;
326326

@@ -346,13 +346,13 @@ regcache_rbtree_node_alloc(struct regmap *map, unsigned int reg)
346346
}
347347

348348
rbnode->block = kmalloc_array(rbnode->blklen, map->cache_word_size,
349-
GFP_KERNEL);
349+
map->alloc_flags);
350350
if (!rbnode->block)
351351
goto err_free;
352352

353353
rbnode->cache_present = kcalloc(BITS_TO_LONGS(rbnode->blklen),
354354
sizeof(*rbnode->cache_present),
355-
GFP_KERNEL);
355+
map->alloc_flags);
356356
if (!rbnode->cache_present)
357357
goto err_free_block;
358358

drivers/base/regmap/regcache.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,29 @@ void regcache_cache_bypass(struct regmap *map, bool enable)
558558
}
559559
EXPORT_SYMBOL_GPL(regcache_cache_bypass);
560560

561+
/**
562+
* regcache_reg_cached - Check if a register is cached
563+
*
564+
* @map: map to check
565+
* @reg: register to check
566+
*
567+
* Reports if a register is cached.
568+
*/
569+
bool regcache_reg_cached(struct regmap *map, unsigned int reg)
570+
{
571+
unsigned int val;
572+
int ret;
573+
574+
map->lock(map->lock_arg);
575+
576+
ret = regcache_read(map, reg, &val);
577+
578+
map->unlock(map->lock_arg);
579+
580+
return ret == 0;
581+
}
582+
EXPORT_SYMBOL_GPL(regcache_reg_cached);
583+
561584
void regcache_set_val(struct regmap *map, void *base, unsigned int idx,
562585
unsigned int val)
563586
{
@@ -587,14 +610,6 @@ void regcache_set_val(struct regmap *map, void *base, unsigned int idx,
587610
cache[idx] = val;
588611
break;
589612
}
590-
#ifdef CONFIG_64BIT
591-
case 8: {
592-
u64 *cache = base;
593-
594-
cache[idx] = val;
595-
break;
596-
}
597-
#endif
598613
default:
599614
BUG();
600615
}
@@ -627,13 +642,6 @@ unsigned int regcache_get_val(struct regmap *map, const void *base,
627642

628643
return cache[idx];
629644
}
630-
#ifdef CONFIG_64BIT
631-
case 8: {
632-
const u64 *cache = base;
633-
634-
return cache[idx];
635-
}
636-
#endif
637645
default:
638646
BUG();
639647
}

drivers/base/regmap/regmap-kunit.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,45 @@ static void cache_drop(struct kunit *test)
836836
regmap_exit(map);
837837
}
838838

839+
static void cache_present(struct kunit *test)
840+
{
841+
struct regcache_types *t = (struct regcache_types *)test->param_value;
842+
struct regmap *map;
843+
struct regmap_config config;
844+
struct regmap_ram_data *data;
845+
unsigned int val;
846+
int i;
847+
848+
config = test_regmap_config;
849+
config.cache_type = t->type;
850+
851+
map = gen_regmap(&config, &data);
852+
KUNIT_ASSERT_FALSE(test, IS_ERR(map));
853+
if (IS_ERR(map))
854+
return;
855+
856+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
857+
data->read[i] = false;
858+
859+
/* No defaults so no registers cached. */
860+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
861+
KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, i));
862+
863+
/* We didn't trigger any reads */
864+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
865+
KUNIT_ASSERT_FALSE(test, data->read[i]);
866+
867+
/* Fill the cache */
868+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
869+
KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &val));
870+
871+
/* Now everything should be cached */
872+
for (i = 0; i < BLOCK_TEST_SIZE; i++)
873+
KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, i));
874+
875+
regmap_exit(map);
876+
}
877+
839878
struct raw_test_types {
840879
const char *name;
841880

@@ -1177,6 +1216,7 @@ static struct kunit_case regmap_test_cases[] = {
11771216
KUNIT_CASE_PARAM(cache_sync_readonly, real_cache_types_gen_params),
11781217
KUNIT_CASE_PARAM(cache_sync_patch, real_cache_types_gen_params),
11791218
KUNIT_CASE_PARAM(cache_drop, sparse_cache_types_gen_params),
1219+
KUNIT_CASE_PARAM(cache_present, sparse_cache_types_gen_params),
11801220

11811221
KUNIT_CASE_PARAM(raw_read_defaults_single, raw_test_types_gen_params),
11821222
KUNIT_CASE_PARAM(raw_read_defaults, raw_test_types_gen_params),

drivers/base/regmap/regmap-mmio.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,6 @@ static int regmap_mmio_noinc_write(void *context, unsigned int reg,
202202
writel(swab32(valp[i]), ctx->regs + reg);
203203
goto out_clk;
204204
}
205-
#ifdef CONFIG_64BIT
206-
case 8:
207-
{
208-
const u64 *valp = (const u64 *)val;
209-
for (i = 0; i < val_count; i++)
210-
writeq(swab64(valp[i]), ctx->regs + reg);
211-
goto out_clk;
212-
}
213-
#endif
214205
default:
215206
ret = -EINVAL;
216207
goto out_clk;
@@ -227,11 +218,6 @@ static int regmap_mmio_noinc_write(void *context, unsigned int reg,
227218
case 4:
228219
writesl(ctx->regs + reg, (const u32 *)val, val_count);
229220
break;
230-
#ifdef CONFIG_64BIT
231-
case 8:
232-
writesq(ctx->regs + reg, (const u64 *)val, val_count);
233-
break;
234-
#endif
235221
default:
236222
ret = -EINVAL;
237223
break;
@@ -363,11 +349,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
363349
case 4:
364350
readsl(ctx->regs + reg, (u32 *)val, val_count);
365351
break;
366-
#ifdef CONFIG_64BIT
367-
case 8:
368-
readsq(ctx->regs + reg, (u64 *)val, val_count);
369-
break;
370-
#endif
371352
default:
372353
ret = -EINVAL;
373354
goto out_clk;
@@ -387,11 +368,6 @@ static int regmap_mmio_noinc_read(void *context, unsigned int reg,
387368
case 4:
388369
swab32_array(val, val_count);
389370
break;
390-
#ifdef CONFIG_64BIT
391-
case 8:
392-
swab64_array(val, val_count);
393-
break;
394-
#endif
395371
default:
396372
ret = -EINVAL;
397373
break;

0 commit comments

Comments
 (0)