History

dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs

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.

Lizhi Hou committed 2 years ago

Commit dcbef071 parent 8d55e8a2 files · +14 −16Browse files

Unified · Split

2 files
  1. drivers/dma/amd/qdma/qdma.c +12 −16
  2. include/linux/platform_data/amd_qdma.h +2 −0
drivers/dma/amd/qdma/qdma.c+12−16
@@ -7,9 +7,9 @@ · 6 unmodified lines
7#include <linux/bitfield.h>7#include <linux/bitfield.h>
8#include <linux/bitops.h>8#include <linux/bitops.h>
9#include <linux/dmaengine.h>9#include <linux/dmaengine.h>
10#include <linux/dma-mapping.h>
10#include <linux/module.h>11#include <linux/module.h>
11#include <linux/mod_devicetable.h>12#include <linux/mod_devicetable.h>
12#include <linux/dma-map-ops.h>
13#include <linux/platform_device.h>13#include <linux/platform_device.h>
14#include <linux/platform_data/amd_qdma.h>14#include <linux/platform_data/amd_qdma.h>
15#include <linux/regmap.h>15#include <linux/regmap.h>
@@ -492,18 +492,9 @@ static int qdma_device_verify(struct qdma_device *qdev) · 476 unmodified lines
492 492
493static int qdma_device_setup(struct qdma_device *qdev)493static int qdma_device_setup(struct qdma_device *qdev)
494{494{
495 struct device *dev = &qdev->pdev->dev;
496 u32 ring_sz = QDMA_DEFAULT_RING_SIZE;495 u32 ring_sz = QDMA_DEFAULT_RING_SIZE;
497 int ret = 0;496 int ret = 0;
498 497
499 while (dev && get_dma_ops(dev))
500 dev = dev->parent;
501 if (!dev) {
502 qdma_err(qdev, "dma device not found");
503 return -EINVAL;
504 }
505 set_dma_ops(&qdev->pdev->dev, get_dma_ops(dev));
506
507 ret = qdma_setup_fmap_context(qdev);498 ret = qdma_setup_fmap_context(qdev);
508 if (ret) {499 if (ret) {
509 qdma_err(qdev, "Failed setup fmap context");500 qdma_err(qdev, "Failed setup fmap context");
@@ -548,11 +539,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan) · 38 unmodified lines
548{539{
549 struct qdma_queue *queue = to_qdma_queue(chan);540 struct qdma_queue *queue = to_qdma_queue(chan);
550 struct qdma_device *qdev = queue->qdev;541 struct qdma_device *qdev = queue->qdev;
551 struct device *dev = qdev->dma_dev.dev;542 struct qdma_platdata *pdata;
552 543
553 qdma_clear_queue_context(queue);544 qdma_clear_queue_context(queue);
554 vchan_free_chan_resources(&queue->vchan);545 vchan_free_chan_resources(&queue->vchan);
555 dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE,546 pdata = dev_get_platdata(&qdev->pdev->dev);
547 dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE,
556 queue->desc_base, queue->dma_desc_base);548 queue->desc_base, queue->dma_desc_base);
557}549}
558 550
@@ -565,6 +557,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan) · 6 unmodified lines
565 struct qdma_queue *queue = to_qdma_queue(chan);557 struct qdma_queue *queue = to_qdma_queue(chan);
566 struct qdma_device *qdev = queue->qdev;558 struct qdma_device *qdev = queue->qdev;
567 struct qdma_ctxt_sw_desc desc;559 struct qdma_ctxt_sw_desc desc;
560 struct qdma_platdata *pdata;
568 size_t size;561 size_t size;
569 int ret;562 int ret;
570 563
@@ -572,8 +565,9 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan) · 1 unmodified line
572 if (ret)565 if (ret)
573 return ret;566 return ret;
574 567
568 pdata = dev_get_platdata(&qdev->pdev->dev);
575 size = queue->ring_size * QDMA_MM_DESC_SIZE;569 size = queue->ring_size * QDMA_MM_DESC_SIZE;
576 queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size,570 queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size,
577 &queue->dma_desc_base,571 &queue->dma_desc_base,
578 GFP_KERNEL);572 GFP_KERNEL);
579 if (!queue->desc_base) {573 if (!queue->desc_base) {
@@ -588,7 +582,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan) · 8 unmodified lines
588 if (ret) {582 if (ret) {
589 qdma_err(qdev, "Failed to setup SW desc ctxt for %s",583 qdma_err(qdev, "Failed to setup SW desc ctxt for %s",
590 chan->name);584 chan->name);
591 dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base,585 dma_free_coherent(pdata->dma_dev, size, queue->desc_base,
592 queue->dma_desc_base);586 queue->dma_desc_base);
593 return ret;587 return ret;
594 }588 }
@@ -948,8 +942,9 @@ static int qdma_init_error_irq(struct qdma_device *qdev) · 353 unmodified lines
948 942
949static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)943static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
950{944{
951 u32 ctxt[QDMA_CTXT_REGMAP_LEN];945 struct qdma_platdata *pdata = dev_get_platdata(&qdev->pdev->dev);
952 struct device *dev = &qdev->pdev->dev;946 struct device *dev = &qdev->pdev->dev;
947 u32 ctxt[QDMA_CTXT_REGMAP_LEN];
953 struct qdma_intr_ring *ring;948 struct qdma_intr_ring *ring;
954 struct qdma_ctxt_intr intr_ctxt;949 struct qdma_ctxt_intr intr_ctxt;
955 u32 vector;950 u32 vector;
@@ -969,7 +964,8 @@ static int qdmam_alloc_qintr_rings(struct qdma_device *qdev) · 13 unmodified lines
969 ring->msix_id = qdev->err_irq_idx + i + 1;964 ring->msix_id = qdev->err_irq_idx + i + 1;
970 ring->ridx = i;965 ring->ridx = i;
971 ring->color = 1;966 ring->color = 1;
972 ring->base = dmam_alloc_coherent(dev, QDMA_INTR_RING_SIZE,967 ring->base = dmam_alloc_coherent(pdata->dma_dev,
968 QDMA_INTR_RING_SIZE,
973 &ring->dev_base, GFP_KERNEL);969 &ring->dev_base, GFP_KERNEL);
974 if (!ring->base) {970 if (!ring->base) {
975 qdma_err(qdev, "Failed to alloc intr ring %d", i);971 qdma_err(qdev, "Failed to alloc intr ring %d", i);
include/linux/platform_data/amd_qdma.h+2−0
@@ -26,11 +26,13 @@ struct dma_slave_map; · 25 unmodified lines
26 * @max_mm_channels: Maximum number of MM DMA channels in each direction26 * @max_mm_channels: Maximum number of MM DMA channels in each direction
27 * @device_map: DMA slave map27 * @device_map: DMA slave map
28 * @irq_index: The index of first IRQ28 * @irq_index: The index of first IRQ
29 * @dma_dev: The device pointer for dma operations
29 */30 */
30struct qdma_platdata {31struct qdma_platdata {
31 u32 max_mm_channels;32 u32 max_mm_channels;
32 u32 irq_index;33 u32 irq_index;
33 struct dma_slave_map *device_map;34 struct dma_slave_map *device_map;
35 struct device *dma_dev;
34};36};
35 37
36#endif /* _PLATDATA_AMD_QDMA_H */38#endif /* _PLATDATA_AMD_QDMA_H */