2 * SRAM allocator for Blackfin on-chip memory
4 * Copyright 2004-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #include <linux/module.h>
10 #include <linux/kernel.h>
11 #include <linux/types.h>
12 #include <linux/miscdevice.h>
13 #include <linux/ioport.h>
14 #include <linux/fcntl.h>
15 #include <linux/init.h>
16 #include <linux/poll.h>
17 #include <linux/proc_fs.h>
18 #include <linux/seq_file.h>
19 #include <linux/spinlock.h>
20 #include <linux/rtc.h>
21 #include <linux/slab.h>
22 #include <linux/mm_types.h>
24 #include <asm/blackfin.h>
25 #include <asm/mem_map.h>
26 #include "blackfin_sram.h"
28 /* the data structure for L1 scratchpad and DATA SRAM */
33 struct sram_piece *next;
36 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1sram_lock);
37 static DEFINE_PER_CPU(struct sram_piece, free_l1_ssram_head);
38 static DEFINE_PER_CPU(struct sram_piece, used_l1_ssram_head);
40 #if L1_DATA_A_LENGTH != 0
41 static DEFINE_PER_CPU(struct sram_piece, free_l1_data_A_sram_head);
42 static DEFINE_PER_CPU(struct sram_piece, used_l1_data_A_sram_head);
45 #if L1_DATA_B_LENGTH != 0
46 static DEFINE_PER_CPU(struct sram_piece, free_l1_data_B_sram_head);
47 static DEFINE_PER_CPU(struct sram_piece, used_l1_data_B_sram_head);
50 #if L1_DATA_A_LENGTH || L1_DATA_B_LENGTH
51 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_data_sram_lock);
54 #if L1_CODE_LENGTH != 0
55 static DEFINE_PER_CPU_SHARED_ALIGNED(spinlock_t, l1_inst_sram_lock);
56 static DEFINE_PER_CPU(struct sram_piece, free_l1_inst_sram_head);
57 static DEFINE_PER_CPU(struct sram_piece, used_l1_inst_sram_head);
61 static spinlock_t l2_sram_lock ____cacheline_aligned_in_smp;
62 static struct sram_piece free_l2_sram_head, used_l2_sram_head;
65 static struct kmem_cache *sram_piece_cache;
67 /* L1 Scratchpad SRAM initialization function */
68 static void __init l1sram_init(void)
71 unsigned long reserve;
76 reserve = sizeof(struct l1_scratch_task_info);
79 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
80 per_cpu(free_l1_ssram_head, cpu).next =
81 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
82 if (!per_cpu(free_l1_ssram_head, cpu).next) {
83 printk(KERN_INFO "Fail to initialize Scratchpad data SRAM.\n");
87 per_cpu(free_l1_ssram_head, cpu).next->paddr = (void *)get_l1_scratch_start_cpu(cpu) + reserve;
88 per_cpu(free_l1_ssram_head, cpu).next->size = L1_SCRATCH_LENGTH - reserve;
89 per_cpu(free_l1_ssram_head, cpu).next->pid = 0;
90 per_cpu(free_l1_ssram_head, cpu).next->next = NULL;
92 per_cpu(used_l1_ssram_head, cpu).next = NULL;
94 /* mutex initialize */
95 spin_lock_init(&per_cpu(l1sram_lock, cpu));
96 printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n",
97 L1_SCRATCH_LENGTH >> 10);
101 static void __init l1_data_sram_init(void)
103 #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0
106 #if L1_DATA_A_LENGTH != 0
107 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
108 per_cpu(free_l1_data_A_sram_head, cpu).next =
109 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
110 if (!per_cpu(free_l1_data_A_sram_head, cpu).next) {
111 printk(KERN_INFO "Fail to initialize L1 Data A SRAM.\n");
115 per_cpu(free_l1_data_A_sram_head, cpu).next->paddr =
116 (void *)get_l1_data_a_start_cpu(cpu) + (_ebss_l1 - _sdata_l1);
117 per_cpu(free_l1_data_A_sram_head, cpu).next->size =
118 L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1);
119 per_cpu(free_l1_data_A_sram_head, cpu).next->pid = 0;
120 per_cpu(free_l1_data_A_sram_head, cpu).next->next = NULL;
122 per_cpu(used_l1_data_A_sram_head, cpu).next = NULL;
124 printk(KERN_INFO "Blackfin L1 Data A SRAM: %d KB (%d KB free)\n",
125 L1_DATA_A_LENGTH >> 10,
126 per_cpu(free_l1_data_A_sram_head, cpu).next->size >> 10);
129 #if L1_DATA_B_LENGTH != 0
130 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
131 per_cpu(free_l1_data_B_sram_head, cpu).next =
132 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
133 if (!per_cpu(free_l1_data_B_sram_head, cpu).next) {
134 printk(KERN_INFO "Fail to initialize L1 Data B SRAM.\n");
138 per_cpu(free_l1_data_B_sram_head, cpu).next->paddr =
139 (void *)get_l1_data_b_start_cpu(cpu) + (_ebss_b_l1 - _sdata_b_l1);
140 per_cpu(free_l1_data_B_sram_head, cpu).next->size =
141 L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1);
142 per_cpu(free_l1_data_B_sram_head, cpu).next->pid = 0;
143 per_cpu(free_l1_data_B_sram_head, cpu).next->next = NULL;
145 per_cpu(used_l1_data_B_sram_head, cpu).next = NULL;
147 printk(KERN_INFO "Blackfin L1 Data B SRAM: %d KB (%d KB free)\n",
148 L1_DATA_B_LENGTH >> 10,
149 per_cpu(free_l1_data_B_sram_head, cpu).next->size >> 10);
150 /* mutex initialize */
154 #if L1_DATA_A_LENGTH != 0 || L1_DATA_B_LENGTH != 0
155 for (cpu = 0; cpu < num_possible_cpus(); ++cpu)
156 spin_lock_init(&per_cpu(l1_data_sram_lock, cpu));
160 static void __init l1_inst_sram_init(void)
162 #if L1_CODE_LENGTH != 0
164 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
165 per_cpu(free_l1_inst_sram_head, cpu).next =
166 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
167 if (!per_cpu(free_l1_inst_sram_head, cpu).next) {
168 printk(KERN_INFO "Failed to initialize L1 Instruction SRAM\n");
172 per_cpu(free_l1_inst_sram_head, cpu).next->paddr =
173 (void *)get_l1_code_start_cpu(cpu) + (_etext_l1 - _stext_l1);
174 per_cpu(free_l1_inst_sram_head, cpu).next->size =
175 L1_CODE_LENGTH - (_etext_l1 - _stext_l1);
176 per_cpu(free_l1_inst_sram_head, cpu).next->pid = 0;
177 per_cpu(free_l1_inst_sram_head, cpu).next->next = NULL;
179 per_cpu(used_l1_inst_sram_head, cpu).next = NULL;
181 printk(KERN_INFO "Blackfin L1 Instruction SRAM: %d KB (%d KB free)\n",
182 L1_CODE_LENGTH >> 10,
183 per_cpu(free_l1_inst_sram_head, cpu).next->size >> 10);
185 /* mutex initialize */
186 spin_lock_init(&per_cpu(l1_inst_sram_lock, cpu));
192 static irqreturn_t l2_ecc_err(int irq, void *dev_id)
196 printk(KERN_ERR "L2 ecc error happened\n");
197 status = bfin_read32(L2CTL0_STAT);
199 printk(KERN_ERR "Core channel error type:0x%x, addr:0x%x\n",
200 bfin_read32(L2CTL0_ET0), bfin_read32(L2CTL0_EADDR0));
202 printk(KERN_ERR "System channel error type:0x%x, addr:0x%x\n",
203 bfin_read32(L2CTL0_ET1), bfin_read32(L2CTL0_EADDR1));
205 status = status >> 8;
207 printk(KERN_ERR "L2 Bank%d error, addr:0x%x\n",
208 status, bfin_read32(L2CTL0_ERRADDR0 + status));
210 panic("L2 Ecc error");
215 static void __init l2_sram_init(void)
222 ret = request_irq(IRQ_L2CTL0_ECC_ERR, l2_ecc_err, 0, "l2-ecc-err",
224 if (unlikely(ret < 0)) {
225 printk(KERN_INFO "Fail to request l2 ecc error interrupt");
230 free_l2_sram_head.next =
231 kmem_cache_alloc(sram_piece_cache, GFP_KERNEL);
232 if (!free_l2_sram_head.next) {
233 printk(KERN_INFO "Fail to initialize L2 SRAM.\n");
237 free_l2_sram_head.next->paddr =
238 (void *)L2_START + (_ebss_l2 - _stext_l2);
239 free_l2_sram_head.next->size =
240 L2_LENGTH - (_ebss_l2 - _stext_l2);
241 free_l2_sram_head.next->pid = 0;
242 free_l2_sram_head.next->next = NULL;
244 used_l2_sram_head.next = NULL;
246 printk(KERN_INFO "Blackfin L2 SRAM: %d KB (%d KB free)\n",
248 free_l2_sram_head.next->size >> 10);
250 /* mutex initialize */
251 spin_lock_init(&l2_sram_lock);
255 static int __init bfin_sram_init(void)
257 sram_piece_cache = kmem_cache_create("sram_piece_cache",
258 sizeof(struct sram_piece),
259 0, SLAB_PANIC, NULL);
268 pure_initcall(bfin_sram_init);
270 /* SRAM allocate function */
271 static void *_sram_alloc(size_t size, struct sram_piece *pfree_head,
272 struct sram_piece *pused_head)
274 struct sram_piece *pslot, *plast, *pavail;
276 if (size <= 0 || !pfree_head || !pused_head)
280 size = (size + 3) & ~3;
282 pslot = pfree_head->next;
285 /* search an available piece slot */
286 while (pslot != NULL && size > pslot->size) {
294 if (pslot->size == size) {
295 plast->next = pslot->next;
298 /* use atomic so our L1 allocator can be used atomically */
299 pavail = kmem_cache_alloc(sram_piece_cache, GFP_ATOMIC);
304 pavail->paddr = pslot->paddr;
306 pslot->paddr += size;
310 pavail->pid = current->pid;
312 pslot = pused_head->next;
315 /* insert new piece into used piece list !!! */
316 while (pslot != NULL && pavail->paddr < pslot->paddr) {
321 pavail->next = pslot;
322 plast->next = pavail;
324 return pavail->paddr;
327 /* Allocate the largest available block. */
328 static void *_sram_alloc_max(struct sram_piece *pfree_head,
329 struct sram_piece *pused_head,
330 unsigned long *psize)
332 struct sram_piece *pslot, *pmax;
334 if (!pfree_head || !pused_head)
337 pmax = pslot = pfree_head->next;
339 /* search an available piece slot */
340 while (pslot != NULL) {
341 if (pslot->size > pmax->size)
351 return _sram_alloc(*psize, pfree_head, pused_head);
354 /* SRAM free function */
355 static int _sram_free(const void *addr,
356 struct sram_piece *pfree_head,
357 struct sram_piece *pused_head)
359 struct sram_piece *pslot, *plast, *pavail;
361 if (!pfree_head || !pused_head)
364 /* search the relevant memory slot */
365 pslot = pused_head->next;
368 /* search an available piece slot */
369 while (pslot != NULL && pslot->paddr != addr) {
377 plast->next = pslot->next;
381 /* insert free pieces back to the free list */
382 pslot = pfree_head->next;
385 while (pslot != NULL && addr > pslot->paddr) {
390 if (plast != pfree_head && plast->paddr + plast->size == pavail->paddr) {
391 plast->size += pavail->size;
392 kmem_cache_free(sram_piece_cache, pavail);
394 pavail->next = plast->next;
395 plast->next = pavail;
399 if (pslot && plast->paddr + plast->size == pslot->paddr) {
400 plast->size += pslot->size;
401 plast->next = pslot->next;
402 kmem_cache_free(sram_piece_cache, pslot);
408 int sram_free(const void *addr)
411 #if L1_CODE_LENGTH != 0
412 if (addr >= (void *)get_l1_code_start()
413 && addr < (void *)(get_l1_code_start() + L1_CODE_LENGTH))
414 return l1_inst_sram_free(addr);
417 #if L1_DATA_A_LENGTH != 0
418 if (addr >= (void *)get_l1_data_a_start()
419 && addr < (void *)(get_l1_data_a_start() + L1_DATA_A_LENGTH))
420 return l1_data_A_sram_free(addr);
423 #if L1_DATA_B_LENGTH != 0
424 if (addr >= (void *)get_l1_data_b_start()
425 && addr < (void *)(get_l1_data_b_start() + L1_DATA_B_LENGTH))
426 return l1_data_B_sram_free(addr);
430 if (addr >= (void *)L2_START
431 && addr < (void *)(L2_START + L2_LENGTH))
432 return l2_sram_free(addr);
437 EXPORT_SYMBOL(sram_free);
439 void *l1_data_A_sram_alloc(size_t size)
441 #if L1_DATA_A_LENGTH != 0
446 cpu = smp_processor_id();
447 /* add mutex operation */
448 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
450 addr = _sram_alloc(size, &per_cpu(free_l1_data_A_sram_head, cpu),
451 &per_cpu(used_l1_data_A_sram_head, cpu));
453 /* add mutex operation */
454 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
456 pr_debug("Allocated address in l1_data_A_sram_alloc is 0x%lx+0x%lx\n",
457 (long unsigned int)addr, size);
464 EXPORT_SYMBOL(l1_data_A_sram_alloc);
466 int l1_data_A_sram_free(const void *addr)
468 #if L1_DATA_A_LENGTH != 0
473 cpu = smp_processor_id();
474 /* add mutex operation */
475 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
477 ret = _sram_free(addr, &per_cpu(free_l1_data_A_sram_head, cpu),
478 &per_cpu(used_l1_data_A_sram_head, cpu));
480 /* add mutex operation */
481 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
488 EXPORT_SYMBOL(l1_data_A_sram_free);
490 void *l1_data_B_sram_alloc(size_t size)
492 #if L1_DATA_B_LENGTH != 0
497 cpu = smp_processor_id();
498 /* add mutex operation */
499 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
501 addr = _sram_alloc(size, &per_cpu(free_l1_data_B_sram_head, cpu),
502 &per_cpu(used_l1_data_B_sram_head, cpu));
504 /* add mutex operation */
505 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
507 pr_debug("Allocated address in l1_data_B_sram_alloc is 0x%lx+0x%lx\n",
508 (long unsigned int)addr, size);
515 EXPORT_SYMBOL(l1_data_B_sram_alloc);
517 int l1_data_B_sram_free(const void *addr)
519 #if L1_DATA_B_LENGTH != 0
524 cpu = smp_processor_id();
525 /* add mutex operation */
526 spin_lock_irqsave(&per_cpu(l1_data_sram_lock, cpu), flags);
528 ret = _sram_free(addr, &per_cpu(free_l1_data_B_sram_head, cpu),
529 &per_cpu(used_l1_data_B_sram_head, cpu));
531 /* add mutex operation */
532 spin_unlock_irqrestore(&per_cpu(l1_data_sram_lock, cpu), flags);
539 EXPORT_SYMBOL(l1_data_B_sram_free);
541 void *l1_data_sram_alloc(size_t size)
543 void *addr = l1_data_A_sram_alloc(size);
546 addr = l1_data_B_sram_alloc(size);
550 EXPORT_SYMBOL(l1_data_sram_alloc);
552 void *l1_data_sram_zalloc(size_t size)
554 void *addr = l1_data_sram_alloc(size);
557 memset(addr, 0x00, size);
561 EXPORT_SYMBOL(l1_data_sram_zalloc);
563 int l1_data_sram_free(const void *addr)
566 ret = l1_data_A_sram_free(addr);
568 ret = l1_data_B_sram_free(addr);
571 EXPORT_SYMBOL(l1_data_sram_free);
573 void *l1_inst_sram_alloc(size_t size)
575 #if L1_CODE_LENGTH != 0
580 cpu = smp_processor_id();
581 /* add mutex operation */
582 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags);
584 addr = _sram_alloc(size, &per_cpu(free_l1_inst_sram_head, cpu),
585 &per_cpu(used_l1_inst_sram_head, cpu));
587 /* add mutex operation */
588 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags);
590 pr_debug("Allocated address in l1_inst_sram_alloc is 0x%lx+0x%lx\n",
591 (long unsigned int)addr, size);
598 EXPORT_SYMBOL(l1_inst_sram_alloc);
600 int l1_inst_sram_free(const void *addr)
602 #if L1_CODE_LENGTH != 0
607 cpu = smp_processor_id();
608 /* add mutex operation */
609 spin_lock_irqsave(&per_cpu(l1_inst_sram_lock, cpu), flags);
611 ret = _sram_free(addr, &per_cpu(free_l1_inst_sram_head, cpu),
612 &per_cpu(used_l1_inst_sram_head, cpu));
614 /* add mutex operation */
615 spin_unlock_irqrestore(&per_cpu(l1_inst_sram_lock, cpu), flags);
622 EXPORT_SYMBOL(l1_inst_sram_free);
624 /* L1 Scratchpad memory allocate function */
625 void *l1sram_alloc(size_t size)
631 cpu = smp_processor_id();
632 /* add mutex operation */
633 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
635 addr = _sram_alloc(size, &per_cpu(free_l1_ssram_head, cpu),
636 &per_cpu(used_l1_ssram_head, cpu));
638 /* add mutex operation */
639 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
644 /* L1 Scratchpad memory allocate function */
645 void *l1sram_alloc_max(size_t *psize)
651 cpu = smp_processor_id();
652 /* add mutex operation */
653 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
655 addr = _sram_alloc_max(&per_cpu(free_l1_ssram_head, cpu),
656 &per_cpu(used_l1_ssram_head, cpu), psize);
658 /* add mutex operation */
659 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
664 /* L1 Scratchpad memory free function */
665 int l1sram_free(const void *addr)
671 cpu = smp_processor_id();
672 /* add mutex operation */
673 spin_lock_irqsave(&per_cpu(l1sram_lock, cpu), flags);
675 ret = _sram_free(addr, &per_cpu(free_l1_ssram_head, cpu),
676 &per_cpu(used_l1_ssram_head, cpu));
678 /* add mutex operation */
679 spin_unlock_irqrestore(&per_cpu(l1sram_lock, cpu), flags);
684 void *l2_sram_alloc(size_t size)
690 /* add mutex operation */
691 spin_lock_irqsave(&l2_sram_lock, flags);
693 addr = _sram_alloc(size, &free_l2_sram_head,
696 /* add mutex operation */
697 spin_unlock_irqrestore(&l2_sram_lock, flags);
699 pr_debug("Allocated address in l2_sram_alloc is 0x%lx+0x%lx\n",
700 (long unsigned int)addr, size);
707 EXPORT_SYMBOL(l2_sram_alloc);
709 void *l2_sram_zalloc(size_t size)
711 void *addr = l2_sram_alloc(size);
714 memset(addr, 0x00, size);
718 EXPORT_SYMBOL(l2_sram_zalloc);
720 int l2_sram_free(const void *addr)
726 /* add mutex operation */
727 spin_lock_irqsave(&l2_sram_lock, flags);
729 ret = _sram_free(addr, &free_l2_sram_head,
732 /* add mutex operation */
733 spin_unlock_irqrestore(&l2_sram_lock, flags);
740 EXPORT_SYMBOL(l2_sram_free);
742 int sram_free_with_lsl(const void *addr)
744 struct sram_list_struct *lsl, **tmp;
745 struct mm_struct *mm = current->mm;
748 for (tmp = &mm->context.sram_list; *tmp; tmp = &(*tmp)->next)
749 if ((*tmp)->addr == addr) {
751 ret = sram_free(addr);
759 EXPORT_SYMBOL(sram_free_with_lsl);
761 /* Allocate memory and keep in L1 SRAM List (lsl) so that the resources are
762 * tracked. These are designed for userspace so that when a process exits,
763 * we can safely reap their resources.
765 void *sram_alloc_with_lsl(size_t size, unsigned long flags)
768 struct sram_list_struct *lsl = NULL;
769 struct mm_struct *mm = current->mm;
771 lsl = kzalloc(sizeof(struct sram_list_struct), GFP_KERNEL);
775 if (flags & L1_INST_SRAM)
776 addr = l1_inst_sram_alloc(size);
778 if (addr == NULL && (flags & L1_DATA_A_SRAM))
779 addr = l1_data_A_sram_alloc(size);
781 if (addr == NULL && (flags & L1_DATA_B_SRAM))
782 addr = l1_data_B_sram_alloc(size);
784 if (addr == NULL && (flags & L2_SRAM))
785 addr = l2_sram_alloc(size);
793 lsl->next = mm->context.sram_list;
794 mm->context.sram_list = lsl;
797 EXPORT_SYMBOL(sram_alloc_with_lsl);
799 #ifdef CONFIG_PROC_FS
800 /* Once we get a real allocator, we'll throw all of this away.
801 * Until then, we need some sort of visibility into the L1 alloc.
803 /* Need to keep line of output the same. Currently, that is 44 bytes
804 * (including newline).
806 static int _sram_proc_show(struct seq_file *m, const char *desc,
807 struct sram_piece *pfree_head,
808 struct sram_piece *pused_head)
810 struct sram_piece *pslot;
812 if (!pfree_head || !pused_head)
815 seq_printf(m, "--- SRAM %-14s Size PID State \n", desc);
817 /* search the relevant memory slot */
818 pslot = pused_head->next;
820 while (pslot != NULL) {
821 seq_printf(m, "%p-%p %10i %5i %-10s\n",
822 pslot->paddr, pslot->paddr + pslot->size,
823 pslot->size, pslot->pid, "ALLOCATED");
828 pslot = pfree_head->next;
830 while (pslot != NULL) {
831 seq_printf(m, "%p-%p %10i %5i %-10s\n",
832 pslot->paddr, pslot->paddr + pslot->size,
833 pslot->size, pslot->pid, "FREE");
840 static int sram_proc_show(struct seq_file *m, void *v)
844 for (cpu = 0; cpu < num_possible_cpus(); ++cpu) {
845 if (_sram_proc_show(m, "Scratchpad",
846 &per_cpu(free_l1_ssram_head, cpu), &per_cpu(used_l1_ssram_head, cpu)))
848 #if L1_DATA_A_LENGTH != 0
849 if (_sram_proc_show(m, "L1 Data A",
850 &per_cpu(free_l1_data_A_sram_head, cpu),
851 &per_cpu(used_l1_data_A_sram_head, cpu)))
854 #if L1_DATA_B_LENGTH != 0
855 if (_sram_proc_show(m, "L1 Data B",
856 &per_cpu(free_l1_data_B_sram_head, cpu),
857 &per_cpu(used_l1_data_B_sram_head, cpu)))
860 #if L1_CODE_LENGTH != 0
861 if (_sram_proc_show(m, "L1 Instruction",
862 &per_cpu(free_l1_inst_sram_head, cpu),
863 &per_cpu(used_l1_inst_sram_head, cpu)))
868 if (_sram_proc_show(m, "L2", &free_l2_sram_head, &used_l2_sram_head))
875 static int sram_proc_open(struct inode *inode, struct file *file)
877 return single_open(file, sram_proc_show, NULL);
880 static const struct file_operations sram_proc_ops = {
881 .open = sram_proc_open,
884 .release = single_release,
887 static int __init sram_proc_init(void)
889 struct proc_dir_entry *ptr;
891 ptr = proc_create("sram", S_IRUGO, NULL, &sram_proc_ops);
893 printk(KERN_WARNING "unable to create /proc/sram\n");
898 late_initcall(sram_proc_init);