Skip to content

Commit 91b3a24

Browse files
committed
Merge branch 'iommu/allwinner/sun50i' into iommu/next
* iommu/allwinner/sun50i: iommu: sun50i: Add H616 compatible string dt-bindings: iommu: add new compatible strings iommu: sun50i: allocate page tables from below 4 GiB iommu: sun50i: clear bypass register
2 parents 83a7eef + 8db07ce commit 91b3a24

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Documentation/devicetree/bindings/iommu/allwinner,sun50i-h6-iommu.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ properties:
1717
The content of the cell is the master ID.
1818

1919
compatible:
20-
const: allwinner,sun50i-h6-iommu
20+
oneOf:
21+
- const: allwinner,sun50i-h6-iommu
22+
- const: allwinner,sun50i-h616-iommu
23+
- items:
24+
- const: allwinner,sun55i-a523-iommu
25+
- const: allwinner,sun50i-h616-iommu
2126

2227
reg:
2328
maxItems: 1

drivers/iommu/sun50i-iommu.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ static int sun50i_iommu_enable(struct sun50i_iommu *iommu)
452452
IOMMU_TLB_PREFETCH_MASTER_ENABLE(3) |
453453
IOMMU_TLB_PREFETCH_MASTER_ENABLE(4) |
454454
IOMMU_TLB_PREFETCH_MASTER_ENABLE(5));
455+
iommu_write(iommu, IOMMU_BYPASS_REG, 0);
455456
iommu_write(iommu, IOMMU_INT_ENABLE_REG, IOMMU_INT_MASK);
456457
iommu_write(iommu, IOMMU_DM_AUT_CTRL_REG(SUN50I_IOMMU_ACI_NONE),
457458
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,
601602
u32 *page_table, *pte_addr;
602603
int ret = 0;
603604

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+
604613
page_table = sun50i_dte_get_page_table(sun50i_domain, iova, gfp);
605614
if (IS_ERR(page_table)) {
606615
ret = PTR_ERR(page_table);
@@ -681,7 +690,8 @@ sun50i_iommu_domain_alloc_paging(struct device *dev)
681690
if (!sun50i_domain)
682691
return NULL;
683692

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));
685695
if (!sun50i_domain->dt)
686696
goto err_free_domain;
687697

@@ -996,7 +1006,7 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
9961006

9971007
iommu->pt_pool = kmem_cache_create(dev_name(&pdev->dev),
9981008
PT_SIZE, PT_SIZE,
999-
SLAB_HWCACHE_ALIGN,
1009+
SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA32,
10001010
NULL);
10011011
if (!iommu->pt_pool)
10021012
return -ENOMEM;
@@ -1057,6 +1067,7 @@ static int sun50i_iommu_probe(struct platform_device *pdev)
10571067

10581068
static const struct of_device_id sun50i_iommu_dt[] = {
10591069
{ .compatible = "allwinner,sun50i-h6-iommu", },
1070+
{ .compatible = "allwinner,sun50i-h616-iommu", },
10601071
{ /* sentinel */ },
10611072
};
10621073
MODULE_DEVICE_TABLE(of, sun50i_iommu_dt);

0 commit comments

Comments
 (0)