]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
authorLizhi Hou <lizhi.hou@amd.com>
Wed, 18 Sep 2024 18:10:22 +0000 (11:10 -0700)
committerVinod Koul <vkoul@kernel.org>
Wed, 4 Dec 2024 12:57:32 +0000 (18:27 +0530)
The get_dma_ops and set_dma_ops APIs were never for driver to use. Remove
these calls from QDMA driver. Instead, pass the DMA device pointer from the
qdma_platdata structure.

Fixes: 73d5fc92a11c ("dmaengine: amd: qdma: Add AMD QDMA driver")
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240918181022.2155715-1-lizhi.hou@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/amd/qdma/qdma.c
include/linux/platform_data/amd_qdma.h

index 6d9079458fe9ccbcd95a578b1585775590cf7700..66f00ad67351a58034f3d1cb1fddb9b5d7d98bf4 100644 (file)
@@ -7,9 +7,9 @@
 #include <linux/bitfield.h>
 #include <linux/bitops.h>
 #include <linux/dmaengine.h>
+#include <linux/dma-mapping.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
-#include <linux/dma-map-ops.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/amd_qdma.h>
 #include <linux/regmap.h>
@@ -492,18 +492,9 @@ static int qdma_device_verify(struct qdma_device *qdev)
 
 static int qdma_device_setup(struct qdma_device *qdev)
 {
-       struct device *dev = &qdev->pdev->dev;
        u32 ring_sz = QDMA_DEFAULT_RING_SIZE;
        int ret = 0;
 
-       while (dev && get_dma_ops(dev))
-               dev = dev->parent;
-       if (!dev) {
-               qdma_err(qdev, "dma device not found");
-               return -EINVAL;
-       }
-       set_dma_ops(&qdev->pdev->dev, get_dma_ops(dev));
-
        ret = qdma_setup_fmap_context(qdev);
        if (ret) {
                qdma_err(qdev, "Failed setup fmap context");
@@ -548,11 +539,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan)
 {
        struct qdma_queue *queue = to_qdma_queue(chan);
        struct qdma_device *qdev = queue->qdev;
-       struct device *dev = qdev->dma_dev.dev;
+       struct qdma_platdata *pdata;
 
        qdma_clear_queue_context(queue);
        vchan_free_chan_resources(&queue->vchan);
-       dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE,
+       pdata = dev_get_platdata(&qdev->pdev->dev);
+       dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE,
                          queue->desc_base, queue->dma_desc_base);
 }
 
@@ -565,6 +557,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
        struct qdma_queue *queue = to_qdma_queue(chan);
        struct qdma_device *qdev = queue->qdev;
        struct qdma_ctxt_sw_desc desc;
+       struct qdma_platdata *pdata;
        size_t size;
        int ret;
 
@@ -572,8 +565,9 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
        if (ret)
                return ret;
 
+       pdata = dev_get_platdata(&qdev->pdev->dev);
        size = queue->ring_size * QDMA_MM_DESC_SIZE;
-       queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size,
+       queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size,
                                              &queue->dma_desc_base,
                                              GFP_KERNEL);
        if (!queue->desc_base) {
@@ -588,7 +582,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
        if (ret) {
                qdma_err(qdev, "Failed to setup SW desc ctxt for %s",
                         chan->name);
-               dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base,
+               dma_free_coherent(pdata->dma_dev, size, queue->desc_base,
                                  queue->dma_desc_base);
                return ret;
        }
@@ -948,8 +942,9 @@ static int qdma_init_error_irq(struct qdma_device *qdev)
 
 static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
 {
-       u32 ctxt[QDMA_CTXT_REGMAP_LEN];
+       struct qdma_platdata *pdata = dev_get_platdata(&qdev->pdev->dev);
        struct device *dev = &qdev->pdev->dev;
+       u32 ctxt[QDMA_CTXT_REGMAP_LEN];
        struct qdma_intr_ring *ring;
        struct qdma_ctxt_intr intr_ctxt;
        u32 vector;
@@ -969,7 +964,8 @@ static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
                ring->msix_id = qdev->err_irq_idx + i + 1;
                ring->ridx = i;
                ring->color = 1;
-               ring->base = dmam_alloc_coherent(dev, QDMA_INTR_RING_SIZE,
+               ring->base = dmam_alloc_coherent(pdata->dma_dev,
+                                                QDMA_INTR_RING_SIZE,
                                                 &ring->dev_base, GFP_KERNEL);
                if (!ring->base) {
                        qdma_err(qdev, "Failed to alloc intr ring %d", i);
index 576d952f97edd433e4d1ac867eeaa2d771dd0456..967a6ef31cf98242a37c78f3530efcef64cbebd1 100644 (file)
@@ -26,11 +26,13 @@ struct dma_slave_map;
  * @max_mm_channels: Maximum number of MM DMA channels in each direction
  * @device_map: DMA slave map
  * @irq_index: The index of first IRQ
+ * @dma_dev: The device pointer for dma operations
  */
 struct qdma_platdata {
        u32                     max_mm_channels;
        u32                     irq_index;
        struct dma_slave_map    *device_map;
+       struct device           *dma_dev;
 };
 
 #endif /* _PLATDATA_AMD_QDMA_H */