mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Scott Cheloha <cheloha@linux.ibm.com>
To: linux-kernel@vger.kernel.org, Michael Ellerman <mpe@ellerman.id.au>
Cc: Nathan Fontenont <ndfont@gmail.com>,
	Nathan Lynch <nathanl@linux.ibm.com>,
	Rick Lindley <ricklind@linux.vnet.ibm.com>
Subject: [PATCH] pseries/hotplug-memory: remove dlpar_memory_{add,remove}_by_index() functions
Date: Mon, 27 Jan 2020 14:08:39 -0600	[thread overview]
Message-ID: <20200127200839.12441-1-cheloha@linux.ibm.com> (raw)

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


             reply	other threads:[~2020-01-27 20:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-27 20:08 Scott Cheloha [this message]
2020-02-10 20:28 ` Nathan Lynch
2020-02-11 22:04   ` Scott Cheloha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200127200839.12441-1-cheloha@linux.ibm.com \
    --to=cheloha@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=nathanl@linux.ibm.com \
    --cc=ndfont@gmail.com \
    --cc=ricklind@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®