Skip to contentSkip to conversation

iovmm: fixes for iovmm module

PATCH Superseded Fernando Guzman Lugo 5 participants 16 messages Oct 1, 2010 – Oct 4, 2010

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#2 lore raw

PATCH 2/4 iovmm: fix roundup for next area and end check for the last area

In reply to Fernando Guzman Lugo

As da_end does not belongs to the area the roundup should be done to da_end and not to da_end + 1.
Also the end check for the last area should be ULONG_MAX - start + 1 >= bytes.

---
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/plat-omap/iovmm.c +3 -3
index 24ca9c4..fc6b109 100644
@@ -289,19 +289,19 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 1, alignement);
+			start = roundup(tmp->da_end, alignement);
 
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 1 >= bytes))
 		goto found;
 
 	dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
Signature · 1 line
1.6.3.3
#3 lore raw

PATCH 3/4 iovmm: add superpages support to fixed da address

This patch adds superpages support to fixed ad address inside iommu_kmap function.

---
 arch/arm/plat-omap/iovmm.c |   61 ++++++++++++++++++++++++++-----------------
 1 files changed, 37 insertions(+), 24 deletions(-)
arch/arm/plat-omap/iovmm.c +37 -24
index fc6b109..e7ffec8 100644
@@ -87,27 +87,37 @@ static size_t sgtable_len(const struct sg_table *sgt)
 }
 #define sgtable_ok(x)	(!!sgtable_len(x))
 
+
+static unsigned max_alignment(u32 addr)
+{
+	int i;
+	unsigned pagesize[] = { SZ_16M, SZ_1M, SZ_64K, SZ_4K, };
+	for (i = 0; i < ARRAY_SIZE(pagesize) && addr & (pagesize[i] - 1); i++)
+		;
+	return (i < ARRAY_SIZE(pagesize)) ? pagesize[i] : 0;
+}
+
+
 /*
  * calculate the optimal number sg elements from total bytes based on
  * iommu superpages
  */
-static unsigned int sgtable_nents(size_t bytes)
+static unsigned int sgtable_nents(size_t bytes, u32 da, u32 pa)
 {
-	int i;
-	unsigned int nr_entries;
-	const unsigned long pagesize[] = { SZ_16M, SZ_1M, SZ_64K, SZ_4K, };
+	unsigned int nr_entries = 0, ent_sz;
 
 	if (!IS_ALIGNED(bytes, PAGE_SIZE)) {
 		pr_err("%s: wrong size %08x\n", __func__, bytes);
 		return 0;
 	}
 
-	nr_entries = 0;
-	for (i = 0; i < ARRAY_SIZE(pagesize); i++) {
-		if (bytes >= pagesize[i]) {
-			nr_entries += (bytes / pagesize[i]);
-			bytes %= pagesize[i];
-		}
+	while (bytes) {
+		ent_sz = max_alignment(da | pa);
+		ent_sz = min(ent_sz, (unsigned)iopgsz_max(bytes));
+		nr_entries++;
+		da += ent_sz;
+		pa += ent_sz;
+		bytes -= ent_sz;
 	}
 	BUG_ON(bytes);
 
@@ -115,7 +125,8 @@ static unsigned int sgtable_nents(size_t bytes)
 }
 
 /* allocate and initialize sg_table header(a kind of 'superblock') */
-static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags)
+static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags,
+							u32 da, u32 pa)
 {
 	unsigned int nr_entries;
 	int err;
@@ -127,9 +138,8 @@ static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags)
 	if (!IS_ALIGNED(bytes, PAGE_SIZE))
 		return ERR_PTR(-EINVAL);
 
-	/* FIXME: IOVMF_DA_FIXED should support 'superpages' */
-	if ((flags & IOVMF_LINEAR) && (flags & IOVMF_DA_ANON)) {
-		nr_entries = sgtable_nents(bytes);
+	if (flags & IOVMF_LINEAR) {
+		nr_entries = sgtable_nents(bytes, da, pa);
 		if (!nr_entries)
 			return ERR_PTR(-EINVAL);
 	} else
@@ -409,7 +419,8 @@ static inline void sgtable_drain_vmalloc(struct sg_table *sgt)
 	BUG_ON(!sgt);
 }
 
