@@ -452,6 +452,7 @@ static int sun50i_iommu_enable(struct sun50i_iommu *iommu)
452
452
IOMMU_TLB_PREFETCH_MASTER_ENABLE (3 ) |
453
453
IOMMU_TLB_PREFETCH_MASTER_ENABLE (4 ) |
454
454
IOMMU_TLB_PREFETCH_MASTER_ENABLE (5 ));
455
+ iommu_write (iommu , IOMMU_BYPASS_REG , 0 );
455
456
iommu_write (iommu , IOMMU_INT_ENABLE_REG , IOMMU_INT_MASK );
456
457
iommu_write (iommu , IOMMU_DM_AUT_CTRL_REG (SUN50I_IOMMU_ACI_NONE ),
457
458
IOMMU_DM_AUT_CTRL_RD_UNAVAIL (SUN50I_IOMMU_ACI_NONE , 0 ) |
@@ -601,6 +602,14 @@ static int sun50i_iommu_map(struct iommu_domain *domain, unsigned long iova,
601
602
u32 * page_table , * pte_addr ;
602
603
int ret = 0 ;
603
604
605
+ /* the IOMMU can only handle 32-bit addresses, both input and output */
606
+ if ((uint64_t )paddr >> 32 ) {
607
+ ret = - EINVAL ;
608
+ dev_warn_once (iommu -> dev ,
609
+ "attempt to map address beyond 4GB\n" );
610
+ goto out ;
611
+ }
612
+
604
613
page_table = sun50i_dte_get_page_table (sun50i_domain , iova , gfp );
605
614
if (IS_ERR (page_table )) {
606
615
ret = PTR_ERR (page_table );
@@ -681,7 +690,8 @@ sun50i_iommu_domain_alloc_paging(struct device *dev)
681
690
if (!sun50i_domain )
682
691
return NULL ;
683
692
684
- sun50i_domain -> dt = iommu_alloc_pages (GFP_KERNEL , get_order (DT_SIZE ));
693
+ sun50i_domain -> dt = iommu_alloc_pages (GFP_KERNEL | GFP_DMA32 ,
694
+ get_order (DT_SIZE ));
685
695
if (!sun50i_domain -> dt )
686
696
goto err_free_domain ;
687
697
@@ -996,7 +1006,7 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
996
1006
997
1007
iommu -> pt_pool = kmem_cache_create (dev_name (& pdev -> dev ),
998
1008
PT_SIZE , PT_SIZE ,
999
- SLAB_HWCACHE_ALIGN ,
1009
+ SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA32 ,
1000
1010
NULL );
1001
1011
if (!iommu -> pt_pool )
1002
1012
return - ENOMEM ;
@@ -1057,6 +1067,7 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
1057
1067
1058
1068
static const struct of_device_id sun50i_iommu_dt [] = {
1059
1069
{ .compatible = "allwinner,sun50i-h6-iommu" , },
1070
+ { .compatible = "allwinner,sun50i-h616-iommu" , },
1060
1071
{ /* sentinel */ },
1061
1072
};
1062
1073
MODULE_DEVICE_TABLE (of , sun50i_iommu_dt );
0 commit comments