All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pseries/hotplug-memory: remove dlpar_memory_{add,remove}_by_index() functions
@ 2020-01-27 20:08 Scott Cheloha
  2020-02-10 20:28 ` Nathan Lynch
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Cheloha @ 2020-01-27 20:08 UTC (permalink / raw)
  To: linux-kernel, Michael Ellerman
  Cc: Nathan Fontenont, Nathan Lynch, Rick Lindley

The dlpar_memory_{add,remove}_by_index() functions are just special
cases of their dlpar_memory_{add,remove}_by_ic() counterparts where
the LMB count is 1.  There is no need to maintain separate code.

In addition, there is a NULL dereference bug in the *_by_index()
functions if the LMB in question is not found.  This bug is not
present in their *_by_ic() counterparts.

Signed-off-by: Scott Cheloha <cheloha@linux.ibm.com>
---
 .../platforms/pseries/hotplug-memory.c        | 74 +------------------
 1 file changed, 2 insertions(+), 72 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index c126b94d1943..df7854c5c1f2 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -473,38 +473,6 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
 	return rc;
 }
 
-static int dlpar_memory_remove_by_index(u32 drc_index)
-{
-	struct drmem_lmb *lmb;
-	int lmb_found;
-	int rc;
-
-	pr_info("Attempting to hot-remove LMB, drc index %x\n", drc_index);
-
-	lmb_found = 0;
-	for_each_drmem_lmb(lmb) {
-		if (lmb->drc_index == drc_index) {
-			lmb_found = 1;
-			rc = dlpar_remove_lmb(lmb);
-			if (!rc)
-				dlpar_release_drc(lmb->drc_index);
-
-			break;
-		}
-	}
-
-	if (!lmb_found)
-		rc = -EINVAL;
-
-	if (rc)
-		pr_info("Failed to hot-remove memory at %llx\n",
-			lmb->base_addr);
-	else
-		pr_info("Memory at %llx was hot-removed\n", lmb->base_addr);
-
-	return rc;
-}
-
 static int dlpar_memory_readd_by_index(u32 drc_index)
 {
 	struct drmem_lmb *lmb;
@@ -631,10 +599,6 @@ static int dlpar_memory_remove_by_count(u32 lmbs_to_remove)
 {
 	return -EOPNOTSUPP;
 }
-static int dlpar_memory_remove_by_index(u32 drc_index)
-{
-	return -EOPNOTSUPP;
-}
 static int dlpar_memory_readd_by_index(u32 drc_index)
 {
 	return -EOPNOTSUPP;
@@ -762,40 +726,6 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
 	return rc;
 }
 
-static int dlpar_memory_add_by_index(u32 drc_index)
-{
-	struct drmem_lmb *lmb;
-	int rc, lmb_found;
-
-	pr_info("Attempting to hot-add LMB, drc index %x\n", drc_index);
-
-	lmb_found = 0;
-	for_each_drmem_lmb(lmb) {
-		if (lmb->drc_index == drc_index) {
-			lmb_found = 1;
-			rc = dlpar_acquire_drc(lmb->drc_index);
-			if (!rc) {
-				rc = dlpar_add_lmb(lmb);
-				if (rc)
-					dlpar_release_drc(lmb->drc_index);
-			}
-
-			break;
-		}
-	}
-
-	if (!lmb_found)
-		rc = -EINVAL;
-
-	if (rc)
-		pr_info("Failed to hot-add memory, drc index %x\n", drc_index);
-	else
-		pr_info("Memory at %llx (drc index %x) was hot-added\n",
-			lmb->base_addr, drc_index);
-
-	return rc;
-}
-
 static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index)
 {
 	struct drmem_lmb *lmb, *start_lmb, *end_lmb;
@@ -887,7 +817,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 			break;
 		case PSERIES_HP_ELOG_ID_DRC_INDEX:
 			drc_index = hp_elog->_drc_u.drc_index;
-			rc = dlpar_memory_add_by_index(drc_index);
+			rc = dlpar_memory_add_by_ic(1, drc_index);
 			break;
 		case PSERIES_HP_ELOG_ID_DRC_IC:
 			count = hp_elog->_drc_u.ic.count;
@@ -908,7 +838,7 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 			break;
 		case PSERIES_HP_ELOG_ID_DRC_INDEX:
 			drc_index = hp_elog->_drc_u.drc_index;
-			rc = dlpar_memory_remove_by_index(drc_index);
+			rc = dlpar_memory_remove_by_ic(1, drc_index);
 			break;
 		case PSERIES_HP_ELOG_ID_DRC_IC:
 			count = hp_elog->_drc_u.ic.count;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-11 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-27 20:08 [PATCH] pseries/hotplug-memory: remove dlpar_memory_{add,remove}_by_index() functions Scott Cheloha
2020-02-10 20:28 ` Nathan Lynch
2020-02-11 22:04   ` Scott Cheloha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.