A remote eDMA provider may need to expose the linked-list (LL) memory
region that was configured by platform glue (typically at boot), so the
peer (host) can map it and operate the remote view of the controller.

Export dw_edma_chan_get_ll_region() to return the LL region associated
with a given dma_chan.

Signed-off-by: Koichiro Den <[email protected]>
---
 drivers/dma/dw-edma/dw-edma-core.c | 26 ++++++++++++++++++++++++++
 include/linux/dma/edma.h           | 14 ++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/drivers/dma/dw-edma/dw-edma-core.c 
b/drivers/dma/dw-edma/dw-edma-core.c
index 0eb8fc1dcc34..c4fb66a9b5f5 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -1209,6 +1209,32 @@ int dw_edma_chan_register_notify(struct dma_chan *dchan,
 }
 EXPORT_SYMBOL_GPL(dw_edma_chan_register_notify);
 
+int dw_edma_chan_get_ll_region(struct dma_chan *dchan,
+                              struct dw_edma_region *region)
+{
+       struct dw_edma_chip *chip;
+       struct dw_edma_chan *chan;
+
+       if (!dchan || !region || !dchan->device)
+               return -ENODEV;
+
+       chan = dchan2dw_edma_chan(dchan);
+       if (!chan)
+               return -ENODEV;
+
+       chip = chan->dw->chip;
+       if (!(chip->flags & DW_EDMA_CHIP_LOCAL))
+               return -EINVAL;
+
+       if (chan->dir == EDMA_DIR_WRITE)
+               *region = chip->ll_region_wr[chan->id];
+       else
+               *region = chip->ll_region_rd[chan->id];
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(dw_edma_chan_get_ll_region);
+
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("Synopsys DesignWare eDMA controller core driver");
 MODULE_AUTHOR("Gustavo Pimentel <[email protected]>");
diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
index 3c538246de07..c9ec426e27ec 100644
--- a/include/linux/dma/edma.h
+++ b/include/linux/dma/edma.h
@@ -153,6 +153,14 @@ bool dw_edma_chan_ignore_irq(struct dma_chan *chan);
 int dw_edma_chan_register_notify(struct dma_chan *chan,
                                 void (*cb)(struct dma_chan *chan, void *user),
                                 void *user);
+
+/**
+ * dw_edma_chan_get_ll_region - get linked list (LL) memory for a dma_chan
+ * @chan: the target DMA channel
+ * @region: output parameter returning the corresponding LL region
+ */
+int dw_edma_chan_get_ll_region(struct dma_chan *chan,
+                              struct dw_edma_region *region);
 #else
 static inline int dw_edma_probe(struct dw_edma_chip *chip)
 {
@@ -182,6 +190,12 @@ static inline int dw_edma_chan_register_notify(struct 
dma_chan *chan,
 {
        return -ENODEV;
 }
+
+static inline int dw_edma_chan_get_ll_region(struct dma_chan *chan,
+                                            struct dw_edma_region *region)
+{
+       return -EINVAL;
+}
 #endif /* CONFIG_DW_EDMA */
 
 struct pci_epc;
-- 
2.51.0


Reply via email to