OMAP:iommu- add TLB preservation support
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Hari,
From: ext Hari Kanigeri <[email protected]>
Subject: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation support
Date: Fri, 23 Apr 2010 01:16:36 +0200
Quoted 4 lines
This patch adds TLB preservation support to IOMMU module
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Hiroshi Doyu <[email protected]>
The above should be "Acked-by:"?
BTW:
Now the code gets a bit complicated for tlb iteration. So what about introducing the following macro?
Not yet tested, though....
Quoted 1 line
From
a88de5ab41792b5a34c460741b8f75f1611327b9Mon Sep 17 00:00:00 2001
From: Hiroshi DOYU <[email protected]>
Date: Fri, 23 Apr 2010 15:18:46 +0300
Subject: [PATCH 1/1] omap iommu: introduce iteration macro for iotlb entries scan
There are some places to scan iotlb entries. This iteration macro could make these code a bit simpler.
--- arch/arm/plat-omap/iommu.c | 55 ++++++++++++++++++++++--------------------- 1 files changed, 28 insertions(+), 27 deletions(-)
arch/arm/plat-omap/iommu.c +28 -27
@@ -25,6 +25,9 @@#include "iopgtable.h" +#define for_each_iotlb_cr (obj, n, i, cr) \ + for (i = 0; (i < n) && (cr = get_iotlb_cr(obj, i)); i++) +/* accommodate the difference between omap1 and omap2/3 */ static const struct iommu_functions *arch_iommu;
@@ -211,6 +214,19 @@ static inline ssize_t iotlb_dump_cr(struct iommu *obj, struct cr_regs *cr,return arch_iommu->dump_cr (obj, cr, buf); } +static struct cr_regs get_iotlb_cr (struct iommu *obj,int n) +{ +struct cr_regs cr; +struct iotlb_lock l; + +iotlb_lock_get (obj, &l); + l.vict = n; +iotlb_lock_set (obj, &l); +iotlb_read_cr (obj, &cr); + +return cr; +} +/** * load_iotlb_entry - Set an iommu tlb entry * @obj: target iommu
@@ -218,7 +234,6 @@ static inline ssize_t iotlb_dump_cr(struct iommu *obj, struct cr_regs *cr,**/ int load_iotlb_entry (struct iommu *obj,struct iotlb_entry *e) { -int i;int err =0 ;struct iotlb_lock l;struct cr_regs *cr;
@@ -235,21 +250,20 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e) goto out; }if (!e->prsvd) { -for (i = l.base; i < obj->nr_tlb_entries; i++) { -struct cr_regs tmp; +int i; +struct cr_regs tmp; -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &tmp); +for_each_iotlb_cr (obj, obj->nr_tlb_entries, i, tmp)if (!iotlb_cr_valid (&tmp))break ; - } +if (i == obj->nr_tlb_entries) {dev_dbg (obj->dev,"%s: full: no entry\n" , __func__); err = -EBUSY ; goto out; } + +iotlb_lock_get (obj, &l); }else { l.vict = l.base;iotlb_lock_set (obj, &l);
@@ -285,20 +299,15 @@ EXPORT_SYMBOL_GPL(load_iotlb_entry);**/ void flush_iotlb_page (struct iommu *obj,u32 da) { -struct iotlb_lock l;int i; +struct cr_regs cr;clk_enable (obj->clk); -for (i =0 ; i < obj->nr_tlb_entries; i++) { -struct cr_regs cr; +for_each_iotlb_cr (obj, obj->nr_tlb_entries, i, cr) {u32 start;size_t bytes; -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &cr);if (!iotlb_cr_valid (&cr))continue ;
@@ -308,7 +317,6 @@ void flush_iotlb_page(struct iommu *obj, u32 da)if ((start <= da) && (da < start + bytes)) {dev_dbg (obj->dev,"%s: %08x<=%08x(%x)\n" , __func__, start, da, bytes); -iotlb_load_cr (obj, &cr);iommu_write_reg (obj,1 ,MMU_FLUSH_ENTRY ); } }
@@ -379,26 +387,19 @@ EXPORT_SYMBOL_GPL(iommu_dump_ctx);static int __dump_tlb_entries (struct iommu *obj,struct cr_regs *crs,int num) {int i; -struct iotlb_lock saved, l; +struct iotlb_lock saved; +struct cr_regs tmp;struct cr_regs *p = crs;clk_enable (obj->clk); -iotlb_lock_get (obj, &saved); -memcpy (&l, &saved,sizeof (saved)); -for (i =0 ; i < num; i++) { -struct cr_regs tmp; - -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &tmp); +for_each_iotlb_cr (obj, num, i, tmp) {if (!iotlb_cr_valid (&tmp))continue ; - *p++ = tmp; } +iotlb_lock_set (obj, &saved);clk_disable (obj->clk);
Signature · 1 line
1.7.1.rc1
Hi Hiroshi,
Quoted 13 lines
-----Original Message-----
From: Hiroshi DOYU [mailto:[email protected]]
Sent: Friday, April 23, 2010 7:34 AM
To: Kanigeri, Hari
Cc: Gupta, Ramesh; [email protected]
Subject: Re: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation supportHi Hari,
From: ext Hari Kanigeri <[email protected]>
Subject: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation support
Date: Fri, 23 Apr 2010 01:16:36 +0200
Quoted 6 lines
Quoted 4 lines
This patch adds TLB preservation support to IOMMU module
Signed-off-by Hari Kanigeri <[email protected]>Signed-off-by Hiroshi Doyu <[email protected]>The above should be "Acked-by:"?
-- By you :)
Quoted 6 lines
BTW:
Now the code gets a bit complicated for tlb iteration. So what about introducing the following macro?Not yet tested, though....
-- I like it. Let me test your changes, and will send a revised patch with these changes.
Hi Hiroshi,
arch/arm/plat-omap/iommu.c line 30
Quoted 12 lines
arch/arm/plat-omap/iommu.c +3
-0@@ -25,6 +25,9 @@#include "iopgtable.h" +#define for_each_iotlb_cr (obj, n, i, cr) \ + for (i = 0; (i < n) && (cr = get_iotlb_cr(obj, i)); i++) +
-- This code is giving compilation error.
Can you please send a new patch after fixing this on top of my patches.
Thank you,
Best regards,
Hari
From: "ext Kanigeri, Hari" <[email protected]>
Subject: RE: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation support
Date: Sat, 24 Apr 2010 01:43:19 +0200
Quoted 9 lines
Hi Hiroshi,
Quoted 7 lines
arch/arm/plat-omap/iommu.c +0
-0@@ -25,6 +25,9 @@
Quoted 6 lines
arch/arm/plat-omap/iommu.c line 30
Quoted 5 lines
arch/arm/plat-omap/iommu.c +3
-0#include "iopgtable.h" +#define for_each_iotlb_cr (obj, n, i, cr) \ + for (i = 0; (i < n) && (cr = get_iotlb_cr(obj, i)); i++) +-- This code is giving compilation error.
Should be like:
+#define for_each_iotlb_cr(obj, n, __i, cr) \
+ for (__i = 0; \
+ (__i < (n)) && (cr = __iotlb_read_cr((obj), __i), true); \
+ __i++)
+
Hi Hiroshi,
Quoted 29 lines
-----Original Message-----
From: Hiroshi DOYU [mailto:[email protected]]
Sent: Saturday, April 24, 2010 1:45 AM
To: Kanigeri, Hari
Cc: Gupta, Ramesh; [email protected]
Subject: Re: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation supportFrom: "ext Kanigeri, Hari" <[email protected]>
Subject: RE: [PATCH 4/4][v4] OMAP:iommu- add TLB preservation support
Date: Sat, 24 Apr 2010 01:43:19 +0200Quoted 9 lines
Hi Hiroshi,
Quoted 7 lines
arch/arm/plat-omap/iommu.c +0
-0@@ -25,6 +25,9 @@Quoted 6 lines
arch/arm/plat-omap/iommu.c line 30
Quoted 5 lines
arch/arm/plat-omap/iommu.c +3
-0#include "iopgtable.h" +#define for_each_iotlb_cr (obj, n, i, cr) \ + for (i = 0; (i < n) && (cr = get_iotlb_cr(obj, i)); i++) +-- This code is giving compilation error.
Should be like:
Review
Quoted 5 lines
(quoted diff) +5
-0+#define for_each_iotlb_cr(obj, n, __i, cr) \ + for (__i = 0; \ + (__i < (n)) && (cr = __iotlb_read_cr((obj), __i), true); \ + __i++) +
-- The change looks good to me.
Thank you,
Best regards,
Hari
PATCH 1/1 omap iommu: introduce iteration macro for iotlb entry scan
From: Hiroshi DOYU <[email protected]>
There are some places to scan iotlb entries. This iteration macro could make these code a bit simpler with proceeding iotlb entries transparently.
--- arch/arm/plat-omap/iommu.c | 58 +++++++++++++++++++++++-------------------- 1 files changed, 31 insertions(+), 27 deletions(-)
arch/arm/plat-omap/iommu.c +31 -27
@@ -24,6 +24,11 @@#include "iopgtable.h" +#define for_each_iotlb_cr (obj, n, __i, cr) \ + for (__i = 0; \ + (__i < (n)) && (cr = __iotlb_read_cr((obj), __i), true); \ + __i++) +/* accommodate the difference between omap1 and omap2/3 */ static const struct iommu_functions *arch_iommu;
@@ -210,6 +215,20 @@ static inline ssize_t iotlb_dump_cr(struct iommu *obj, struct cr_regs *cr,return arch_iommu->dump_cr (obj, cr, buf); } +/* only used in iotlb iteration for-loop */ +static struct cr_regs __iotlb_read_cr (struct iommu *obj,int n) +{ +struct cr_regs cr; +struct iotlb_lock l; + +iotlb_lock_get (obj, &l); + l.vict = n; +iotlb_lock_set (obj, &l); +iotlb_read_cr (obj, &cr); + +return cr; +} +/** * load_iotlb_entry - Set an iommu tlb entry * @obj: target iommu
@@ -217,7 +236,6 @@ static inline ssize_t iotlb_dump_cr(struct iommu *obj, struct cr_regs *cr,**/ int load_iotlb_entry (struct iommu *obj,struct iotlb_entry *e) { -int i;int err =0 ;struct iotlb_lock l;struct cr_regs *cr;
@@ -234,21 +252,20 @@ int load_iotlb_entry(struct iommu *obj, struct iotlb_entry *e) goto out; }if (!e->prsvd) { -for (i = l.base; i < obj->nr_tlb_entries; i++) { -struct cr_regs tmp; +int i; +struct cr_regs tmp; -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &tmp); +for_each_iotlb_cr (obj, obj->nr_tlb_entries, i, tmp)if (!iotlb_cr_valid (&tmp))break ; - } +if (i == obj->nr_tlb_entries) {dev_dbg (obj->dev,"%s: full: no entry\n" , __func__); err = -EBUSY ; goto out; } + +iotlb_lock_get (obj, &l); }else { l.vict = l.base;iotlb_lock_set (obj, &l);
@@ -284,20 +301,15 @@ EXPORT_SYMBOL_GPL(load_iotlb_entry);**/ void flush_iotlb_page (struct iommu *obj,u32 da) { -struct iotlb_lock l;int i; +struct cr_regs cr;clk_enable (obj->clk); -for (i =0 ; i < obj->nr_tlb_entries; i++) { -struct cr_regs cr; +for_each_iotlb_cr (obj, obj->nr_tlb_entries, i, cr) {u32 start;size_t bytes; -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &cr);if (!iotlb_cr_valid (&cr))continue ;
@@ -307,7 +319,6 @@ void flush_iotlb_page(struct iommu *obj, u32 da)if ((start <= da) && (da < start + bytes)) {dev_dbg (obj->dev,"%s: %08x<=%08x(%x)\n" , __func__, start, da, bytes); -iotlb_load_cr (obj, &cr);iommu_write_reg (obj,1 ,MMU_FLUSH_ENTRY ); } }
@@ -378,26 +389,19 @@ EXPORT_SYMBOL_GPL(iommu_dump_ctx);static int __dump_tlb_entries (struct iommu *obj,struct cr_regs *crs,int num) {int i; -struct iotlb_lock saved, l; +struct iotlb_lock saved; +struct cr_regs tmp;struct cr_regs *p = crs;clk_enable (obj->clk); -iotlb_lock_get (obj, &saved); -memcpy (&l, &saved,sizeof (saved)); -for (i =0 ; i < num; i++) { -struct cr_regs tmp; - -iotlb_lock_get (obj, &l); - l.vict = i; -iotlb_lock_set (obj, &l); -iotlb_read_cr (obj, &tmp); +for_each_iotlb_cr (obj, num, i, tmp) {if (!iotlb_cr_valid (&tmp))continue ; - *p++ = tmp; } +iotlb_lock_set (obj, &saved);clk_disable (obj->clk);
Signature · 1 line
1.7.1.rc1