Skip to content

Commit 61ef248

Browse files
Wu FengguangH. Peter Anvin
authored andcommitted
resources: introduce generic page_is_ram()
It's based on walk_system_ram_range(), for archs that don't have their own page_is_ram(). The static verions in MIPS and SCORE are also made global. v4: prefer plain 1 instead of PAGE_IS_RAM (H. Peter Anvin) v3: add comment (KAMEZAWA Hiroyuki) "AFAIK, this "System RAM" information has been used for kdump to grab valid memory area and seems good for the kernel itself." v2: add PAGE_IS_RAM macro (Américo Wang) Cc: Chen Liqin <liqin.chen@sunplusct.com> Cc: Lennox Wu <lennox.wu@gmail.com> Cc: Américo Wang <xiyou.wangcong@gmail.com> Cc: linux-mips@linux-mips.org Cc: Yinghai Lu <yinghai@kernel.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> LKML-Reference: <20100122081619.GA6431@localhost> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
1 parent ccef086 commit 61ef248

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎arch/mips/mm/init.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void __init fixrange_init(unsigned long start, unsigned long end,
294294
}
295295

296296
#ifndef CONFIG_NEED_MULTIPLE_NODES
297-
static int __init page_is_ram(unsigned long pagenr)
297+
int page_is_ram(unsigned long pagenr)
298298
{
299299
int i;
300300

‎arch/score/mm/init.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static unsigned long setup_zero_page(void)
5959
}
6060

6161
#ifndef CONFIG_NEED_MULTIPLE_NODES
62-
static int __init page_is_ram(unsigned long pagenr)
62+
int page_is_ram(unsigned long pagenr)
6363
{
6464
if (pagenr >= min_low_pfn && pagenr < max_low_pfn)
6565
return 1;

‎include/linux/ioport.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,7 @@ extern int
188188
walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
189189
void *arg, int (*func)(unsigned long, unsigned long, void *));
190190

191+
extern int page_is_ram(unsigned long pfn);
192+
191193
#endif /* __ASSEMBLY__ */
192194
#endif /* _LINUX_IOPORT_H */

‎kernel/resource.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,19 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
297297

298298
#endif
299299

300+
static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg)
301+
{
302+
return 1;
303+
}
304+
/*
305+
* This generic page_is_ram() returns true if specified address is
306+
* registered as "System RAM" in iomem_resource list.
307+
*/
308+
int __attribute__((weak)) page_is_ram(unsigned long pfn)
309+
{
310+
return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1;
311+
}
312+
300313
/*
301314
* Find empty slot in the resource tree given range and alignment.
302315
*/

0 commit comments

Comments
 (0)