All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] regmap: add iopoll-like atomic polling macro
@ 2020-01-09  5:09 ` Sameer Pujar
  0 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-09  5:09 UTC (permalink / raw)
  To: broonie; +Cc: jonathanh, linux-kernel, linux-tegra, Sameer Pujar

This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
is atomic version of already available 'regmap_read_poll_timeout' macro.

It should be noted that above atomic macro cannot be used by all regmaps.
If the regmap is set up for atomic use (flat or no cache and MMIO) then
only it can use.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 include/linux/regmap.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index dfe493a..f0a092a 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -145,6 +145,51 @@ struct reg_sequence {
 })
 
 /**
+ * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs
+ *
+ * @map: Regmap to read from
+ * @addr: Address to poll
+ * @val: Unsigned integer variable to read the value into
+ * @cond: Break condition (usually involving @val)
+ * @delay_us: Time to udelay between reads in us (0 tight-loops).
+ *            Should be less than ~10us since udelay is used
+ *            (see Documentation/timers/timers-howto.rst).
+ * @timeout_us: Timeout in us, 0 means never timeout
+ *
+ * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * error return value in case of a error read. In the two former cases,
+ * the last read value at @addr is stored in @val.
+ *
+ * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
+ *
+ * Note: In general regmap cannot be used in atomic context. If you want to use
+ * this macro then first setup your regmap for atomic use (flat or no cache
+ * and MMIO regmap).
+ */
+#define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
+({ \
+	u64 __timeout_us = (timeout_us); \
+	unsigned long __delay_us = (delay_us); \
+	ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
+	int __ret; \
+	for (;;) { \
+		__ret = regmap_read((map), (addr), &(val)); \
+		if (__ret) \
+			break; \
+		if (cond) \
+			break; \
+		if ((__timeout_us) && \
+		    ktime_compare(ktime_get(), __timeout) > 0) { \
+			__ret = regmap_read((map), (addr), &(val)); \
+			break; \
+		} \
+		if (__delay_us) \
+			udelay(__delay_us); \
+	} \
+	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
+})
+
+/**
  * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
  *
  * @field: Regmap field to read from
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v3] regmap: add iopoll-like atomic polling macro
@ 2020-01-09  5:09 ` Sameer Pujar
  0 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-09  5:09 UTC (permalink / raw)
  To: broonie; +Cc: jonathanh, linux-kernel, linux-tegra, Sameer Pujar

This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
is atomic version of already available 'regmap_read_poll_timeout' macro.

