Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 908eedc6 authored by KAMEZAWA Hiroyuki's avatar KAMEZAWA Hiroyuki Committed by Linus Torvalds
Browse files

walk system ram range



Originally, walk_memory_resource() was introduced to traverse all memory
of "System RAM" for detecting memory hotplug/unplug range.  For doing so,
flags of IORESOUCE_MEM|IORESOURCE_BUSY was used and this was enough for
memory hotplug.

But for using other purpose, /proc/kcore, this may includes some firmware
area marked as IORESOURCE_BUSY | IORESOUCE_MEM.  This patch makes the
check strict to find out busy "System RAM".

Note: PPC64 keeps their own walk_memory_resouce(), which walk through
ppc64's lmb informaton.  Because old kclist_add() is called per lmb, this
patch makes no difference in behavior, finally.

And this patch removes CONFIG_MEMORY_HOTPLUG check from this function.
Because pfn_valid() just show "there is memmap or not* and cannot be used
for "there is physical memory or not", this function is useful in generic
to scan physical memory range.

Signed-off-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Cc: Américo Wang <xiyou.wangcong@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Roland Dreier <rolandd@cisco.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9492587c
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -143,8 +143,8 @@ int arch_add_memory(int nid, u64 start, u64 size)
 * memory regions, find holes and callback for contiguous regions.
 * memory regions, find holes and callback for contiguous regions.
 */
 */
int
int
walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
			int (*func)(unsigned long, unsigned long, void *))
		void *arg, int (*func)(unsigned long, unsigned long, void *))
{
{
	struct lmb_property res;
	struct lmb_property res;
	unsigned long pfn, len;
	unsigned long pfn, len;
@@ -166,7 +166,7 @@ walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg,
	}
	}
	return ret;
	return ret;
}
}
EXPORT_SYMBOL_GPL(walk_memory_resource);
EXPORT_SYMBOL_GPL(walk_system_ram_range);


/*
/*
 * Initialize the bootmem system and give it all the memory we
 * Initialize the bootmem system and give it all the memory we
+1 −1
Original line number Original line Diff line number Diff line
@@ -2463,7 +2463,7 @@ int ehca_create_busmap(void)
	int ret;
	int ret;


	ehca_mr_len = 0;
	ehca_mr_len = 0;
	ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, NULL,
	ret = walk_system_ram_range(0, 1ULL << MAX_PHYSMEM_BITS, NULL,
				   ehca_create_busmap_callback);
				   ehca_create_busmap_callback);
	return ret;
	return ret;
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -751,7 +751,7 @@ int ehea_create_busmap(void)


	mutex_lock(&ehea_busmap_mutex);
	mutex_lock(&ehea_busmap_mutex);
	ehea_mr_len = 0;
	ehea_mr_len = 0;
	ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, NULL,
	ret = walk_system_ram_range(0, 1ULL << MAX_PHYSMEM_BITS, NULL,
				   ehea_create_busmap_callback);
				   ehea_create_busmap_callback);
	mutex_unlock(&ehea_busmap_mutex);
	mutex_unlock(&ehea_busmap_mutex);
	return ret;
	return ret;
+4 −0
Original line number Original line Diff line number Diff line
@@ -184,5 +184,9 @@ extern void __devm_release_region(struct device *dev, struct resource *parent,
extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
extern int iomem_is_exclusive(u64 addr);
extern int iomem_is_exclusive(u64 addr);


extern int
walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
		void *arg, int (*func)(unsigned long, unsigned long, void *));

#endif /* __ASSEMBLY__ */
#endif /* __ASSEMBLY__ */
#endif	/* _LINUX_IOPORT_H */
#endif	/* _LINUX_IOPORT_H */
+0 −8
Original line number Original line Diff line number Diff line
@@ -191,14 +191,6 @@ static inline void register_page_bootmem_info_node(struct pglist_data *pgdat)


#endif /* ! CONFIG_MEMORY_HOTPLUG */
#endif /* ! CONFIG_MEMORY_HOTPLUG */


/*
 * Walk through all memory which is registered as resource.
 * arg is (start_pfn, nr_pages, private_arg_pointer)
 */
extern int walk_memory_resource(unsigned long start_pfn,
			unsigned long nr_pages, void *arg,
			int (*func)(unsigned long, unsigned long, void *));

#ifdef CONFIG_MEMORY_HOTREMOVE
#ifdef CONFIG_MEMORY_HOTREMOVE


extern int is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);
extern int is_mem_section_removable(unsigned long pfn, unsigned long nr_pages);
Loading