Re: [PATCH v2 01/12] dmaengine: dw-edma: Add hardware channel filter
From: Koichiro Den
Date: Thu Jun 04 2026 - 22:30:10 EST
On Thu, Jun 04, 2026 at 04:40:06PM -0400, Frank Li wrote:
> 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
Thanks for the review.
It is used by the DesignWare EP resource provider added in part 2:
https://lore.kernel.org/linux-pci/20260525063129.3316894-4-den@xxxxxxxxxxxxx/
Since that provider lives outside drivers/dma/dw-edma, the filter definition
needs to be visible outside the dw-edma core.
As a side note, this was added in v2, after Sashiko's feedback [1]. The v2 model
is:
- The PCI aux resource provider describes static HW channel resources, rather
than potentially unstable dma_chan pointers.
- When the EPF delegates some of the channels to the peer host, it requests
the channel by matching the HW channel id.
If the lifetime/removal model changes based on your feedback on [PATCH v2
03/12], we could possibly go back to the v1 model [2], where the PCI aux
resource provider describes channel resources with dma_chan pointers. In that
case, we would need to document that those dma_chan pointers must remain valid
for the lifetime of the aux resource consumer, and this dw_edma_hw_chan_filter
helper would no longer be needed; dw_edma_find_channel() could be revived [3].
[1] https://lore.kernel.org/dmaengine/20260521065525.C65DB1F000E9@xxxxxxxxxxxxxxx/
[2] https://lore.kernel.org/linux-pci/20260521063405.2842644-3-den@xxxxxxxxxxxxx/
[3] https://lore.kernel.org/dmaengine/20260521063115.2842238-3-den@xxxxxxxxxxxxx/
Best regards,
Koichiro
>
> 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
> >