It should be noted that above atomic macro cannot be used by all regmaps.
If the regmap is set up for atomic use (flat or no cache and MMIO) then
only it can use.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 include/linux/regmap.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index dfe493a..f0a092a 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -145,6 +145,51 @@ struct reg_sequence {
 })
 
 /**
+ * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs
+ *
+ * @map: Regmap to read from
+ * @addr: Address to poll
+ * @val: Unsigned integer variable to read the value into
+ * @cond: Break condition (usually involving @val)
+ * @delay_us: Time to udelay between reads in us (0 tight-loops).
+ *            Should be less than ~10us since udelay is used
+ *            (see Documentation/timers/timers-howto.rst).
+ * @timeout_us: Timeout in us, 0 means never timeout
+ *
+ * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * error return value in case of a error read. In the two former cases,
+ * the last read value at @addr is stored in @val.
+ *
+ * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
+ *
+ * Note: In general regmap cannot be used in atomic context. If you want to use
+ * this macro then first setup your regmap for atomic use (flat or no cache
+ * and MMIO regmap).
+ */
+#define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
+({ \
+	u64 __timeout_us = (timeout_us); \
+	unsigned long __delay_us = (delay_us); \
+	ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
+	int __ret; \
+	for (;;) { \
+		__ret = regmap_read((map), (addr), &(val)); \
+		if (__ret) \
+			break; \
+		if (cond) \
+			break; \
+		if ((__timeout_us) && \
+		    ktime_compare(ktime_get(), __timeout) > 0) { \
+			__ret = regmap_read((map), (addr), &(val)); \
+			break; \
+		} \
+		if (__delay_us) \
+			udelay(__delay_us); \
+	} \
+	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
+})
+
+/**
  * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
  *
  * @field: Regmap field to read from
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
  2020-01-09  5:09 ` Sameer Pujar
  (?)
@ 2020-01-09  6:00 ` Dmitry Osipenko
  2020-01-09  7:24     ` Sameer Pujar
  -1 siblings, 1 reply; 12+ messages in thread
From: Dmitry Osipenko @ 2020-01-09  6:00 UTC (permalink / raw)
  To: Sameer Pujar, broonie; +Cc: jonathanh, linux-kernel, linux-tegra

09.01.2020 08:09, Sameer Pujar пишет:
> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
> is atomic version of already available 'regmap_read_poll_timeout' macro.
> 
> It should be noted that above atomic macro cannot be used by all regmaps.
> If the regmap is set up for atomic use (flat or no cache and MMIO) then
> only it can use.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> ---

Could you please explain what is the targeted use-case here?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
  2020-01-09  6:00 ` Dmitry Osipenko
@ 2020-01-09  7:24     ` Sameer Pujar
  0 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-09  7:24 UTC (permalink / raw)
  To: Dmitry Osipenko, broonie; +Cc: jonathanh, linux-kernel, linux-tegra


On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 09.01.2020 08:09, Sameer Pujar пишет:
>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>
>> It should be noted that above atomic macro cannot be used by all regmaps.
>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>> only it can use.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
> Could you please explain what is the targeted use-case here?

I was trying to use regmap_read_poll_timeout() to poll for status change 
of a register. This resulted in "BUG: scheduling while atomic". The 
callback function, in which I was trying to use the macro, runs in 
atomic context. Hence new atomic macro is added. I was checking ALSA 
playback/capture and trigger() callback had to monitor some register status.

In general, the new macro can be used in atomic callbacks where regmap 
interface is used and polling is required.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
@ 2020-01-09  7:24     ` Sameer Pujar
  0 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-09  7:24 UTC (permalink / raw)
  To: Dmitry Osipenko, broonie; +Cc: jonathanh, linux-kernel, linux-tegra


On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 09.01.2020 08:09, Sameer Pujar пишет:
>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>
>> It should be noted that above atomic macro cannot be used by all regmaps.
>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>> only it can use.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
> Could you please explain what is the targeted use-case here?

I was trying to use regmap_read_poll_timeout() to poll for status change 
of a register. This resulted in "BUG: scheduling while atomic". The 
callback function, in which I was trying to use the macro, runs in 
atomic context. Hence new atomic macro is added. I was checking ALSA 
playback/capture and trigger() callback had to monitor some register status.

In general, the new macro can be used in atomic callbacks where regmap 
interface is used and polling is required.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
  2020-01-09  7:24     ` Sameer Pujar
@ 2020-01-09 13:57         ` Dmitry Osipenko
  -1 siblings, 0 replies; 12+ messages in thread
From: Dmitry Osipenko @ 2020-01-09 13:57 UTC (permalink / raw)
  To: Sameer Pujar, broonie-DgEjT+Ai2ygdnm+yROfE0A
  Cc: jonathanh-DDmLM1+adcrQT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

09.01.2020 10:24, Sameer Pujar пишет:
> 
> On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 09.01.2020 08:09, Sameer Pujar пишет:
>>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>>
>>> It should be noted that above atomic macro cannot be used by all
>>> regmaps.
>>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>>> only it can use.
>>>
>>> Signed-off-by: Sameer Pujar <spujar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>>> ---
>> Could you please explain what is the targeted use-case here?
> 
> I was trying to use regmap_read_poll_timeout() to poll for status change
> of a register. This resulted in "BUG: scheduling while atomic". The
> callback function, in which I was trying to use the macro, runs in
> atomic context. Hence new atomic macro is added. I was checking ALSA
> playback/capture and trigger() callback had to monitor some register
> status.
> 
> In general, the new macro can be used in atomic callbacks where regmap
> interface is used and polling is required.
> 

You should send a full patchset because it may turn out that the patch
which makes use of the new feature isn't correct or maybe the new
feature isn't really needed.

If there was a previous discussion about the need for this change, then
you should provide a link to that discussion.

Please note that usually changes without a real use-case in kernel are
not getting picked up or they are getting removed later on if nobody
makes use of them, so I assume this is a kind of an RFC patch for now.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
@ 2020-01-09 13:57         ` Dmitry Osipenko
  0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Osipenko @ 2020-01-09 13:57 UTC (permalink / raw)
  To: Sameer Pujar, broonie; +Cc: jonathanh, linux-kernel, linux-tegra

09.01.2020 10:24, Sameer Pujar пишет:
> 
> On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 09.01.2020 08:09, Sameer Pujar пишет:
>>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>>
>>> It should be noted that above atomic macro cannot be used by all
>>> regmaps.
>>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>>> only it can use.
>>>
>>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>>> ---
>> Could you please explain what is the targeted use-case here?
> 
> I was trying to use regmap_read_poll_timeout() to poll for status change
> of a register. This resulted in "BUG: scheduling while atomic". The
> callback function, in which I was trying to use the macro, runs in
> atomic context. Hence new atomic macro is added. I was checking ALSA
> playback/capture and trigger() callback had to monitor some register
> status.
> 
> In general, the new macro can be used in atomic callbacks where regmap
> interface is used and polling is required.
> 

You should send a full patchset because it may turn out that the patch
which makes use of the new feature isn't correct or maybe the new
feature isn't really needed.

If there was a previous discussion about the need for this change, then
you should provide a link to that discussion.

Please note that usually changes without a real use-case in kernel are
not getting picked up or they are getting removed later on if nobody
makes use of them, so I assume this is a kind of an RFC patch for now.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Applied "regmap: add iopoll-like atomic polling macro" to the regmap tree
  2020-01-09  5:09 ` Sameer Pujar
@ 2020-01-09 21:30     ` Mark Brown
  -1 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2020-01-09 21:30 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, jonathanh-DDmLM1+adcrQT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

The patch

   regmap: add iopoll-like atomic polling macro

has been applied to the regmap tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-5.6

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

From 50816a4c39263913d8cfd1ee32f90102679606c6 Mon Sep 17 00:00:00 2001
From: Sameer Pujar <spujar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Date: Thu, 9 Jan 2020 10:39:50 +0530
Subject: [PATCH] regmap: add iopoll-like atomic polling macro

This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
is atomic version of already available 'regmap_read_poll_timeout' macro.

It should be noted that above atomic macro cannot be used by all regmaps.
If the regmap is set up for atomic use (flat or no cache and MMIO) then
only it can use.

Signed-off-by: Sameer Pujar <spujar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Link: https://lore.kernel.org/r/1578546590-24737-1-git-send-email-spujar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 include/linux/regmap.h | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index dfe493ac692d..f0a092a1a96d 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -144,6 +144,51 @@ struct reg_sequence {
 	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
 })
 
+/**
+ * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs
+ *
+ * @map: Regmap to read from
+ * @addr: Address to poll
+ * @val: Unsigned integer variable to read the value into
+ * @cond: Break condition (usually involving @val)
+ * @delay_us: Time to udelay between reads in us (0 tight-loops).
+ *            Should be less than ~10us since udelay is used
+ *            (see Documentation/timers/timers-howto.rst).
+ * @timeout_us: Timeout in us, 0 means never timeout
+ *
+ * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * error return value in case of a error read. In the two former cases,
+ * the last read value at @addr is stored in @val.
+ *
+ * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
+ *
+ * Note: In general regmap cannot be used in atomic context. If you want to use
+ * this macro then first setup your regmap for atomic use (flat or no cache
+ * and MMIO regmap).
+ */
+#define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
+({ \
+	u64 __timeout_us = (timeout_us); \
+	unsigned long __delay_us = (delay_us); \
+	ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
+	int __ret; \
+	for (;;) { \
+		__ret = regmap_read((map), (addr), &(val)); \
+		if (__ret) \
+			break; \
+		if (cond) \
+			break; \
+		if ((__timeout_us) && \
+		    ktime_compare(ktime_get(), __timeout) > 0) { \
+			__ret = regmap_read((map), (addr), &(val)); \
+			break; \
+		} \
+		if (__delay_us) \
+			udelay(__delay_us); \
+	} \
+	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
+})
+
 /**
  * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
  *
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Applied "regmap: add iopoll-like atomic polling macro" to the regmap tree
@ 2020-01-09 21:30     ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2020-01-09 21:30 UTC (permalink / raw)
  To: Sameer Pujar; +Cc: broonie, jonathanh, linux-kernel, linux-tegra, Mark Brown

The patch

   regmap: add iopoll-like atomic polling macro

has been applied to the regmap tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-5.6

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

From 50816a4c39263913d8cfd1ee32f90102679606c6 Mon Sep 17 00:00:00 2001
From: Sameer Pujar <spujar@nvidia.com>
Date: Thu, 9 Jan 2020 10:39:50 +0530
Subject: [PATCH] regmap: add iopoll-like atomic polling macro

This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
is atomic version of already available 'regmap_read_poll_timeout' macro.

It should be noted that above atomic macro cannot be used by all regmaps.
If the regmap is set up for atomic use (flat or no cache and MMIO) then
only it can use.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Link: https://lore.kernel.org/r/1578546590-24737-1-git-send-email-spujar@nvidia.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/linux/regmap.h | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index dfe493ac692d..f0a092a1a96d 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -144,6 +144,51 @@ struct reg_sequence {
 	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
 })
 
+/**
+ * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs
+ *
+ * @map: Regmap to read from
+ * @addr: Address to poll
+ * @val: Unsigned integer variable to read the value into
+ * @cond: Break condition (usually involving @val)
+ * @delay_us: Time to udelay between reads in us (0 tight-loops).
+ *            Should be less than ~10us since udelay is used
+ *            (see Documentation/timers/timers-howto.rst).
+ * @timeout_us: Timeout in us, 0 means never timeout
+ *
+ * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read
+ * error return value in case of a error read. In the two former cases,
+ * the last read value at @addr is stored in @val.
+ *
+ * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h.
+ *
+ * Note: In general regmap cannot be used in atomic context. If you want to use
+ * this macro then first setup your regmap for atomic use (flat or no cache
+ * and MMIO regmap).
+ */
+#define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \
+({ \
+	u64 __timeout_us = (timeout_us); \
+	unsigned long __delay_us = (delay_us); \
+	ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \
+	int __ret; \
+	for (;;) { \
+		__ret = regmap_read((map), (addr), &(val)); \
+		if (__ret) \
+			break; \
+		if (cond) \
+			break; \
+		if ((__timeout_us) && \
+		    ktime_compare(ktime_get(), __timeout) > 0) { \
+			__ret = regmap_read((map), (addr), &(val)); \
+			break; \
+		} \
+		if (__delay_us) \
+			udelay(__delay_us); \
+	} \
+	__ret ?: ((cond) ? 0 : -ETIMEDOUT); \
+})
+
 /**
  * regmap_field_read_poll_timeout - Poll until a condition is met or timeout
  *
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
  2020-01-09 13:57         ` Dmitry Osipenko
@ 2020-01-10  4:50           ` Sameer Pujar
  -1 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-10  4:50 UTC (permalink / raw)
  To: Dmitry Osipenko, broonie; +Cc: jonathanh, linux-kernel, linux-tegra


On 1/9/2020 7:27 PM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 09.01.2020 10:24, Sameer Pujar пишет:
>> On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> 09.01.2020 08:09, Sameer Pujar пишет:
>>>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>>>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>>>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>>>
>>>> It should be noted that above atomic macro cannot be used by all
>>>> regmaps.
>>>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>>>> only it can use.
>>>>
>>>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>>>> ---
>>> Could you please explain what is the targeted use-case here?
>> I was trying to use regmap_read_poll_timeout() to poll for status change
>> of a register. This resulted in "BUG: scheduling while atomic". The
>> callback function, in which I was trying to use the macro, runs in
>> atomic context. Hence new atomic macro is added. I was checking ALSA
>> playback/capture and trigger() callback had to monitor some register
>> status.
>>
>> In general, the new macro can be used in atomic callbacks where regmap
>> interface is used and polling is required.
>>
> You should send a full patchset because it may turn out that the patch
> which makes use of the new feature isn't correct or maybe the new
> feature isn't really needed.
>
> If there was a previous discussion about the need for this change, then
> you should provide a link to that discussion.
>
> Please note that usually changes without a real use-case in kernel are
> not getting picked up or they are getting removed later on if nobody
> makes use of them, so I assume this is a kind of an RFC patch for now.

OK. I will send this as part of the complete series. Thank you.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
@ 2020-01-10  4:50           ` Sameer Pujar
  0 siblings, 0 replies; 12+ messages in thread
From: Sameer Pujar @ 2020-01-10  4:50 UTC (permalink / raw)
  To: Dmitry Osipenko, broonie; +Cc: jonathanh, linux-kernel, linux-tegra


On 1/9/2020 7:27 PM, Dmitry Osipenko wrote:
> External email: Use caution opening links or attachments
>
>
> 09.01.2020 10:24, Sameer Pujar пишет:
>> On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
>>> External email: Use caution opening links or attachments
>>>
>>>
>>> 09.01.2020 08:09, Sameer Pujar пишет:
>>>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>>>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>>>> is atomic version of already available 'regmap_read_poll_timeout' macro.
>>>>
>>>> It should be noted that above atomic macro cannot be used by all
>>>> regmaps.
>>>> If the regmap is set up for atomic use (flat or no cache and MMIO) then
>>>> only it can use.
>>>>
>>>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>>>> ---
>>> Could you please explain what is the targeted use-case here?
>> I was trying to use regmap_read_poll_timeout() to poll for status change
>> of a register. This resulted in "BUG: scheduling while atomic". The
>> callback function, in which I was trying to use the macro, runs in
>> atomic context. Hence new atomic macro is added. I was checking ALSA
>> playback/capture and trigger() callback had to monitor some register
>> status.
>>
>> In general, the new macro can be used in atomic callbacks where regmap
>> interface is used and polling is required.
>>
> You should send a full patchset because it may turn out that the patch
> which makes use of the new feature isn't correct or maybe the new
> feature isn't really needed.
>
> If there was a previous discussion about the need for this change, then
> you should provide a link to that discussion.
>
> Please note that usually changes without a real use-case in kernel are
> not getting picked up or they are getting removed later on if nobody
> makes use of them, so I assume this is a kind of an RFC patch for now.

OK. I will send this as part of the complete series. Thank you.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] regmap: add iopoll-like atomic polling macro
  2020-01-10  4:50           ` Sameer Pujar
  (?)
@ 2020-01-10 22:07           ` Dmitry Osipenko
  -1 siblings, 0 replies; 12+ messages in thread
From: Dmitry Osipenko @ 2020-01-10 22:07 UTC (permalink / raw)
  To: Sameer Pujar, broonie; +Cc: jonathanh, linux-kernel, linux-tegra

10.01.2020 07:50, Sameer Pujar пишет:
> 
> On 1/9/2020 7:27 PM, Dmitry Osipenko wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> 09.01.2020 10:24, Sameer Pujar пишет:
>>> On 1/9/2020 11:30 AM, Dmitry Osipenko wrote:
>>>> External email: Use caution opening links or attachments
>>>>
>>>>
>>>> 09.01.2020 08:09, Sameer Pujar пишет:
>>>>> This patch adds a macro 'regmap_read_poll_timeout_atomic' that works
>>>>> similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This
>>>>> is atomic version of already available 'regmap_read_poll_timeout'
>>>>> macro.
>>>>>
>>>>> It should be noted that above atomic macro cannot be used by all
>>>>> regmaps.
>>>>> If the regmap is set up for atomic use (flat or no cache and MMIO)
>>>>> then
>>>>> only it can use.
>>>>>
>>>>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>>>>> ---
>>>> Could you please explain what is the targeted use-case here?
>>> I was trying to use regmap_read_poll_timeout() to poll for status change
>>> of a register. This resulted in "BUG: scheduling while atomic". The
>>> callback function, in which I was trying to use the macro, runs in
>>> atomic context. Hence new atomic macro is added. I was checking ALSA
>>> playback/capture and trigger() callback had to monitor some register
>>> status.
>>>
>>> In general, the new macro can be used in atomic callbacks where regmap
>>> interface is used and polling is required.
>>>
>> You should send a full patchset because it may turn out that the patch
>> which makes use of the new feature isn't correct or maybe the new
>> feature isn't really needed.
>>
>> If there was a previous discussion about the need for this change, then
>> you should provide a link to that discussion.
>>
>> Please note that usually changes without a real use-case in kernel are
>> not getting picked up or they are getting removed later on if nobody
>> makes use of them, so I assume this is a kind of an RFC patch for now.
> 
> OK. I will send this as part of the complete series. Thank you.
> 

Thanks! Please feel free to add me to the CC list, I'll take a look at
the patches.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-01-10 22:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  5:09 [PATCH v3] regmap: add iopoll-like atomic polling macro Sameer Pujar
2020-01-09  5:09 ` Sameer Pujar
2020-01-09  6:00 ` Dmitry Osipenko
2020-01-09  7:24   ` Sameer Pujar
2020-01-09  7:24     ` Sameer Pujar
     [not found]     ` <b9f5459f-007e-3139-a3cf-c7dfd3fc335a-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-01-09 13:57       ` Dmitry Osipenko
2020-01-09 13:57         ` Dmitry Osipenko
2020-01-10  4:50         ` Sameer Pujar
2020-01-10  4:50           ` Sameer Pujar
2020-01-10 22:07           ` Dmitry Osipenko
     [not found] ` <1578546590-24737-1-git-send-email-spujar-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2020-01-09 21:30   ` Applied "regmap: add iopoll-like atomic polling macro" to the regmap tree Mark Brown
2020-01-09 21:30     ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.