summaryrefslogtreecommitdiff
path: root/recipes/kexecboot/linux-kexecboot-2.6.29/dss2/0034-DSS2-VRAM-improve-omap_vram_add_region.patch
blob: dd0188640670ed9b8dcf6587b43294459d283cf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
From 946eb774e95cdc2f2fa5cdc24aa69229f82814b8 Mon Sep 17 00:00:00 2001
From: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Date: Thu, 16 Apr 2009 17:56:00 +0300
Subject: [PATCH 34/69] DSS2: VRAM: improve omap_vram_add_region()

Combine postponed and non-posponed versions of omap_vram_add_region.
Make the func non-static, so it can be called from board files.
---
 arch/arm/plat-omap/include/mach/vram.h |    1 +
 arch/arm/plat-omap/vram.c              |   54 +++++++++++++------------------
 2 files changed, 24 insertions(+), 31 deletions(-)

diff --git a/arch/arm/plat-omap/include/mach/vram.h b/arch/arm/plat-omap/include/mach/vram.h
index f176562..8639e08 100644
--- a/arch/arm/plat-omap/include/mach/vram.h
+++ b/arch/arm/plat-omap/include/mach/vram.h
@@ -24,6 +24,7 @@
 
 #include <asm/types.h>
 
+extern int omap_vram_add_region(unsigned long paddr, size_t size);
 extern int omap_vram_free(unsigned long paddr, size_t size);
 extern int omap_vram_alloc(int mtype, size_t size, unsigned long *paddr);
 extern int omap_vram_reserve(unsigned long paddr, size_t size);
diff --git a/arch/arm/plat-omap/vram.c b/arch/arm/plat-omap/vram.c
index 520f260..8e9fe77 100644
--- a/arch/arm/plat-omap/vram.c
+++ b/arch/arm/plat-omap/vram.c
@@ -60,6 +60,7 @@
  * time when we cannot yet allocate the region list */
 #define MAX_POSTPONED_REGIONS 10
 
+static bool vram_initialized;
 static int postponed_cnt __initdata;
 static struct {
 	unsigned long paddr;
@@ -145,39 +146,32 @@ static void omap_vram_free_allocation(struct vram_alloc *va)
 	kfree(va);
 }
 
-static __init int omap_vram_add_region_postponed(unsigned long paddr,
-		size_t size)
-{
-	if (postponed_cnt == MAX_POSTPONED_REGIONS)
-		return -ENOMEM;
-
-	postponed_regions[postponed_cnt].paddr = paddr;
-	postponed_regions[postponed_cnt].size = size;
-
-	++postponed_cnt;
-
-	return 0;
-}
-
-/* add/remove_region can be exported if there's need to add/remove regions
- * runtime */
-static int omap_vram_add_region(unsigned long paddr, size_t size)
+int omap_vram_add_region(unsigned long paddr, size_t size)
 {
 	struct vram_region *rm;
 	unsigned pages;
 
-	DBG("adding region paddr %08lx size %d\n",
-			paddr, size);
+	if (vram_initialized) {
+		DBG("adding region paddr %08lx size %d\n",
+				paddr, size);
 
-	size &= PAGE_MASK;
-	pages = size >> PAGE_SHIFT;
+		size &= PAGE_MASK;
+		pages = size >> PAGE_SHIFT;
 
-	rm = omap_vram_create_region(paddr, pages);
-	if (rm == NULL)
-		return -ENOMEM;
+		rm = omap_vram_create_region(paddr, pages);
+		if (rm == NULL)
+			return -ENOMEM;
+
+		list_add(&rm->list, &region_list);
+	} else {
+		if (postponed_cnt == MAX_POSTPONED_REGIONS)
+			return -ENOMEM;
 
-	list_add(&rm->list, &region_list);
+		postponed_regions[postponed_cnt].paddr = paddr;
+		postponed_regions[postponed_cnt].size = size;
 
+		++postponed_cnt;
+	}
 	return 0;
 }
 
@@ -438,6 +432,8 @@ static __init int omap_vram_init(void)
 {
 	int i, r;
 
+	vram_initialized = 1;
+
 	for (i = 0; i < postponed_cnt; i++)
 		omap_vram_add_region(postponed_regions[i].paddr,
 				postponed_regions[i].size);
@@ -472,10 +468,6 @@ static void __init omapfb_early_vram(char **p)
 	omapfb_def_sdram_vram_size = memparse(*p, p);
 	if (**p == ',')
 		omapfb_def_sdram_vram_start = simple_strtoul((*p) + 1, p, 16);
-
-	printk("omapfb_early_vram, %d, 0x%x\n",
-			omapfb_def_sdram_vram_size,
-			omapfb_def_sdram_vram_start);
 }
 __early_param("vram=", omapfb_early_vram);
 
@@ -538,7 +530,7 @@ void __init omapfb_reserve_sdram(void)
 		BUG_ON(paddr & ~PAGE_MASK);
 	}
 
-	omap_vram_add_region_postponed(paddr, size);
+	omap_vram_add_region(paddr, size);
 
 	pr_info("Reserving %u bytes SDRAM for VRAM\n", size);
 }
@@ -594,7 +586,7 @@ unsigned long __init omapfb_reserve_sram(unsigned long sram_pstart,
 		reserved = pend_avail - paddr;
 	size_avail = pend_avail - reserved - pstart_avail;
 
-	omap_vram_add_region_postponed(paddr, size);
+	omap_vram_add_region(paddr, size);
 
 	if (reserved)
 		pr_info("Reserving %lu bytes SRAM for VRAM\n", reserved);
-- 
1.6.2.4