@@ -126,6 +126,7 @@ struct mtk_iommu_domain {
126
126
struct io_pgtable_cfg cfg ;
127
127
struct io_pgtable_ops * iop ;
128
128
129
+ struct mtk_iommu_data * data ;
129
130
struct iommu_domain domain ;
130
131
};
131
132
@@ -351,6 +352,7 @@ static int mtk_iommu_domain_finalise(struct mtk_iommu_domain *dom)
351
352
return - EINVAL ;
352
353
}
353
354
355
+ dom -> data = data ;
354
356
/* Update our support page sizes bitmap */
355
357
dom -> domain .pgsize_bitmap = dom -> cfg .pgsize_bitmap ;
356
358
return 0 ;
@@ -442,10 +444,9 @@ static int mtk_iommu_map(struct iommu_domain *domain, unsigned long iova,
442
444
phys_addr_t paddr , size_t size , int prot , gfp_t gfp )
443
445
{
444
446
struct mtk_iommu_domain * dom = to_mtk_domain (domain );
445
- struct mtk_iommu_data * data = mtk_iommu_get_m4u_data ();
446
447
447
448
/* The "4GB mode" M4U physically can not use the lower remap of Dram. */
448
- if (data -> enable_4GB )
449
+ if (dom -> data -> enable_4GB )
449
450
paddr |= BIT_ULL (32 );
450
451
451
452
/* Synchronize with the tlb_lock */
@@ -468,36 +469,37 @@ static size_t mtk_iommu_unmap(struct iommu_domain *domain,
468
469
469
470
static void mtk_iommu_flush_iotlb_all (struct iommu_domain * domain )
470
471
{
471
- mtk_iommu_tlb_flush_all (mtk_iommu_get_m4u_data ());
472
+ struct mtk_iommu_domain * dom = to_mtk_domain (domain );
473
+
474
+ mtk_iommu_tlb_flush_all (dom -> data );
472
475
}
473
476
474
477
static void mtk_iommu_iotlb_sync (struct iommu_domain * domain ,
475
478
struct iommu_iotlb_gather * gather )
476
479
{
477
- struct mtk_iommu_data * data = mtk_iommu_get_m4u_data ( );
480
+ struct mtk_iommu_domain * dom = to_mtk_domain ( domain );
478
481
size_t length = gather -> end - gather -> start + 1 ;
479
482
480
483
mtk_iommu_tlb_flush_range_sync (gather -> start , length , gather -> pgsize ,
481
- data );
484
+ dom -> data );
482
485
}
483
486
484
487
static void mtk_iommu_sync_map (struct iommu_domain * domain , unsigned long iova ,
485
488
size_t size )
486
489
{
487
- struct mtk_iommu_data * data = mtk_iommu_get_m4u_data ( );
490
+ struct mtk_iommu_domain * dom = to_mtk_domain ( domain );
488
491
489
- mtk_iommu_tlb_flush_range_sync (iova , size , size , data );
492
+ mtk_iommu_tlb_flush_range_sync (iova , size , size , dom -> data );
490
493
}
491
494
492
495
static phys_addr_t mtk_iommu_iova_to_phys (struct iommu_domain * domain ,
493
496
dma_addr_t iova )
494
497
{
495
498
struct mtk_iommu_domain * dom = to_mtk_domain (domain );
496
- struct mtk_iommu_data * data = mtk_iommu_get_m4u_data ();
497
499
phys_addr_t pa ;
498
500
499
501
pa = dom -> iop -> iova_to_phys (dom -> iop , iova );
500
- if (data -> enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE )
502
+ if (dom -> data -> enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE )
501
503
pa &= ~BIT_ULL (32 );
502
504
503
505
return pa ;
0 commit comments