aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorBadari Pulavarty <pbadari@us.ibm.com>2008-04-18 16:33:53 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-29 01:57:53 -0400
commit9d88a2eb6e05c07aa0d484b8fa1372722fa921d0 (patch)
tree782b288099fbd96ed779c033f2c1322ff1822950 /arch
parent98d5c21c812e4e3b795f5bd912f407ed7c5e4e38 (diff)
[POWERPC] Provide walk_memory_resource() for powerpc
Provide walk_memory_resource() for 64-bit powerpc. PowerPC maintains logical memory region mapping in the lmb.memory structure. Walk through these structures and do the callbacks for the contiguous chunks. Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com> Cc: Yasunori Goto <y-goto@jp.fujitsu.com> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/mm/mem.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index d9e37f365b54..f67e118116fa 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -154,19 +154,35 @@ out:
154 154
155/* 155/*
156 * walk_memory_resource() needs to make sure there is no holes in a given 156 * walk_memory_resource() needs to make sure there is no holes in a given
157 * memory range. On PPC64, since this range comes from /sysfs, the range 157 * memory range. PPC64 does not maintain the memory layout in /proc/iomem.
158 * is guaranteed to be valid, non-overlapping and can not contain any 158 * Instead it maintains it in lmb.memory structures. Walk through the
159 * holes. By the time we get here (memory add or remove), /proc/device-tree 159 * memory regions, find holes and callback for contiguous regions.
160 * is updated and correct. Only reason we need to check against device-tree
161 * would be if we allow user-land to specify a memory range through a
162 * system call/ioctl etc. instead of doing offline/online through /sysfs.
163 */ 160 */
164int 161int
165walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, 162walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
166 int (*func)(unsigned long, unsigned long, void *)) 163 int (*func)(unsigned long, unsigned long, void *))
167{ 164{
168 return (*func)(start_pfn, nr_pages, arg); 165 struct lmb_property res;
166 unsigned long pfn, len;
167 u64 end;
168 int ret = -1;
169
170 res.base = (u64) start_pfn << PAGE_SHIFT;
171 res.size = (u64) nr_pages << PAGE_SHIFT;
172
173 end = res.base + res.size - 1;
174 while ((res.base < end) && (lmb_find(&res) >= 0)) {
175 pfn = (unsigned long)(res.base >> PAGE_SHIFT);
176 len = (unsigned long)(res.size >> PAGE_SHIFT);
177 ret = (*func)(pfn, len, arg);
178 if (ret)
179 break;
180 res.base += (res.size + 1);
181 res.size = (end - res.base + 1);
182 }
183 return ret;
169} 184}
185EXPORT_SYMBOL_GPL(walk_memory_resource);
170 186
171#endif /* CONFIG_MEMORY_HOTPLUG */ 187#endif /* CONFIG_MEMORY_HOTPLUG */
172 188