
This must be done at the time of a memory removal so that no
pfn_to_page(), virt_to_phys(), etc... operations can be done
on the removed memory.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
---

 memhotplug-dave/mm/nonlinear.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+)

diff -puN mm/nonlinear.c~G5-nonlinear-invalidation mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~G5-nonlinear-invalidation	2004-10-08 00:15:00.000000000 -0700
+++ memhotplug-dave/mm/nonlinear.c	2004-10-08 00:15:00.000000000 -0700
@@ -135,3 +135,36 @@ page_to_pfn(struct page *page)
 		(page - mem_section[page_section(page)].mem_map);
 }
 
+
+int invalidate_phys_mapping(unsigned long pfn, unsigned long nr_pages)
+{
+	unsigned int section_nr = pfn_to_section(pfn);
+	int nr_sections = nr_pages >> (SECTION_SHIFT - PAGE_SHIFT);
+	unsigned long memmap_size = sizeof(struct page) * nr_pages;
+	unsigned int i;
+
+	printk(KERN_DEBUG "%s(%08lx, %08lx)\n", __func__, pfn, nr_pages);
+	printk(KERN_DEBUG "\tsection_nr: %d\n", section_nr);
+	printk(KERN_DEBUG "\tnr_sections: %d\n", nr_sections);
+
+	if (pfn_to_section(pfn) == pfn_to_section(pfn-1)) {
+		 printk("%s() start pfn: %ld not section-aligned\n", __func__, pfn);
+		 return -EINVAL;
+	}
+
+	for (i = section_nr; i < section_nr + nr_sections; i++) {
+		 struct mem_section *ms = &mem_section[phys_section[i]];
+		 struct page *mem_map_page = virt_to_page(ms->mem_map);
+
+		 ms->mem_map = NULL;
+		 printk(KERN_DEBUG "%s(%08lx, %08lx)\n", __func__, pfn, nr_pages);
+		 printk(KERN_DEBUG "\tphys_section[%d]: %08lx\n", i, phys_section[i]);
+		 printk(KERN_DEBUG "\tmem_section[%d].phys_section: %08lx\n",
+			i, mem_section[phys_section[i]].phys_section);
+		 phys_section[i] = INVALID_PHYS_SECTION;
+		 ms->phys_section = INVALID_SECTION;
+	}
+	return 0;
+}
+
+
_
