Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 271564
b: refs/heads/master
c: 329d8d3
h: refs/heads/master
v: v3
  • Loading branch information
Laurent Pinchart authored and Joerg Roedel committed Sep 5, 2011
1 parent 2a7dc17 commit 931affc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 024ae884a657f8ddeeff6b472c1fe538f277980e
refs/heads/master: 329d8d3b474923087f6988737ff12137b58e55cc
36 changes: 26 additions & 10 deletions trunk/drivers/iommu/omap-iovmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@

static struct kmem_cache *iovm_area_cachep;

/* return the offset of the first scatterlist entry in a sg table */
static unsigned int sgtable_offset(const struct sg_table *sgt)
{
if (!sgt || !sgt->nents)
return 0;

return sgt->sgl->offset;
}

/* return total bytes of sg buffers */
static size_t sgtable_len(const struct sg_table *sgt)
{
Expand All @@ -39,11 +48,17 @@ static size_t sgtable_len(const struct sg_table *sgt)
for_each_sg(sgt->sgl, sg, sgt->nents, i) {
size_t bytes;

bytes = sg->length;
bytes = sg->length + sg->offset;

if (!iopgsz_ok(bytes)) {
pr_err("%s: sg[%d] not iommu pagesize(%x)\n",
__func__, i, bytes);
pr_err("%s: sg[%d] not iommu pagesize(%u %u)\n",
__func__, i, bytes, sg->offset);
return 0;
}

if (i && sg->offset) {
pr_err("%s: sg[%d] offset not allowed in internal "
"entries\n", __func__, i);
return 0;
}

Expand Down Expand Up @@ -164,8 +179,8 @@ static void *vmap_sg(const struct sg_table *sgt)
u32 pa;
int err;

pa = sg_phys(sg);
bytes = sg->length;
pa = sg_phys(sg) - sg->offset;
bytes = sg->length + sg->offset;

BUG_ON(bytes != PAGE_SIZE);

Expand Down Expand Up @@ -405,8 +420,8 @@ static int map_iovm_area(struct iommu_domain *domain, struct iovm_struct *new,
u32 pa;
size_t bytes;

pa = sg_phys(sg);
bytes = sg->length;
pa = sg_phys(sg) - sg->offset;
bytes = sg->length + sg->offset;

flags &= ~IOVMF_PGSZ_MASK;

Expand All @@ -432,7 +447,7 @@ static int map_iovm_area(struct iommu_domain *domain, struct iovm_struct *new,
for_each_sg(sgt->sgl, sg, i, j) {
size_t bytes;

bytes = sg->length;
bytes = sg->length + sg->offset;
order = get_order(bytes);

/* ignore failures.. we're already handling one */
Expand Down Expand Up @@ -461,7 +476,7 @@ static void unmap_iovm_area(struct iommu_domain *domain, struct omap_iommu *obj,
size_t bytes;
int order;

bytes = sg->length;
bytes = sg->length + sg->offset;
order = get_order(bytes);

err = iommu_unmap(domain, start, order);
Expand Down Expand Up @@ -600,7 +615,7 @@ u32 omap_iommu_vmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da,
if (IS_ERR_VALUE(da))
vunmap_sg(va);

return da;
return da + sgtable_offset(sgt);
}
EXPORT_SYMBOL_GPL(omap_iommu_vmap);

Expand All @@ -620,6 +635,7 @@ omap_iommu_vunmap(struct iommu_domain *domain, struct omap_iommu *obj, u32 da)
* 'sgt' is allocated before 'omap_iommu_vmalloc()' is called.
* Just returns 'sgt' to the caller to free
*/
da &= PAGE_MASK;
sgt = unmap_vm_area(domain, obj, da, vunmap_sg,
IOVMF_DISCONT | IOVMF_MMIO);
if (!sgt)
Expand Down

0 comments on commit 931affc

Please sign in to comment.