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>
@@ -492,18 +492,9 @@ static int qdma_device_verify(struct qdma_device *qdev)
492492
493493static int qdma_device_setup (struct qdma_device * qdev )
494494{
495- struct device * dev = & qdev -> pdev -> dev ;
496495 u32 ring_sz = QDMA_DEFAULT_RING_SIZE ;
497496 int ret = 0 ;
498497
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-
507498 ret = qdma_setup_fmap_context (qdev );
508499 if (ret ) {
509500 qdma_err (qdev , "Failed setup fmap context" );
@@ -548,11 +539,12 @@ static void qdma_free_queue_resources(struct dma_chan *chan)
548539{
549540 struct qdma_queue * queue = to_qdma_queue (chan );
550541 struct qdma_device * qdev = queue -> qdev ;
551- struct device * dev = qdev -> dma_dev . dev ;
542+ struct qdma_platdata * pdata ;
552543
553544 qdma_clear_queue_context (queue );
554545 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 ,
556548 queue -> desc_base , queue -> dma_desc_base );
557549}
558550
@@ -565,15 +557,17 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
565557 struct qdma_queue * queue = to_qdma_queue (chan );
566558 struct qdma_device * qdev = queue -> qdev ;
567559 struct qdma_ctxt_sw_desc desc ;
560+ struct qdma_platdata * pdata ;
568561 size_t size ;
569562 int ret ;
570563
571564 ret = qdma_clear_queue_context (queue );
572565 if (ret )
573566 return ret ;
574567
568+ pdata = dev_get_platdata (& qdev -> pdev -> dev );
575569 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 ,
577571 & queue -> dma_desc_base ,
578572 GFP_KERNEL );
579573 if (!queue -> desc_base ) {
@@ -588,7 +582,7 @@ static int qdma_alloc_queue_resources(struct dma_chan *chan)
588582 if (ret ) {
589583 qdma_err (qdev , "Failed to setup SW desc ctxt for %s" ,
590584 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 ,
592586 queue -> dma_desc_base );
593587 return ret ;
594588 }
@@ -948,8 +942,9 @@ static int qdma_init_error_irq(struct qdma_device *qdev)
948942
949943static int qdmam_alloc_qintr_rings (struct qdma_device * qdev )
950944{
951- u32 ctxt [ QDMA_CTXT_REGMAP_LEN ] ;
945+ struct qdma_platdata * pdata = dev_get_platdata ( & qdev -> pdev -> dev ) ;
952946 struct device * dev = & qdev -> pdev -> dev ;
947+ u32 ctxt [QDMA_CTXT_REGMAP_LEN ];
953948 struct qdma_intr_ring * ring ;
954949 struct qdma_ctxt_intr intr_ctxt ;
955950 u32 vector ;
@@ -969,7 +964,8 @@ static int qdmam_alloc_qintr_rings(struct qdma_device *qdev)
969964 ring -> msix_id = qdev -> err_irq_idx + i + 1 ;
970965 ring -> ridx = i ;
971966 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 ,
973969 & ring -> dev_base , GFP_KERNEL );
974970 if (!ring -> base ) {
975971 qdma_err (qdev , "Failed to alloc intr ring %d" , i );
0 commit comments