git: 5f2070adb943 - main - Only support a 4 level smmu page table

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Thu, 16 Mar 2023 16:46:07 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f2070adb943b64a286e140f3ebd00da43001845

commit 5f2070adb943b64a286e140f3ebd00da43001845
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2023-03-16 15:34:54 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2023-03-16 16:45:42 +0000

    Only support a 4 level smmu page table
    
    We only ever build a 4 level page table for the Arm SMMU. Remove the
    support for a 3 level table.
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D38949
---
 sys/arm64/iommu/iommu_pmap.c | 43 +++----------------------------------------
 1 file changed, 3 insertions(+), 40 deletions(-)

diff --git a/sys/arm64/iommu/iommu_pmap.c b/sys/arm64/iommu/iommu_pmap.c
index 80a0515a0c2c..acef3d8d3368 100644
--- a/sys/arm64/iommu/iommu_pmap.c
+++ b/sys/arm64/iommu/iommu_pmap.c
@@ -388,8 +388,8 @@ _smmu_pmap_unwire_l3(pmap_t pmap, vm_offset_t va, vm_page_t m,
 	smmu_pmap_add_delayed_free_list(m, free, TRUE);
 }
 
-static int
-smmu_pmap_pinit_levels(pmap_t pmap, int levels)
+int
+smmu_pmap_pinit(pmap_t pmap)
 {
 	vm_page_t m;
 
@@ -404,31 +404,12 @@ smmu_pmap_pinit_levels(pmap_t pmap, int levels)
 	vm_radix_init(&pmap->pm_root);
 	bzero(&pmap->pm_stats, sizeof(pmap->pm_stats));
 
-	MPASS(levels == 3 || levels == 4);
-	pmap->pm_levels = levels;
-
-	/*
-	 * Allocate the level 1 entry to use as the root. This will increase
-	 * the refcount on the level 1 page so it won't be removed until
-	 * pmap_release() is called.
-	 */
-	if (pmap->pm_levels == 3) {
-		PMAP_LOCK(pmap);
-		m = _pmap_alloc_l3(pmap, NUL2E + NUL1E);
-		PMAP_UNLOCK(pmap);
-	}
+	pmap->pm_levels = 4;
 	pmap->pm_ttbr = VM_PAGE_TO_PHYS(m);
 
 	return (1);
 }
 
-int
-smmu_pmap_pinit(pmap_t pmap)
-{
-
-	return (smmu_pmap_pinit_levels(pmap, 4));
-}
-
 /*
  * This routine is called if the desired page table page does not exist.
  *
@@ -567,26 +548,8 @@ _pmap_alloc_l3(pmap_t pmap, vm_pindex_t ptepindex)
 void
 smmu_pmap_release(pmap_t pmap)
 {
-	boolean_t rv __diagused;
-	struct spglist free;
 	vm_page_t m;
 
-	if (pmap->pm_levels != 4) {
-		KASSERT(pmap->pm_stats.resident_count == 1,
-		    ("pmap_release: pmap resident count %ld != 0",
-		    pmap->pm_stats.resident_count));
-		KASSERT((pmap->pm_l0[0] & ATTR_DESCR_VALID) == ATTR_DESCR_VALID,
-		    ("pmap_release: Invalid l0 entry: %lx", pmap->pm_l0[0]));
-
-		SLIST_INIT(&free);
-		m = PHYS_TO_VM_PAGE(pmap->pm_ttbr);
-		PMAP_LOCK(pmap);
-		rv = smmu_pmap_unwire_l3(pmap, 0, m, &free);
-		PMAP_UNLOCK(pmap);
-		MPASS(rv == TRUE);
-		vm_page_free_pages_toq(&free, true);
-	}
-
 	KASSERT(pmap->pm_stats.resident_count == 0,
 	    ("pmap_release: pmap resident count %ld != 0",
 	    pmap->pm_stats.resident_count));