-static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
+static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, u32 da,
+								size_t len)
 {
 	unsigned int i;
 	struct scatterlist *sg;
@@ -420,7 +431,8 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
 	for_each_sg(sgt->sgl, sg, sgt->nents, i) {
 		size_t bytes;
 
-		bytes = iopgsz_max(len);
+		bytes = max_alignment(da | pa);
+		bytes = min(bytes, (size_t)iopgsz_max(len));
 
 		BUG_ON(!iopgsz_ok(bytes));
 
@@ -429,6 +441,7 @@ static void sgtable_fill_kmalloc(struct sg_table *sgt, u32 pa, size_t len)
 		 * 'pa' is cotinuous(linear).
 		 */
 		pa += bytes;
+		da += bytes;
 		len -= bytes;
 	}
 	BUG_ON(len);
@@ -695,18 +708,18 @@ u32 iommu_vmalloc(struct iommu *obj, u32 da, size_t bytes, u32 flags)
 	if (!va)
 		return -ENOMEM;
 
-	sgt = sgtable_alloc(bytes, flags);
+	flags &= IOVMF_HW_MASK;
+	flags |= IOVMF_DISCONT;
+	flags |= IOVMF_ALLOC;
+	flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
+
+	sgt = sgtable_alloc(bytes, flags, da, 0);
 	if (IS_ERR(sgt)) {
 		da = PTR_ERR(sgt);
 		goto err_sgt_alloc;
 	}
 	sgtable_fill_vmalloc(sgt, va);
 
-	flags &= IOVMF_HW_MASK;
-	flags |= IOVMF_DISCONT;
-	flags |= IOVMF_ALLOC;
-	flags |= (da ? IOVMF_DA_FIXED : IOVMF_DA_ANON);
-
 	da = __iommu_vmap(obj, da, sgt, va, bytes, flags);
 	if (IS_ERR_VALUE(da))
 		goto err_iommu_vmap;
@@ -746,11 +759,11 @@ static u32 __iommu_kmap(struct iommu *obj, u32 da, u32 pa, void *va,
 {
 	struct sg_table *sgt;
 
-	sgt = sgtable_alloc(bytes, flags);
+	sgt = sgtable_alloc(bytes, flags, da, pa);
 	if (IS_ERR(sgt))
 		return PTR_ERR(sgt);
 
-	sgtable_fill_kmalloc(sgt, pa, bytes);
+	sgtable_fill_kmalloc(sgt, pa, da, bytes);
 
 	da = map_iommu_region(obj, da, sgt, va, bytes, flags);
 	if (IS_ERR_VALUE(da)) {
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/4 iommu: remove CONFIG_MPU_BRIDGE_IOMMU

In reply to Fernando Guzman Lugo

remove CONFIG_MPU_BRIDGE_IOMMU in order to create iommu_device for iva2.

---
 arch/arm/mach-omap2/omap-iommu.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/omap-iommu.c +0 -2
index f5a1aad..bb8c01d 100644
@@ -35,7 +35,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "cam_ick",
 		},
 	},
-#if defined(CONFIG_MPU_BRIDGE_IOMMU)
 	{
 		.base = 0x5d000000,
 		.irq = 28,
@@ -45,7 +44,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "iva2_ck",
 		},
 	},
-#endif
 };
 #define NR_OMAP3_IOMMU_DEVICES ARRAY_SIZE(omap3_devices)
 static struct platform_device *omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
Signature · 1 line
1.6.3.3
#4 lore raw

PATCH 4/4 iovmm: replace __iounmap with omap_iounmap

In reply to Fernando Guzman Lugo

Omap platform is omap_iounmap function.

---
 arch/arm/plat-omap/iovmm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
 mode change 100644 => 100755 arch/arm/plat-omap/iovmm.c
arch/arm/plat-omap/iovmm.c +1 -1
old mode 100644
new mode 100755
index e7ffec8..326776d
@@ -824,7 +824,7 @@ void iommu_kunmap(struct iommu *obj, u32 da)
 	struct sg_table *sgt;
 	typedef void (*func_t)(const void *);
 
