mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c: octeon/thunderx: Fix DMA mask + improvements
@ 2026-11-04 10:49 Paul Cercueil
  2026-11-04 10:49 ` [PATCH 1/3] i2c: octeon: Add error state recovery Paul Cercueil
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paul Cercueil @ 2026-11-04 10:49 UTC (permalink / raw)
  To: Robert Richter, Andi Shyti
  Cc: linux-i2c, linux-kernel, Thomas Petazzoni, Sunil Kovvuri Goutham,
	Umesh Kumar, Shashank Gupta, Tanmay Jagdale, Paul Cercueil

Hi Robert, Andi,

This patchset adds a fix to the ThunderX driver where the DMA mask was
not set, sometimes preventing MSI-X from being initialized properly.

The first patch improves error handling on the bus, and the third patch
improves the latency in HS mode.

Cheers,
-Paul

Tanmay Jagdale (3):
  i2c: octeon: Add error state recovery
  i2c: thunderx: Set DMA mask
  i2c: thunderx: Use polling with delay in HS mode

 drivers/i2c/busses/i2c-octeon-core.c     | 31 ++++++++++++++----------
 drivers/i2c/busses/i2c-thunderx-pcidrv.c |  4 +++
 2 files changed, 22 insertions(+), 13 deletions(-)

-- 
2.47.3


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

* [PATCH 1/3] i2c: octeon: Add error state recovery
  2026-11-04 10:49 [PATCH 0/3] i2c: octeon/thunderx: Fix DMA mask + improvements Paul Cercueil
@ 2026-11-04 10:49 ` Paul Cercueil
  2026-11-04 10:49 ` [PATCH 2/3] i2c: thunderx: Set DMA mask Paul Cercueil
  2026-11-04 10:49 ` [PATCH 3/3] i2c: thunderx: Use polling with delay in HS mode Paul Cercueil
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2026-11-04 10:49 UTC (permalink / raw)
  To: Robert Richter, Andi Shyti
  Cc: linux-i2c, linux-kernel, Thomas Petazzoni, Sunil Kovvuri Goutham,
	Umesh Kumar, Shashank Gupta, Tanmay Jagdale, Paul Cercueil

From: Tanmay Jagdale <tanmay@marvell.com>

Whenever a Bus Error state occurs, trigger a software recovery to
attempt to return to a working state.

Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
 drivers/i2c/busses/i2c-octeon-core.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index 93a49e4637ec..9f72ec1feaa0 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -205,6 +205,17 @@ static int octeon_i2c_hlc_wait(struct octeon_i2c *i2c)
 	return 0;
 }
 
+static int octeon_i2c_recovery(struct octeon_i2c *i2c)
+{
+	int ret;
+
+	ret = i2c_recover_bus(&i2c->adap);
+	if (ret)
+		/* recover failed, try hardware re-init */
+		ret = octeon_i2c_init_lowlevel(i2c);
+	return ret;
+}
+
 static int octeon_i2c_check_status(struct octeon_i2c *i2c, int final_read)
 {
 	u8 stat;
@@ -265,8 +276,9 @@ static int octeon_i2c_check_status(struct octeon_i2c *i2c, int final_read)
 		return -EOPNOTSUPP;
 
 	case STAT_TXDATA_NAK:
-	case STAT_BUS_ERROR:
 		return -EIO;
+	case STAT_BUS_ERROR:
+		return octeon_i2c_recovery(i2c) ? -EIO : -EAGAIN;
 	case STAT_TXADDR_NAK:
 	case STAT_RXADDR_NAK:
 	case STAT_AD2W_NAK:
@@ -277,24 +289,13 @@ static int octeon_i2c_check_status(struct octeon_i2c *i2c, int final_read)
 		/* Set BUS_MON_RST to reset bus monitor */
 		mode |= BUS_MON_RST_MASK;
 		octeon_i2c_writeq_flush(mode, i2c->twsi_base + OCTEON_REG_MODE(i2c));
-		return -EIO;
+		return octeon_i2c_recovery(i2c) ? -EIO : -EAGAIN;
 	default:
 		dev_err(i2c->dev, "unhandled state: %d\n", stat);
 		return -EIO;
 	}
 }
 
