diff mbox

[v2,11/13] iommu/arm: smmu: Squash map_pages/unmap_pages with map_page/unmap_page

Message ID 1501003615-15274-12-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Tyshchenko July 25, 2017, 5:26 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Eliminate TODO by squashing single-page stuff with multi-page one.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
CC: Julien Grall <julien.grall@arm.com>

---
   Changes in v1:
      -

   Changes in v2:
      -
---
 xen/drivers/passthrough/arm/smmu.c | 48 +++++---------------------------------
 1 file changed, 6 insertions(+), 42 deletions(-)

Comments

Julien Grall Aug. 3, 2017, 12:36 p.m. UTC | #1
Hi,

On 25/07/17 18:26, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>
> Eliminate TODO by squashing single-page stuff with multi-page one.
>
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> CC: Julien Grall <julien.grall@arm.com>

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,
Oleksandr Tyshchenko Aug. 3, 2017, 1:26 p.m. UTC | #2
Hi, Julien

On Thu, Aug 3, 2017 at 3:36 PM, Julien Grall <julien.grall@arm.com> wrote:
> Hi,
>
> On 25/07/17 18:26, Oleksandr Tyshchenko wrote:
>>
>> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>>
>> Eliminate TODO by squashing single-page stuff with multi-page one.
>>
>> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>> CC: Julien Grall <julien.grall@arm.com>
>
>
> Acked-by: Julien Grall <julien.grall@arm.com>
Thank you!

>
> Cheers,
>
> --
> Julien Grall
diff mbox

Patch

diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 652b58c..021031a 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -2737,8 +2737,8 @@  static void arm_smmu_iommu_domain_teardown(struct domain *d)
 	xfree(xen_domain);
 }
 
-static int __must_check arm_smmu_map_page(struct domain *d, unsigned long gfn,
-			unsigned long mfn, unsigned int flags)
+static int __must_check arm_smmu_map_pages(struct domain *d, unsigned long gfn,
+			unsigned long mfn, unsigned int order, unsigned int flags)
 {
 	p2m_type_t t;
 
@@ -2763,10 +2763,11 @@  static int __must_check arm_smmu_map_page(struct domain *d, unsigned long gfn,
 	 * The function guest_physmap_add_entry replaces the current mapping
 	 * if there is already one...
 	 */
-	return guest_physmap_add_entry(d, _gfn(gfn), _mfn(mfn), 0, t);
+	return guest_physmap_add_entry(d, _gfn(gfn), _mfn(mfn), order, t);
 }
 
-static int __must_check arm_smmu_unmap_page(struct domain *d, unsigned long gfn)
+static int __must_check arm_smmu_unmap_pages(struct domain *d,
+			unsigned long gfn, unsigned int order)
 {
 	/*
 	 * This function should only be used by gnttab code when the domain
@@ -2775,44 +2776,7 @@  static int __must_check arm_smmu_unmap_page(struct domain *d, unsigned long gfn)
 	if ( !is_domain_direct_mapped(d) )
 		return -EINVAL;
 
-	return guest_physmap_remove_page(d, _gfn(gfn), _mfn(gfn), 0);
-}
-
-/* TODO: Optimize by squashing map_pages/unmap_pages with map_page/unmap_page */
-static int __must_check arm_smmu_map_pages(struct domain *d, unsigned long gfn,
-		unsigned long mfn, unsigned int order, unsigned int flags)
-{
-	unsigned long i;
-	int rc = 0;
-
-	for (i = 0; i < (1UL << order); i++) {
-		rc = arm_smmu_map_page(d, gfn + i, mfn + i, flags);
-		if (unlikely(rc)) {
-			while (i--)
-				/* If statement to satisfy __must_check. */
-				if (arm_smmu_unmap_page(d, gfn + i))
-					continue;
-
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int __must_check arm_smmu_unmap_pages(struct domain *d,
-		unsigned long gfn, unsigned int order)
-{
-	unsigned long i;
-	int rc = 0;
-
-	for (i = 0; i < (1UL << order); i++) {
-		int ret = arm_smmu_unmap_page(d, gfn + i);
-		if (!rc)
-			rc = ret;
-	}
-
-	return rc;
+	return guest_physmap_remove_page(d, _gfn(gfn), _mfn(gfn), order);
 }
 
 static const struct iommu_ops arm_smmu_iommu_ops = {