18 #include <asm/machdep.h>
20 #include <asm/sparsemem.h>
22 static unsigned long get_memblock_size(
void)
36 }
else if (machine_is(pseries)) {
38 unsigned int memzero_size = 0;
43 memzero_size = resource_size(&
r);
53 sprintf(buf,
"/memory@%x", memzero_size);
57 memblock_size = resource_size(&
r);
73 return get_memblock_size();
76 static int pseries_remove_memblock(
unsigned long base,
unsigned int memblock_size)
78 unsigned long start, start_pfn;
82 unsigned long sections_to_remove;
102 sections_to_remove = (memblock_size >>
PAGE_SHIFT) / PAGES_PER_SECTION;
103 for (section = 0; section < sections_to_remove; section++) {
104 unsigned long pfn = start_pfn + section * PAGES_PER_SECTION;
105 ret = __remove_pages(zone, pfn, PAGES_PER_SECTION);
119 ret = remove_section_mapping(start, start + memblock_size);
129 static int pseries_remove_memory(
struct device_node *np)
132 const unsigned int *
regs;
134 unsigned int lmb_size;
141 if (type ==
NULL ||
strcmp(type,
"memory") != 0)
151 base = *(
unsigned long *)regs;
154 ret = pseries_remove_memblock(base, lmb_size);
158 static int pseries_add_memory(
struct device_node *np)
161 const unsigned int *
regs;
163 unsigned int lmb_size;
170 if (type ==
NULL ||
strcmp(type,
"memory") != 0)
180 base = *(
unsigned long *)regs;
187 return (ret < 0) ? -
EINVAL : 0;
190 static int pseries_drconf_memory(
unsigned long *base,
unsigned int action)
192 unsigned long memblock_size;
195 memblock_size = get_memblock_size();
199 if (action == PSERIES_DRCONF_MEM_ADD) {
201 rc = (rc < 0) ? -
EINVAL : 0;
202 }
else if (action == PSERIES_DRCONF_MEM_REMOVE) {
203 rc = pseries_remove_memblock(*base, memblock_size);
212 unsigned long action,
void *
node)
217 case PSERIES_RECONFIG_ADD:
218 err = pseries_add_memory(node);
220 case PSERIES_RECONFIG_REMOVE:
221 err = pseries_remove_memory(node);
223 case PSERIES_DRCONF_MEM_ADD:
224 case PSERIES_DRCONF_MEM_REMOVE:
225 err = pseries_drconf_memory(node, action);
228 return notifier_from_errno(err);
232 .notifier_call = pseries_memory_notifier,
235 static int __init pseries_memory_hotplug_init(
void)
237 if (firmware_has_feature(FW_FEATURE_LPAR))