Skip to contentSkip to conversation

i2c: tegra: Wait for config load atomically while in ISR

PATCH Applied Mikko Perttunen 3 participants 4 messages Jan 11, 2021 – Jan 12, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: tegra: Wait for config load atomically while in ISR

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")

---
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(-)
drivers/i2c/busses/i2c-tegra.c +1 -1
index 6f08c0c3238d..0727383f4940 100644
@@ -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);
 
Signature · 1 line
2.30.0
reviewer Reviewed-by on v2 1/1
#1 lore raw

11.01.2021 19:08, Mikko Perttunen пишет:

Quoted 26 lines

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")

---
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(-)
drivers/i2c/busses/i2c-tegra.c +0 -0
index 6f08c0c3238d..0727383f4940 100644

drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev, · line 539

Quoted 8 lines
drivers/i2c/busses/i2c-tegra.c +1 -1
@@ -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 lore raw

11.01.2021 22:31, Dmitry Osipenko пишет:

Quoted 29 lines

11.01.2021 19:08, Mikko Perttunen пишет:

Quoted 28 lines

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")

---
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(-)
drivers/i2c/busses/i2c-tegra.c +0 -0
index 6f08c0c3238d..0727383f4940 100644
@@ -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;
 
Quoted 9 lines

drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_poll_register(struct tegra_i2c_dev *i2c_dev, · line 539

Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +1 -1
-	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);
 

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

Applied
#3 lore raw
In reply to Mikko Perttunen
Quoted 11 lines · 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")

Applied to for-current, thanks!