aboutsummaryrefslogtreecommitdiff
path: root/arch/blackfin/mm/blackfin_sram.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/mm/blackfin_sram.c')
-rw-r--r--arch/blackfin/mm/blackfin_sram.c111
1 files changed, 90 insertions, 21 deletions
diff --git a/arch/blackfin/mm/blackfin_sram.c b/arch/blackfin/mm/blackfin_sram.c
index dd0c6501c42..68107924639 100644
--- a/arch/blackfin/mm/blackfin_sram.c
+++ b/arch/blackfin/mm/blackfin_sram.c
@@ -7,7 +7,7 @@
* Description: SRAM driver for Blackfin ADSP-BF5xx
*
* Modified:
- * Copyright 2004-2006 Analog Devices Inc.
+ * Copyright 2004-2007 Analog Devices Inc.
*
* Bugs: Enter bugs at http://blackfin.uclinux.org/
*
@@ -63,6 +63,7 @@ struct l1_sram_piece {
void *paddr;
int size;
int flag;
+ pid_t pid;
};
static struct l1_sram_piece l1_ssram[CONFIG_L1_MAX_PIECE];
@@ -80,7 +81,7 @@ static struct l1_sram_piece l1_inst_sram[CONFIG_L1_MAX_PIECE];
#endif
/* L1 Scratchpad SRAM initialization function */
-void l1sram_init(void)
+void __init l1sram_init(void)
{
printk(KERN_INFO "Blackfin Scratchpad data SRAM: %d KB\n",
L1_SCRATCH_LENGTH >> 10);
@@ -94,42 +95,43 @@ void l1sram_init(void)
spin_lock_init(&l1sram_lock);
}
-void l1_data_sram_init(void)
+void __init l1_data_sram_init(void)
{
#if L1_DATA_A_LENGTH != 0
- printk(KERN_INFO "Blackfin DATA_A SRAM: %d KB\n",
- L1_DATA_A_LENGTH >> 10);
-
memset(&l1_data_A_sram, 0x00, sizeof(l1_data_A_sram));
- l1_data_A_sram[0].paddr = (void*)L1_DATA_A_START +
- (_ebss_l1 - _sdata_l1);
+ l1_data_A_sram[0].paddr = (void *)L1_DATA_A_START +
+ (_ebss_l1 - _sdata_l1);
l1_data_A_sram[0].size = L1_DATA_A_LENGTH - (_ebss_l1 - _sdata_l1);
l1_data_A_sram[0].flag = SRAM_SLT_FREE;
+
+ printk(KERN_INFO "Blackfin Data A SRAM: %d KB (%d KB free)\n",
+ L1_DATA_A_LENGTH >> 10, l1_data_A_sram[0].size >> 10);
#endif
#if L1_DATA_B_LENGTH != 0
- printk(KERN_INFO "Blackfin DATA_B SRAM: %d KB\n",
- L1_DATA_B_LENGTH >> 10);
-
memset(&l1_data_B_sram, 0x00, sizeof(l1_data_B_sram));
- l1_data_B_sram[0].paddr = (void*)L1_DATA_B_START;
- l1_data_B_sram[0].size = L1_DATA_B_LENGTH;
+ l1_data_B_sram[0].paddr = (void *)L1_DATA_B_START +
+ (_ebss_b_l1 - _sdata_b_l1);
+ l1_data_B_sram[0].size = L1_DATA_B_LENGTH - (_ebss_b_l1 - _sdata_b_l1);
l1_data_B_sram[0].flag = SRAM_SLT_FREE;
+
+ printk(KERN_INFO "Blackfin Data B SRAM: %d KB (%d KB free)\n",
+ L1_DATA_B_LENGTH >> 10, l1_data_B_sram[0].size >> 10);
#endif
/* mutex initialize */
spin_lock_init(&l1_data_sram_lock);
}
-void l1_inst_sram_init(void)
+void __init l1_inst_sram_init(void)
{
#if L1_CODE_LENGTH != 0
- printk(KERN_INFO "Blackfin Instruction SRAM: %d KB\n",
- L1_CODE_LENGTH >> 10);
-
memset(&l1_inst_sram, 0x00, sizeof(l1_inst_sram));
l1_inst_sram[0].paddr = (void*)L1_CODE_START + (_etext_l1 - _stext_l1);
l1_inst_sram[0].size = L1_CODE_LENGTH - (_etext_l1 - _stext_l1);
l1_inst_sram[0].flag = SRAM_SLT_FREE;
+
+ printk(KERN_INFO "Blackfin Instruction SRAM: %d KB (%d KB free)\n",
+ L1_CODE_LENGTH >> 10, l1_inst_sram[0].size >> 10);
#endif
/* mutex initialize */
@@ -149,12 +151,13 @@ static void *_l1_sram_alloc(size_t size, struct l1_sram_piece *pfree, int count)
size = (size + 3) & ~3;
/* not use the good method to match the best slot !!! */
- /* search an available memeory slot */
+ /* search an available memory slot */
for (i = 0; i < count; i++) {
if ((pfree[i].flag == SRAM_SLT_FREE)
&& (pfree[i].size >= size)) {
addr = pfree[i].paddr;
pfree[i].flag = SRAM_SLT_ALLOCATED;
+ pfree[i].pid = current->pid;
index = i;
break;
}
@@ -162,10 +165,11 @@ static void *_l1_sram_alloc(size_t size, struct l1_sram_piece *pfree, int count)
if (i >= count)
return NULL;
- /* updated the NULL memeory slot !!! */
+ /* updated the NULL memory slot !!! */
if (pfree[i].size > size) {
for (i = 0; i < count; i++) {
if (pfree[i].flag == SRAM_SLT_NULL) {
+ pfree[i].pid = 0;
pfree[i].flag = SRAM_SLT_FREE;
pfree[i].paddr = addr + size;
pfree[i].size = pfree[index].size - size;
@@ -186,7 +190,7 @@ static void *_l1_sram_alloc_max(struct l1_sram_piece *pfree, int count,
int i, index = -1;
void *addr = NULL;
- /* search an available memeory slot */
+ /* search an available memory slot */
for (i = 0; i < count; i++) {
if (pfree[i].flag == SRAM_SLT_FREE && pfree[i].size > best) {
addr = pfree[i].paddr;
@@ -198,13 +202,15 @@ static void *_l1_sram_alloc_max(struct l1_sram_piece *pfree, int count,
return NULL;
*psize = best;
+ pfree[index].pid = current->pid;
pfree[index].flag = SRAM_SLT_ALLOCATED;
return addr;
}
/* L1 memory free function */
static int _l1_sram_free(const void *addr,
- struct l1_sram_piece *pfree, int count)
+ struct l1_sram_piece *pfree,
+ int count)
{
int i, index = 0;
@@ -222,12 +228,14 @@ static int _l1_sram_free(const void *addr,
if (i >= count)
return -1;
+ pfree[index].pid = 0;
pfree[index].flag = SRAM_SLT_FREE;
/* link the next address slot */
for (i = 0; i < count; i++) {
if (((pfree[index].paddr + pfree[index].size) == pfree[i].paddr)
&& (pfree[i].flag == SRAM_SLT_FREE)) {
+ pfree[i].pid = 0;
pfree[i].flag = SRAM_SLT_NULL;
pfree[index].size += pfree[i].size;
pfree[index].flag = SRAM_SLT_FREE;
@@ -538,3 +546,64 @@ void *sram_alloc_with_lsl(size_t size, unsigned long flags)
return addr;
}
EXPORT_SYMBOL(sram_alloc_with_lsl);
+
+#ifdef CONFIG_PROC_FS
+/* Once we get a real allocator, we'll throw all of this away.
+ * Until then, we need some sort of visibility into the L1 alloc.
+ */
+static void _l1sram_proc_read(char *buf, int *len, const char *desc,
+ struct l1_sram_piece *pfree, const int array_size)
+{
+ int i;
+
+ *len += sprintf(&buf[*len], "--- L1 %-14s Size PID State\n", desc);
+ for (i = 0; i < array_size; ++i) {
+ const char *alloc_type;
+ switch (pfree[i].flag) {
+ case SRAM_SLT_NULL: alloc_type = "NULL"; break;
+ case SRAM_SLT_FREE: alloc_type = "FREE"; break;
+ case SRAM_SLT_ALLOCATED: alloc_type = "ALLOCATED"; break;
+ default: alloc_type = "????"; break;
+ }
+ *len += sprintf(&buf[*len], "%p-%p %8i %4i %s\n",
+ pfree[i].paddr, pfree[i].paddr + pfree[i].size,
+ pfree[i].size, pfree[i].pid, alloc_type);
+ }
+}
+static int l1sram_proc_read(char *buf, char **start, off_t offset, int count,
+ int *eof, void *data)
+{
+ int len = 0;
+
+ _l1sram_proc_read(buf, &len, "Scratchpad",
+ l1_ssram, ARRAY_SIZE(l1_ssram));
+#if L1_DATA_A_LENGTH != 0
+ _l1sram_proc_read(buf, &len, "Data A",
+ l1_data_A_sram, ARRAY_SIZE(l1_data_A_sram));
+#endif
+#if L1_DATA_B_LENGTH != 0
+ _l1sram_proc_read(buf, &len, "Data B",
+ l1_data_B_sram, ARRAY_SIZE(l1_data_B_sram));
+#endif
+#if L1_CODE_LENGTH != 0
+ _l1sram_proc_read(buf, &len, "Instruction",
+ l1_inst_sram, ARRAY_SIZE(l1_inst_sram));
+#endif
+
+ return len;
+}
+
+static int __init l1sram_proc_init(void)
+{
+ struct proc_dir_entry *ptr;
+ ptr = create_proc_entry("sram", S_IFREG | S_IRUGO, NULL);
+ if (!ptr) {
+ printk(KERN_WARNING "unable to create /proc/sram\n");
+ return -1;
+ }
+ ptr->owner = THIS_MODULE;
+ ptr->read_proc = l1sram_proc_read;
+ return 0;
+}
+late_initcall(l1sram_proc_init);
+#endif