Skip to content

Commit 7b3fe2c

Browse files
committed
dmaengine: amd: qdma: Remove using the private get and set dma_ops APIs
commit dcbef07 Author: Lizhi Hou <lizhi.hou@amd.com> Date: Wed Sep 18 11:10:22 2024 -0700 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: 73d5fc9 ("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> (cherry picked from commit dcbef07) Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com> JIRA: https://issues.redhat.com/browse/RHEL-78703 Upstream-Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
1 parent b2396f4 commit 7b3fe2c

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

drivers/dma/amd/qdma/qdma.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <linux/bitfield.h>
88
#include <linux/bitops.h>
99
#include <linux/dmaengine.h>
10+
#include <linux/dma-mapping.h>
1011
#include <linux/module.h>
1112
#include <linux/mod_devicetable.h>
12-
#include <linux/dma-map-ops.h>
1313
#include <linux/platform_device.h>
1414
#include <linux/platform_data/amd_qdma.h>
1515
#include <linux/regmap.h>
@@ -496,18 +496,9 @@ static int qdma_device_verify(struct qdma_device *qdev)
496496

497497
static int qdma_device_setup(struct qdma_device *qdev)
498498
{
499-
struct device *dev = &qdev->pdev->dev;
500499
u32 ring_sz = QDMA_DEFAULT_RING_SIZE;
501500
int ret = 0;
502501

503-
while (dev && get_dma_ops(dev))
504-
dev = dev->parent;
505-
if (!dev) {
506-
qdma_err(qdev, "dma device not found");
507-
return -EINVAL;
508-
}
509-
set_dma_ops(&qdev->pdev->dev, get_dma_ops(dev));
510-
511502
ret = qdma_setup_fmap_context(qdev);
512503
if (ret) {
513504
qdma_err(qdev, "Failed setup fmap context");
@@ -552,11 +543,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan)
552543
{
553544
struct qdma_queue *queue = to_qdma_queue(chan);
554545
struct qdma_device *qdev = queue->qdev;
555-
struct device *dev = qdev->dma_dev.dev;
546+
struct qdma_platdata *pdata;
556547

557548
qdma_clear_queue_context(queue);
558549
vchan_free_chan_resources(&queue->vchan);
559-
dma_free_coherent(dev, queue->ring_size * QDMA_MM_DESC_SIZE,
550+
pdata = dev_get_platdata(&qdev->pdev->dev);
551+
dma_free_coherent(pdata->dma_dev, queue->ring_size * QDMA_MM_DESC_SIZE,
560552
queue->desc_base, queue->dma_desc_base);
561553
}
562554

@@ -569,15 +561,17 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
569561
struct qdma_queue *queue = to_qdma_queue(chan);
570562
struct qdma_device *qdev = queue->qdev;
571563
struct qdma_ctxt_sw_desc desc;
564+
struct qdma_platdata *pdata;
572565
size_t size;
573566
int ret;
574567

575568
ret = qdma_clear_queue_context(queue);
576569
if (ret)
577570
return ret;
578571

572+
pdata = dev_get_platdata(&qdev->pdev->dev);
579573
size = queue->ring_size * QDMA_MM_DESC_SIZE;
580-
queue->desc_base = dma_alloc_coherent(qdev->dma_dev.dev, size,
574+
queue->desc_base = dma_alloc_coherent(pdata->dma_dev, size,
581575
&queue->dma_desc_base,
582576
GFP_KERNEL);
583577
if (!queue->desc_base) {
@@ -592,7 +586,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
592586
if (ret) {
593587
qdma_err(qdev, "Failed to setup SW desc ctxt for %s",
594588
chan->name);
595-
dma_free_coherent(qdev->dma_dev.dev, size, queue->desc_base,
589+
dma_free_coherent(pdata->dma_dev, size, queue->desc_base,
596590
queue->dma_desc_base);
597591
return ret;
598592
}
@@ -952,8 +946,9 @@ static int qdma_init_error_irq(struct qdma_device *qdev)
952946

953947
static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
954948
{
955-
u32 ctxt[QDMA_CTXT_REGMAP_LEN];
949+
struct qdma_platdata *pdata = dev_get_platdata(&qdev->pdev->dev);
956950
struct device *dev = &qdev->pdev->dev;
951+
u32 ctxt[QDMA_CTXT_REGMAP_LEN];
957952
struct qdma_intr_ring *ring;
958953
struct qdma_ctxt_intr intr_ctxt;
959954
u32 vector;
@@ -973,7 +968,8 @@ static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
973968
ring->msix_id = qdev->err_irq_idx + i + 1;
974969
ring->ridx = i;
975970
ring->color = 1;
976-
ring->base = dmam_alloc_coherent(dev, QDMA_INTR_RING_SIZE,
971+
ring->base = dmam_alloc_coherent(pdata->dma_dev,
972+
QDMA_INTR_RING_SIZE,
977973
&ring->dev_base, GFP_KERNEL);
978974
if (!ring->base) {
979975
qdma_err(qdev, "Failed to alloc intr ring %d", i);

include/linux/platform_data/amd_qdma.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ struct dma_slave_map;
2626
* @max_mm_channels: Maximum number of MM DMA channels in each direction
2727
* @device_map: DMA slave map
2828
* @irq_index: The index of first IRQ
29+
* @dma_dev: The device pointer for dma operations
2930
*/
3031
struct qdma_platdata {
3132
u32 max_mm_channels;
3233
u32 irq_index;
3334
struct dma_slave_map *device_map;
35+
struct device *dma_dev;
3436
};
3537

3638
#endif /* _PLATDATA_AMD_QDMA_H */

0 commit comments

Comments
 (0)