Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

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>

authored by

Lizhi Hou and committed by
Vinod Koul
dcbef079 8d55e8a1

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