blob: f5eec0fc46df220e2cc4724834b532dd0a83445c [file] [log] [blame]
Badari Pulavarty57b53922008-04-18 13:33:50 -07001/*
2 * pseries Memory Hotplug infrastructure.
3 *
4 * Copyright (C) 2008 Badari Pulavarty, IBM Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
Nathan Fontenot999e2da2015-02-10 13:47:02 -060012#define pr_fmt(fmt) "pseries-hotplug-mem: " fmt
13
Badari Pulavarty57b53922008-04-18 13:33:50 -070014#include <linux/of.h>
Rob Herring26a20562013-09-26 07:40:04 -050015#include <linux/of_address.h>
Yinghai Lu95f72d12010-07-12 14:36:09 +100016#include <linux/memblock.h>
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100017#include <linux/memory.h>
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -060018#include <linux/memory_hotplug.h>
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -060019#include <linux/slab.h>
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100020
Badari Pulavarty57b53922008-04-18 13:33:50 -070021#include <asm/firmware.h>
22#include <asm/machdep.h>
Rob Herring26a20562013-09-26 07:40:04 -050023#include <asm/prom.h>
Michael Neuling0b2f8282009-02-08 14:49:39 +000024#include <asm/sparsemem.h>
Anton Blanchard1217d342014-08-20 08:55:19 +100025#include "pseries.h"
Badari Pulavarty57b53922008-04-18 13:33:50 -070026
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -060027static bool rtas_hp_event;
28
Anton Blancharda5d86252014-06-04 17:50:47 +100029unsigned long pseries_memory_block_size(void)
Nathan Fontenotc540ada2011-01-20 10:45:20 -060030{
31 struct device_node *np;
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100032 unsigned int memblock_size = MIN_MEMORY_BLOCK_SIZE;
33 struct resource r;
Nathan Fontenotc540ada2011-01-20 10:45:20 -060034
35 np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
36 if (np) {
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100037 const __be64 *size;
Nathan Fontenotc540ada2011-01-20 10:45:20 -060038
39 size = of_get_property(np, "ibm,lmb-size", NULL);
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100040 if (size)
41 memblock_size = be64_to_cpup(size);
Nathan Fontenotc540ada2011-01-20 10:45:20 -060042 of_node_put(np);
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100043 } else if (machine_is(pseries)) {
44 /* This fallback really only applies to pseries */
Nathan Fontenotc540ada2011-01-20 10:45:20 -060045 unsigned int memzero_size = 0;
Nathan Fontenotc540ada2011-01-20 10:45:20 -060046
47 np = of_find_node_by_path("/memory@0");
48 if (np) {
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100049 if (!of_address_to_resource(np, 0, &r))
50 memzero_size = resource_size(&r);
Nathan Fontenotc540ada2011-01-20 10:45:20 -060051 of_node_put(np);
52 }
53
54 if (memzero_size) {
55 /* We now know the size of memory@0, use this to find
56 * the first memoryblock and get its size.
57 */
58 char buf[64];
59
60 sprintf(buf, "/memory@%x", memzero_size);
61 np = of_find_node_by_path(buf);
62 if (np) {
Benjamin Herrenschmidt770e1ac2011-06-14 10:57:51 +100063 if (!of_address_to_resource(np, 0, &r))
64 memblock_size = resource_size(&r);
Nathan Fontenotc540ada2011-01-20 10:45:20 -060065 of_node_put(np);
66 }
67 }
68 }
Nathan Fontenotc540ada2011-01-20 10:45:20 -060069 return memblock_size;
70}
71
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -060072static void dlpar_free_drconf_property(struct property *prop)
73{
74 kfree(prop->name);
75 kfree(prop->value);
76 kfree(prop);
77}
78
79static struct property *dlpar_clone_drconf_property(struct device_node *dn)
80{
81 struct property *prop, *new_prop;
82 struct of_drconf_cell *lmbs;
83 u32 num_lmbs, *p;
84 int i;
85
86 prop = of_find_property(dn, "ibm,dynamic-memory", NULL);
87 if (!prop)
88 return NULL;
89
90 new_prop = kzalloc(sizeof(*new_prop), GFP_KERNEL);
91 if (!new_prop)
92 return NULL;
93
94 new_prop->name = kstrdup(prop->name, GFP_KERNEL);
95 new_prop->value = kmalloc(prop->length, GFP_KERNEL);
96 if (!new_prop->name || !new_prop->value) {
97 dlpar_free_drconf_property(new_prop);
98 return NULL;
99 }
100
101 memcpy(new_prop->value, prop->value, prop->length);
102 new_prop->length = prop->length;
103
104 /* Convert the property to cpu endian-ness */
105 p = new_prop->value;
106 *p = be32_to_cpu(*p);
107
108 num_lmbs = *p++;
109 lmbs = (struct of_drconf_cell *)p;
110
111 for (i = 0; i < num_lmbs; i++) {
112 lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
113 lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
114 lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
115 }
116
117 return new_prop;
118}
119
120static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
121{
122 unsigned long section_nr;
123 struct mem_section *mem_sect;
124 struct memory_block *mem_block;
125
126 section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
127 mem_sect = __nr_to_section(section_nr);
128
129 mem_block = find_memory_block(mem_sect);
130 return mem_block;
131}
132
David Rientjes4edd7ce2013-04-29 15:08:22 -0700133#ifdef CONFIG_MEMORY_HOTREMOVE
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600134static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)
135{
136 unsigned long block_sz, start_pfn;
137 int sections_per_block;
138 int i, nid;
139
140 start_pfn = base >> PAGE_SHIFT;
141
Li Zhong42dbfc82014-04-10 16:25:31 +0800142 lock_device_hotplug();
143
144 if (!pfn_valid(start_pfn))
145 goto out;
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600146
Anton Blancharda5d86252014-06-04 17:50:47 +1000147 block_sz = pseries_memory_block_size();
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600148 sections_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE;
149 nid = memory_add_physaddr_to_nid(base);
150
151 for (i = 0; i < sections_per_block; i++) {
152 remove_memory(nid, base, MIN_MEMORY_BLOCK_SIZE);
153 base += MIN_MEMORY_BLOCK_SIZE;
154 }
155
Li Zhong42dbfc82014-04-10 16:25:31 +0800156out:
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600157 /* Update memory regions for memory remove */
158 memblock_remove(base, memblock_size);
Li Zhong42dbfc82014-04-10 16:25:31 +0800159 unlock_device_hotplug();
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600160 return 0;
161}
162
163static int pseries_remove_mem_node(struct device_node *np)
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000164{
165 const char *type;
Thomas Falconc9ac4082014-08-19 15:44:57 -0500166 const __be32 *regs;
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000167 unsigned long base;
Benjamin Herrenschmidt3fdfd992010-07-23 10:35:52 +1000168 unsigned int lmb_size;
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000169 int ret = -EINVAL;
170
171 /*
172 * Check to see if we are actually removing memory
173 */
174 type = of_get_property(np, "device_type", NULL);
175 if (type == NULL || strcmp(type, "memory") != 0)
176 return 0;
177
178 /*
Li Zhong4646d132014-08-07 13:11:58 +0800179 * Find the base address and size of the memblock
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000180 */
181 regs = of_get_property(np, "reg", NULL);
182 if (!regs)
183 return ret;
184
Thomas Falconc9ac4082014-08-19 15:44:57 -0500185 base = be64_to_cpu(*(unsigned long *)regs);
186 lmb_size = be32_to_cpu(regs[3]);
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000187
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600188 pseries_remove_memblock(base, lmb_size);
189 return 0;
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000190}
David Rientjes4edd7ce2013-04-29 15:08:22 -0700191#else
192static inline int pseries_remove_memblock(unsigned long base,
193 unsigned int memblock_size)
194{
195 return -EOPNOTSUPP;
196}
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600197static inline int pseries_remove_mem_node(struct device_node *np)
David Rientjes4edd7ce2013-04-29 15:08:22 -0700198{
Gavin Shanf1b39292014-08-11 19:16:19 +1000199 return 0;
David Rientjes4edd7ce2013-04-29 15:08:22 -0700200}
201#endif /* CONFIG_MEMORY_HOTREMOVE */
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000202
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600203static int dlpar_add_lmb(struct of_drconf_cell *lmb)
204{
205 struct memory_block *mem_block;
206 unsigned long block_sz;
207 int nid, rc;
208
209 if (lmb->flags & DRCONF_MEM_ASSIGNED)
210 return -EINVAL;
211
212 block_sz = memory_block_size_bytes();
213
214 rc = dlpar_acquire_drc(lmb->drc_index);
215 if (rc)
216 return rc;
217
218 /* Find the node id for this address */
219 nid = memory_add_physaddr_to_nid(lmb->base_addr);
220
221 /* Add the memory */
222 rc = add_memory(nid, lmb->base_addr, block_sz);
223 if (rc) {
224 dlpar_release_drc(lmb->drc_index);
225 return rc;
226 }
227
228 /* Register this block of memory */
229 rc = memblock_add(lmb->base_addr, block_sz);
230 if (rc) {
231 remove_memory(nid, lmb->base_addr, block_sz);
232 dlpar_release_drc(lmb->drc_index);
233 return rc;
234 }
235
236 mem_block = lmb_to_memblock(lmb);
237 if (!mem_block) {
238 remove_memory(nid, lmb->base_addr, block_sz);
239 dlpar_release_drc(lmb->drc_index);
240 return -EINVAL;
241 }
242
243 rc = device_online(&mem_block->dev);
244 put_device(&mem_block->dev);
245 if (rc) {
246 remove_memory(nid, lmb->base_addr, block_sz);
247 dlpar_release_drc(lmb->drc_index);
248 return rc;
249 }
250
251 lmb->flags |= DRCONF_MEM_ASSIGNED;
252 return 0;
253}
254
255static int dlpar_memory_add_by_count(u32 lmbs_to_add, struct property *prop)
256{
257 struct of_drconf_cell *lmbs;
258 u32 num_lmbs, *p;
259 int lmbs_available = 0;
260 int lmbs_added = 0;
261 int i, rc;
262
263 pr_info("Attempting to hot-add %d LMB(s)\n", lmbs_to_add);
264
265 if (lmbs_to_add == 0)
266 return -EINVAL;
267
268 p = prop->value;
269 num_lmbs = *p++;
270 lmbs = (struct of_drconf_cell *)p;
271
272 /* Validate that there are enough LMBs to satisfy the request */
273 for (i = 0; i < num_lmbs; i++) {
274 if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED))
275 lmbs_available++;
276 }
277
278 if (lmbs_available < lmbs_to_add)
279 return -EINVAL;
280
281 for (i = 0; i < num_lmbs && lmbs_to_add != lmbs_added; i++) {
282 rc = dlpar_add_lmb(&lmbs[i]);
283 if (rc)
284 continue;
285
286 lmbs_added++;
287
288 /* Mark this lmb so we can remove it later if all of the
289 * requested LMBs cannot be added.
290 */
291 lmbs[i].reserved = 1;
292 }
293
294 if (lmbs_added != lmbs_to_add) {
295 /* TODO: remove added lmbs */
296 rc = -EINVAL;
297 } else {
298 for (i = 0; i < num_lmbs; i++) {
299 if (!lmbs[i].reserved)
300 continue;
301
302 pr_info("Memory at %llx (drc index %x) was hot-added\n",
303 lmbs[i].base_addr, lmbs[i].drc_index);
304 lmbs[i].reserved = 0;
305 }
306 }
307
308 return rc;
309}
310
311static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
312{
313 struct of_drconf_cell *lmbs;
314 u32 num_lmbs, *p;
315 int i, lmb_found;
316 int rc;
317
318 pr_info("Attempting to hot-add LMB, drc index %x\n", drc_index);
319
320 p = prop->value;
321 num_lmbs = *p++;
322 lmbs = (struct of_drconf_cell *)p;
323
324 lmb_found = 0;
325 for (i = 0; i < num_lmbs; i++) {
326 if (lmbs[i].drc_index == drc_index) {
327 lmb_found = 1;
328 rc = dlpar_add_lmb(&lmbs[i]);
329 break;
330 }
331 }
332
333 if (!lmb_found)
334 rc = -EINVAL;
335
336 if (rc)
337 pr_info("Failed to hot-add memory, drc index %x\n", drc_index);
338 else
339 pr_info("Memory at %llx (drc index %x) was hot-added\n",
340 lmbs[i].base_addr, drc_index);
341
342 return rc;
343}
344
345static void dlpar_update_drconf_property(struct device_node *dn,
346 struct property *prop)
347{
348 struct of_drconf_cell *lmbs;
349 u32 num_lmbs, *p;
350 int i;
351
352 /* Convert the property back to BE */
353 p = prop->value;
354 num_lmbs = *p;
355 *p = cpu_to_be32(*p);
356 p++;
357
358 lmbs = (struct of_drconf_cell *)p;
359 for (i = 0; i < num_lmbs; i++) {
360 lmbs[i].base_addr = cpu_to_be64(lmbs[i].base_addr);
361 lmbs[i].drc_index = cpu_to_be32(lmbs[i].drc_index);
362 lmbs[i].flags = cpu_to_be32(lmbs[i].flags);
363 }
364
365 rtas_hp_event = true;
366 of_update_property(dn, prop);
367 rtas_hp_event = false;
368}
369
Nathan Fontenot999e2da2015-02-10 13:47:02 -0600370int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
371{
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600372 struct device_node *dn;
373 struct property *prop;
374 u32 count, drc_index;
375 int rc;
376
377 count = hp_elog->_drc_u.drc_count;
378 drc_index = hp_elog->_drc_u.drc_index;
Nathan Fontenot999e2da2015-02-10 13:47:02 -0600379
380 lock_device_hotplug();
381
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600382 dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
383 if (!dn)
384 return -EINVAL;
385
386 prop = dlpar_clone_drconf_property(dn);
387 if (!prop) {
388 of_node_put(dn);
389 return -EINVAL;
390 }
391
Nathan Fontenot999e2da2015-02-10 13:47:02 -0600392 switch (hp_elog->action) {
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600393 case PSERIES_HP_ELOG_ACTION_ADD:
394 if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)
395 rc = dlpar_memory_add_by_count(count, prop);
396 else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX)
397 rc = dlpar_memory_add_by_index(drc_index, prop);
398 else
399 rc = -EINVAL;
400 break;
Nathan Fontenot999e2da2015-02-10 13:47:02 -0600401 default:
402 pr_err("Invalid action (%d) specified\n", hp_elog->action);
403 rc = -EINVAL;
404 break;
405 }
406
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600407 if (rc)
408 dlpar_free_drconf_property(prop);
409 else
410 dlpar_update_drconf_property(dn, prop);
411
412 of_node_put(dn);
Nathan Fontenot999e2da2015-02-10 13:47:02 -0600413 unlock_device_hotplug();
414 return rc;
415}
416
Nathan Fontenot9ac8cde2014-01-27 10:54:06 -0600417static int pseries_add_mem_node(struct device_node *np)
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700418{
419 const char *type;
Thomas Falconc9ac4082014-08-19 15:44:57 -0500420 const __be32 *regs;
Nathan Fontenot92ecd172008-07-03 13:20:58 +1000421 unsigned long base;
Benjamin Herrenschmidt3fdfd992010-07-23 10:35:52 +1000422 unsigned int lmb_size;
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700423 int ret = -EINVAL;
424
425 /*
426 * Check to see if we are actually adding memory
427 */
428 type = of_get_property(np, "device_type", NULL);
429 if (type == NULL || strcmp(type, "memory") != 0)
430 return 0;
431
432 /*
Yinghai Lu95f72d12010-07-12 14:36:09 +1000433 * Find the base and size of the memblock
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700434 */
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700435 regs = of_get_property(np, "reg", NULL);
436 if (!regs)
437 return ret;
438
Thomas Falconc9ac4082014-08-19 15:44:57 -0500439 base = be64_to_cpu(*(unsigned long *)regs);
440 lmb_size = be32_to_cpu(regs[3]);
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700441
442 /*
443 * Update memory region to represent the memory add
444 */
Benjamin Herrenschmidt3fdfd992010-07-23 10:35:52 +1000445 ret = memblock_add(base, lmb_size);
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000446 return (ret < 0) ? -EINVAL : 0;
447}
448
Grant Likelyf5242e52014-11-24 17:58:01 +0000449static int pseries_update_drconf_memory(struct of_reconfig_data *pr)
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000450{
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000451 struct of_drconf_cell *new_drmem, *old_drmem;
Nathan Fontenotc540ada2011-01-20 10:45:20 -0600452 unsigned long memblock_size;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000453 u32 entries;
Thomas Falconc9ac4082014-08-19 15:44:57 -0500454 __be32 *p;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000455 int i, rc = -EINVAL;
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000456
Nathan Fontenot5f97b2a2015-02-10 13:48:25 -0600457 if (rtas_hp_event)
458 return 0;
459
Anton Blancharda5d86252014-06-04 17:50:47 +1000460 memblock_size = pseries_memory_block_size();
Nathan Fontenotc540ada2011-01-20 10:45:20 -0600461 if (!memblock_size)
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000462 return -EINVAL;
463
Thomas Falconc9ac4082014-08-19 15:44:57 -0500464 p = (__be32 *) pr->old_prop->value;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000465 if (!p)
466 return -EINVAL;
467
468 /* The first int of the property is the number of lmb's described
469 * by the property. This is followed by an array of of_drconf_cell
Li Zhong4646d132014-08-07 13:11:58 +0800470 * entries. Get the number of entries and skip to the array of
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000471 * of_drconf_cell's.
472 */
Thomas Falconc9ac4082014-08-19 15:44:57 -0500473 entries = be32_to_cpu(*p++);
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000474 old_drmem = (struct of_drconf_cell *)p;
475
Thomas Falconc9ac4082014-08-19 15:44:57 -0500476 p = (__be32 *)pr->prop->value;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000477 p++;
478 new_drmem = (struct of_drconf_cell *)p;
479
480 for (i = 0; i < entries; i++) {
Thomas Falconc9ac4082014-08-19 15:44:57 -0500481 if ((be32_to_cpu(old_drmem[i].flags) & DRCONF_MEM_ASSIGNED) &&
482 (!(be32_to_cpu(new_drmem[i].flags) & DRCONF_MEM_ASSIGNED))) {
483 rc = pseries_remove_memblock(
484 be64_to_cpu(old_drmem[i].base_addr),
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000485 memblock_size);
486 break;
Thomas Falconc9ac4082014-08-19 15:44:57 -0500487 } else if ((!(be32_to_cpu(old_drmem[i].flags) &
488 DRCONF_MEM_ASSIGNED)) &&
489 (be32_to_cpu(new_drmem[i].flags) &
490 DRCONF_MEM_ASSIGNED)) {
491 rc = memblock_add(be64_to_cpu(old_drmem[i].base_addr),
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000492 memblock_size);
493 rc = (rc < 0) ? -EINVAL : 0;
494 break;
495 }
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000496 }
Nathan Fontenot3c3f67e2008-07-03 13:22:39 +1000497 return rc;
Badari Pulavarty98d5c212008-04-18 13:33:52 -0700498}
499
Badari Pulavarty57b53922008-04-18 13:33:50 -0700500static int pseries_memory_notifier(struct notifier_block *nb,
Grant Likelyf5242e52014-11-24 17:58:01 +0000501 unsigned long action, void *data)
Badari Pulavarty57b53922008-04-18 13:33:50 -0700502{
Grant Likelyf5242e52014-11-24 17:58:01 +0000503 struct of_reconfig_data *rd = data;
Akinobu Mitade2780a2011-06-21 03:35:56 +0000504 int err = 0;
Badari Pulavarty57b53922008-04-18 13:33:50 -0700505
506 switch (action) {
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000507 case OF_RECONFIG_ATTACH_NODE:
Grant Likelyf5242e52014-11-24 17:58:01 +0000508 err = pseries_add_mem_node(rd->dn);
Badari Pulavarty57b53922008-04-18 13:33:50 -0700509 break;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000510 case OF_RECONFIG_DETACH_NODE:
Grant Likelyf5242e52014-11-24 17:58:01 +0000511 err = pseries_remove_mem_node(rd->dn);
Badari Pulavarty57b53922008-04-18 13:33:50 -0700512 break;
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000513 case OF_RECONFIG_UPDATE_PROPERTY:
Grant Likelyf5242e52014-11-24 17:58:01 +0000514 if (!strcmp(rd->prop->name, "ibm,dynamic-memory"))
515 err = pseries_update_drconf_memory(rd);
Badari Pulavarty57b53922008-04-18 13:33:50 -0700516 break;
517 }
Akinobu Mitade2780a2011-06-21 03:35:56 +0000518 return notifier_from_errno(err);
Badari Pulavarty57b53922008-04-18 13:33:50 -0700519}
520
521static struct notifier_block pseries_mem_nb = {
522 .notifier_call = pseries_memory_notifier,
523};
524
525static int __init pseries_memory_hotplug_init(void)
526{
527 if (firmware_has_feature(FW_FEATURE_LPAR))
Nathan Fontenot1cf3d8b2012-10-02 16:57:57 +0000528 of_reconfig_notifier_register(&pseries_mem_nb);
Badari Pulavarty57b53922008-04-18 13:33:50 -0700529
Badari Pulavarty57b53922008-04-18 13:33:50 -0700530 return 0;
531}
532machine_device_initcall(pseries, pseries_memory_hotplug_init);