From: Guenter Roeck Date: Thu, 20 Jul 2023 03:28:48 +0000 (-0700) Subject: regmap: Reject fast_io regmap configurations with RBTREE and MAPLE caches X-Git-Tag: v6.6-rc1~169^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ee43f5bb23340c27603c3ad8ef94f677ad7cb9ad;p=thirdparty%2Flinux.git regmap: Reject fast_io regmap configurations with RBTREE and MAPLE caches REGCACHE_RBTREE and REGCACHE_MAPLE dynamically allocate memory for regmap operations. This is incompatible with spinlock based locking which is used for fast_io operations. Reject affected configurations. Signed-off-by: Guenter Roeck Link: https://lore.kernel.org/r/20230720032848.1306349-2-linux@roeck-us.net Signed-off-by: Mark Brown --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 8b37451fa9315..6c637b18d6b0b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -723,6 +723,15 @@ struct regmap *__regmap_init(struct device *dev, } else { if ((bus && bus->fast_io) || config->fast_io) { + /* + * fast_io is incompatible with REGCACHE_RBTREE and REGCACHE_MAPLE + * since both need to dynamically allocate memory. + */ + if (config->cache_type == REGCACHE_RBTREE || + config->cache_type == REGCACHE_MAPLE) { + ret = -EINVAL; + goto err_name; + } if (config->use_raw_spinlock) { raw_spin_lock_init(&map->raw_spinlock); map->lock = regmap_lock_raw_spinlock;