Re: [PATCH v2 01/12] dmaengine: dw-edma: Add hardware channel filter

From: Frank Li

Date: Thu Jun 04 2026 - 16:40:23 EST


On Mon, May 25, 2026 at 03:24:09PM +0900, Koichiro Den wrote:
> Add a dma_request_channel() filter that matches a DesignWare eDMA
> write/read hardware channel by hardware channel number.
>
> PCI endpoint resource enumeration can describe hardware channel metadata
> and let consumers claim it through the normal DMAengine request path.
> This avoids returning an unclaimed dma_chan pointer to the caller and does
> not require making dma_get_slave_channel() public.
>
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---
> Changes in v2:
> - New patch. Replace the raw channel lookup helper with a
> dma_request_channel() filter.
> - Do not make dma_get_slave_channel() public.
> Patch 01/12 "dmaengine: Make dma_get_slave_channel() public" is
> dropped.
>
> drivers/dma/dw-edma/dw-edma-core.c | 15 +++++++++++++++
> include/linux/dma/edma.h | 18 ++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index c2feb3adc79f..80b4a168225b 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -1189,6 +1189,21 @@ int dw_edma_remove(struct dw_edma_chip *chip)
> }
> EXPORT_SYMBOL_GPL(dw_edma_remove);
>
> +bool dw_edma_filter_hw_chan(struct dma_chan *dchan, void *param)
> +{
> + struct dw_edma_hw_chan_filter *filter = param;
> + struct dw_edma_chan *chan;
> +
> + if (!filter || dchan->device->dev != filter->dma_dev)
> + return false;
> +
> + chan = dchan2dw_edma_chan(dchan);
> +
> + return chan->dir == (filter->write ? EDMA_DIR_WRITE : EDMA_DIR_READ) &&
> + chan->id == filter->id;
> +}
> +EXPORT_SYMBOL_GPL(dw_edma_filter_hw_chan);
> +
> MODULE_LICENSE("GPL v2");
> MODULE_DESCRIPTION("Synopsys DesignWare eDMA controller core driver");
> MODULE_AUTHOR("Gustavo Pimentel <gustavo.pimentel@xxxxxxxxxxxx>");
> diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
> index 1fafd5b0e315..3e15cf83b784 100644
> --- a/include/linux/dma/edma.h
> +++ b/include/linux/dma/edma.h
> @@ -106,10 +106,23 @@ struct dw_edma_chip {
> bool cfg_non_ll;
> };
>
> +/**
> + * struct dw_edma_hw_chan_filter - DesignWare eDMA hardware channel selector
> + * @dma_dev: DMA controller device to match
> + * @write: true to select a write channel, false to select a read channel
> + * @id: hardware channel number within the selected direction
> + */
> +struct dw_edma_hw_chan_filter {
> + struct device *dma_dev;
> + bool write;
> + u16 id;
> +};
> +

I have not seen user for this, not sure why it need be in this public header

Frank

> /* Export to the platform drivers */
> #if IS_REACHABLE(CONFIG_DW_EDMA)
> int dw_edma_probe(struct dw_edma_chip *chip);
> int dw_edma_remove(struct dw_edma_chip *chip);
> +bool dw_edma_filter_hw_chan(struct dma_chan *chan, void *param);
> #else
> static inline int dw_edma_probe(struct dw_edma_chip *chip)
> {
> @@ -120,6 +133,11 @@ static inline int dw_edma_remove(struct dw_edma_chip *chip)
> {
> return 0;
> }
> +
> +static inline bool dw_edma_filter_hw_chan(struct dma_chan *chan, void *param)
> +{
> + return false;
> +}
> #endif /* CONFIG_DW_EDMA */
>
> #endif /* _DW_EDMA_H */
> --
> 2.51.0
>