1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pseries Memory Hotplug infrastructure.
5 * Copyright (C) 2008 Badari Pulavarty, IBM Corporation
8 #define pr_fmt(fmt) "pseries-hotplug-mem: " fmt
11 #include <linux/of_address.h>
12 #include <linux/memblock.h>
13 #include <linux/memory.h>
14 #include <linux/memory_hotplug.h>
15 #include <linux/slab.h>
17 #include <asm/firmware.h>
18 #include <asm/machdep.h>
20 #include <asm/sparsemem.h>
21 #include <asm/fadump.h>
22 #include <asm/drmem.h>
25 static bool rtas_hp_event;
27 unsigned long pseries_memory_block_size(void)
29 struct device_node *np;
30 u64 memblock_size = MIN_MEMORY_BLOCK_SIZE;
33 np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
37 size = of_get_property(np, "ibm,lmb-size", NULL);
39 memblock_size = be64_to_cpup(size);
41 } else if (machine_is(pseries)) {
42 /* This fallback really only applies to pseries */
43 unsigned int memzero_size = 0;
45 np = of_find_node_by_path("/memory@0");
47 if (!of_address_to_resource(np, 0, &r))
48 memzero_size = resource_size(&r);
53 /* We now know the size of memory@0, use this to find
54 * the first memoryblock and get its size.
58 sprintf(buf, "/memory@%x", memzero_size);
59 np = of_find_node_by_path(buf);
61 if (!of_address_to_resource(np, 0, &r))
62 memblock_size = resource_size(&r);
70 static void dlpar_free_property(struct property *prop)
77 static struct property *dlpar_clone_property(struct property *prop,
80 struct property *new_prop;
82 new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
86 new_prop->name = kstrdup(prop->name, GFP_KERNEL);
87 new_prop->value = kzalloc(prop_size, GFP_KERNEL);
88 if (!new_prop->name || !new_prop->value) {
89 dlpar_free_property(new_prop);
93 memcpy(new_prop->value, prop->value, prop->length);
94 new_prop->length = prop_size;
96 of_property_set_flag(new_prop, OF_DYNAMIC);
100 static bool find_aa_index(struct device_node *dr_node,
101 struct property *ala_prop,
102 const u32 *lmb_assoc, u32 *aa_index)
104 u32 *assoc_arrays, new_prop_size;
105 struct property *new_prop;
106 int aa_arrays, aa_array_entries, aa_array_sz;
110 * The ibm,associativity-lookup-arrays property is defined to be
111 * a 32-bit value specifying the number of associativity arrays
112 * followed by a 32-bitvalue specifying the number of entries per
113 * array, followed by the associativity arrays.
115 assoc_arrays = ala_prop->value;
117 aa_arrays = be32_to_cpu(assoc_arrays[0]);
118 aa_array_entries = be32_to_cpu(assoc_arrays[1]);
119 aa_array_sz = aa_array_entries * sizeof(u32);
121 for (i = 0; i < aa_arrays; i++) {
122 index = (i * aa_array_entries) + 2;
124 if (memcmp(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz))
131 new_prop_size = ala_prop->length + aa_array_sz;
132 new_prop = dlpar_clone_property(ala_prop, new_prop_size);
136 assoc_arrays = new_prop->value;
138 /* increment the number of entries in the lookup array */
139 assoc_arrays[0] = cpu_to_be32(aa_arrays + 1);
141 /* copy the new associativity into the lookup array */
142 index = aa_arrays * aa_array_entries + 2;
143 memcpy(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz);
145 of_update_property(dr_node, new_prop);
148 * The associativity lookup array index for this lmb is
149 * number of entries - 1 since we added its associativity
150 * to the end of the lookup array.
152 *aa_index = be32_to_cpu(assoc_arrays[0]) - 1;
156 static int update_lmb_associativity_index(struct drmem_lmb *lmb)
158 struct device_node *parent, *lmb_node, *dr_node;
159 struct property *ala_prop;
160 const u32 *lmb_assoc;
164 parent = of_find_node_by_path("/");
168 lmb_node = dlpar_configure_connector(cpu_to_be32(lmb->drc_index),
174 lmb_assoc = of_get_property(lmb_node, "ibm,associativity", NULL);
176 dlpar_free_cc_nodes(lmb_node);
180 dr_node = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
182 dlpar_free_cc_nodes(lmb_node);
186 ala_prop = of_find_property(dr_node, "ibm,associativity-lookup-arrays",
189 of_node_put(dr_node);
190 dlpar_free_cc_nodes(lmb_node);
194 found = find_aa_index(dr_node, ala_prop, lmb_assoc, &aa_index);
196 of_node_put(dr_node);
197 dlpar_free_cc_nodes(lmb_node);
200 pr_err("Could not find LMB associativity\n");
204 lmb->aa_index = aa_index;
208 static struct memory_block *lmb_to_memblock(struct drmem_lmb *lmb)
210 unsigned long section_nr;
211 struct mem_section *mem_sect;
212 struct memory_block *mem_block;
214 section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
215 mem_sect = __nr_to_section(section_nr);
217 mem_block = find_memory_block(mem_sect);
221 static int get_lmb_range(u32 drc_index, int n_lmbs,
222 struct drmem_lmb **start_lmb,
223 struct drmem_lmb **end_lmb)
225 struct drmem_lmb *lmb, *start, *end;
226 struct drmem_lmb *limit;
229 for_each_drmem_lmb(lmb) {
230 if (lmb->drc_index == drc_index) {
239 end = &start[n_lmbs];
241 limit = &drmem_info->lmbs[drmem_info->n_lmbs];
250 static int dlpar_change_lmb_state(struct drmem_lmb *lmb, bool online)
252 struct memory_block *mem_block;
255 mem_block = lmb_to_memblock(lmb);
259 if (online && mem_block->dev.offline)
260 rc = device_online(&mem_block->dev);
261 else if (!online && !mem_block->dev.offline)
262 rc = device_offline(&mem_block->dev);
266 put_device(&mem_block->dev);
271 static int dlpar_online_lmb(struct drmem_lmb *lmb)
273 return dlpar_change_lmb_state(lmb, true);
276 #ifdef CONFIG_MEMORY_HOTREMOVE
277 static int dlpar_offline_lmb(struct drmem_lmb *lmb)
279 return dlpar_change_lmb_state(lmb, false);
282 static int pseries_remove_memblock(unsigned long base, unsigned long memblock_size)
284 unsigned long block_sz, start_pfn;
285 int sections_per_block;
288 start_pfn = base >> PAGE_SHIFT;
290 lock_device_hotplug();
292 if (!pfn_valid(start_pfn))
295 block_sz = pseries_memory_block_size();
296 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
297 nid = memory_add_physaddr_to_nid(base);
299 for (i = 0; i < sections_per_block; i++) {
300 __remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE);
301 base += MIN_MEMORY_BLOCK_SIZE;
305 /* Update memory regions for memory remove */
306 memblock_remove(base, memblock_size);
307 unlock_device_hotplug();
311 static int pseries_remove_mem_node(struct device_node *np)
315 unsigned long lmb_size;
317 int addr_cells, size_cells;
320 * Check to see if we are actually removing memory
322 if (!of_node_is_type(np, "memory"))
326 * Find the base address and size of the memblock
328 prop = of_get_property(np, "reg", NULL);
332 addr_cells = of_n_addr_cells(np);
333 size_cells = of_n_size_cells(np);
336 * "reg" property represents (addr,size) tuple.
338 base = of_read_number(prop, addr_cells);
340 lmb_size = of_read_number(prop, size_cells);
342 pseries_remove_memblock(base, lmb_size);
346 static bool lmb_is_removable(struct drmem_lmb *lmb)
348 int i, scns_per_block;
350 unsigned long pfn, block_sz;
353 if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
356 block_sz = memory_block_size_bytes();
357 scns_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
358 phys_addr = lmb->base_addr;
360 #ifdef CONFIG_FA_DUMP
362 * Don't hot-remove memory that falls in fadump boot memory area
363 * and memory that is reserved for capturing old kernel memory.
365 if (is_fadump_memory_area(phys_addr, block_sz))
369 for (i = 0; i < scns_per_block; i++) {
370 pfn = PFN_DOWN(phys_addr);
371 if (!pfn_present(pfn)) {
372 phys_addr += MIN_MEMORY_BLOCK_SIZE;
376 rc &= is_mem_section_removable(pfn, PAGES_PER_SECTION);
377 phys_addr += MIN_MEMORY_BLOCK_SIZE;
380 return rc ? true : false;
383 static int dlpar_add_lmb(struct drmem_lmb *);
385 static int dlpar_remove_lmb(struct drmem_lmb *lmb)
387 struct memory_block *mem_block;
388 unsigned long block_sz;
391 if (!lmb_is_removable(lmb))
394 mem_block = lmb_to_memblock(lmb);
395 if (mem_block == NULL)
398 rc = dlpar_offline_lmb(lmb);
400 put_device(&mem_block->dev);
404 block_sz = pseries_memory_block_size();
406 __remove_memory(mem_block->nid, lmb->base_addr, block_sz);
407 put_device(&mem_block->dev);
409 /* Update memory regions for memory remove */
410 memblock_remove(lmb->base_addr, block_sz);
412 invalidate_lmb_associativity_index(lmb);
413 lmb->flags &= ~DRCONF_MEM_ASSIGNED;
418 static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
420 struct drmem_lmb *lmb;
421 int lmbs_removed = 0;
422 int lmbs_available = 0;
425 pr_info("Attempting to hot-remove %d LMB(s)\n", lmbs_to_remove);
427 if (lmbs_to_remove == 0)
430 /* Validate that there are enough LMBs to satisfy the request */
431 for_each_drmem_lmb(lmb) {
432 if (lmb_is_removable(lmb))
435 if (lmbs_available == lmbs_to_remove)
439 if (lmbs_available < lmbs_to_remove) {
440 pr_info("Not enough LMBs available (%d of %d) to satisfy request\n",
441 lmbs_available, lmbs_to_remove);
445 for_each_drmem_lmb(lmb) {
446 rc = dlpar_remove_lmb(lmb);
450 /* Mark this lmb so we can add it later if all of the
451 * requested LMBs cannot be removed.
453 drmem_mark_lmb_reserved(lmb);
456 if (lmbs_removed == lmbs_to_remove)
460 if (lmbs_removed != lmbs_to_remove) {
461 pr_err("Memory hot-remove failed, adding LMB's back\n");
463 for_each_drmem_lmb(lmb) {
464 if (!drmem_lmb_reserved(lmb))
467 rc = dlpar_add_lmb(lmb);
469 pr_err("Failed to add LMB back, drc index %x\n",
472 drmem_remove_lmb_reservation(lmb);
477 for_each_drmem_lmb(lmb) {
478 if (!drmem_lmb_reserved(lmb))
481 dlpar_release_drc(lmb->drc_index);
482 pr_info("Memory at %llx was hot-removed\n",
485 drmem_remove_lmb_reservation(lmb);
493 static int dlpar_memory_remove_by_index(u32 drc_index)
495 struct drmem_lmb *lmb;
499 pr_debug("Attempting to hot-remove LMB, drc index %x\n", drc_index);
502 for_each_drmem_lmb(lmb) {
503 if (lmb->drc_index == drc_index) {
505 rc = dlpar_remove_lmb(lmb);
507 dlpar_release_drc(lmb->drc_index);
514 pr_debug("Failed to look up LMB for drc index %x\n", drc_index);
517 pr_debug("Failed to hot-remove memory at %llx\n",
520 pr_debug("Memory at %llx was hot-removed\n", lmb->base_addr);
526 static int dlpar_memory_readd_by_index(u32 drc_index)
528 struct drmem_lmb *lmb;
532 pr_info("Attempting to update LMB, drc index %x\n", drc_index);
535 for_each_drmem_lmb(lmb) {
536 if (lmb->drc_index == drc_index) {
538 rc = dlpar_remove_lmb(lmb);
540 rc = dlpar_add_lmb(lmb);
542 dlpar_release_drc(lmb->drc_index);
552 pr_info("Failed to update memory at %llx\n",
555 pr_info("Memory at %llx was updated\n", lmb->base_addr);
560 static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
562 struct drmem_lmb *lmb, *start_lmb, *end_lmb;
563 int lmbs_available = 0;
566 pr_info("Attempting to hot-remove %u LMB(s) at %x\n",
567 lmbs_to_remove, drc_index);
569 if (lmbs_to_remove == 0)
572 rc = get_lmb_range(drc_index, lmbs_to_remove, &start_lmb, &end_lmb);
576 /* Validate that there are enough LMBs to satisfy the request */
577 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
578 if (lmb->flags & DRCONF_MEM_RESERVED)
584 if (lmbs_available < lmbs_to_remove)
587 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
588 if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
591 rc = dlpar_remove_lmb(lmb);
595 drmem_mark_lmb_reserved(lmb);
599 pr_err("Memory indexed-count-remove failed, adding any removed LMBs\n");
602 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
603 if (!drmem_lmb_reserved(lmb))
606 rc = dlpar_add_lmb(lmb);
608 pr_err("Failed to add LMB, drc index %x\n",
611 drmem_remove_lmb_reservation(lmb);
615 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
616 if (!drmem_lmb_reserved(lmb))
619 dlpar_release_drc(lmb->drc_index);
620 pr_info("Memory at %llx (drc index %x) was hot-removed\n",
621 lmb->base_addr, lmb->drc_index);
623 drmem_remove_lmb_reservation(lmb);
631 static inline int pseries_remove_memblock(unsigned long base,
632 unsigned long memblock_size)
636 static inline int pseries_remove_mem_node(struct device_node *np)
640 static inline int dlpar_memory_remove(struct pseries_hp_errorlog *hp_elog)
644 static int dlpar_remove_lmb(struct drmem_lmb *lmb)
648 static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
652 static int dlpar_memory_remove_by_index(u32 drc_index)
656 static int dlpar_memory_readd_by_index(u32 drc_index)
661 static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index)
665 #endif /* CONFIG_MEMORY_HOTREMOVE */
667 static int dlpar_add_lmb(struct drmem_lmb *lmb)
669 unsigned long block_sz;
672 if (lmb->flags & DRCONF_MEM_ASSIGNED)
675 rc = update_lmb_associativity_index(lmb);
677 dlpar_release_drc(lmb->drc_index);
681 block_sz = memory_block_size_bytes();
683 /* Find the node id for this address. */
684 nid = memory_add_physaddr_to_nid(lmb->base_addr);
687 rc = __add_memory(nid, lmb->base_addr, block_sz);
689 invalidate_lmb_associativity_index(lmb);
693 rc = dlpar_online_lmb(lmb);
695 __remove_memory(nid, lmb->base_addr, block_sz);
696 invalidate_lmb_associativity_index(lmb);
698 lmb->flags |= DRCONF_MEM_ASSIGNED;
704 static int dlpar_memory_add_by_count(u32 lmbs_to_add)
706 struct drmem_lmb *lmb;
707 int lmbs_available = 0;
711 pr_info("Attempting to hot-add %d LMB(s)\n", lmbs_to_add);
713 if (lmbs_to_add == 0)
716 /* Validate that there are enough LMBs to satisfy the request */
717 for_each_drmem_lmb(lmb) {
718 if (!(lmb->flags & DRCONF_MEM_ASSIGNED))
721 if (lmbs_available == lmbs_to_add)
725 if (lmbs_available < lmbs_to_add)
728 for_each_drmem_lmb(lmb) {
729 if (lmb->flags & DRCONF_MEM_ASSIGNED)
732 rc = dlpar_acquire_drc(lmb->drc_index);
736 rc = dlpar_add_lmb(lmb);
738 dlpar_release_drc(lmb->drc_index);
742 /* Mark this lmb so we can remove it later if all of the
743 * requested LMBs cannot be added.
745 drmem_mark_lmb_reserved(lmb);
748 if (lmbs_added == lmbs_to_add)
752 if (lmbs_added != lmbs_to_add) {
753 pr_err("Memory hot-add failed, removing any added LMBs\n");
755 for_each_drmem_lmb(lmb) {
756 if (!drmem_lmb_reserved(lmb))
759 rc = dlpar_remove_lmb(lmb);
761 pr_err("Failed to remove LMB, drc index %x\n",
764 dlpar_release_drc(lmb->drc_index);
766 drmem_remove_lmb_reservation(lmb);
770 for_each_drmem_lmb(lmb) {
771 if (!drmem_lmb_reserved(lmb))
774 pr_debug("Memory at %llx (drc index %x) was hot-added\n",
775 lmb->base_addr, lmb->drc_index);
776 drmem_remove_lmb_reservation(lmb);
784 static int dlpar_memory_add_by_index(u32 drc_index)
786 struct drmem_lmb *lmb;
789 pr_info("Attempting to hot-add LMB, drc index %x\n", drc_index);
792 for_each_drmem_lmb(lmb) {
793 if (lmb->drc_index == drc_index) {
795 rc = dlpar_acquire_drc(lmb->drc_index);
797 rc = dlpar_add_lmb(lmb);
799 dlpar_release_drc(lmb->drc_index);
810 pr_info("Failed to hot-add memory, drc index %x\n", drc_index);
812 pr_info("Memory at %llx (drc index %x) was hot-added\n",
813 lmb->base_addr, drc_index);
818 static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index)
820 struct drmem_lmb *lmb, *start_lmb, *end_lmb;
821 int lmbs_available = 0;
824 pr_info("Attempting to hot-add %u LMB(s) at index %x\n",
825 lmbs_to_add, drc_index);
827 if (lmbs_to_add == 0)
830 rc = get_lmb_range(drc_index, lmbs_to_add, &start_lmb, &end_lmb);
834 /* Validate that the LMBs in this range are not reserved */
835 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
836 if (lmb->flags & DRCONF_MEM_RESERVED)
842 if (lmbs_available < lmbs_to_add)
845 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
846 if (lmb->flags & DRCONF_MEM_ASSIGNED)
849 rc = dlpar_acquire_drc(lmb->drc_index);
853 rc = dlpar_add_lmb(lmb);
855 dlpar_release_drc(lmb->drc_index);
859 drmem_mark_lmb_reserved(lmb);
863 pr_err("Memory indexed-count-add failed, removing any added LMBs\n");
865 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
866 if (!drmem_lmb_reserved(lmb))
869 rc = dlpar_remove_lmb(lmb);
871 pr_err("Failed to remove LMB, drc index %x\n",
874 dlpar_release_drc(lmb->drc_index);
876 drmem_remove_lmb_reservation(lmb);
880 for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
881 if (!drmem_lmb_reserved(lmb))
884 pr_info("Memory at %llx (drc index %x) was hot-added\n",
885 lmb->base_addr, lmb->drc_index);
886 drmem_remove_lmb_reservation(lmb);
893 int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
895 u32 count, drc_index;
898 lock_device_hotplug();
900 switch (hp_elog->action) {
901 case PSERIES_HP_ELOG_ACTION_ADD:
902 switch (hp_elog->id_type) {
903 case PSERIES_HP_ELOG_ID_DRC_COUNT:
904 count = hp_elog->_drc_u.drc_count;
905 rc = dlpar_memory_add_by_count(count);
907 case PSERIES_HP_ELOG_ID_DRC_INDEX:
908 drc_index = hp_elog->_drc_u.drc_index;
909 rc = dlpar_memory_add_by_index(drc_index);
911 case PSERIES_HP_ELOG_ID_DRC_IC:
912 count = hp_elog->_drc_u.ic.count;
913 drc_index = hp_elog->_drc_u.ic.index;
914 rc = dlpar_memory_add_by_ic(count, drc_index);
922 case PSERIES_HP_ELOG_ACTION_REMOVE:
923 switch (hp_elog->id_type) {
924 case PSERIES_HP_ELOG_ID_DRC_COUNT:
925 count = hp_elog->_drc_u.drc_count;
926 rc = dlpar_memory_remove_by_count(count);
928 case PSERIES_HP_ELOG_ID_DRC_INDEX:
929 drc_index = hp_elog->_drc_u.drc_index;
930 rc = dlpar_memory_remove_by_index(drc_index);
932 case PSERIES_HP_ELOG_ID_DRC_IC:
933 count = hp_elog->_drc_u.ic.count;
934 drc_index = hp_elog->_drc_u.ic.index;
935 rc = dlpar_memory_remove_by_ic(count, drc_index);
943 case PSERIES_HP_ELOG_ACTION_READD:
944 drc_index = hp_elog->_drc_u.drc_index;
945 rc = dlpar_memory_readd_by_index(drc_index);
948 pr_err("Invalid action (%d) specified\n", hp_elog->action);
954 rtas_hp_event = true;
955 rc = drmem_update_dt();
956 rtas_hp_event = false;
959 unlock_device_hotplug();
963 static int pseries_add_mem_node(struct device_node *np)
967 unsigned long lmb_size;
969 int addr_cells, size_cells;
972 * Check to see if we are actually adding memory
974 if (!of_node_is_type(np, "memory"))
978 * Find the base and size of the memblock
980 prop = of_get_property(np, "reg", NULL);
984 addr_cells = of_n_addr_cells(np);
985 size_cells = of_n_size_cells(np);
987 * "reg" property represents (addr,size) tuple.
989 base = of_read_number(prop, addr_cells);
991 lmb_size = of_read_number(prop, size_cells);
994 * Update memory region to represent the memory add
996 ret = memblock_add(base, lmb_size);
997 return (ret < 0) ? -EINVAL : 0;
1000 static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
1002 struct of_drconf_cell_v1 *new_drmem, *old_drmem;
1003 unsigned long memblock_size;
1006 int i, rc = -EINVAL;
1011 memblock_size = pseries_memory_block_size();
1018 p = (__be32 *) pr->old_prop->value;
1022 /* The first int of the property is the number of lmb's described
1023 * by the property. This is followed by an array of of_drconf_cell
1024 * entries. Get the number of entries and skip to the array of
1027 entries = be32_to_cpu(*p++);
1028 old_drmem = (struct of_drconf_cell_v1 *)p;
1030 p = (__be32 *)pr->prop->value;
1032 new_drmem = (struct of_drconf_cell_v1 *)p;
1034 for (i = 0; i < entries; i++) {
1035 if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) &&
1036 (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) {
1037 rc = pseries_remove_memblock(
1038 be64_to_cpu(old_drmem[i].base_addr),
1041 } else if ((!(be32_to_cpu(old_drmem[i].flags) &
1042 DRCONF_MEM_ASSIGNED)) &&
1043 (be32_to_cpu(new_drmem[i].flags) &
1044 DRCONF_MEM_ASSIGNED)) {
1045 rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr),
1047 rc = (rc < 0) ? -EINVAL : 0;
1054 static int pseries_memory_notifier(struct notifier_block *nb,
1055 unsigned long action, void *data)
1057 struct of_reconfig_data *rd = data;
1061 case OF_RECONFIG_ATTACH_NODE:
1062 err = pseries_add_mem_node(rd->dn);
1064 case OF_RECONFIG_DETACH_NODE:
1065 err = pseries_remove_mem_node(rd->dn);
1067 case OF_RECONFIG_UPDATE_PROPERTY:
1068 if (!strcmp(rd->prop->name, "ibm,dynamic-memory"))
1069 err = pseries_update_drconf_memory(rd);
1072 return notifier_from_errno(err);
1075 static struct notifier_block pseries_mem_nb = {
1076 .notifier_call = pseries_memory_notifier,
1079 static int __init pseries_memory_hotplug_init(void)
1081 if (firmware_has_feature(FW_FEATURE_LPAR))
1082 of_reconfig_notifier_register(&pseries_mem_nb);
1086 machine_device_initcall(pseries, pseries_memory_hotplug_init);