Re: [PATCH v3 1/3] dmaengine: qcom: gpi: Add I2C bus recovery opcode support

From: Aniket RANDIVE

Date: Tue Nov 03 2026 - 02:26:13 EST




On 10/27/2026 7:04 PM, Mukesh Savaliya wrote:


On 10/27/2026 10:43 AM, Aniket Randive wrote:
[...]
diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
index c41bfac65ddf..394e7287f6e9 100644
--- a/drivers/dma/qcom/gpi.c
+++ b/drivers/dma/qcom/gpi.c

[...]

@@ -1692,6 +1709,7 @@ static int gpi_create_i2c_tre(struct gchan *chan, struct gpi_desc *desc,
              tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_BEI);
      }
+log_tre:
      for (i = 0; i < tre_idx; i++)
          dev_dbg(dev, "TRE:%d %x:%x:%x:%x\n", i, desc->tre[i].dword[0],
              desc->tre[i].dword[1], desc->tre[i].dword[2], desc- >tre[i].dword[3]);
@@ -1825,6 +1843,18 @@ gpi_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
          nr_tre = 2;
      if (direction == DMA_DEV_TO_MEM) /* rx */
          nr_tre = 1;
+    /*
+     * Recovery opcodes do not require DMA data TREs, only CONFIG
+     * (for set_config) and GO TREs. Since gpi_prep_slave_sg() is
+     * shared with SPI, verify the channel is I2C before accessing
+     * the configuration data.
I think i have mentioned earlier also. gpi_prep_slave_sg() Not only shared with spi but rather say, is a common function for all protocols.> +     */

Currently, the GPI driver has only I2C and SPI clients, so I mentioned SPI specifically. However, UART may also use GSI mode in the future. I’ll update the comment to state that gpi_prep_slave_sg() is common to all protocols.

+    if (gchan->protocol == QCOM_GPI_I2C) {
+        struct gpi_i2c_config *i2c = gchan->config;
+
+        if (i2c->op == I2C_BUS_CLEAR || i2c->op == I2C_STOP_ON_BUS)
+            nr_tre = set_config ? 2 : 1;
+    }
      /* calculate # of elements required & available */
      nr = gpi_ring_num_elements_avail(ch_ring);
diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/ i2c-qcom-geni.c
[...]