diff options
Diffstat (limited to 'arch/arm/plat-omap/iovmm.c')
-rw-r--r-- | arch/arm/plat-omap/iovmm.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c index fa6e64332a9e..6dc1296c8c77 100644 --- a/arch/arm/plat-omap/iovmm.c +++ b/arch/arm/plat-omap/iovmm.c | |||
@@ -280,13 +280,14 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da, | |||
280 | alignement = PAGE_SIZE; | 280 | alignement = PAGE_SIZE; |
281 | 281 | ||
282 | if (flags & IOVMF_DA_ANON) { | 282 | if (flags & IOVMF_DA_ANON) { |
283 | /* | 283 | start = obj->da_start; |
284 | * Reserve the first page for NULL | 284 | |
285 | */ | ||
286 | start = PAGE_SIZE; | ||
287 | if (flags & IOVMF_LINEAR) | 285 | if (flags & IOVMF_LINEAR) |
288 | alignement = iopgsz_max(bytes); | 286 | alignement = iopgsz_max(bytes); |
289 | start = roundup(start, alignement); | 287 | start = roundup(start, alignement); |
288 | } else if (start < obj->da_start || start > obj->da_end || | ||
289 | obj->da_end - start < bytes) { | ||
290 | return ERR_PTR(-EINVAL); | ||
290 | } | 291 | } |
291 | 292 | ||
292 | tmp = NULL; | 293 | tmp = NULL; |
@@ -299,16 +300,16 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da, | |||
299 | if (prev_end > start) | 300 | if (prev_end > start) |
300 | break; | 301 | break; |
301 | 302 | ||
302 | if (start + bytes <= tmp->da_start) | 303 | if (tmp->da_start > start && (tmp->da_start - start) >= bytes) |
303 | goto found; | 304 | goto found; |
304 | 305 | ||
305 | if (flags & IOVMF_DA_ANON) | 306 | if (tmp->da_end >= start && flags & IOVMF_DA_ANON) |
306 | start = roundup(tmp->da_end + 1, alignement); | 307 | start = roundup(tmp->da_end + 1, alignement); |
307 | 308 | ||
308 | prev_end = tmp->da_end; | 309 | prev_end = tmp->da_end; |
309 | } | 310 | } |
310 | 311 | ||
311 | if ((start >= prev_end) && (ULONG_MAX - start + 1 >= bytes)) | 312 | if ((start >= prev_end) && (obj->da_end - start >= bytes)) |
312 | goto found; | 313 | goto found; |
313 | 314 | ||
314 | dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n", | 315 | dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n", |