-	sgt = unmap_vm_area(obj, da, (func_t)__iounmap,
+	sgt = unmap_vm_area(obj, da, (func_t)omap_iounmap,
 			    IOVMF_LINEAR | IOVMF_MMIO);
 	if (!sgt)
 		dev_dbg(obj->dev, "%s: No sgt\n", __func__);
Signature · 1 line
1.6.3.3
#0 lore raw

cover iovmm: fixes for iovmm module

This patches are needed in order to tidspbridge can use iovmm with no issues.

Fernando Guzman Lugo (4):
iommu: remove CONFIG_MPU_BRIDGE_IOMMU
iovmm: fix roundup for next area and end check for the last area
iovmm: add superpages support to fixed da address
iovmm: replace __iounmap with omap_iounmap

 arch/arm/mach-omap2/omap-iommu.c |    2 -
 arch/arm/plat-omap/iovmm.c       |   69 ++++++++++++++++++++++---------------
 2 files changed, 41 insertions(+), 30 deletions(-)
 mode change 100644 => 100755 arch/arm/plat-omap/iovmm.c
#14 lore raw

RE: [PATCH 1/4] iommu: remove CONFIG_MPU_BRIDGE_IOMMU

In reply to Fernando Guzman Lugo
Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Guzman Lugo, Fernando
Sent: Friday, October 01, 2010 8:39 AM
To: [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Guzman Lugo, Fernando
Subject: [PATCH 1/4] iommu: remove CONFIG_MPU_BRIDGE_IOMMU

remove CONFIG_MPU_BRIDGE_IOMMU in order to create
iommu_device
for iva2.

---
 arch/arm/mach-omap2/omap-iommu.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/omap-iommu.c +0 -0

omap2/omap-iommu.c
index f5a1aad..bb8c01d 100644

arch/arm/mach-omap2/omap-iommu.c +0 -2
@@ -35,7 +35,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "cam_ick",
 		},
 	},
-#if defined(CONFIG_MPU_BRIDGE_IOMMU)
 	{
 		.base = 0x5d000000,
 		.irq = 28,
@@ -45,7 +44,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "iva2_ck",
 		},
 	},
-#endif
 };
 #define NR_OMAP3_IOMMU_DEVICES
 ARRAY_SIZE(omap3_devices)

static struct platform_device
*omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
--
1.6.3.3

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Fernando,

I have already submitted this patch and it is being discussed here.
http://www.mail-archive.com/[email protected]/msg35615.html

Regards,
Yogesh.

#5 lore raw

Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

In reply to Fernando Guzman Lugo

Hi,

Quoted 18 lines · ext Fernando Guzman Lugo

As da_end does not belongs to the area the roundup should be done to da_end and not to da_end + 1.
Also the end check for the last area should be ULONG_MAX - start + 1 >= bytes.

---
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/plat-omap/iovmm.c +0 -0
index 24ca9c4..fc6b109 100644
@@ -289,19 +289,19 @@ static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da, · line 299

Quoted 10 lines
arch/arm/plat-omap/iovmm.c +2 -2
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 1, alignement);
+			start = roundup(tmp->da_end, alignement);

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a valid area. Without this gap, such situation may produce data corruption which is much more difficult to track.

Br,

David

Quoted 17 lines
arch/arm/plat-omap/iovmm.c +1 -1
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 1 >= bytes))
 		goto found;
 
 	dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
Signature · 7 lines
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
#15 lore raw

RE: [PATCH 1/4] iommu: remove CONFIG_MPU_BRIDGE_IOMMU

In reply to Marathe, Yogesh

Hi Yogesh,

Quoted 56 lines

-----Original Message-----
From: Marathe, Yogesh
Sent: Friday, October 01, 2010 4:33 AM
To: Guzman Lugo, Fernando; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: RE: [PATCH 1/4] iommu: remove CONFIG_MPU_BRIDGE_IOMMU

Quoted 44 lines

-----Original Message-----
From: [email protected] [mailto:linux-omap- [email protected]] On Behalf Of Guzman Lugo, Fernando
Sent: Friday, October 01, 2010 8:39 AM
To: [email protected]
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Guzman Lugo, Fernando
Subject: [PATCH 1/4] iommu: remove CONFIG_MPU_BRIDGE_IOMMU

remove CONFIG_MPU_BRIDGE_IOMMU in order to create iommu_device for iva2.

---
 arch/arm/mach-omap2/omap-iommu.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-omap2/omap-iommu.c +0 -0

omap2/omap-iommu.c index f5a1aad..bb8c01d 100644

arch/arm/mach-omap2/omap-iommu.c +0 -2
@@ -35,7 +35,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "cam_ick",
 		},
 	},
