From 61527d7e6998e87b3acd04f1cd2f4d6814385051 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Fri, 2 Oct 2026 16:23:40 -0400 Subject: [PATCH] dmaengine: add dmaengine_get_provider_device() API Add dmaengine_get_provider_device() API and kernel doc for dmaengine_get_dma_device() to describe the difference. dmaengine_get_dma_device() is used for DMA mapping because some DMA engines provide per-channel iommu mapping. dmaengine_get_provider_device() is used to find a DMA engine channel by a filter function. In most cases they return the same value, but they have different semantic meanings. Signed-off-by: Frank Li Link: https://patch.msgid.link/20261002202341.253152-1-Frank.Li@oss.nxp.com Signed-off-by: Vinod Koul --- include/linux/dma/imx-dma.h | 6 ++++-- include/linux/dmaengine.h | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/linux/dma/imx-dma.h b/include/linux/dma/imx-dma.h index 16e491f63883..7c678316b757 100644 --- a/include/linux/dma/imx-dma.h +++ b/include/linux/dma/imx-dma.h @@ -59,8 +59,10 @@ struct imx_dma_data { static inline int imx_dma_is_general_purpose(struct dma_chan *chan) { - return !strcmp(chan->device->dev->driver->name, "imx-sdma") || - !strcmp(chan->device->dev->driver->name, "imx-dma"); + struct device *dev = dmaengine_get_provider_device(chan); + + return !strcmp(dev->driver->name, "imx-sdma") || + !strcmp(dev->driver->name, "imx-dma"); } /** diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 713f3ad68330..1ee63fdb90a7 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -2122,12 +2122,31 @@ static inline struct device *dmaengine_chan_dev(struct dma_chan *chan) return &chan->chan_dev->device; } +/* + * dmaengine_get_provider_device() - Get DMA engine provider device. Typical + * use is to find a DMA channel by filter. + * @chan: DMA channel + * + * Return: Pointer to the DMA engine provider device. + */ +static inline struct device *dmaengine_get_provider_device(struct dma_chan *chan) +{ + return chan->device->dev; +} + +/* + * dmaengine_get_dma_device() - Get DMA device used for DMA mapping. Some + * DMA engines provide per-channel iommu mapping. + * @chan: DMA channel + * + * Return: Pointer to the device used for DMA mapping. + */ static inline struct device *dmaengine_get_dma_device(struct dma_chan *chan) { if (chan->chan_dev->chan_dma_dev) return dmaengine_chan_dev(chan); - return chan->device->dev; + return dmaengine_get_provider_device(chan); } #endif /* DMAENGINE_H */