Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'regmap-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap

Pull regmap updates from Mark Brown:
"The main thing for regmap this time around is some improvements of the
lockdep annotations which stop some false positives. We also have one
new helper for setting a bitmask to the same value, and several test
improvements"

* tag 'regmap-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
regmap: provide regmap_assign_bits()
regmap: irq: Set lockdep class for hierarchical IRQ domains
regmap: maple: Provide lockdep (sub)class for maple tree's internal lock
regmap: kunit: Fix repeated test param
regcache: Improve documentation of available cache types
regmap: Specifically test writing 0 as a value to sparse caches
regmap-irq: Consistently use memset32() in regmap_irq_thread()

+78 -6
+1
drivers/base/regmap/internal.h
··· 59 59 unsigned long raw_spinlock_flags; 60 60 }; 61 61 }; 62 + struct lock_class_key *lock_key; 62 63 regmap_lock lock; 63 64 regmap_unlock unlock; 64 65 void *lock_arg; /* This is passed to lock/unlock functions */
+3
drivers/base/regmap/regcache-maple.c
··· 355 355 356 356 mt_init(mt); 357 357 358 + if (!mt_external_lock(mt) && map->lock_key) 359 + lockdep_set_class_and_subclass(&mt->ma_lock, map->lock_key, 1); 360 + 358 361 if (!map->num_reg_defaults) 359 362 return 0; 360 363
+5 -4
drivers/base/regmap/regmap-irq.c
··· 364 364 memset32(data->status_buf, GENMASK(31, 0), chip->num_regs); 365 365 } else if (chip->num_main_regs) { 366 366 unsigned int max_main_bits; 367 - unsigned long size; 368 - 369 - size = chip->num_regs * sizeof(unsigned int); 370 367 371 368 max_main_bits = (chip->num_main_status_bits) ? 372 369 chip->num_main_status_bits : chip->num_regs; 373 370 /* 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); 375 372 376 373 /* We could support bulk read for main status registers 377 374 * but I don't expect to see devices with really many main ··· 511 514 return IRQ_NONE; 512 515 } 513 516 517 + static struct lock_class_key regmap_irq_lock_class; 518 + static struct lock_class_key regmap_irq_request_class; 519 + 514 520 static int regmap_irq_map(struct irq_domain *h, unsigned int virq, 515 521 irq_hw_number_t hw) 516 522 { 517 523 struct regmap_irq_chip_data *data = h->host_data; 518 524 519 525 irq_set_chip_data(virq, data); 526 + irq_set_lockdep_class(virq, &regmap_irq_lock_class, &regmap_irq_request_class); 520 527 irq_set_chip(virq, &data->irq_chip); 521 528 irq_set_nested_thread(virq, 1); 522 529 irq_set_parent(virq, data->irq);
+44 -1
drivers/base/regmap/regmap-kunit.c
··· 126 126 { .cache = REGCACHE_RBTREE, .from_reg = 0x2003 }, 127 127 { .cache = REGCACHE_RBTREE, .from_reg = 0x2004 }, 128 128 { .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 }, 130 130 { .cache = REGCACHE_MAPLE, .from_reg = 0x2001 }, 131 131 { .cache = REGCACHE_MAPLE, .from_reg = 0x2002 }, 132 132 { .cache = REGCACHE_MAPLE, .from_reg = 0x2003 }, ··· 1499 1499 KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, param->from_reg + i)); 1500 1500 } 1501 1501 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 + 1502 1544 /* Check that caching the window register works with sync */ 1503 1545 static void cache_range_window_reg(struct kunit *test) 1504 1546 { ··· 2054 2012 KUNIT_CASE_PARAM(cache_drop_all_and_sync_no_defaults, sparse_cache_types_gen_params), 2055 2013 KUNIT_CASE_PARAM(cache_drop_all_and_sync_has_defaults, sparse_cache_types_gen_params), 2056 2014 KUNIT_CASE_PARAM(cache_present, sparse_cache_types_gen_params), 2015 + KUNIT_CASE_PARAM(cache_write_zero, sparse_cache_types_gen_params), 2057 2016 KUNIT_CASE_PARAM(cache_range_window_reg, real_cache_types_only_gen_params), 2058 2017 2059 2018 KUNIT_CASE_PARAM(raw_read_defaults_single, raw_test_types_gen_params),
+1
drivers/base/regmap/regmap.c
··· 745 745 lock_key, lock_name); 746 746 } 747 747 map->lock_arg = map; 748 + map->lock_key = lock_key; 748 749 } 749 750 750 751 /*
+24 -1
include/linux/regmap.h
··· 54 54 #define REGMAP_UPSHIFT(s) (-(s)) 55 55 #define REGMAP_DOWNSHIFT(s) (s) 56 56 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 + */ 58 65 enum regcache_type { 59 66 REGCACHE_NONE, 60 67 REGCACHE_RBTREE, ··· 1335 1328 return regmap_update_bits_base(map, reg, bits, 0, NULL, false, false); 1336 1329 } 1337 1330 1331 + static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, 1332 + unsigned int bits, bool value) 1333 + { 1334 + if (value) 1335 + return regmap_set_bits(map, reg, bits); 1336 + else 1337 + return regmap_clear_bits(map, reg, bits); 1338 + } 1339 + 1338 1340 int regmap_test_bits(struct regmap *map, unsigned int reg, unsigned int bits); 1339 1341 1340 1342 /** ··· 1807 1791 1808 1792 static inline int regmap_clear_bits(struct regmap *map, 1809 1793 unsigned int reg, unsigned int bits) 1794 + { 1795 + WARN_ONCE(1, "regmap API is disabled"); 1796 + return -EINVAL; 1797 + } 1798 + 1799 + static inline int regmap_assign_bits(struct regmap *map, unsigned int reg, 1800 + unsigned int bits, bool value) 1810 1801 { 1811 1802 WARN_ONCE(1, "regmap API is disabled"); 1812 1803 return -EINVAL;