[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251023071916.901355-18-den@valinux.co.jp>
Date: Thu, 23 Oct 2025 16:19:08 +0900
From: Koichiro Den <den@...inux.co.jp>
To: ntb@...ts.linux.dev,
linux-pci@...r.kernel.org,
dmaengine@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: mani@...nel.org,
kwilczynski@...nel.org,
kishon@...nel.org,
bhelgaas@...gle.com,
corbet@....net,
vkoul@...nel.org,
jdmason@...zu.us,
dave.jiang@...el.com,
allenbh@...il.com,
Basavaraj.Natikar@....com,
Shyam-sundar.S-k@....com,
kurt.schwemmer@...rosemi.com,
logang@...tatee.com,
jingoohan1@...il.com,
lpieralisi@...nel.org,
robh@...nel.org,
jbrunet@...libre.com,
Frank.Li@....com,
fancer.lancer@...il.com,
arnd@...db.de,
pstanner@...hat.com,
elfring@...rs.sourceforge.net
Subject: [RFC PATCH 17/25] dmaengine: dw-edma: Add dw_edma_find_by_child() helper
Add a helper to locate a dw_edma instance by its child device pointer.
Used by PCI endpoint functions to locate the shared eDMA controller.
Signed-off-by: Koichiro Den <den@...inux.co.jp>
---
drivers/dma/dw-edma/dw-edma-core.c | 26 ++++++++++++++++++++++++++
drivers/dma/dw-edma/dw-edma-core.h | 2 ++
include/linux/dma/edma.h | 5 +++++
3 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 28cc319e224d..6c7495504456 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -24,6 +24,9 @@
#include "../dmaengine.h"
#include "../virt-dma.h"
+static DEFINE_MUTEX(dw_edma_list_lock);
+static LIST_HEAD(dw_edma_list);
+
static inline
struct dw_edma_desc *vd2dw_edma_desc(struct virt_dma_desc *vd)
{
@@ -964,6 +967,22 @@ void dw_edma_unregister_selfirq(struct dw_edma *dw,
}
EXPORT_SYMBOL_GPL(dw_edma_unregister_selfirq);
+struct dw_edma *dw_edma_find_by_child(struct device *child)
+{
+ struct dw_edma *dw;
+
+ if (!child)
+ return NULL;
+
+ guard(mutex)(&dw_edma_list_lock);
+ list_for_each_entry(dw, &dw_edma_list, node)
+ if (child->parent == dw->dma.dev)
+ return dw;
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(dw_edma_find_by_child);
+
int dw_edma_probe(struct dw_edma_chip *chip)
{
struct device *dev;
@@ -1035,6 +1054,10 @@ int dw_edma_probe(struct dw_edma_chip *chip)
chip->dw = dw;
+ INIT_LIST_HEAD(&dw->node);
+ guard(mutex)(&dw_edma_list_lock);
+ list_add_tail(&dw->node, &dw_edma_list);
+
return 0;
err_irq_free:
@@ -1080,6 +1103,9 @@ int dw_edma_remove(struct dw_edma_chip *chip)
list_del(&chan->vc.chan.device_node);
}
+ guard(mutex)(&dw_edma_list_lock);
+ list_del(&dw->node);
+
return 0;
}
EXPORT_SYMBOL_GPL(dw_edma_remove);
diff --git a/drivers/dma/dw-edma/dw-edma-core.h b/drivers/dma/dw-edma/dw-edma-core.h
index 7d7dd9f13863..249d7e153cbf 100644
--- a/drivers/dma/dw-edma/dw-edma-core.h
+++ b/drivers/dma/dw-edma/dw-edma-core.h
@@ -122,6 +122,8 @@ struct dw_edma {
struct list_head selfirq_handlers;
spinlock_t selfirq_lock;
+
+ struct list_head node;
};
typedef void (*dw_edma_handler_t)(struct dw_edma_chan *);
diff --git a/include/linux/dma/edma.h b/include/linux/dma/edma.h
index 1f11b70e1b1a..abc59ffde62c 100644
--- a/include/linux/dma/edma.h
+++ b/include/linux/dma/edma.h
@@ -115,6 +115,7 @@ int dw_edma_register_selfirq(struct dw_edma *dw,
dw_edma_selfirq_fn fn, void *data);
void dw_edma_unregister_selfirq(struct dw_edma *dw,
dw_edma_selfirq_fn fn, void *data);
+struct dw_edma *dw_edma_find_by_child(struct device *child);
#else
static inline int dw_edma_probe(struct dw_edma_chip *chip)
{
@@ -141,6 +142,10 @@ static inline void dw_edma_unregister_selfirq(struct dw_edma *dw,
dw_edma_selfirq_fn fn, void *data)
{
}
+struct dw_edma *dw_edma_find_by_child(struct device *child)
+{
+ return NULL;
+}
#endif /* CONFIG_DW_EDMA */
#endif /* _DW_EDMA_H */
--
2.48.1
Powered by blists - more mailing lists