-#if defined(CONFIG_MPU_BRIDGE_IOMMU)
 	{
 		.base = 0x5d000000,
 		.irq = 28,
@@ -45,7 +44,6 @@ static struct iommu_device omap3_devices[] = {
 			.clk_name = "iva2_ck",
 		},
 	},
-#endif
 };
 #define NR_OMAP3_IOMMU_DEVICES
 ARRAY_SIZE(omap3_devices)

static struct platform_device
*omap3_iommu_pdev[NR_OMAP3_IOMMU_DEVICES];
--
1.6.3.3

Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe

linux-omap"

Quoted 8 lines
Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 1 line

info at http://vger.kernel.org/majordomo-info.html

Fernando,

I have already submitted this patch and it is being discussed here.
http://www.mail-archive.com/[email protected]/msg35615.html

Thanks Yogesh I was not aware of that. So please discard this patch.

Regards,
Fernando.

Quoted 5 lines

Regards,
Yogesh.

#6 lore raw

RE: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

In reply to David Cohen
Quoted 46 lines

-----Original Message-----
From: David Cohen [mailto:[email protected]]
Sent: Friday, October 01, 2010 5:57 AM
To: Guzman Lugo, Fernando
Cc: Doyu Hiroshi (Nokia-MS/Espoo); Contreras Felipe (Nokia-MS/Helsinki); Palande Ameya (Nokia-MS/Helsinki); [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Hi,

Quoted 1 line · ext Fernando Guzman Lugo

As da_end does not belongs to the area the roundup should

be done to

Quoted 2 lines

da_end and not to da_end + 1.
Also the end check for the last area should be ULONG_MAX -

start + 1

Review

Quoted 8 lines
Quoted 1 line

= bytes.

---
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct 

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 10 lines
arch/arm/plat-omap/iovmm.c +1 -1
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
Quoted 9 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da, · line 299

Quoted 3 lines
arch/arm/plat-omap/iovmm.c +1 -1
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 1, alignement);
+			start = roundup(tmp->da_end, alignement);

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a valid area. Without this gap, such situation may produce data corruption which is much more difficult to track.

That only works when you are accessing sequencially beyond the End of the vm_area. However if you are accessing a random address Which is in the mmu tables you still can corrupt memory which does Not belong to you. That looks not very effective then why waste Memory?

Maybe other mechanism should be implemente like in the process Switching when if the process has DMM virtual memory area and if So enablig only that area (all other process areas will be Dissabled and it would get a mmufault in case of access). However That increase the time of switching between process.

Regards,
Fernando.

Quoted 23 lines

Br,

David

Quoted 17 lines
arch/arm/plat-omap/iovmm.c +1 -2
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 1 >= bytes))
 		goto found;
 
 	dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
--

1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#7 lore raw

Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Quoted 1 line · Fernando

[snip]

Quoted 30 lines
Quoted 20 lines

Review

Quoted 4 lines
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct 

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 10 lines
arch/arm/plat-omap/iovmm.c +1 -1
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
Quoted 9 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da, · line 299

Quoted 3 lines
arch/arm/plat-omap/iovmm.c +1 -1
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 1, alignement);
+			start = roundup(tmp->da_end, alignement);

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a valid area. Without this gap, such situation may produce data corruption which is much more difficult to track.

Quoted 5 lines

That only works when you are accessing sequencially beyond the End of the vm_area. However if you are accessing a random address Which is in the mmu tables you still can corrupt memory which does Not belong to you. That looks not very effective then why waste Memory?

The main intention is to detect sequential access beyond the end of the vm area and it is effective for that purpose.
i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the captured image, to write more data than it should. The workaround described in the errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make sure the new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

Quoted 6 lines

Maybe other mechanism should be implemente like in the process Switching when if the process has DMM virtual memory area and if So enablig only that area (all other process areas will be Dissabled and it would get a mmufault in case of access). However That increase the time of switching between process.

Sure. We can have other mechanisms. But in the above scenario, H3A submodule has sequential access and can corrupt its own data. It has more than one buffer and they're likely to be mapped to sequential memory areas without the mechanism you're about to remove.

If you're able to implement a better mechanism, please remove this one just when a new is already there. :)

Regards,

David

Quoted 27 lines

Regards,
Fernando.

Quoted 23 lines

Br,

David

