diff options
Diffstat (limited to 'arch/blackfin/mm/sram-alloc.c')
-rw-r--r-- | arch/blackfin/mm/sram-alloc.c | 339 |
1 files changed, 196 insertions, 143 deletions
diff --git a/arch/blackfin/mm/sram-alloc.c b/arch/blackfin/mm/sram-alloc.c index cc6f336e7313..834cab7438a8 100644 --- a/arch/blackfin/mm/sram-alloc.c +++ b/arch/blackfin/mm/sram-alloc.c | |||
@@ -39,10 +39,13 @@ | |||
39 | #include <linux/spinlock.h> | 39 | #include <linux/spinlock.h> |
40 | #include <linux/rtc.h> | 40 | #include <linux/rtc.h> |
41 | #include <asm/blackfin.h> | 41 | #include <asm/blackfin.h> |
42 | #include <asm/mem_map.h> | ||
42 | #include "blackfin_sram.h" | 43 | #include "blackfin_sram.h" |
43 | 44 | ||
44 | static spinlock_t l1sram_lock, l1_data_sram_lock, l1_inst_sram_lock; | 45 | static DEFINE_PER_CPU(spinlock_t, l1sram_lock) ____cacheline_aligned_in_smp; |
45 | static spinlock_t l2_sram_lock; | 46 | static DEFINE_PER_CPU(spinlock_t, l1_data_sram_lock) ____cacheline_aligned_in_smp; |
47 | static DEFINE_PER_CPU(spinlock_t, l1_inst_sram_lock) ____cacheline_aligned_in_smp; | ||
48 | static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp; | ||
46 | 49 | ||
47 | /* the data structure for L1 scratchpad and DATA SRAM */ | 50 | /* the data structure for L1 scratchpad and DATA SRAM */ |
48 | struct sram_piece { | 51 | struct sram_piece { |
@@ -52,18 +55,22 @@ struct sram_piece { | |||
52 | struct sram_piece *next; | 55 | struct sram_piece *next; |
53 | }; | 56 | }; |
54 | 57 | ||
55 | static struct sram_piece free_l1_ssram_head, used_l1_ssram_head; | 58 | static DEFINE_PER_CPU(struct sram_piece, free_l1_ssram_head); |
59 | static DEFINE_PER_CPU(struct sram_piece, used_l1_ssram_head); | ||
56 | 60 | ||
57 | #if L1_DATA_A_LENGTH != 0 | 61 | #if L1_DATA_A_LENGTH != 0 |
58 | static struct sram_piece free_l1_data_A_sram_head, used_l1_data_A_sram_head; | 62 | static DEFINE_PER_CPU(struct sram_piece, free_l1_data_A_sram_head); |
63 | static DEFINE_PER_CPU(struct sram_piece, used_l1_data_A_sram_head); | ||
59 | #endif | 64 | #endif |
60 | 65 | ||
61 | #if L1_DATA_B_LENGTH != 0 | 66 | #if L1_DATA_B_LENGTH != 0 |
62 | static struct sram_piece free_l1_data_B_sram_head, used_l1_data_B_sram_head; | 67 | static DEFINE_PER_CPU(struct sram_piece, free_l1_data_B_sram_head); |
68 | static DEFINE_PER_CPU(struct sram_piece, used_l1_data_B_sram_head); | ||
63 | #endif | 69 | #endif |
64 | 70 | ||
65 | #if L1_CODE_LENGTH != 0 | 71 | #if L1_CODE_LENGTH != 0 |
66 | static struct sram_piece free_l1_inst_sram_head, used_l1_inst_sram_head; | 72 | static DEFINE_PER_CPU(struct sram_piece, free_l1_inst_sram_head); |
73 | static DEFINE_PER_CPU(struct sram_piece, used_l1_inst_sram_head); | ||
67 | #endif | 74 | #endif |
68 | 75 | ||
69 | #if L2_LENGTH != 0 | 76 | #if L2_LENGTH != 0 |
@@ -75,102 +82,117 @@ static struct kmem_cache *sram_piece_cache; | |||
75 | /* L1 Scratchpad SRAM initialization function */ | 82 | /* L1 Scratchpad SRAM initialization function */ |
76 | static void __init l1sram_init(void) | 83 | static void __init l1sram_init(void) |
77 | { | 84 | { |
78 | free_l1_ssram_head.next = | 85 | unsigned int cpu; |
79 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); | 86 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { |
80 | if (!free_l1_ssram_head.next) { | 87 | per_cpu(free_l1_ssram_head, cpu).next = |
81 | printk(KERN_INFO "Failed to initialize Scratchpad data SRAM\n"); | 88 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); |
82 | return; | 89 | if (!per_cpu(free_l1_ssram_head, cpu).next) { |
90 | printk(KERN_INFO "Fail to initialize Scratchpad data SRAM.\n"); | ||
91 | return; | ||
92 | } | ||
93 | |||
94 | per_cpu(free_l1_ssram_head, cpu).next->paddr = (void *)get_l1_scratch_start_cpu(cpu); | ||
95 | per_cpu(free_l1_ssram_head, cpu).next->size = L1_SCRATCH_LENGTH; | ||
96 | per_cpu(free_l1_ssram_head, cpu).next->pid = 0; | ||
97 | per_cpu(free_l1_ssram_head, cpu).next->next = NULL; | ||
98 | |||
99 | per_cpu(used_l1_ssram_head, cpu).next = NULL; | ||
100 | |||
101 | /* mutex initialize */ | ||
102 | spin_lock_init(&per_cpu(l1sram_lock, cpu)); | ||
103 | printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n", | ||
104 | L1_SCRATCH_LENGTH >> 10); | ||
83 | } | 105 | } |
84 | |||
85 | free_l1_ssram_head.next->paddr = (void *)L1_SCRATCH_START; | ||
86 | free_l1_ssram_head.next->size = L1_SCRATCH_LENGTH; | ||
87 | free_l1_ssram_head.next->pid = 0; | ||
88 | free_l1_ssram_head.next->next = NULL; | ||
89 | |||
90 | used_l1_ssram_head.next = NULL; | ||
91 | |||
92 | /* mutex initialize */ | ||
93 | spin_lock_init(&l1sram_lock); | ||
94 | |||
95 | printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n", | ||
96 | L1_SCRATCH_LENGTH >> 10); | ||
97 | } | 106 | } |
98 | 107 | ||
99 | static void __init l1_data_sram_init(void) | 108 | static void __init l1_data_sram_init(void) |
100 | { | 109 | { |
110 | #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0 | ||
111 | unsigned int cpu; | ||
112 | #endif | ||
101 | #if L1_DATA_A_LENGTH != 0 | 113 | #if L1_DATA_A_LENGTH != 0 |
102 | free_l1_data_A_sram_head.next = | 114 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { |
103 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); | 115 | per_cpu(free_l1_data_A_sram_head, cpu).next = |
104 | if (!free_l1_data_A_sram_head.next) { | 116 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); |
105 | printk(KERN_INFO "Failed to initialize L1 Data A SRAM\n"); | 117 | if (!per_cpu(free_l1_data_A_sram_head, cpu).next) { |
106 | return; | 118 | printk(KERN_INFO "Fail to initialize L1 Data A SRAM.\n"); |
119 | return; | ||
120 | } | ||
121 | |||
122 | per_cpu(free_l1_data_A_sram_head, cpu).next->paddr = | ||
123 | (void *)get_l1_data_a_start_cpu(cpu) + (_ebss_l1 - _sdata_l1); | ||
124 | per_cpu(free_l1_data_A_sram_head, cpu).next->size = | ||
125 | L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1); | ||
126 | per_cpu(free_l1_data_A_sram_head, cpu).next->pid = 0; | ||
127 | per_cpu(free_l1_data_A_sram_head, cpu).next->next = NULL; | ||
128 | |||
129 | per_cpu(used_l1_data_A_sram_head, cpu).next = NULL; | ||
130 | |||
131 | printk(KERN_INFO "Blackfin L1 Data A SRAM: %d KB (%d KB free)\n", | ||
132 | L1_DATA_A_LENGTH >> 10, | ||
133 | per_cpu(free_l1_data_A_sram_head, cpu).next->size >> 10); | ||
107 | } | 134 | } |
108 | |||
109 | free_l1_data_A_sram_head.next->paddr = | ||
110 | (void *)L1_DATA_A_START + (_ebss_l1 - _sdata_l1); | ||
111 | free_l1_data_A_sram_head.next->size = | ||
112 | L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1); | ||
113 | free_l1_data_A_sram_head.next->pid = 0; | ||
114 | free_l1_data_A_sram_head.next->next = NULL; | ||
115 | |||
116 | used_l1_data_A_sram_head.next = NULL; | ||
117 | |||
118 | printk(KERN_INFO "Blackfin L1 Data A SRAM: %d KB (%d KB free)\n", | ||
119 | L1_DATA_A_LENGTH >> 10, | ||
120 | free_l1_data_A_sram_head.next->size >> 10); | ||
121 | #endif | 135 | #endif |
122 | #if L1_DATA_B_LENGTH != 0 | 136 | #if L1_DATA_B_LENGTH != 0 |
123 | free_l1_data_B_sram_head.next = | 137 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { |
124 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); | 138 | per_cpu(free_l1_data_B_sram_head, cpu).next = |
125 | if (!free_l1_data_B_sram_head.next) { | 139 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); |
126 | printk(KERN_INFO "Failed to initialize L1 Data B SRAM\n"); | 140 | if (!per_cpu(free_l1_data_B_sram_head, cpu).next) { |
127 | return; | 141 | printk(KERN_INFO "Fail to initialize L1 Data B SRAM.\n"); |
142 | return; | ||
143 | } | ||
144 | |||
145 | per_cpu(free_l1_data_B_sram_head, cpu).next->paddr = | ||
146 | (void *)get_l1_data_b_start_cpu(cpu) + (_ebss_b_l1 - _sdata_b_l1); | ||
147 | per_cpu(free_l1_data_B_sram_head, cpu).next->size = | ||
148 | L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1); | ||
149 | per_cpu(free_l1_data_B_sram_head, cpu).next->pid = 0; | ||
150 | per_cpu(free_l1_data_B_sram_head, cpu).next->next = NULL; | ||
151 | |||
152 | per_cpu(used_l1_data_B_sram_head, cpu).next = NULL; | ||
153 | |||
154 | printk(KERN_INFO "Blackfin L1 Data B SRAM: %d KB (%d KB free)\n", | ||
155 | L1_DATA_B_LENGTH >> 10, | ||
156 | per_cpu(free_l1_data_B_sram_head, cpu).next->size >> 10); | ||
157 | /* mutex initialize */ | ||
128 | } | 158 | } |
129 | |||
130 | free_l1_data_B_sram_head.next->paddr = | ||
131 | (void *)L1_DATA_B_START + (_ebss_b_l1 - _sdata_b_l1); | ||
132 | free_l1_data_B_sram_head.next->size = | ||
133 | L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1); | ||
134 | free_l1_data_B_sram_head.next->pid = 0; | ||
135 | free_l1_data_B_sram_head.next->next = NULL; | ||
136 | |||
137 | used_l1_data_B_sram_head.next = NULL; | ||
138 | |||
139 | printk(KERN_INFO "Blackfin L1 Data B SRAM: %d KB (%d KB free)\n", | ||
140 | L1_DATA_B_LENGTH >> 10, | ||
141 | free_l1_data_B_sram_head.next->size >> 10); | ||
142 | #endif | 159 | #endif |
143 | 160 | ||
144 | /* mutex initialize */ | 161 | #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0 |
145 | spin_lock_init(&l1_data_sram_lock); | 162 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) |
163 | spin_lock_init(&per_cpu(l1_data_sram_lock, cpu)); | ||
164 | #endif | ||
146 | } | 165 | } |
147 | 166 | ||
148 | static void __init l1_inst_sram_init(void) | 167 | static void __init l1_inst_sram_init(void) |
149 | { | 168 | { |
150 | #if L1_CODE_LENGTH != 0 | 169 | #if L1_CODE_LENGTH != 0 |
151 | free_l1_inst_sram_head.next = | 170 | unsigned int cpu; |
152 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); | 171 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { |
153 | if (!free_l1_inst_sram_head.next) { | 172 | per_cpu(free_l1_inst_sram_head, cpu).next = |
154 | printk(KERN_INFO "Failed to initialize L1 Instruction SRAM\n"); | 173 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); |
155 | return; | 174 | if (!per_cpu(free_l1_inst_sram_head, cpu).next) { |
175 | printk(KERN_INFO "Failed to initialize L1 Instruction SRAM\n"); | ||
176 | return; | ||
177 | } | ||
178 | |||
179 | per_cpu(free_l1_inst_sram_head, cpu).next->paddr = | ||
180 | (void *)get_l1_code_start_cpu(cpu) + (_etext_l1 - _stext_l1); | ||
181 | per_cpu(free_l1_inst_sram_head, cpu).next->size = | ||
182 | L1_CODE_LENGTH - (_etext_l1 - _stext_l1); | ||
183 | per_cpu(free_l1_inst_sram_head, cpu).next->pid = 0; | ||
184 | per_cpu(free_l1_inst_sram_head, cpu).next->next = NULL; | ||
185 | |||
186 | per_cpu(used_l1_inst_sram_head, cpu).next = NULL; | ||
187 | |||
188 | printk(KERN_INFO "Blackfin L1 Instruction SRAM: %d KB (%d KB free)\n", | ||
189 | L1_CODE_LENGTH >> 10, | ||
190 | per_cpu(free_l1_inst_sram_head, cpu).next->size >> 10); | ||
191 | |||
192 | /* mutex initialize */ | ||
193 | spin_lock_init(&per_cpu(l1_inst_sram_lock, cpu)); | ||
156 | } | 194 | } |
157 | |||
158 | free_l1_inst_sram_head.next->paddr = | ||
159 | (void *)L1_CODE_START + (_etext_l1 - _stext_l1); | ||
160 | free_l1_inst_sram_head.next->size = | ||
161 | L1_CODE_LENGTH - (_etext_l1 - _stext_l1); | ||
162 | free_l1_inst_sram_head.next->pid = 0; | ||
163 | free_l1_inst_sram_head.next->next = NULL; | ||
164 | |||
165 | used_l1_inst_sram_head.next = NULL; | ||
166 | |||
167 | printk(KERN_INFO "Blackfin L1 Instruction SRAM: %d KB (%d KB free)\n", | ||
168 | L1_CODE_LENGTH >> 10, | ||
169 | free_l1_inst_sram_head.next->size >> 10); | ||
170 | #endif | 195 | #endif |
171 | |||
172 | /* mutex initialize */ | ||
173 | spin_lock_init(&l1_inst_sram_lock); | ||
174 | } | 196 | } |
175 | 197 | ||
176 | static void __init l2_sram_init(void) | 198 | static void __init l2_sram_init(void) |
@@ -179,7 +201,7 @@ static void __init l2_sram_init(void) | |||
179 | free_l2_sram_head.next = | 201 | free_l2_sram_head.next = |
180 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); | 202 | kmem_cache_alloc(sram_piece_cache, GFP_KERNEL); |
181 | if (!free_l2_sram_head.next) { | 203 | if (!free_l2_sram_head.next) { |
182 | printk(KERN_INFO "Failed to initialize L2 SRAM\n"); | 204 | printk(KERN_INFO "Fail to initialize L2 SRAM.\n"); |
183 | return; | 205 | return; |
184 | } | 206 | } |
185 | 207 | ||
@@ -200,6 +222,7 @@ static void __init l2_sram_init(void) | |||
200 | /* mutex initialize */ | 222 | /* mutex initialize */ |
201 | spin_lock_init(&l2_sram_lock); | 223 | spin_lock_init(&l2_sram_lock); |
202 | } | 224 | } |
225 | |||
203 | void __init bfin_sram_init(void) | 226 | void __init bfin_sram_init(void) |
204 | { | 227 | { |
205 | sram_piece_cache = kmem_cache_create("sram_piece_cache", | 228 | sram_piece_cache = kmem_cache_create("sram_piece_cache", |
@@ -353,20 +376,20 @@ int sram_free(const void *addr) | |||
353 | { | 376 | { |
354 | 377 | ||
355 | #if L1_CODE_LENGTH != 0 | 378 | #if L1_CODE_LENGTH != 0 |
356 | if (addr >= (void *)L1_CODE_START | 379 | if (addr >= (void *)get_l1_code_start() |
357 | && addr < (void *)(L1_CODE_START + L1_CODE_LENGTH)) | 380 | && addr < (void *)(get_l1_code_start() + L1_CODE_LENGTH)) |
358 | return l1_inst_sram_free(addr); | 381 | return l1_inst_sram_free(addr); |
359 | else | 382 | else |
360 | #endif | 383 | #endif |
361 | #if L1_DATA_A_LENGTH != 0 | 384 | #if L1_DATA_A_LENGTH != 0 |
362 | if (addr >= (void *)L1_DATA_A_START | 385 | if (addr >= (void *)get_l1_data_a_start() |
363 | && addr < (void *)(L1_DATA_A_START + L1_DATA_A_LENGTH)) | 386 | && addr < (void *)(get_l1_data_a_start() + L1_DATA_A_LENGTH)) |
364 | return l1_data_A_sram_free(addr); | 387 | return l1_data_A_sram_free(addr); |
365 | else | 388 | else |
366 | #endif | 389 | #endif |
367 | #if L1_DATA_B_LENGTH != 0 | 390 | #if L1_DATA_B_LENGTH != 0 |
368 | if (addr >= (void *)L1_DATA_B_START | 391 | if (addr >= (void *)get_l1_data_b_start() |
369 | && addr < (void *)(L1_DATA_B_START + L1_DATA_B_LENGTH)) | 392 | && addr < (void *)(get_l1_data_b_start() + L1_DATA_B_LENGTH)) |
370 | return l1_data_B_sram_free(addr); | 393 | return l1_data_B_sram_free(addr); |
371 | else | 394 | else |
372 | #endif | 395 | #endif |
@@ -384,17 +407,20 @@ void *l1_data_A_sram_alloc(size_t size) | |||
384 | { | 407 | { |
385 | unsigned long flags; | 408 | unsigned long flags; |
386 | void *addr = NULL; | 409 | void *addr = NULL; |
410 | unsigned int cpu; | ||
387 | 411 | ||
412 | cpu = get_cpu(); | ||
388 | /* add mutex operation */ | 413 | /* add mutex operation */ |
389 | spin_lock_irqsave(&l1_data_sram_lock, flags); | 414 | spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); |
390 | 415 | ||
391 | #if L1_DATA_A_LENGTH != 0 | 416 | #if L1_DATA_A_LENGTH != 0 |
392 | addr = _sram_alloc(size, &free_l1_data_A_sram_head, | 417 | addr = _sram_alloc(size, &per_cpu(free_l1_data_A_sram_head, cpu), |
393 | &used_l1_data_A_sram_head); | 418 | &per_cpu(used_l1_data_A_sram_head, cpu)); |
394 | #endif | 419 | #endif |
395 | 420 | ||
396 | /* add mutex operation */ | 421 | /* add mutex operation */ |
397 | spin_unlock_irqrestore(&l1_data_sram_lock, flags); | 422 | spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); |
423 | put_cpu(); | ||
398 | 424 | ||
399 | pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n", | 425 | pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n", |
400 | (long unsigned int)addr, size); | 426 | (long unsigned int)addr, size); |
@@ -407,19 +433,22 @@ int l1_data_A_sram_free(const void *addr) | |||
407 | { | 433 | { |
408 | unsigned long flags; | 434 | unsigned long flags; |
409 | int ret; | 435 | int ret; |
436 | unsigned int cpu; | ||
410 | 437 | ||
438 | cpu = get_cpu(); | ||
411 | /* add mutex operation */ | 439 | /* add mutex operation */ |
412 | spin_lock_irqsave(&l1_data_sram_lock, flags); | 440 | spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); |
413 | 441 | ||
414 | #if L1_DATA_A_LENGTH != 0 | 442 | #if L1_DATA_A_LENGTH != 0 |
415 | ret = _sram_free(addr, &free_l1_data_A_sram_head, | 443 | ret = _sram_free(addr, &per_cpu(free_l1_data_A_sram_head, cpu), |
416 | &used_l1_data_A_sram_head); | 444 | &per_cpu(used_l1_data_A_sram_head, cpu)); |
417 | #else | 445 | #else |
418 | ret = -1; | 446 | ret = -1; |
419 | #endif | 447 | #endif |
420 | 448 | ||
421 | /* add mutex operation */ | 449 | /* add mutex operation */ |
422 | spin_unlock_irqrestore(&l1_data_sram_lock, flags); | 450 | spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); |
451 | put_cpu(); | ||
423 | 452 | ||
424 | return ret; | 453 | return ret; |
425 | } | 454 | } |
@@ -430,15 +459,18 @@ void *l1_data_B_sram_alloc(size_t size) | |||
430 | #if L1_DATA_B_LENGTH != 0 | 459 | #if L1_DATA_B_LENGTH != 0 |
431 | unsigned long flags; | 460 | unsigned long flags; |
432 | void *addr; | 461 | void *addr; |
462 | unsigned int cpu; | ||
433 | 463 | ||
464 | cpu = get_cpu(); | ||
434 | /* add mutex operation */ | 465 | /* add mutex operation */ |
435 | spin_lock_irqsave(&l1_data_sram_lock, flags); | 466 | spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); |
436 | 467 | ||
437 | addr = _sram_alloc(size, &free_l1_data_B_sram_head, | 468 | addr = _sram_alloc(size, &per_cpu(free_l1_data_B_sram_head, cpu), |
438 | &used_l1_data_B_sram_head); | 469 | &per_cpu(used_l1_data_B_sram_head, cpu)); |
439 | 470 | ||
440 | /* add mutex operation */ | 471 | /* add mutex operation */ |
441 | spin_unlock_irqrestore(&l1_data_sram_lock, flags); | 472 | spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); |
473 | put_cpu(); | ||
442 | 474 | ||
443 | pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n", | 475 | pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n", |
444 | (long unsigned int)addr, size); | 476 | (long unsigned int)addr, size); |
@@ -455,15 +487,18 @@ int l1_data_B_sram_free(const void *addr) | |||
455 | #if L1_DATA_B_LENGTH != 0 | 487 | #if L1_DATA_B_LENGTH != 0 |
456 | unsigned long flags; | 488 | unsigned long flags; |
457 | int ret; | 489 | int ret; |
490 | unsigned int cpu; | ||
458 | 491 | ||
492 | cpu = get_cpu(); | ||
459 | /* add mutex operation */ | 493 | /* add mutex operation */ |
460 | spin_lock_irqsave(&l1_data_sram_lock, flags); | 494 | spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags); |
461 | 495 | ||
462 | ret = _sram_free(addr, &free_l1_data_B_sram_head, | 496 | ret = _sram_free(addr, &per_cpu(free_l1_data_B_sram_head, cpu), |
463 | &used_l1_data_B_sram_head); | 497 | &per_cpu(used_l1_data_B_sram_head, cpu)); |
464 | 498 | ||
465 | /* add mutex operation */ | 499 | /* add mutex operation */ |
466 | spin_unlock_irqrestore(&l1_data_sram_lock, flags); | 500 | spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags); |
501 | put_cpu(); | ||
467 | 502 | ||
468 | return ret; | 503 | return ret; |
469 | #else | 504 | #else |
@@ -509,15 +544,18 @@ void *l1_inst_sram_alloc(size_t size) | |||
509 | #if L1_CODE_LENGTH != 0 | 544 | #if L1_CODE_LENGTH != 0 |
510 | unsigned long flags; | 545 | unsigned long flags; |
511 | void *addr; | 546 | void *addr; |
547 | unsigned int cpu; | ||
512 | 548 | ||
549 | cpu = get_cpu(); | ||
513 | /* add mutex operation */ | 550 | /* add mutex operation */ |
514 | spin_lock_irqsave(&l1_inst_sram_lock, flags); | 551 | spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags); |
515 | 552 | ||
516 | addr = _sram_alloc(size, &free_l1_inst_sram_head, | 553 | addr = _sram_alloc(size, &per_cpu(free_l1_inst_sram_head, cpu), |
517 | &used_l1_inst_sram_head); | 554 | &per_cpu(used_l1_inst_sram_head, cpu)); |
518 | 555 | ||
519 | /* add mutex operation */ | 556 | /* add mutex operation */ |
520 | spin_unlock_irqrestore(&l1_inst_sram_lock, flags); | 557 | spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags); |
558 | put_cpu(); | ||
521 | 559 | ||
522 | pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n", | 560 | pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n", |
523 | (long unsigned int)addr, size); | 561 | (long unsigned int)addr, size); |
@@ -534,15 +572,18 @@ int l1_inst_sram_free(const void *addr) | |||
534 | #if L1_CODE_LENGTH != 0 | 572 | #if L1_CODE_LENGTH != 0 |
535 | unsigned long flags; | 573 | unsigned long flags; |
536 | int ret; | 574 | int ret; |
575 | unsigned int cpu; | ||
537 | 576 | ||
577 | cpu = get_cpu(); | ||
538 | /* add mutex operation */ | 578 | /* add mutex operation */ |
539 | spin_lock_irqsave(&l1_inst_sram_lock, flags); | 579 | spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags); |
540 | 580 | ||
541 | ret = _sram_free(addr, &free_l1_inst_sram_head, | 581 | ret = _sram_free(addr, &per_cpu(free_l1_inst_sram_head, cpu), |
542 | &used_l1_inst_sram_head); | 582 | &per_cpu(used_l1_inst_sram_head, cpu)); |
543 | 583 | ||
544 | /* add mutex operation */ | 584 | /* add mutex operation */ |
545 | spin_unlock_irqrestore(&l1_inst_sram_lock, flags); | 585 | spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags); |
586 | put_cpu(); | ||
546 | 587 | ||
547 | return ret; | 588 | return ret; |
548 | #else | 589 | #else |
@@ -556,15 +597,18 @@ void *l1sram_alloc(size_t size) | |||
556 | { | 597 | { |
557 | unsigned long flags; | 598 | unsigned long flags; |
558 | void *addr; | 599 | void *addr; |
600 | unsigned int cpu; | ||
559 | 601 | ||
602 | cpu = get_cpu(); | ||
560 | /* add mutex operation */ | 603 | /* add mutex operation */ |
561 | spin_lock_irqsave(&l1sram_lock, flags); | 604 | spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); |
562 | 605 | ||
563 | addr = _sram_alloc(size, &free_l1_ssram_head, | 606 | addr = _sram_alloc(size, &per_cpu(free_l1_ssram_head, cpu), |
564 | &used_l1_ssram_head); | 607 | &per_cpu(used_l1_ssram_head, cpu)); |
565 | 608 | ||
566 | /* add mutex operation */ | 609 | /* add mutex operation */ |
567 | spin_unlock_irqrestore(&l1sram_lock, flags); | 610 | spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); |
611 | put_cpu(); | ||
568 | 612 | ||
569 | return addr; | 613 | return addr; |
570 | } | 614 | } |
@@ -574,15 +618,18 @@ void *l1sram_alloc_max(size_t *psize) | |||
574 | { | 618 | { |
575 | unsigned long flags; | 619 | unsigned long flags; |
576 | void *addr; | 620 | void *addr; |
621 | unsigned int cpu; | ||
577 | 622 | ||
623 | cpu = get_cpu(); | ||
578 | /* add mutex operation */ | 624 | /* add mutex operation */ |
579 | spin_lock_irqsave(&l1sram_lock, flags); | 625 | spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); |
580 | 626 | ||
581 | addr = _sram_alloc_max(&free_l1_ssram_head, | 627 | addr = _sram_alloc_max(&per_cpu(free_l1_ssram_head, cpu), |
582 | &used_l1_ssram_head, psize); | 628 | &per_cpu(used_l1_ssram_head, cpu), psize); |
583 | 629 | ||
584 | /* add mutex operation */ | 630 | /* add mutex operation */ |
585 | spin_unlock_irqrestore(&l1sram_lock, flags); | 631 | spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); |
632 | put_cpu(); | ||
586 | 633 | ||
587 | return addr; | 634 | return addr; |
588 | } | 635 | } |
@@ -592,15 +639,18 @@ int l1sram_free(const void *addr) | |||
592 | { | 639 | { |
593 | unsigned long flags; | 640 | unsigned long flags; |
594 | int ret; | 641 | int ret; |
642 | unsigned int cpu; | ||
595 | 643 | ||
644 | cpu = get_cpu(); | ||
596 | /* add mutex operation */ | 645 | /* add mutex operation */ |
597 | spin_lock_irqsave(&l1sram_lock, flags); | 646 | spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags); |
598 | 647 | ||
599 | ret = _sram_free(addr, &free_l1_ssram_head, | 648 | ret = _sram_free(addr, &per_cpu(free_l1_ssram_head, cpu), |
600 | &used_l1_ssram_head); | 649 | &per_cpu(used_l1_ssram_head, cpu)); |
601 | 650 | ||
602 | /* add mutex operation */ | 651 | /* add mutex operation */ |
603 | spin_unlock_irqrestore(&l1sram_lock, flags); | 652 | spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags); |
653 | put_cpu(); | ||
604 | 654 | ||
605 | return ret; | 655 | return ret; |
606 | } | 656 | } |
@@ -761,33 +811,36 @@ static int sram_proc_read(char *buf, char **start, off_t offset, int count, | |||
761 | int *eof, void *data) | 811 | int *eof, void *data) |
762 | { | 812 | { |
763 | int len = 0; | 813 | int len = 0; |
814 | unsigned int cpu; | ||
764 | 815 | ||
765 | if (_sram_proc_read(buf, &len, count, "Scratchpad", | 816 | for (cpu = 0; cpu < num_possible_cpus(); ++cpu) { |
766 | &free_l1_ssram_head, &used_l1_ssram_head)) | 817 | if (_sram_proc_read(buf, &len, count, "Scratchpad", |
767 | goto not_done; | 818 | &per_cpu(free_l1_ssram_head, cpu), &per_cpu(used_l1_ssram_head, cpu))) |
819 | goto not_done; | ||
768 | #if L1_DATA_A_LENGTH != 0 | 820 | #if L1_DATA_A_LENGTH != 0 |
769 | if (_sram_proc_read(buf, &len, count, "L1 Data A", | 821 | if (_sram_proc_read(buf, &len, count, "L1 Data A", |
770 | &free_l1_data_A_sram_head, | 822 | &per_cpu(free_l1_data_A_sram_head, cpu), |
771 | &used_l1_data_A_sram_head)) | 823 | &per_cpu(used_l1_data_A_sram_head, cpu))) |
772 | goto not_done; | 824 | goto not_done; |
773 | #endif | 825 | #endif |
774 | #if L1_DATA_B_LENGTH != 0 | 826 | #if L1_DATA_B_LENGTH != 0 |
775 | if (_sram_proc_read(buf, &len, count, "L1 Data B", | 827 | if (_sram_proc_read(buf, &len, count, "L1 Data B", |
776 | &free_l1_data_B_sram_head, | 828 | &per_cpu(free_l1_data_B_sram_head, cpu), |
777 | &used_l1_data_B_sram_head)) | 829 | &per_cpu(used_l1_data_B_sram_head, cpu))) |
778 | goto not_done; | 830 | goto not_done; |
779 | #endif | 831 | #endif |
780 | #if L1_CODE_LENGTH != 0 | 832 | #if L1_CODE_LENGTH != 0 |
781 | if (_sram_proc_read(buf, &len, count, "L1 Instruction", | 833 | if (_sram_proc_read(buf, &len, count, "L1 Instruction", |
782 | &free_l1_inst_sram_head, &used_l1_inst_sram_head)) | 834 | &per_cpu(free_l1_inst_sram_head, cpu), |
783 | goto not_done; | 835 | &per_cpu(used_l1_inst_sram_head, cpu))) |
836 | goto not_done; | ||
784 | #endif | 837 | #endif |
838 | } | ||
785 | #if L2_LENGTH != 0 | 839 | #if L2_LENGTH != 0 |
786 | if (_sram_proc_read(buf, &len, count, "L2", | 840 | if (_sram_proc_read(buf, &len, count, "L2", &free_l2_sram_head, |
787 | &free_l2_sram_head, &used_l2_sram_head)) | 841 | &used_l2_sram_head)) |
788 | goto not_done; | 842 | goto not_done; |
789 | #endif | 843 | #endif |
790 | |||
791 | *eof = 1; | 844 | *eof = 1; |
792 | not_done: | 845 | not_done: |
793 | return len; | 846 | return len; |