-static int octeon_i2c_recovery(struct octeon_i2c *i2c)
-{
-	int ret;
-
-	ret = i2c_recover_bus(&i2c->adap);
-	if (ret)
-		/* recover failed, try hardware re-init */
-		ret = octeon_i2c_init_lowlevel(i2c);
-	return ret;
-}
-
 /**
  * octeon_i2c_start - send START to the bus
  * @i2c: The struct octeon_i2c
-- 
2.47.3


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

* [PATCH 2/3] i2c: thunderx: Set DMA mask
  2026-11-04 10:49 [PATCH 0/3] i2c: octeon/thunderx: Fix DMA mask + improvements Paul Cercueil
  2026-11-04 10:49 ` [PATCH 1/3] i2c: octeon: Add error state recovery Paul Cercueil
@ 2026-11-04 10:49 ` Paul Cercueil
  2026-11-04 10:49 ` [PATCH 3/3] i2c: thunderx: Use polling with delay in HS mode Paul Cercueil
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2026-11-04 10:49 UTC (permalink / raw)
  To: Robert Richter, Andi Shyti
  Cc: linux-i2c, linux-kernel, Thomas Petazzoni, Sunil Kovvuri Goutham,
	Umesh Kumar, Shashank Gupta, Tanmay Jagdale, stable,
	Paul Cercueil

From: Tanmay Jagdale <tanmay@marvell.com>

Without it, MSI-X initialization can fail.

Fixes: 4c21541d8da1 ("i2c: thunderx: Replace pci_enable_msix()")
Cc: stable@vger.kernel.org
Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
 drivers/i2c/busses/i2c-thunderx-pcidrv.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
index 3959f23fc440..2208337e649b 100644
--- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c
+++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
@@ -198,6 +198,10 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
 	i2c->hlc_int_enable = thunder_i2c_hlc_int_enable;
 	i2c->hlc_int_disable = thunder_i2c_hlc_int_disable;
 
+	ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(48));
+	if (ret < 0)
+		goto error;
+
 	ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
 	if (ret < 0)
 		goto error;
-- 
2.47.3


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

* [PATCH 3/3] i2c: thunderx: Use polling with delay in HS mode
  2026-11-04 10:49 [PATCH 0/3] i2c: octeon/thunderx: Fix DMA mask + improvements Paul Cercueil
  2026-11-04 10:49 ` [PATCH 1/3] i2c: octeon: Add error state recovery Paul Cercueil
  2026-11-04 10:49 ` [PATCH 2/3] i2c: thunderx: Set DMA mask Paul Cercueil
@ 2026-11-04 10:49 ` Paul Cercueil
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Cercueil @ 2026-11-04 10:49 UTC (permalink / raw)
  To: Robert Richter, Andi Shyti
  Cc: linux-i2c, linux-kernel, Thomas Petazzoni, Sunil Kovvuri Goutham,
	Umesh Kumar, Shashank Gupta, Tanmay Jagdale, Paul Cercueil

From: Tanmay Jagdale <tanmay@marvell.com>

High I2C transaction latencies exceeding 1 second were intermittently
observed while operating in HS mode. These delays caused DTLS handshakes
between the main processor and firmware processors to time out,
resulting in increased startup time.

Replace the existing wait mechanism with delayed polling in HS mode to
improve transfer responsiveness and avoid prolonged latency spikes.

Signed-off-by: Tanmay Jagdale <tanmay@marvell.com>
Co-developed-by: Paul Cercueil <paul.cercueil@bootlin.com>
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---
 drivers/i2c/busses/i2c-octeon-core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/i2c/busses/i2c-octeon-core.c b/drivers/i2c/busses/i2c-octeon-core.c
index 9f72ec1feaa0..4c05d2d00cbe 100644
--- a/drivers/i2c/busses/i2c-octeon-core.c
+++ b/drivers/i2c/busses/i2c-octeon-core.c
@@ -15,6 +15,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/iopoll.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -65,6 +66,9 @@ static int octeon_i2c_wait(struct octeon_i2c *i2c)
 		return octeon_i2c_test_iflg(i2c) ? 0 : -ETIMEDOUT;
 	}
 
+	if (!IS_LS_FREQ(i2c->twsi_freq))
+		return poll_timeout_us_atomic(, octeon_i2c_test_iflg(i2c), 1, 1000, false);
+
 	i2c->int_enable(i2c);
 	time_left = wait_event_timeout(i2c->queue, octeon_i2c_test_iflg(i2c),
 				       i2c->adap.timeout);
-- 
2.47.3


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

end of thread, other threads:[~2026-11-04 10:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 10:49 [PATCH 0/3] i2c: octeon/thunderx: Fix DMA mask + improvements Paul Cercueil
2026-11-04 10:49 ` [PATCH 1/3] i2c: octeon: Add error state recovery Paul Cercueil
2026-11-04 10:49 ` [PATCH 2/3] i2c: thunderx: Set DMA mask Paul Cercueil
2026-11-04 10:49 ` [PATCH 3/3] i2c: thunderx: Use polling with delay in HS mode Paul Cercueil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®