Quoted 17 lines
arch/arm/plat-omap/iovmm.c +1 -2
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 1 >= bytes))
 		goto found;
 
 	dev_dbg(obj->dev, "%s: no space to fit %08x(%x) flags: %08x\n",
--

1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#8 lore raw

RE: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Quoted 61 lines

-----Original Message-----
From: David Cohen [mailto:[email protected]]
Sent: Friday, October 01, 2010 12:53 PM
To: Guzman Lugo, Fernando
Cc: Doyu Hiroshi (Nokia-MS/Espoo); Contreras Felipe (Nokia-MS/Helsinki); Palande Ameya (Nokia-MS/Helsinki); [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+			start = roundup(tmp->da_end, 

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

Quoted 11 lines

The main intention is to detect sequential access beyond the end of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the captured image, to write more data than it should. The workaround described in the errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make sure the new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look good to You?

Thnaks for the comments,
Fernando.

Quoted 53 lines
Quoted 4 lines

Maybe other mechanism should be implemente like in the process Switching when if the process has DMM virtual memory area and if So enablig only that area (all other process areas will be

Dissabled and

Quoted 1 line

it would get a mmufault in case of access). However That

increase the

Quoted 1 line

time of switching between process.

Sure. We can have other mechanisms. But in the above scenario, H3A submodule has sequential access and can corrupt its own data. It has more than one buffer and they're likely to be mapped to sequential memory areas without the mechanism you're about to remove.

If you're able to implement a better mechanism, please remove this one just when a new is already there. :)

Regards,

David

Quoted 7 lines

Regards,
Fernando.

Quoted 3 lines

Br,

Quoted 8 lines
Quoted 8 lines

David

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 6 lines
arch/arm/plat-omap/iovmm.c +1 -1
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 

1 >= bytes))

Quoted 3 lines
Quoted 3 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 3 lines
arch/arm/plat-omap/iovmm.c +0 -0
 		goto found;
 
 	dev_dbg(obj->dev, "%s: no space to fit %08x(%x) 

flags: %08x\n",

Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
arch/arm/plat-omap/iovmm.c +0 -1
--

1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw

Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Quoted 61 lines · Fernando
Quoted 49 lines
Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
 	prev_end = 0;
 	list_for_each_entry(tmp, &obj->mmap, list) {
 
-		if (prev_end >= start)
+		if (prev_end > start)
 			break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
 		if (start + bytes <= tmp->da_start)
 			goto found;
 
 		if (flags & IOVMF_DA_ANON)
-			start = roundup(tmp->da_end + 

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+			start = roundup(tmp->da_end, 

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

Quoted 11 lines

The main intention is to detect sequential access beyond the end of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the captured image, to write more data than it should. The workaround described in the errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make sure the new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

Quoted 3 lines

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look good to You?

Do you mean in this patch?
All changes make sense only if you're removing the gap, except for the fix below.

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 6 lines
arch/arm/plat-omap/iovmm.c +1 -1
 		prev_end = tmp->da_end;
 	}
 
-	if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+	if ((start >= prev_end) && (ULONG_MAX - start + 

1 >= bytes))

This fix is partially valid. The correct change must be only:
- if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+ if ((start > prev_end) && (ULONG_MAX - start + 1 >= bytes))

Otherwise you wouldn't guarantee the gap for fixed da.

Br,

David

#10 lore raw

RE: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Quoted 73 lines

________________________________________
From: David Cohen [[email protected]]
Sent: Saturday, October 02, 2010 2:49 AM
To: Guzman Lugo, Fernando
Cc: Doyu Hiroshi (Nokia-MS/Espoo); Contreras Felipe (Nokia-MS/Helsinki);
Palande Ameya (Nokia-MS/Helsinki); [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for
the last area

Quoted 61 lines · Fernando
Quoted 60 lines
Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines
 arch/arm/plat-omap/iovmm.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
      prev_end = 0;
      list_for_each_entry(tmp, &obj->mmap, list) {
 
-             if (prev_end >= start)
+             if (prev_end > start)
                      break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct *alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
              if (start + bytes <= tmp->da_start)
                      goto found;
 
              if (flags & IOVMF_DA_ANON)
-                     start = roundup(tmp->da_end +

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+                     start = roundup(tmp->da_end,

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

The main intention is to detect sequential access beyond the end of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the captured image, to write more data than it should. The workaround described in the errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make sure the new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

Quoted 7 lines
Quoted 3 lines

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look good to You?

Do you mean in this patch?
All changes make sense only if you're removing the gap, except for the fix below.

The thing is, the dspbridge needs to map some register in order to DSP can read and configure some of them. We need to map some pages with fix addresses and to do that I use iommu_kmap. So when some of that pages are contiguous I get his error:

"%s: no space to fit %08x(%x) flags: %08x\n"

Which is not true. The page to page perfectly fix, but the check with 1 byte more avoid that it could be mapped and I am getting the error.

I am not agree with the gap, but I am ok when it is not fixed address as below code

if (flags & IOVMF_DA_ANON)

        start = roundup(tmp->da_end + 1, alignement);

But it is breaking the tidspbridge when the gap is used for fixed addresses.

It should not fail when we want to map a page what is freed just because of the gap. Please let me know what you thing.

Thanks,
Fernando.

Quoted 20 lines

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

arch/arm/plat-omap/iovmm.c

Quoted 6 lines
              prev_end = tmp->da_end;
      }
arch/arm/plat-omap/iovmm.c +1 -1
-     if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+     if ((start >= prev_end) && (ULONG_MAX - start +

1 >= bytes))

This fix is partially valid. The correct change must be only:

(quoted diff) +1 -1
-       if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+       if ((start > prev_end) && (ULONG_MAX - start + 1 >= bytes))

Otherwise you wouldn't guarantee the gap for fixed da.

Br,

David

#11 lore raw

Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Hi,

I have no access to my @nokia.com e-mail at this moment, so I'm replying using my personal one.

Quoted 84 lines · Fernando
Quoted 63 lines · Fernando
Quoted 61 lines
Quoted 60 lines
Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines

 arch/arm/plat-omap/iovmm.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
       prev_end = 0;
       list_for_each_entry(tmp, &obj->mmap, list) {
 
-             if (prev_end >= start)
+             if (prev_end > start)
                       break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
               if (start + bytes <= tmp->da_start)
                       goto found;
 
               if (flags & IOVMF_DA_ANON)
-                     start = roundup(tmp->da_end +

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+                     start = roundup(tmp->da_end,

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

The main intention is to detect sequential access beyond the end of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the captured image, to write more data than it should. The workaround described in the errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make sure the new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

Quoted 7 lines
Quoted 3 lines

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look good to You?

Do you mean in this patch?
All changes make sense only if you're removing the gap, except for the fix below.

The thing is, the dspbridge needs to map some register in order to DSP can read and configure some of them. We need to map some pages with fix addresses and to do that I use iommu_kmap. So when some of that pages are contiguous I get his error:

"%s: no space to fit %08x(%x) flags: %08x\n"

Which is not true. The page to page perfectly fix, but the check with 1 byte more avoid that it could be mapped and I am getting the error.

I am not agree with the gap, but I am ok when it is not fixed address as below code

Quoted 7 lines

if (flags & IOVMF_DA_ANON)
       start = roundup(tmp->da_end + 1, alignement);

But it is breaking the tidspbridge when the gap is used for fixed addresses.

It should not fail when we want to map a page what is freed just because of the gap. Please let me know what you thing.

I got your point. I agree the gap shouldn't be forced for fixed da. IMO you can apply this change when !(flags & IOVMF_DA_ANON).

Regards,

David

Quoted 29 lines

Thanks,
Fernando.

Quoted 15 lines

[snip]

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

              prev_end = tmp->da_end;
      }

-     if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+     if ((start >= prev_end) && (ULONG_MAX - start +

1 >= bytes))

This fix is partially valid. The correct change must be only:
-       if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+       if ((start > prev_end) && (ULONG_MAX - start + 1 >= bytes))

Quoted 5 lines

Otherwise you wouldn't guarantee the gap for fixed da.

Br,

David

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#13 lore raw

Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

In reply to Guzman Lugo, Fernando
Quoted 130 lines · Fernando
Quoted 117 lines

-----Original Message-----
From: David Cohen [mailto:[email protected]]
Sent: Monday, October 04, 2010 7:11 AM
To: Guzman Lugo, Fernando
Cc: David Cohen; Doyu Hiroshi (Nokia-MS/Espoo); Contreras Felipe (Nokia-MS/Helsinki); Palande Ameya (Nokia-MS/Helsinki); [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Hi,

I have no access to my @nokia.com e-mail at this moment, so I'm replying using my personal one.

Quoted 2 lines · Fernando
Quoted 2 lines

On Fri, Oct 01, 2010 at 09:21:36PM +0200, ext Guzman Lugo,

Quoted 42 lines · Fernando
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines

 arch/arm/plat-omap/iovmm.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
       prev_end = 0;
       list_for_each_entry(tmp, &obj->mmap, list) {
 
-             if (prev_end >= start)
+             if (prev_end > start)
                       break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
               if (start + bytes <= tmp->da_start)
                       goto found;
 
               if (flags & IOVMF_DA_ANON)
-                     start = roundup(tmp->da_end +

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+                     start = roundup(tmp->da_end,

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

The main intention is to detect sequential access

beyond the end

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the

captured image, to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

write more data than it should. The workaround

described in the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make

sure the

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look

good to You?

Quoted 6 lines
Quoted 4 lines

Do you mean in this patch?
All changes make sense only if you're removing the gap, except for the fix below.

The thing is, the dspbridge needs to map some register in

order to DSP

Quoted 7 lines

can read and configure some of them. We need to map some pages with fix addresses and to do that I use iommu_kmap. So when some of that pages are contiguous I get his error:

"%s: no space to fit %08x(%x) flags: %08x\n"

Which is not true. The page to page perfectly fix, but the

check with

Quoted 1 line

1 byte more avoid that it could be mapped and I am getting

the error.

Quoted 2 lines

I am not agree with the gap, but I am ok when it is not

fixed address

Quoted 6 lines

as below code

if (flags & IOVMF_DA_ANON)
       start = roundup(tmp->da_end + 1, alignement);

But it is breaking the tidspbridge when the gap is used for

Quoted 8 lines

fixed addresses.

Quoted 2 lines

It should not fail when we want to map a page what is freed

just because of the gap.

Quoted 1 line

Please let me know what you thing.

I got your point. I agree the gap shouldn't be forced for fixed da. IMO you can apply this change when !(flags & IOVMF_DA_ANON).

As for not fixed address it always travers the list from the Beginning. The only change need to revert in my patch is when We roundup. That means keeping:

Quoted 5 lines

if (flags & IOVMF_DA_ANON)
       start = roundup(tmp->da_end + 1, alignement);

Is enough to create the gap for not fixed address. I will Update the patch and send them again.

Sounds fine for me. Please, update the patch and I'll ack it.

Br,

David

Quoted 42 lines

Thanks,
Fernando.

Quoted 38 lines

Regards,

David

Quoted 20 lines

Thanks,
Fernando.

Quoted 16 lines

[snip]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

              prev_end = tmp->da_end;
      }

-     if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+     if ((start >= prev_end) && (ULONG_MAX - start +

1 >= bytes))

This fix is partially valid. The correct change must be only:
-       if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+       if ((start > prev_end) && (ULONG_MAX - start + 1 >= bytes))

Quoted 7 lines
Quoted 5 lines

Otherwise you wouldn't guarantee the gap for fixed da.

Br,

David

--
To unsubscribe from this list: send the line "unsubscribe

linux-omap"

Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 2 lines

info at  http://vger.kernel.org/majordomo-info.html

#12 lore raw

RE: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

In reply to David Cohen
Quoted 117 lines

-----Original Message-----
From: David Cohen [mailto:[email protected]]
Sent: Monday, October 04, 2010 7:11 AM
To: Guzman Lugo, Fernando
Cc: David Cohen; Doyu Hiroshi (Nokia-MS/Espoo); Contreras Felipe (Nokia-MS/Helsinki); Palande Ameya (Nokia-MS/Helsinki); [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/4] iovmm: fix roundup for next area and end check for the last area

Hi,

I have no access to my @nokia.com e-mail at this moment, so I'm replying using my personal one.

Quoted 2 lines · Fernando
Quoted 2 lines

On Fri, Oct 01, 2010 at 09:21:36PM +0200, ext Guzman Lugo,

Quoted 42 lines · Fernando
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 1 line · Fernando

[snip]

Quoted 17 lines
Quoted 17 lines

Review

Quoted 4 lines

 arch/arm/plat-omap/iovmm.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/arch/arm/plat-omap/iovmm.c

arch/arm/plat-omap/iovmm.c static struct iovm_struct

Quoted 4 lines

index 24ca9c4..fc6b109 100644

arch/arm/plat-omap/iovmm.c +0 -0
@@ -289,19 +289,19 @@ static struct iovm_struct

*alloc_iovm_area(struct iommu *obj, u32 da,

Quoted 7 lines
arch/arm/plat-omap/iovmm.c +1 -1
       prev_end = 0;
       list_for_each_entry(tmp, &obj->mmap, list) {
 
-             if (prev_end >= start)
+             if (prev_end > start)
                       break;
 
Quoted 5 lines
Quoted 5 lines

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 5 lines
arch/arm/plat-omap/iovmm.c +0 -1
               if (start + bytes <= tmp->da_start)
                       goto found;
 
               if (flags & IOVMF_DA_ANON)
-                     start = roundup(tmp->da_end +

1, alignement);

Quoted 1 line
Quoted 1 line

arch/arm/plat-omap/iovmm.c static struct iovm_struct · line 299

Quoted 1 line
arch/arm/plat-omap/iovmm.c +1 -0
+                     start = roundup(tmp->da_end,

alignement);

Quoted 4 lines
Quoted 4 lines

There's a lack of comment here, but the purpose of tmp->da_end + 1 is to create a gap between iovm areas to force to trigger iommu faults when some access exceeds a

valid area.

Quoted 1 line
Quoted 1 line

Without this gap, such situation may produce data

corruption which

Quoted 3 lines
Quoted 1 line

is much more difficult to track.

That only works when you are accessing sequencially beyond

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

the End of

Quoted 1 line

the vm_area. However if you are accessing a random address

Which is in

Quoted 1 line

the mmu tables you still can corrupt memory which does Not

belong to

Quoted 1 line

you. That looks not very effective then why waste Memory?

The main intention is to detect sequential access

beyond the end

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

of the vm area and it is effective for that purpose. i.e., OMAP3 ISP has a hw issue which makes its H3A submodule, responsible to produce statistics data for the

captured image, to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

write more data than it should. The workaround

described in the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

errata wasn't enough to avoid error conditions, so a different approach was implemented. This gap did help me to make

sure the

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

new workaround is valid and no data corruption was occurring anymore.
Anyway, I can't see why memory is being wasted.

I was taking about vitual memory waste (maybe not so important). Is ok for me then keep the gap. Do other changes look

good to You?

Quoted 6 lines
Quoted 4 lines

Do you mean in this patch?
All changes make sense only if you're removing the gap, except for the fix below.

The thing is, the dspbridge needs to map some register in

order to DSP

Quoted 7 lines

can read and configure some of them. We need to map some pages with fix addresses and to do that I use iommu_kmap. So when some of that pages are contiguous I get his error:

"%s: no space to fit %08x(%x) flags: %08x\n"

Which is not true. The page to page perfectly fix, but the

check with

Quoted 1 line

1 byte more avoid that it could be mapped and I am getting

the error.

Quoted 2 lines

I am not agree with the gap, but I am ok when it is not

fixed address

Quoted 6 lines

as below code

if (flags & IOVMF_DA_ANON)
       start = roundup(tmp->da_end + 1, alignement);

But it is breaking the tidspbridge when the gap is used for

Quoted 8 lines

fixed addresses.

Quoted 2 lines

It should not fail when we want to map a page what is freed

just because of the gap.

Quoted 1 line

Please let me know what you thing.

I got your point. I agree the gap shouldn't be forced for fixed da. IMO you can apply this change when !(flags & IOVMF_DA_ANON).

As for not fixed address it always travers the list from the Beginning. The only change need to revert in my patch is when We roundup. That means keeping:

if (flags & IOVMF_DA_ANON)
       start = roundup(tmp->da_end + 1, alignement);

Is enough to create the gap for not fixed address. I will Update the patch and send them again.

Thanks,
Fernando.

Quoted 30 lines

Regards,

David

Quoted 25 lines

Thanks,
Fernando.

Quoted 21 lines

[snip]

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

              prev_end = tmp->da_end;
      }

-     if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+     if ((start >= prev_end) && (ULONG_MAX - start +

1 >= bytes))

This fix is partially valid. The correct change must be only:
-       if ((start > prev_end) && (ULONG_MAX - start >= bytes))
+       if ((start > prev_end) && (ULONG_MAX - start + 1 >= bytes))

Otherwise you wouldn't guarantee the gap for fixed da.

Br,

David

Quoted 8 lines
Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe

linux-omap"

Quoted 1 line

in the body of a message to [email protected] More

majordomo

Quoted 2 lines

info at  http://vger.kernel.org/majordomo-info.html

--

To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html