linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ohad Ben-Cohen <ohad@wizery.com>
To: <iommu@lists.linux-foundation.org>
Cc: <linux-omap@vger.kernel.org>,
	Hiroshi DOYU <Hiroshi.DOYU@nokia.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Joerg Roedel <Joerg.Roedel@amd.com>,
	David Woodhouse <dwmw2@infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	David Brown <davidb@codeaurora.org>,
	Arnd Bergmann <arnd@arndb.de>, <linux-kernel@vger.kernel.org>,
	Ohad Ben-Cohen <ohad@wizery.com>
Subject: [PATCH 4/7] iommu/omap: ->unmap() should return order of unmapped page
Date: Fri,  2 Sep 2011 20:32:33 +0300	[thread overview]
Message-ID: <1314984756-4400-5-git-send-email-ohad@wizery.com> (raw)
In-Reply-To: <1314984756-4400-1-git-send-email-ohad@wizery.com>

Users of the IOMMU API (kvm specifically) assume that iommu_unmap()
returns the order of the unmapped page.

Fix omap_iommu_unmap() to do so and adopt omap-iovmm accordingly.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
 drivers/iommu/omap-iommu.c |   13 ++++---------
 drivers/iommu/omap-iovmm.c |    2 +-
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index 4311bc3..bd5f606 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -1081,18 +1081,13 @@ static int omap_iommu_unmap(struct iommu_domain *domain, unsigned long da,
 	struct omap_iommu_domain *omap_domain = domain->priv;
 	struct omap_iommu *oiommu = omap_domain->iommu_dev;
 	struct device *dev = oiommu->dev;
-	size_t bytes = PAGE_SIZE << order;
-	size_t ret;
+	size_t unmap_size;
 
-	dev_dbg(dev, "unmapping da 0x%lx size 0x%x\n", da, bytes);
+	dev_dbg(dev, "unmapping da 0x%lx order %d\n", da, order);
 
-	ret = iopgtable_clear_entry(oiommu, da);
-	if (ret != bytes) {
-		dev_err(dev, "entry @ 0x%lx was %d; not %d\n", da, ret, bytes);
-		return -EINVAL;
-	}
+	unmap_size = iopgtable_clear_entry(oiommu, da);
 
-	return 0;
+	return unmap_size ? get_order(unmap_size) : -EINVAL;
 }
 
 static int
diff --git a/drivers/iommu/omap-iovmm.c b/drivers/iommu/omap-iovmm.c
index 39bdb92..e8fdb88 100644
--- a/drivers/iommu/omap-iovmm.c
+++ b/drivers/iommu/omap-iovmm.c
@@ -480,7 +480,7 @@ static void unmap_iovm_area(struct iommu_domain *domain, struct omap_iommu *obj,
 		order = get_order(bytes);
 
 		err = iommu_unmap(domain, start, order);
-		if (err)
+		if (err < 0)
 			break;
 
 		dev_dbg(obj->dev, "%s: unmap %08x(%x) %08x\n",
-- 
1.7.4.1


  parent reply	other threads:[~2011-09-02 17:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-02 17:32 [PATCH/RFC 0/7] iommu: fixes & extensions Ohad Ben-Cohen
2011-09-02 17:32 ` [PATCH 1/7] iommu/omap-iovmm: support non page-aligned buffers in iommu_vmap Ohad Ben-Cohen
2011-09-02 17:32 ` [PATCH 2/7] iommu/omap: cleanup: remove a redundant statement Ohad Ben-Cohen
2011-09-02 17:32 ` [PATCH 3/7] iommu/core: use the existing IS_ALIGNED macro Ohad Ben-Cohen
2011-09-02 17:32 ` Ohad Ben-Cohen [this message]
2011-09-02 17:32 ` [PATCH 5/7] iommu/msm: ->unmap() should return order of unmapped page Ohad Ben-Cohen
2011-09-02 18:36   ` David Brown
2011-09-02 17:32 ` [RFC 6/7] iommu/core: add fault reporting Ohad Ben-Cohen
2011-09-05 10:00   ` Roedel, Joerg
2011-09-07 16:36     ` Ohad Ben-Cohen
2011-09-02 17:32 ` [RFC 7/7] iommu/core: split mapping to page sizes as supported by the hardware Ohad Ben-Cohen
2011-09-07  1:30   ` KyongHo Cho
2011-09-07  6:01     ` Ohad Ben-Cohen
     [not found]       ` <CAHQjnOMnOjAJ6QuuLmLa1UKvTRHfyyjiUYrfvzLx8FSsCixxng@mail.gmail.com>
     [not found]         ` <CAK=WgbbFhmiC=PJfmyPOhbHGtiPFOcmqBx7nSpkuDX36hPYgbA@mail.gmail.com>
2011-09-08 12:51           ` KyongHo Cho
2011-09-08 14:03             ` Ohad Ben-Cohen
2011-09-06 10:15 ` [PATCH/RFC 0/7] iommu: fixes & extensions Roedel, Joerg
2011-09-06 11:28   ` Ohad Ben-Cohen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1314984756-4400-5-git-send-email-ohad@wizery.com \
    --to=ohad@wizery.com \
    --cc=Hiroshi.DOYU@nokia.com \
    --cc=Joerg.Roedel@amd.com \
    --cc=arnd@arndb.de \
    --cc=davidb@codeaurora.org \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).