Skip to content

Commit 943db62

Browse files
nfontmpe
authored andcommitted
powerpc/pseries: Revert 'Auto-online hotplugged memory'
This reverts commit ec99907 ("powerpc/pseries: Auto-online hotplugged memory"), and 9dc5128 ("powerpc: Fix unused function warning 'lmb_to_memblock'"). Using the auto-online acpability does online added memory but does not update the associated device struct to indicate that the memory is online. This causes the pseries memory DLPAR code to fail when trying to remove a LMB that was previously removed and added back. This happens when validating that the LMB is removable. This patch reverts to the previous behavior of calling device_online() to online the LMB when it is DLPAR added and moves the lmb_to_memblock() routine out of CONFIG_MEMORY_HOTREMOVE now that we call it for add. Fixes: ec99907 ("powerpc/pseries: Auto-online hotplugged memory") Cc: [email protected] # v4.8+ Signed-off-by: Nathan Fontenot <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent a311e73 commit 943db62

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

arch/powerpc/configs/pseries_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ CONFIG_KEXEC_FILE=y
5858
CONFIG_IRQ_ALL_CPUS=y
5959
CONFIG_MEMORY_HOTPLUG=y
6060
CONFIG_MEMORY_HOTREMOVE=y
61-
CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y
6261
CONFIG_KSM=y
6362
CONFIG_TRANSPARENT_HUGEPAGE=y
6463
CONFIG_PPC_64K_PAGES=y

arch/powerpc/platforms/pseries/hotplug-memory.c

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,19 @@ static int dlpar_remove_device_tree_lmb(struct of_drconf_cell *lmb)
320320
return dlpar_update_device_tree_lmb(lmb);
321321
}
322322

323+
static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
324+
{
325+
unsigned long section_nr;
326+
struct mem_section *mem_sect;
327+
struct memory_block *mem_block;
328+
329+
section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
330+
mem_sect = __nr_to_section(section_nr);
331+
332+
mem_block = find_memory_block(mem_sect);
333+
return mem_block;
334+
}
335+
323336
#ifdef CONFIG_MEMORY_HOTREMOVE
324337
static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)
325338
{
@@ -407,19 +420,6 @@ static bool lmb_is_removable(struct of_drconf_cell *lmb)
407420

408421
static int dlpar_add_lmb(struct of_drconf_cell *);
409422

410-
static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
411-
{
412-
unsigned long section_nr;
413-
struct mem_section *mem_sect;
414-
struct memory_block *mem_block;
415-
416-
section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
417-
mem_sect = __nr_to_section(section_nr);
418-
419-
mem_block = find_memory_block(mem_sect);
420-
return mem_block;
421-
}
422-
423423
static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
424424
{
425425
struct memory_block *mem_block;
@@ -728,6 +728,20 @@ static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
728728
}
729729
#endif /* CONFIG_MEMORY_HOTREMOVE */
730730

731+
static int dlpar_online_lmb(struct of_drconf_cell *lmb)
732+
{
733+
struct memory_block *mem_block;
734+
int rc;
735+
736+
mem_block = lmb_to_memblock(lmb);
737+
if (!mem_block)
738+
return -EINVAL;
739+
740+
rc = device_online(&mem_block->dev);
741+
put_device(&mem_block->dev);
742+
return rc;
743+
}
744+
731745
static int dlpar_add_lmb(struct of_drconf_cell *lmb)
732746
{
733747
unsigned long block_sz;
@@ -751,10 +765,18 @@ static int dlpar_add_lmb(struct of_drconf_cell *lmb)
751765

752766
/* Add the memory */
753767
rc = add_memory(nid, lmb->base_addr, block_sz);
754-
if (rc)
768+
if (rc) {
755769
dlpar_remove_device_tree_lmb(lmb);
756-
else
770+
return rc;
771+
}
772+
773+
rc = dlpar_online_lmb(lmb);
774+
if (rc) {
775+
remove_memory(nid, lmb->base_addr, block_sz);
776+
dlpar_remove_device_tree_lmb(lmb);
777+
} else {
757778
lmb->flags |= DRCONF_MEM_ASSIGNED;
779+
}
758780

759781
return rc;
760782
}

0 commit comments

Comments
 (0)