]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/memory_hotplug.c
Merge branch 'linux_next' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
[karo-tx-linux.git] / mm / memory_hotplug.c
index ee3765760818a6623f86e48a6d775d2d6c2a75a2..a221fac1f47d39aef56278758765c023a7981796 100644 (file)
@@ -436,6 +436,40 @@ static int __meminit __add_section(int nid, struct zone *zone,
        return register_new_memory(nid, __pfn_to_section(phys_start_pfn));
 }
 
+/*
+ * Reasonably generic function for adding memory.  It is
+ * expected that archs that support memory hotplug will
+ * call this function after deciding the zone to which to
+ * add the new pages.
+ */
+int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn,
+                       unsigned long nr_pages)
+{
+       unsigned long i;
+       int err = 0;
+       int start_sec, end_sec;
+       /* during initialize mem_map, align hot-added range to section */
+       start_sec = pfn_to_section_nr(phys_start_pfn);
+       end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1);
+
+       for (i = start_sec; i <= end_sec; i++) {
+               err = __add_section(nid, zone, i << PFN_SECTION_SHIFT);
+
+               /*
+                * EEXIST is finally dealt with by ioresource collision
+                * check. see add_memory() => register_memory_resource()
+                * Warning will be printed if there is collision.
+                */
+               if (err && (err != -EEXIST))
+                       break;
+               err = 0;
+       }
+
+       return err;
+}
+EXPORT_SYMBOL_GPL(__add_pages);
+
+#ifdef CONFIG_MEMORY_HOTREMOVE
 /* find the smallest valid pfn in the range [start_pfn, end_pfn) */
 static int find_smallest_section_pfn(int nid, struct zone *zone,
                                     unsigned long start_pfn,
@@ -658,39 +692,6 @@ static int __remove_section(struct zone *zone, struct mem_section *ms)
        return 0;
 }
 
-/*
- * Reasonably generic function for adding memory.  It is
- * expected that archs that support memory hotplug will
- * call this function after deciding the zone to which to
- * add the new pages.
- */
-int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn,
-                       unsigned long nr_pages)
-{
-       unsigned long i;
-       int err = 0;
-       int start_sec, end_sec;
-       /* during initialize mem_map, align hot-added range to section */
-       start_sec = pfn_to_section_nr(phys_start_pfn);
-       end_sec = pfn_to_section_nr(phys_start_pfn + nr_pages - 1);
-
-       for (i = start_sec; i <= end_sec; i++) {
-               err = __add_section(nid, zone, i << PFN_SECTION_SHIFT);
-
-               /*
-                * EEXIST is finally dealt with by ioresource collision
-                * check. see add_memory() => register_memory_resource()
-                * Warning will be printed if there is collision.
-                */
-               if (err && (err != -EEXIST))
-                       break;
-               err = 0;
-       }
-
-       return err;
-}
-EXPORT_SYMBOL_GPL(__add_pages);
-
 /**
  * __remove_pages() - remove sections of pages from a zone
  * @zone: zone from which pages need to be removed
@@ -705,8 +706,10 @@ EXPORT_SYMBOL_GPL(__add_pages);
 int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
                 unsigned long nr_pages)
 {
-       unsigned long i, ret = 0;
+       unsigned long i;
        int sections_to_remove;
+       resource_size_t start, size;
+       int ret = 0;
 
        /*
         * We can only remove entire sections
@@ -714,7 +717,12 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
        BUG_ON(phys_start_pfn & ~PAGE_SECTION_MASK);
        BUG_ON(nr_pages % PAGES_PER_SECTION);
 
-       release_mem_region(phys_start_pfn << PAGE_SHIFT, nr_pages * PAGE_SIZE);
+       start = phys_start_pfn << PAGE_SHIFT;
+       size = nr_pages * PAGE_SIZE;
+       ret = release_mem_region_adjustable(&iomem_resource, start, size);
+       if (ret)
+               pr_warn("Unable to release resource <%016llx-%016llx> (%d)\n",
+                               start, start + size - 1, ret);
 
        sections_to_remove = nr_pages / PAGES_PER_SECTION;
        for (i = 0; i < sections_to_remove; i++) {
@@ -726,6 +734,7 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
        return ret;
 }
 EXPORT_SYMBOL_GPL(__remove_pages);
+#endif /* CONFIG_MEMORY_HOTREMOVE */
 
 int set_online_page_callback(online_page_callback_t callback)
 {
@@ -1613,7 +1622,7 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages)
 /**
  * walk_memory_range - walks through all mem sections in [start_pfn, end_pfn)
  * @start_pfn: start pfn of the memory range
- * @end_pfn: end pft of the memory range
+ * @end_pfn: end pfn of the memory range
  * @arg: argument passed to func
  * @func: callback for each memory section walked
  *
@@ -1681,11 +1690,15 @@ static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)
 {
        int ret = !is_memblock_offlined(mem);
 
-       if (unlikely(ret))
+       if (unlikely(ret)) {
+               phys_addr_t beginpa, endpa;
+
+               beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr));
+               endpa = PFN_PHYS(section_nr_to_pfn(mem->end_section_nr + 1))-1;
                pr_warn("removing memory fails, because memory "
-                       "[%#010llx-%#010llx] is onlined\n",
-                       PFN_PHYS(section_nr_to_pfn(mem->start_section_nr)),
-                       PFN_PHYS(section_nr_to_pfn(mem->end_section_nr + 1))-1);
+                       "[%pa-%pa] is onlined\n",
+                       &beginpa, &endpa);
+       }
 
        return ret;
 }