[PATCH RFC 02/12] dmaengine: Add common dma_ll_desc and dma_linklist_item for link-list controllers

Frank Li posted 12 patches 1 week, 4 days ago
[PATCH RFC 02/12] dmaengine: Add common dma_ll_desc and dma_linklist_item for link-list controllers
Posted by Frank Li 1 week, 4 days ago
Introduce common dma_ll_desc and dma_linklist_item structures for
link-list–based DMA controllers. This lays the groundwork for adding more
shared APIs to a common DMA link-list library and reduces duplication
across drivers.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/dma/virt-dma.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/dma/virt-dma.h b/drivers/dma/virt-dma.h
index 081eb910d0b0cd2b60232736587c698fff787cb9..82f3f8244f6eca036a027c9a4c9339fcb87e8d2c 100644
--- a/drivers/dma/virt-dma.h
+++ b/drivers/dma/virt-dma.h
@@ -19,11 +19,32 @@ struct virt_dma_desc {
 	struct list_head node;
 };
 
+struct dma_linklist_item {
+	dma_addr_t paddr;
+	void *vaddr;
+};
+
+/*
+ * Must put to last one if need extend it
+ *   struct vendor_dma_ll_desc {
+ *	...
+ *	struct dma_ll_desc ldesc;
+ *   }
+ */
+struct dma_ll_desc {
+	struct virt_dma_desc vdesc;
+	bool iscyclic;
+	enum dma_transfer_direction dir;
+	u32 n_its;
+	struct dma_linklist_item its[];
+};
+
 struct dma_linklist_ops {
 	int (*stop)(struct dma_chan *chan);
 };
 
 struct dma_linklist {
+	struct dma_pool *pool;
 	const struct dma_linklist_ops *ops;
 };
 
@@ -247,6 +268,11 @@ static inline void vchan_synchronize(struct virt_dma_chan *vc)
 }
 
 #if IS_ENABLED(CONFIG_DMA_LINKLIST)
+static inline struct dma_ll_desc *to_dma_ll_desc(struct virt_dma_desc *vdesc)
+{
+	return container_of(vdesc, struct dma_ll_desc, vdesc);
+}
+
 int vchan_dma_ll_init(struct virt_dma_chan *vc,
 		      const struct dma_linklist_ops *ops, size_t size,
 		      size_t align, size_t boundary);

-- 
2.34.1