
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 |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+)

diff -puN mm/nonlinear.c~I1-nonlinear-invalidation mm/nonlinear.c
--- memhotplug/mm/nonlinear.c~I1-nonlinear-invalidation	2004-12-10 13:52:50.000000000 -0800
+++ memhotplug-dave/mm/nonlinear.c	2004-12-10 13:52:50.000000000 -0800
@@ -136,3 +136,33 @@ 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++) {
+		ms->mem_map = NULL;
+		printk(KERN_DEBUG "%s(%08lx, %08lx)\n", __func__, pfn, nr_pages);
+		printk(KERN_DEBUG "\tphys_section[%d]: %08x\n", i, phys_section[i]);
+		printk(KERN_DEBUG "\tmem_section[%d].phys_section: %08x\n",
+			i, mem_section[phys_section[i]].phys_section);
+		phys_section[i] = INVALID_PHYS_SECTION;
+		ms->phys_section = INVALID_SECTION;
+	}
+	return 0;
+}
+
+
_
