diff options
author | Bernd Schmidt <bernds_cb1@t-online.de> | 2009-01-07 10:14:38 -0500 |
---|---|---|
committer | Bryan Wu <cooloney@kernel.org> | 2009-01-07 10:14:38 -0500 |
commit | dbdf20db537a5369c65330f878ad4905020a8bfa (patch) | |
tree | c7fa553755e2d75a6e98d3f32fbe41fab9f72609 /arch/blackfin/kernel/cplbinfo.c | |
parent | 6651ece9e257302ee695ee76e69a4427f7033235 (diff) |
Blackfin arch: Faster C implementation of no-MPU CPLB handler
This is a mixture ofcMichael McTernan's patch and the existing cplb-mpu code.
We ditch the old cplb-nompu implementation, which is a good example of
why a good algorithm in a HLL is preferrable to a bad algorithm written in
assembly. Rather than try to construct a table of all posible CPLBs and
search it, we just create a (smaller) table of memory regions and
their attributes. Some of the data structures are now unified for both
the mpu and nompu cases. A lot of needless complexity in cplbinit.c is
removed.
Further optimizations:
* compile cplbmgr.c with a lot of -ffixed-reg options, and omit saving
these registers on the stack when entering a CPLB exception.
* lose cli/nop/nop/sti sequences for some workarounds - these don't
* make
sense in an exception context
Additional code unification should be possible after this.
[Mike Frysinger <vapier.adi@gmail.com>:
- convert CPP if statements to C if statements
- remove redundant statements
- use a do...while loop rather than a for loop to get slightly better
optimization and to avoid gcc "may be used uninitialized" warnings ...
we know that the [id]cplb_nr_bounds variables will never be 0, so this
is OK
- the no-mpu code was the last user of MAX_MEM_SIZE and with that rewritten,
we can punt it
- add some BUG_ON() checks to make sure we dont overflow the small
cplb_bounds array
- add i/d cplb entries for the bootrom because there is functions/data in
there we want to access
- we do not need a NULL trailing entry as any time we access the bounds
arrays, we use the nr_bounds variable
]
Signed-off-by: Michael McTernan <mmcternan@airvana.com>
Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bernd Schmidt <bernds_cb1@t-online.de>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/kernel/cplbinfo.c')
-rw-r--r-- | arch/blackfin/kernel/cplbinfo.c | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/arch/blackfin/kernel/cplbinfo.c b/arch/blackfin/kernel/cplbinfo.c index 1d3bbec1a195..64d78300dd08 100644 --- a/arch/blackfin/kernel/cplbinfo.c +++ b/arch/blackfin/kernel/cplbinfo.c | |||
@@ -20,8 +20,6 @@ static char const page_strtbl[][3] = { "1K", "4K", "1M", "4M" }; | |||
20 | #define page(flags) (((flags) & 0x30000) >> 16) | 20 | #define page(flags) (((flags) & 0x30000) >> 16) |
21 | #define strpage(flags) page_strtbl[page(flags)] | 21 | #define strpage(flags) page_strtbl[page(flags)] |
22 | 22 | ||
23 | #ifdef CONFIG_MPU | ||
24 | |||
25 | struct cplbinfo_data { | 23 | struct cplbinfo_data { |
26 | loff_t pos; | 24 | loff_t pos; |
27 | char cplb_type; | 25 | char cplb_type; |
@@ -75,88 +73,6 @@ static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) | |||
75 | } | 73 | } |
76 | } | 74 | } |
77 | 75 | ||
78 | #else | ||
79 | |||
80 | struct cplbinfo_data { | ||
81 | loff_t pos; | ||
82 | char cplb_type; | ||
83 | u32 mem_control; | ||
84 | unsigned long *pdt_tables, *pdt_swapcount; | ||
85 | unsigned long cplb_addr, cplb_data; | ||
86 | }; | ||
87 | |||
88 | extern int page_size_table[]; | ||
89 | |||
90 | static int cplb_find_entry(unsigned long addr_tbl, unsigned long data_tbl, | ||
91 | unsigned long addr_find, unsigned long data_find) | ||
92 | { | ||
93 | int i; | ||
94 | |||
95 | for (i = 0; i < 16; ++i) { | ||
96 | unsigned long cplb_addr = bfin_read32(addr_tbl + i * 4); | ||
97 | unsigned long cplb_data = bfin_read32(data_tbl + i * 4); | ||
98 | if (addr_find >= cplb_addr && | ||
99 | addr_find < cplb_addr + page_size_table[page(cplb_data)] && | ||
100 | cplb_data == data_find) | ||
101 | return i; | ||
102 | } | ||
103 | |||
104 | return -1; | ||
105 | } | ||
106 | |||
107 | static void cplbinfo_print_header(struct seq_file *m) | ||
108 | { | ||
109 | seq_printf(m, "Address\t\tData\tSize\tValid\tLocked\tSwapin\tiCount\toCount\n"); | ||
110 | } | ||
111 | |||
112 | static int cplbinfo_nomore(struct cplbinfo_data *cdata) | ||
113 | { | ||
114 | return cdata->pdt_tables[cdata->pos * 2] == 0xffffffff; | ||
115 | } | ||
116 | |||
117 | static int cplbinfo_show(struct seq_file *m, void *p) | ||
118 | { | ||
119 | struct cplbinfo_data *cdata; | ||
120 | unsigned long data, addr; | ||
121 | int entry; | ||
122 | loff_t pos; | ||
123 | |||
124 | cdata = p; | ||
125 | pos = cdata->pos * 2; | ||
126 | addr = cdata->pdt_tables[pos]; | ||
127 | data = cdata->pdt_tables[pos + 1]; | ||
128 | entry = cplb_find_entry(cdata->cplb_addr, cdata->cplb_data, addr, data); | ||
129 | |||
130 | seq_printf(m, | ||
131 | "0x%08lx\t0x%05lx\t%s\t%c\t%c\t%2d\t%ld\t%ld\n", | ||
132 | addr, data, strpage(data), | ||
133 | (data & CPLB_VALID) ? 'Y' : 'N', | ||
134 | (data & CPLB_LOCK) ? 'Y' : 'N', entry, | ||
135 | cdata->pdt_swapcount[pos], | ||
136 | cdata->pdt_swapcount[pos + 1]); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static void cplbinfo_seq_init(struct cplbinfo_data *cdata, unsigned int cpu) | ||
142 | { | ||
143 | if (cdata->cplb_type == 'I') { | ||
144 | cdata->mem_control = bfin_read_IMEM_CONTROL(); | ||
145 | cdata->pdt_tables = ipdt_tables[cpu]; | ||
146 | cdata->pdt_swapcount = ipdt_swapcount_tables[cpu]; | ||
147 | cdata->cplb_addr = ICPLB_ADDR0; | ||
148 | cdata->cplb_data = ICPLB_DATA0; | ||
149 | } else { | ||
150 | cdata->mem_control = bfin_read_DMEM_CONTROL(); | ||
151 | cdata->pdt_tables = dpdt_tables[cpu]; | ||
152 | cdata->pdt_swapcount = dpdt_swapcount_tables[cpu]; | ||
153 | cdata->cplb_addr = DCPLB_ADDR0; | ||
154 | cdata->cplb_data = DCPLB_DATA0; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | #endif | ||
159 | |||
160 | static void *cplbinfo_start(struct seq_file *m, loff_t *pos) | 76 | static void *cplbinfo_start(struct seq_file *m, loff_t *pos) |
161 | { | 77 | { |
162 | struct cplbinfo_data *cdata = m->private; | 78 | struct cplbinfo_data *cdata = m->private; |