diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2006-11-30 15:39:18 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-11-30 17:52:28 -0500 |
commit | b7dc96d75309346c1213875be68fdbbec92da5e7 (patch) | |
tree | b6f85da5e99cb3f20fef42504ce7b82b4a69c6fc | |
parent | 0215ffb08ce99e2bb59eca114a99499a4d06e704 (diff) |
[ARM] Clean up discontigmem support
Most architectures have fairly simple discontiguous memory - a
simple set of successive regions each containing some memory.
These can be described simply as a log2 of their maximum size,
along with the base address of the first region and the number
of regions.
The base address is already described by PHYS_PFN_OFFSET, and
the number of regions via the MAX_NUMNODES and the number of
online nodes.
If we then supply the log2 of their maximum size, all the other
discontigmem macros can move into generic code.
There is one exception: lh7a40x seems to have a more complicated
setup; this is left alone.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | include/asm-arm/arch-aaec2000/memory.h | 40 | ||||
-rw-r--r-- | include/asm-arm/arch-clps711x/memory.h | 53 | ||||
-rw-r--r-- | include/asm-arm/arch-lh7a40x/memory.h | 12 | ||||
-rw-r--r-- | include/asm-arm/arch-pxa/memory.h | 36 | ||||
-rw-r--r-- | include/asm-arm/arch-sa1100/memory.h | 34 | ||||
-rw-r--r-- | include/asm-arm/memory.h | 39 |
6 files changed, 54 insertions, 160 deletions
diff --git a/include/asm-arm/arch-aaec2000/memory.h b/include/asm-arm/arch-aaec2000/memory.h index 24b51cccde8f..9eceb4148922 100644 --- a/include/asm-arm/arch-aaec2000/memory.h +++ b/include/asm-arm/arch-aaec2000/memory.h | |||
@@ -17,8 +17,6 @@ | |||
17 | #define __virt_to_bus(x) __virt_to_phys(x) | 17 | #define __virt_to_bus(x) __virt_to_phys(x) |
18 | #define __bus_to_virt(x) __phys_to_virt(x) | 18 | #define __bus_to_virt(x) __phys_to_virt(x) |
19 | 19 | ||
20 | #ifdef CONFIG_DISCONTIGMEM | ||
21 | |||
22 | /* | 20 | /* |
23 | * The nodes are the followings: | 21 | * The nodes are the followings: |
24 | * | 22 | * |
@@ -27,42 +25,6 @@ | |||
27 | * node 2: 0xf800.0000 - 0xfbff.ffff | 25 | * node 2: 0xf800.0000 - 0xfbff.ffff |
28 | * node 3: 0xfc00.0000 - 0xffff.ffff | 26 | * node 3: 0xfc00.0000 - 0xffff.ffff |
29 | */ | 27 | */ |
30 | 28 | #define NODE_MEM_SIZE_BITS 26 | |
31 | /* | ||
32 | * Given a kernel address, find the home node of the underlying memory. | ||
33 | */ | ||
34 | #define KVADDR_TO_NID(addr) \ | ||
35 | (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT) | ||
36 | |||
37 | /* | ||
38 | * Given a page frame number, convert it to a node id. | ||
39 | */ | ||
40 | #define PFN_TO_NID(pfn) \ | ||
41 | (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MAX_MEM_SHIFT - PAGE_SHIFT)) | ||
42 | |||
43 | /* | ||
44 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
45 | * and return the mem_map of that node. | ||
46 | */ | ||
47 | #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) | ||
48 | |||
49 | /* | ||
50 | * Given a page frame number, find the owning node of the memory | ||
51 | * and return the mem_map of that node. | ||
52 | */ | ||
53 | #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
54 | |||
55 | /* | ||
56 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory | ||
57 | * and returns the index corresponding to the appropriate page in the | ||
58 | * node's mem_map. | ||
59 | */ | ||
60 | #define LOCAL_MAP_NR(addr) \ | ||
61 | (((unsigned long)(addr) & (NODE_MAX_MEM_SIZE - 1)) >> PAGE_SHIFT) | ||
62 | |||
63 | #define NODE_MAX_MEM_SHIFT 26 | ||
64 | #define NODE_MAX_MEM_SIZE (1 << NODE_MAX_MEM_SHIFT) | ||
65 | |||
66 | #endif /* CONFIG_DISCONTIGMEM */ | ||
67 | 29 | ||
68 | #endif /* __ASM_ARCH_MEMORY_H */ | 30 | #endif /* __ASM_ARCH_MEMORY_H */ |
diff --git a/include/asm-arm/arch-clps711x/memory.h b/include/asm-arm/arch-clps711x/memory.h index c6e8dcf674de..42768cc8bfb4 100644 --- a/include/asm-arm/arch-clps711x/memory.h +++ b/include/asm-arm/arch-clps711x/memory.h | |||
@@ -62,7 +62,15 @@ | |||
62 | * memory bank. For those systems, simply undefine CONFIG_DISCONTIGMEM. | 62 | * memory bank. For those systems, simply undefine CONFIG_DISCONTIGMEM. |
63 | */ | 63 | */ |
64 | 64 | ||
65 | #ifdef CONFIG_DISCONTIGMEM | 65 | /* |
66 | * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211 | ||
67 | * uses only one of the two banks (bank #1). However, even within | ||
68 | * bank #1, memory is discontiguous. | ||
69 | * | ||
70 | * The EDB7211 has two 8MB DRAM areas with 8MB of empty space between | ||
71 | * them, so we use 24 for the node max shift to get 16MB node sizes. | ||
72 | */ | ||
73 | |||
66 | /* | 74 | /* |
67 | * Because of the wide memory address space between physical RAM banks on the | 75 | * Because of the wide memory address space between physical RAM banks on the |
68 | * SA1100, it's much more convenient to use Linux's NUMA support to implement | 76 | * SA1100, it's much more convenient to use Linux's NUMA support to implement |
@@ -80,48 +88,7 @@ | |||
80 | * node 2: 0xd0000000 - 0xd7ffffff | 88 | * node 2: 0xd0000000 - 0xd7ffffff |
81 | * node 3: 0xd8000000 - 0xdfffffff | 89 | * node 3: 0xd8000000 - 0xdfffffff |
82 | */ | 90 | */ |
83 | 91 | #define NODE_MEM_SIZE_BITS 24 | |
84 | /* | ||
85 | * Given a kernel address, find the home node of the underlying memory. | ||
86 | */ | ||
87 | #define KVADDR_TO_NID(addr) \ | ||
88 | (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MAX_MEM_SHIFT) | ||
89 | |||
90 | /* | ||
91 | * Given a page frame number, convert it to a node id. | ||
92 | */ | ||
93 | #define PFN_TO_NID(pfn) \ | ||
94 | (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MAX_MEM_SHIFT - PAGE_SHIFT)) | ||
95 | |||
96 | /* | ||
97 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
98 | * and returns the mem_map of that node. | ||
99 | */ | ||
100 | #define ADDR_TO_MAPBASE(kaddr) \ | ||
101 | NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr))) | ||
102 | |||
103 | #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
104 | |||
105 | /* | ||
106 | * Given a kaddr, LOCAL_MAR_NR finds the owning node of the memory | ||
107 | * and returns the index corresponding to the appropriate page in the | ||
108 | * node's mem_map. | ||
109 | */ | ||
110 | #define LOCAL_MAP_NR(addr) \ | ||
111 | (((unsigned long)(addr) & (NODE_MAX_MEM_SIZE - 1)) >> PAGE_SHIFT) | ||
112 | |||
113 | /* | ||
114 | * The PS7211 allows up to 256MB max per DRAM bank, but the EDB7211 | ||
115 | * uses only one of the two banks (bank #1). However, even within | ||
116 | * bank #1, memory is discontiguous. | ||
117 | * | ||
118 | * The EDB7211 has two 8MB DRAM areas with 8MB of empty space between | ||
119 | * them, so we use 24 for the node max shift to get 16MB node sizes. | ||
120 | */ | ||
121 | #define NODE_MAX_MEM_SHIFT 24 | ||
122 | #define NODE_MAX_MEM_SIZE (1<<NODE_MAX_MEM_SHIFT) | ||
123 | |||
124 | #endif /* CONFIG_DISCONTIGMEM */ | ||
125 | 92 | ||
126 | #endif | 93 | #endif |
127 | 94 | ||
diff --git a/include/asm-arm/arch-lh7a40x/memory.h b/include/asm-arm/arch-lh7a40x/memory.h index 9f1a58cbf407..9b0c8012e713 100644 --- a/include/asm-arm/arch-lh7a40x/memory.h +++ b/include/asm-arm/arch-lh7a40x/memory.h | |||
@@ -58,18 +58,6 @@ | |||
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
62 | * and return the mem_map of that node. | ||
63 | */ | ||
64 | # define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) | ||
65 | |||
66 | /* | ||
67 | * Given a page frame number, find the owning node of the memory | ||
68 | * and return the mem_map of that node. | ||
69 | */ | ||
70 | # define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
71 | |||
72 | /* | ||
73 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory | 61 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory |
74 | * and returns the index corresponding to the appropriate page in the | 62 | * and returns the index corresponding to the appropriate page in the |
75 | * node's mem_map. | 63 | * node's mem_map. |
diff --git a/include/asm-arm/arch-pxa/memory.h b/include/asm-arm/arch-pxa/memory.h index eaf6d43939e9..e17f9881faf0 100644 --- a/include/asm-arm/arch-pxa/memory.h +++ b/include/asm-arm/arch-pxa/memory.h | |||
@@ -27,7 +27,6 @@ | |||
27 | #define __virt_to_bus(x) __virt_to_phys(x) | 27 | #define __virt_to_bus(x) __virt_to_phys(x) |
28 | #define __bus_to_virt(x) __phys_to_virt(x) | 28 | #define __bus_to_virt(x) __phys_to_virt(x) |
29 | 29 | ||
30 | #ifdef CONFIG_DISCONTIGMEM | ||
31 | /* | 30 | /* |
32 | * The nodes are matched with the physical SDRAM banks as follows: | 31 | * The nodes are matched with the physical SDRAM banks as follows: |
33 | * | 32 | * |
@@ -35,38 +34,9 @@ | |||
35 | * node 1: 0xa4000000-0xa7ffffff --> 0xc4000000-0xc7ffffff | 34 | * node 1: 0xa4000000-0xa7ffffff --> 0xc4000000-0xc7ffffff |
36 | * node 2: 0xa8000000-0xabffffff --> 0xc8000000-0xcbffffff | 35 | * node 2: 0xa8000000-0xabffffff --> 0xc8000000-0xcbffffff |
37 | * node 3: 0xac000000-0xafffffff --> 0xcc000000-0xcfffffff | 36 | * node 3: 0xac000000-0xafffffff --> 0xcc000000-0xcfffffff |
37 | * | ||
38 | * This needs a node mem size of 26 bits. | ||
38 | */ | 39 | */ |
39 | 40 | #define NODE_MEM_SIZE_BITS 26 | |
40 | /* | ||
41 | * Given a kernel address, find the home node of the underlying memory. | ||
42 | */ | ||
43 | #define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 26) | ||
44 | |||
45 | /* | ||
46 | * Given a page frame number, convert it to a node id. | ||
47 | */ | ||
48 | #define PFN_TO_NID(pfn) (((pfn) - PHYS_PFN_OFFSET) >> (26 - PAGE_SHIFT)) | ||
49 | |||
50 | /* | ||
51 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
52 | * and returns the mem_map of that node. | ||
53 | */ | ||
54 | #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) | ||
55 | |||
56 | /* | ||
57 | * Given a page frame number, find the owning node of the memory | ||
58 | * and returns the mem_map of that node. | ||
59 | */ | ||
60 | #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
61 | |||
62 | /* | ||
63 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory | ||
64 | * and returns the index corresponding to the appropriate page in the | ||
65 | * node's mem_map. | ||
66 | */ | ||
67 | #define LOCAL_MAP_NR(addr) \ | ||
68 | (((unsigned long)(addr) & 0x03ffffff) >> PAGE_SHIFT) | ||
69 | |||
70 | #endif | ||
71 | 41 | ||
72 | #endif | 42 | #endif |
diff --git a/include/asm-arm/arch-sa1100/memory.h b/include/asm-arm/arch-sa1100/memory.h index 1ff172dc8e33..0e907fc6d42a 100644 --- a/include/asm-arm/arch-sa1100/memory.h +++ b/include/asm-arm/arch-sa1100/memory.h | |||
@@ -39,7 +39,6 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes); | |||
39 | #define __virt_to_bus(x) __virt_to_phys(x) | 39 | #define __virt_to_bus(x) __virt_to_phys(x) |
40 | #define __bus_to_virt(x) __phys_to_virt(x) | 40 | #define __bus_to_virt(x) __phys_to_virt(x) |
41 | 41 | ||
42 | #ifdef CONFIG_DISCONTIGMEM | ||
43 | /* | 42 | /* |
44 | * Because of the wide memory address space between physical RAM banks on the | 43 | * Because of the wide memory address space between physical RAM banks on the |
45 | * SA1100, it's much convenient to use Linux's NUMA support to implement our | 44 | * SA1100, it's much convenient to use Linux's NUMA support to implement our |
@@ -57,38 +56,7 @@ void sa1111_adjust_zones(int node, unsigned long *size, unsigned long *holes); | |||
57 | * node 2: 0xd0000000 - 0xd7ffffff | 56 | * node 2: 0xd0000000 - 0xd7ffffff |
58 | * node 3: 0xd8000000 - 0xdfffffff | 57 | * node 3: 0xd8000000 - 0xdfffffff |
59 | */ | 58 | */ |
60 | 59 | #define NODE_MEM_SIZE_BITS 27 | |
61 | /* | ||
62 | * Given a kernel address, find the home node of the underlying memory. | ||
63 | */ | ||
64 | #define KVADDR_TO_NID(addr) (((unsigned long)(addr) - PAGE_OFFSET) >> 27) | ||
65 | |||
66 | /* | ||
67 | * Given a page frame number, convert it to a node id. | ||
68 | */ | ||
69 | #define PFN_TO_NID(pfn) (((pfn) - PHYS_PFN_OFFSET) >> (27 - PAGE_SHIFT)) | ||
70 | |||
71 | /* | ||
72 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
73 | * and return the mem_map of that node. | ||
74 | */ | ||
75 | #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) | ||
76 | |||
77 | /* | ||
78 | * Given a page frame number, find the owning node of the memory | ||
79 | * and return the mem_map of that node. | ||
80 | */ | ||
81 | #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
82 | |||
83 | /* | ||
84 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory | ||
85 | * and returns the index corresponding to the appropriate page in the | ||
86 | * node's mem_map. | ||
87 | */ | ||
88 | #define LOCAL_MAP_NR(addr) \ | ||
89 | (((unsigned long)(addr) & 0x07ffffff) >> PAGE_SHIFT) | ||
90 | |||
91 | #endif | ||
92 | 60 | ||
93 | /* | 61 | /* |
94 | * Cache flushing area - SA1100 zero bank | 62 | * Cache flushing area - SA1100 zero bank |
diff --git a/include/asm-arm/memory.h b/include/asm-arm/memory.h index 91d536c215d7..d9bfb39adabf 100644 --- a/include/asm-arm/memory.h +++ b/include/asm-arm/memory.h | |||
@@ -215,6 +215,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
215 | * virt_addr_valid(k) indicates whether a virtual address is valid | 215 | * virt_addr_valid(k) indicates whether a virtual address is valid |
216 | */ | 216 | */ |
217 | #ifndef CONFIG_DISCONTIGMEM | 217 | #ifndef CONFIG_DISCONTIGMEM |
218 | |||
218 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET | 219 | #define ARCH_PFN_OFFSET PHYS_PFN_OFFSET |
219 | #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) | 220 | #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) |
220 | 221 | ||
@@ -230,6 +231,7 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
230 | * around in memory. | 231 | * around in memory. |
231 | */ | 232 | */ |
232 | #include <linux/numa.h> | 233 | #include <linux/numa.h> |
234 | |||
233 | #define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) | 235 | #define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) |
234 | #define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) | 236 | #define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) |
235 | 237 | ||
@@ -256,6 +258,43 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
256 | */ | 258 | */ |
257 | #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) | 259 | #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) |
258 | 260 | ||
261 | /* | ||
262 | * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory | ||
263 | * and returns the mem_map of that node. | ||
264 | */ | ||
265 | #define ADDR_TO_MAPBASE(kaddr) NODE_MEM_MAP(KVADDR_TO_NID(kaddr)) | ||
266 | |||
267 | /* | ||
268 | * Given a page frame number, find the owning node of the memory | ||
269 | * and returns the mem_map of that node. | ||
270 | */ | ||
271 | #define PFN_TO_MAPBASE(pfn) NODE_MEM_MAP(PFN_TO_NID(pfn)) | ||
272 | |||
273 | #ifdef NODE_MEM_SIZE_BITS | ||
274 | #define NODE_MEM_SIZE_MASK ((1 << NODE_MEM_SIZE_BITS) - 1) | ||
275 | |||
276 | /* | ||
277 | * Given a kernel address, find the home node of the underlying memory. | ||
278 | */ | ||
279 | #define KVADDR_TO_NID(addr) \ | ||
280 | (((unsigned long)(addr) - PAGE_OFFSET) >> NODE_MEM_SIZE_BITS) | ||
281 | |||
282 | /* | ||
283 | * Given a page frame number, convert it to a node id. | ||
284 | */ | ||
285 | #define PFN_TO_NID(pfn) \ | ||
286 | (((pfn) - PHYS_PFN_OFFSET) >> (NODE_MEM_SIZE_BITS - PAGE_SHIFT)) | ||
287 | |||
288 | /* | ||
289 | * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory | ||
290 | * and returns the index corresponding to the appropriate page in the | ||
291 | * node's mem_map. | ||
292 | */ | ||
293 | #define LOCAL_MAP_NR(addr) \ | ||
294 | (((unsigned long)(addr) & NODE_MEM_SIZE_MASK) >> PAGE_SHIFT) | ||
295 | |||
296 | #endif /* NODE_MEM_SIZE_BITS */ | ||
297 | |||
259 | #endif /* !CONFIG_DISCONTIGMEM */ | 298 | #endif /* !CONFIG_DISCONTIGMEM */ |
260 | 299 | ||
261 | /* | 300 | /* |