From patchwork Fri Sep 2 17:32:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 1122702 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p82HXObQ021282 for ; Fri, 2 Sep 2011 17:33:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753931Ab1IBRdM (ORCPT ); Fri, 2 Sep 2011 13:33:12 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:55839 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753884Ab1IBRdK (ORCPT ); Fri, 2 Sep 2011 13:33:10 -0400 Received: by wyh22 with SMTP id 22so2141409wyh.19 for ; Fri, 02 Sep 2011 10:33:09 -0700 (PDT) Received: by 10.216.220.129 with SMTP id o1mr1245740wep.84.1314984789025; Fri, 02 Sep 2011 10:33:09 -0700 (PDT) Received: from localhost.localdomain (93-173-174-182.bb.netvision.net.il [93.173.174.182]) by mx.google.com with ESMTPS id fq2sm2376189wbb.24.2011.09.02.10.33.05 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Sep 2011 10:33:07 -0700 (PDT) From: Ohad Ben-Cohen To: Cc: , Hiroshi DOYU , Laurent Pinchart , Joerg Roedel , David Woodhouse , , David Brown , Arnd Bergmann , , Ohad Ben-Cohen Subject: [PATCH 4/7] iommu/omap: ->unmap() should return order of unmapped page Date: Fri, 2 Sep 2011 20:32:33 +0300 Message-Id: <1314984756-4400-5-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314984756-4400-1-git-send-email-ohad@wizery.com> References: <1314984756-4400-1-git-send-email-ohad@wizery.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 02 Sep 2011 17:33:24 +0000 (UTC) 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 --- 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",