linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Use master-abort for slave probes
@ 2020-05-06  9:36 Russell King - ARM Linux admin
  2020-05-06  9:36 ` [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message() Russell King
  2020-05-06  9:36 ` [PATCH 2/2] i2c: pxa: use master-abort for device probes Russell King
  0 siblings, 2 replies; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2020-05-06  9:36 UTC (permalink / raw)
  To: linux-i2c

Hi,

This series allows us to use the "master abort" feature when probing
slaves rather than resetting the controller, which allows more
graceful recovery to bus free state after sending the address byte.

The i2c-pxa controller expects to send data after the address byte
rather than a stop.  Rather than resetting the bus (and thus forcing
a bus-free state by releasing the SCL line) which may leave the bus
in an indeterminant state, use the master-abort command instead.

This patch series applies on top of the previous posted cleanup patches,
although it may also apply to -rc.

 drivers/i2c/busses/i2c-pxa.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

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

* [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message()
  2020-05-06  9:36 [PATCH 0/2] Use master-abort for slave probes Russell King - ARM Linux admin
@ 2020-05-06  9:36 ` Russell King
  2020-05-12 10:38   ` Wolfram Sang
  2020-05-06  9:36 ` [PATCH 2/2] i2c: pxa: use master-abort for device probes Russell King
  1 sibling, 1 reply; 5+ messages in thread
From: Russell King @ 2020-05-06  9:36 UTC (permalink / raw)
  To: linux-i2c

If we timeout during a message transfer, the control register may
contain bits that cause an action to be set. Read-modify-writing the
register leaving these bits set may trigger the hardware to attempt
one of these actions unintentionally.

Always clear these bits when cleaning up after a message or after
a timeout.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/i2c/busses/i2c-pxa.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index db739cce93ac..a72d07bdb793 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -795,11 +795,9 @@ static inline void i2c_pxa_stop_message(struct pxa_i2c *i2c)
 {
 	u32 icr;
 
-	/*
-	 * Clear the STOP and ACK flags
-	 */
+	/* Clear the START, STOP, ACK, TB and MA flags */
 	icr = readl(_ICR(i2c));
-	icr &= ~(ICR_STOP | ICR_ACKNAK);
+	icr &= ~(ICR_START | ICR_STOP | ICR_ACKNAK | ICR_TB | ICR_MA);
 	writel(icr, _ICR(i2c));
 }
 
-- 
2.20.1


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

* [PATCH 2/2] i2c: pxa: use master-abort for device probes
  2020-05-06  9:36 [PATCH 0/2] Use master-abort for slave probes Russell King - ARM Linux admin
  2020-05-06  9:36 ` [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message() Russell King
@ 2020-05-06  9:36 ` Russell King
  2020-05-12 10:39   ` Wolfram Sang
  1 sibling, 1 reply; 5+ messages in thread
From: Russell King @ 2020-05-06  9:36 UTC (permalink / raw)
  To: linux-i2c

Use master-abort to send the stop condition after an address cycle
rather than resetting the controller.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/i2c/busses/i2c-pxa.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index a72d07bdb793..0e194d6cd1b5 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -940,14 +940,8 @@ static void i2c_pxa_irq_txempty(struct pxa_i2c *i2c, u32 isr)
 		icr &= ~ICR_ALDIE;
 		icr |= ICR_START | ICR_TB;
 	} else {
-		if (i2c->msg->len == 0) {
-			/*
-			 * Device probes have a message length of zero
-			 * and need the bus to be reset before it can
-			 * be used again.
-			 */
-			i2c_pxa_reset(i2c);
-		}
+		if (i2c->msg->len == 0)
+			icr |= ICR_MA;
 		i2c_pxa_master_complete(i2c, 0);
 	}
 
-- 
2.20.1


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

* Re: [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message()
  2020-05-06  9:36 ` [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message() Russell King
@ 2020-05-12 10:38   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2020-05-12 10:38 UTC (permalink / raw)
  To: Russell King; +Cc: linux-i2c

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

On Wed, May 06, 2020 at 10:36:38AM +0100, Russell King wrote:
> If we timeout during a message transfer, the control register may
> contain bits that cause an action to be set. Read-modify-writing the
> register leaving these bits set may trigger the hardware to attempt
> one of these actions unintentionally.
> 
> Always clear these bits when cleaning up after a message or after
> a timeout.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied to for-next, thanks! I was considering for-current, though, but
there have been no real bug reports, so for-next it is.


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

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

* Re: [PATCH 2/2] i2c: pxa: use master-abort for device probes
  2020-05-06  9:36 ` [PATCH 2/2] i2c: pxa: use master-abort for device probes Russell King
@ 2020-05-12 10:39   ` Wolfram Sang
  0 siblings, 0 replies; 5+ messages in thread
From: Wolfram Sang @ 2020-05-12 10:39 UTC (permalink / raw)
  To: Russell King; +Cc: linux-i2c

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

On Wed, May 06, 2020 at 10:36:43AM +0100, Russell King wrote:
> Use master-abort to send the stop condition after an address cycle
> rather than resetting the controller.
> 
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

Applied to for-next, thanks!


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

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

end of thread, other threads:[~2020-05-12 10:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06  9:36 [PATCH 0/2] Use master-abort for slave probes Russell King - ARM Linux admin
2020-05-06  9:36 ` [PATCH 1/2] i2c: pxa: clear all master action bits in i2c_pxa_stop_message() Russell King
2020-05-12 10:38   ` Wolfram Sang
2020-05-06  9:36 ` [PATCH 2/2] i2c: pxa: use master-abort for device probes Russell King
2020-05-12 10:39   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).