* [PATCH 1/2] regmap: add regmap_might_sleep()
@ 2022-11-21 15:08 Michael Walle
2022-11-21 15:08 ` [PATCH 2/2] gpio: regmap: use new regmap_might_sleep() Michael Walle
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Walle @ 2022-11-21 15:08 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Bartosz Golaszewski
Cc: linux-kernel, linux-gpio, William Breathitt Gray, Michael Walle
With the dawn of MMIO gpio-regmap users, it is desirable to let
gpio-regmap ask the regmap if it might sleep during an access so
it can pass that information to gpiochip. Add a new regmap_might_sleep()
to query the regmap.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/base/regmap/regmap.c | 13 +++++++++++++
include/linux/regmap.h | 7 +++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index c6d6d53e8cd3..d12d669157f2 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -3486,6 +3486,19 @@ int regmap_get_reg_stride(struct regmap *map)
}
EXPORT_SYMBOL_GPL(regmap_get_reg_stride);
+/**
+ * regmap_might_sleep() - Returns whether a regmap access might sleep.
+ *
+ * @map: Register map to operate on.
+ *
+ * Returns true if an access to the register might sleep, else false.
+ */
+bool regmap_might_sleep(struct regmap *map)
+{
+ return map->can_sleep;
+}
+EXPORT_SYMBOL_GPL(regmap_might_sleep);
+
int regmap_parse_val(struct regmap *map, const void *buf,
unsigned int *val)
{
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index ca3434dca3a0..3faf5d5dbb26 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1219,6 +1219,7 @@ static inline int regmap_write_bits(struct regmap *map, unsigned int reg,
int regmap_get_val_bytes(struct regmap *map);
int regmap_get_max_register(struct regmap *map);
int regmap_get_reg_stride(struct regmap *map);
+bool regmap_might_sleep(struct regmap *map);
int regmap_async_complete(struct regmap *map);
bool regmap_can_raw_write(struct regmap *map);
size_t regmap_get_raw_read_max(struct regmap *map);
@@ -1905,6 +1906,12 @@ static inline int regmap_get_reg_stride(struct regmap *map)
return -EINVAL;
}
+static inline bool regmap_might_sleep(struct regmap *map)
+{
+ WARN_ONCE(1, "regmap API is disabled");
+ return true;
+}
+
static inline int regcache_sync(struct regmap *map)
{
WARN_ONCE(1, "regmap API is disabled");
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] gpio: regmap: use new regmap_might_sleep()
2022-11-21 15:08 [PATCH 1/2] regmap: add regmap_might_sleep() Michael Walle
@ 2022-11-21 15:08 ` Michael Walle
2022-11-22 14:49 ` (subset) [PATCH 1/2] regmap: add regmap_might_sleep() Mark Brown
2022-11-22 19:43 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Michael Walle @ 2022-11-21 15:08 UTC (permalink / raw)
To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Bartosz Golaszewski
Cc: linux-kernel, linux-gpio, William Breathitt Gray, Michael Walle
Now that the regmap can be queried whether it might sleep, we can get
rid of the conservative setting "can_sleep = true". New drivers which
want to use gpio-regmap and can access the registers memory-mapped won't
have the restriction that their consumers have to use the
gpiod_*cansleep() variants anymore.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/gpio/gpio-regmap.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 6383136cbe59..16404ca6ac38 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -249,15 +249,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
chip->ngpio = config->ngpio;
chip->names = config->names;
chip->label = config->label ?: dev_name(config->parent);
-
- /*
- * If our regmap is fast_io we should probably set can_sleep to false.
- * Right now, the regmap doesn't save this property, nor is there any
- * access function for it.
- * The only regmap type which uses fast_io is regmap-mmio. For now,
- * assume a safe default of true here.
- */
- chip->can_sleep = true;
+ chip->can_sleep = regmap_might_sleep(config->regmap);
chip->get = gpio_regmap_get;
if (gpio->reg_set_base && gpio->reg_clr_base)
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: (subset) [PATCH 1/2] regmap: add regmap_might_sleep()
2022-11-21 15:08 [PATCH 1/2] regmap: add regmap_might_sleep() Michael Walle
2022-11-21 15:08 ` [PATCH 2/2] gpio: regmap: use new regmap_might_sleep() Michael Walle
@ 2022-11-22 14:49 ` Mark Brown
2022-11-22 19:43 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-11-22 14:49 UTC (permalink / raw)
To: Linus Walleij, Michael Walle, Rafael J . Wysocki,
Bartosz Golaszewski, Greg Kroah-Hartman
Cc: William Breathitt Gray, linux-kernel, linux-gpio
On Mon, 21 Nov 2022 16:08:42 +0100, Michael Walle wrote:
> With the dawn of MMIO gpio-regmap users, it is desirable to let
> gpio-regmap ask the regmap if it might sleep during an access so
> it can pass that information to gpiochip. Add a new regmap_might_sleep()
> to query the regmap.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next
Thanks!
[1/2] regmap: add regmap_might_sleep()
commit: a6d99022e56e8c1ddc4c75895ed9e3ce5da88453
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] regmap: add regmap_might_sleep()
2022-11-21 15:08 [PATCH 1/2] regmap: add regmap_might_sleep() Michael Walle
2022-11-21 15:08 ` [PATCH 2/2] gpio: regmap: use new regmap_might_sleep() Michael Walle
2022-11-22 14:49 ` (subset) [PATCH 1/2] regmap: add regmap_might_sleep() Mark Brown
@ 2022-11-22 19:43 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-11-22 19:43 UTC (permalink / raw)
To: Michael Walle
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, Linus Walleij,
Bartosz Golaszewski, linux-kernel, linux-gpio,
William Breathitt Gray
[-- Attachment #1: Type: text/plain, Size: 1138 bytes --]
On Mon, Nov 21, 2022 at 04:08:42PM +0100, Michael Walle wrote:
> With the dawn of MMIO gpio-regmap users, it is desirable to let
> gpio-regmap ask the regmap if it might sleep during an access so
> it can pass that information to gpiochip. Add a new regmap_might_sleep()
> to query the regmap.
The following changes since commit 9abf2313adc1ca1b6180c508c25f22f9395cc780:
Linux 6.1-rc1 (2022-10-16 15:36:24 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git tags/regmap-might-sleep
for you to fetch changes up to a6d99022e56e8c1ddc4c75895ed9e3ce5da88453:
regmap: add regmap_might_sleep() (2022-11-22 12:23:17 +0000)
----------------------------------------------------------------
regmap: Add regmap_might_sleep()
Add an interface allowing generic users to determine if a regmap might
use sleeping operations.
----------------------------------------------------------------
Michael Walle (1):
regmap: add regmap_might_sleep()
drivers/base/regmap/regmap.c | 13 +++++++++++++
include/linux/regmap.h | 7 +++++++
2 files changed, 20 insertions(+)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-22 19:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-21 15:08 [PATCH 1/2] regmap: add regmap_might_sleep() Michael Walle
2022-11-21 15:08 ` [PATCH 2/2] gpio: regmap: use new regmap_might_sleep() Michael Walle
2022-11-22 14:49 ` (subset) [PATCH 1/2] regmap: add regmap_might_sleep() Mark Brown
2022-11-22 19:43 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox