iommu/omap: ->unmap() should return order of unmapped page
authorOhad Ben-Cohen <ohad@wizery.com>
Fri, 2 Sep 2011 17:32:33 +0000 (13:32 -0400)
committerJoerg Roedel <joerg.roedel@amd.com>
Mon, 5 Sep 2011 13:14:37 +0000 (15:14 +0200)
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>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
drivers/iommu/omap-iommu.c
drivers/iommu/omap-iovmm.c

index 4311bc32cfa644148d781c9cf02c24fcc144be6b..bd5f6064c74adb0287a76ce74f7ba24a3e3b3ba9 100644 (file)
@@ -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
index 39bdb92aa96f21f175e34713d5a221863639dece..e8fdb8830f698184b08cb2a919b1358648ea4efb 100644 (file)
@@ -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",