i2c: octeon/thunderx: Fix DMA mask + improvements
Subsystems (3)
cover i2c: octeon/thunderx: Fix DMA mask + improvements
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(-)
Signature · 1 line
2.47.3
PATCH 1/3 i2c: octeon: Add error state recovery
From: Tanmay Jagdale <[email protected]>
Whenever a Bus Error state occurs, trigger a software recovery to attempt to return to a working state.
--- drivers/i2c/busses/i2c-octeon-core.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/i2c/busses/i2c-octeon-core.c +14 -13
@@ -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
Signature · 1 line
2.47.3
PATCH 2/3 i2c: thunderx: Set DMA mask
In reply to Paul CercueilFrom: Tanmay Jagdale <[email protected]>
Without it, MSI-X initialization can fail.
--- drivers/i2c/busses/i2c-thunderx-pcidrv.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/i2c/busses/i2c-thunderx-pcidrv.c +4 -0
@@ -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;
Signature · 1 line
2.47.3
PATCH 3/3 i2c: thunderx: Use polling with delay in HS mode
In reply to Paul CercueilFrom: Tanmay Jagdale <[email protected]>
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.
--- drivers/i2c/busses/i2c-octeon-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/i2c/busses/i2c-octeon-core.c +4 -0
@@ -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);
Signature · 1 line
2.47.3