linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH 3/3] powerpc/pseries: Cleanup property cloning in memory dlpar
Date: Wed, 10 Feb 2016 11:13:29 -0600	[thread overview]
Message-ID: <56BB6FB9.2020701@linux.vnet.ibm.com> (raw)
In-Reply-To: <56BB6EA5.9090405@linux.vnet.ibm.com>

Now that the DLPAR add/remove flow updates the ibm,dynamic-memory device
tree property each time we add or remove a LMB the work needed to clone
this property can be reduced.

Prior to performing any memory DLPAR operation we now clone the device
tree property once and convert it to cpu format. This copy is then used
to walk through LMBs as we process them and is thrown away when we
are finished. There is no longer a need to convert the entire property to
cpu format and then back to BE every time we update it, we can just parse
it in its native BE format and update the one LMB we need to modify
before updating the property.

This patch removes the BE => cpu conversion step in the clone routine and
creates a drconf_property_to_cpu() routine to make this conversion for the
one time we need to convert the entire property. This then allows us
to remove dlpar_update_drconf_property() since we can now do everything
in dlpar_update_device_tree_lmb().

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/pseries/hotplug-memory.c |   79 +++++++++--------------
 1 file changed, 32 insertions(+), 47 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 2ce1385..4e0cde9 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -79,9 +79,6 @@ static void dlpar_free_drconf_property(struct property *prop)
 static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 {
 	struct property *prop, *new_prop;
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i;
 
 	prop = of_find_property(dn, "ibm,dynamic-memory", NULL);
 	if (!prop)
@@ -99,48 +96,9 @@ static struct property *dlpar_clone_drconf_property(struct device_node *dn)
 	}
 
 	new_prop->length = prop->length;
-
-	/* Convert the property to cpu endian-ness */
-	p = new_prop->value;
-	*p = be32_to_cpu(*p);
-
-	num_lmbs = *p++;
-	lmbs = (struct of_drconf_cell *)p;
-
-	for (i = 0; i < num_lmbs; i++) {
-		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
-		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
-		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
-	}
-
 	return new_prop;
 }
 
-static void dlpar_update_drconf_property(struct device_node *dn,
-					 struct property *prop)
-{
-	struct of_drconf_cell *lmbs;
-	u32 num_lmbs, *p;
-	int i;
-
-	/* Convert the property back to BE */
-	p = prop->value;
-	num_lmbs = *p;
-	*p = cpu_to_be32(*p);
-	p++;
-
-	lmbs = (struct of_drconf_cell *)p;
-	for (i = 0; i < num_lmbs; i++) {
-		lmbs[i].base_addr = cpu_to_be64(lmbs[i].base_addr);
-		lmbs[i].drc_index = cpu_to_be32(lmbs[i].drc_index);
-		lmbs[i].flags = cpu_to_be32(lmbs[i].flags);
-	}
-
-	rtas_hp_event = true;
-	of_update_property(dn, prop);
-	rtas_hp_event = false;
-}
-
 static int dlpar_update_device_tree_lmb(struct of_drconf_cell *lmb)
 {
 	struct device_node *dn;
@@ -160,19 +118,24 @@ static int dlpar_update_device_tree_lmb(struct of_drconf_cell *lmb)
 	}
 
 	p = prop->value;
-	num_lmbs = *p++;
+	num_lmbs = be32_to_cpu(*p);
+	p++;
 	lmbs = (struct of_drconf_cell *)p;
 
 	for (i = 0; i < num_lmbs; i++) {
-		if (lmbs[i].drc_index == lmb->drc_index) {
-			lmbs[i].flags = lmb->flags;
-			lmbs[i].aa_index = lmb->aa_index;
+		u32 this_drc_index = be32_to_cpu(lmbs[i].drc_index);
 
-			dlpar_update_drconf_property(dn, prop);
+		if (this_drc_index == lmb->drc_index) {
+			lmbs[i].flags = cpu_to_be32(lmb->flags);
+			lmbs[i].aa_index = cpu_to_be32(lmb->aa_index);
 			break;
 		}
 	}
 
+	rtas_hp_event = true;
+	of_update_property(dn, prop);
+	rtas_hp_event = false;
+
 	of_node_put(dn);
 	return 0;
 }
@@ -701,6 +664,26 @@ static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
 	return rc;
 }
 
+static void drconf_property_to_cpu(struct property *prop)
+{
+	struct of_drconf_cell *lmbs;
+	int i, num_lmbs;
+	u32 *p;
+
+	/* Convert the property to cpu endian-ness */
+	p = prop->value;
+	*p = be32_to_cpu(*p);
+
+	num_lmbs = *p++;
+	lmbs = (struct of_drconf_cell *)p;
+
+	for (i = 0; i < num_lmbs; i++) {
+		lmbs[i].base_addr = be64_to_cpu(lmbs[i].base_addr);
+		lmbs[i].drc_index = be32_to_cpu(lmbs[i].drc_index);
+		lmbs[i].flags = be32_to_cpu(lmbs[i].flags);
+	}
+}
+
 int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 {
 	struct device_node *dn;
@@ -725,6 +708,8 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
 		goto dlpar_memory_out;
 	}
 
+	drconf_property_to_cpu(prop);
+
 	switch (hp_elog->action) {
 	case PSERIES_HP_ELOG_ACTION_ADD:
 		if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT)

  parent reply	other threads:[~2016-02-10 17:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 17:08 [PATCH 0/3] powerpc/pseries: Update affinity index during memory dlpar Nathan Fontenot
2016-02-10 17:10 ` [PATCH 1/3] powerpc/pseries: Refactor dlpar_add_lmb() code Nathan Fontenot
2016-04-11 12:35   ` [1/3] " Michael Ellerman
2016-02-10 17:12 ` [PATCH 2/3] powerpc/pseries: Update LMB associativity index during DLPAR add/remove Nathan Fontenot
2016-04-11 12:35   ` [2/3] " Michael Ellerman
2016-02-10 17:13 ` Nathan Fontenot [this message]
2016-03-01 23:02   ` [3/3] powerpc/pseries: Cleanup property cloning in memory dlpar Michael Ellerman
2016-03-02  1:47     ` Michael Ellerman
2016-03-04  3:45       ` Nathan Fontenot

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=56BB6FB9.2020701@linux.vnet.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).