]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
i2c: tegra: use dmaengine_get_dma_device() for DMA buffer allocation
authorAkhil R <akhilrajeev@nvidia.com>
Mon, 18 May 2026 11:40:10 +0000 (17:10 +0530)
committerAndi Shyti <andi.shyti@kernel.org>
Mon, 8 Jun 2026 19:23:22 +0000 (21:23 +0200)
Use dmaengine_get_dma_device() to obtain the correct struct device
pointer for dma_alloc_coherent() instead of directly dereferencing
chan->device->dev.

The dmaengine_get_dma_device() helper checks whether the DMA channel
has a per-channel DMA device (chan->dev->chan_dma_dev) and returns it
when available, falling back to the controller device otherwise. On
platforms where the DMA controller sits behind an IOMMU with
per-channel IOVA spaces (e.g. Tegra264 GPC DMA), the per-channel
device carries the correct DMA mapping context. Using the controller
device directly would allocate DMA buffers against the wrong IOMMU
domain, leading to SMMU faults at runtime.

On platforms without per-channel DMA devices the helper returns the
same pointer as before, so there is no change in behavior for existing
hardware.

Assisted-by: Cursor:claude-4.6-opus
Signed-off-by: Akhil R <akhilrajeev@nvidia.com>
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260518114013.62065-2-akhilrajeev@nvidia.com
drivers/i2c/busses/i2c-tegra.c

index 3e9327e3750a51e3d48a770c154e7ec0b634ad06..a6859059a2e886f136b86ecb55986c1fb477ae8e 100644 (file)
@@ -712,7 +712,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
                goto err_out;
        }
 
-       i2c_dev->dma_dev = i2c_dev->dma_chan->device->dev;
+       i2c_dev->dma_dev = dmaengine_get_dma_device(i2c_dev->dma_chan);
        i2c_dev->dma_buf_size = i2c_dev->hw->quirks->max_write_len +
                                I2C_PACKET_HEADER_SIZE;