All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR
@ 2021-01-11 16:08 Mikko Perttunen
  2021-01-11 19:31 ` Dmitry Osipenko
  2021-01-11 21:40 ` Wolfram Sang
  0 siblings, 2 replies; 4+ messages in thread
From: Mikko Perttunen @ 2021-01-11 16:08 UTC (permalink / raw)
  To: ldewangan, digetx, thierry.reding, jonathanh, wsa
  Cc: linux-i2c, linux-tegra, linux-kernel, Mikko Perttunen, stable

Upon a communication error, the interrupt handler can call
tegra_i2c_disable_packet_mode. This causes a sleeping poll to happen
unless the current transaction was marked atomic. Fix this by
making the poll happen atomically if we are in an IRQ.

This matches the behavior prior to the patch mentioned
in the Fixes tag.

Fixes: ede2299f7101 ("i2c: tegra: Support atomic transfers")
Cc: stable@vger.kernel.org
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
v2:
* Use in_irq() instead of passing a flag from the ISR.
  Thanks to Dmitry for the suggestion.
* Update commit message.
---
 drivers/i2c/busses/i2c-tegra.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 6f08c0c3238d..0727383f4940 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -533,7 +533,7 @@ static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev,
 	void __iomem *addr = i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg);
 	u32 val;
 
-	if (!i2c_dev->atomic_mode)
+	if (!i2c_dev->atomic_mode && !in_irq())
 		return readl_relaxed_poll_timeout(addr, val, !(val & mask),
 						  delay_us, timeout_us);
 
-- 
2.30.0


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

* Re: [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR
  2021-01-11 16:08 [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR Mikko Perttunen
@ 2021-01-11 19:31 ` Dmitry Osipenko
  2021-01-12  6:48   ` Dmitry Osipenko
  2021-01-11 21:40 ` Wolfram Sang
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Osipenko @ 2021-01-11 19:31 UTC (permalink / raw)
  To: Mikko Perttunen, ldewangan, thierry.reding, jonathanh, wsa
  Cc: linux-i2c, linux-tegra, linux-kernel, stable

11.01.2021 19:08, Mikko Perttunen пишет:
> Upon a communication error, the interrupt handler can call
> tegra_i2c_disable_packet_mode. This causes a sleeping poll to happen
> unless the current transaction was marked atomic. Fix this by
> making the poll happen atomically if we are in an IRQ.
> 
> This matches the behavior prior to the patch mentioned
> in the Fixes tag.
> 
> Fixes: ede2299f7101 ("i2c: tegra: Support atomic transfers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> v2:
> * Use in_irq() instead of passing a flag from the ISR.
>   Thanks to Dmitry for the suggestion.
> * Update commit message.
> ---
>  drivers/i2c/busses/i2c-tegra.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 6f08c0c3238d..0727383f4940 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -533,7 +533,7 @@ static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev,
>  	void __iomem *addr = i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg);
>  	u32 val;
>  
> -	if (!i2c_dev->atomic_mode)
> +	if (!i2c_dev->atomic_mode && !in_irq())
>  		return readl_relaxed_poll_timeout(addr, val, !(val & mask),
>  						  delay_us, timeout_us);
>  
> 

Reviewed-by: Dmitry Osipenko <digetx@gmail.com>

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

* Re: [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR
  2021-01-11 16:08 [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR Mikko Perttunen
  2021-01-11 19:31 ` Dmitry Osipenko
@ 2021-01-11 21:40 ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-01-11 21:40 UTC (permalink / raw)
  To: Mikko Perttunen
  Cc: ldewangan, digetx, thierry.reding, jonathanh, linux-i2c,
	linux-tegra, linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Mon, Jan 11, 2021 at 06:08:32PM +0200, Mikko Perttunen wrote:
> Upon a communication error, the interrupt handler can call
> tegra_i2c_disable_packet_mode. This causes a sleeping poll to happen
> unless the current transaction was marked atomic. Fix this by
> making the poll happen atomically if we are in an IRQ.
> 
> This matches the behavior prior to the patch mentioned
> in the Fixes tag.
> 
> Fixes: ede2299f7101 ("i2c: tegra: Support atomic transfers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR
  2021-01-11 19:31 ` Dmitry Osipenko
@ 2021-01-12  6:48   ` Dmitry Osipenko
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Osipenko @ 2021-01-12  6:48 UTC (permalink / raw)
  To: Mikko Perttunen, ldewangan, thierry.reding, jonathanh, wsa
  Cc: linux-i2c, linux-tegra, linux-kernel, stable

11.01.2021 22:31, Dmitry Osipenko пишет:
> 11.01.2021 19:08, Mikko Perttunen пишет:
>> Upon a communication error, the interrupt handler can call
>> tegra_i2c_disable_packet_mode. This causes a sleeping poll to happen
>> unless the current transaction was marked atomic. Fix this by
>> making the poll happen atomically if we are in an IRQ.
>>
>> This matches the behavior prior to the patch mentioned
>> in the Fixes tag.
>>
>> Fixes: ede2299f7101 ("i2c: tegra: Support atomic transfers")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
>> ---
>> v2:
>> * Use in_irq() instead of passing a flag from the ISR.
>>   Thanks to Dmitry for the suggestion.
>> * Update commit message.
>> ---
>>  drivers/i2c/busses/i2c-tegra.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index 6f08c0c3238d..0727383f4940 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -533,7 +533,7 @@ static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev,
>>  	void __iomem *addr = i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg);
>>  	u32 val;
>>  
>> -	if (!i2c_dev->atomic_mode)
>> +	if (!i2c_dev->atomic_mode && !in_irq())
>>  		return readl_relaxed_poll_timeout(addr, val, !(val & mask),
>>  						  delay_us, timeout_us);
>>  
>>
> 
> Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
> 

Perhaps a follow up change could be to use a threaded interrupt context,
I'll type a patch for that.

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

end of thread, other threads:[~2021-01-12  6:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 16:08 [PATCH v2] i2c: tegra: Wait for config load atomically while in ISR Mikko Perttunen
2021-01-11 19:31 ` Dmitry Osipenko
2021-01-12  6:48   ` Dmitry Osipenko
2021-01-11 21:40 ` Wolfram Sang

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.