Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2019-10-03 11:56:31 +0200
committerMichal Suchanek <msuchanek@suse.de>2019-10-03 12:00:48 +0200
commitfea548086858334e2acfeaf13f66bea1c475c0d0 (patch)
tree66912ce4c82a4b666dfa691b3b15d5a676a44322
parent1c86730dc1fd79733ef5fe3588e86f40a0efabe8 (diff)
powerpc/pseries/memory-hotplug: Fix return value type of
find_aa_index (bsc#1065729).
-rw-r--r--patches.suse/powerpc-pseries-memory-hotplug-Fix-return-value-type.patch186
-rw-r--r--series.conf1
2 files changed, 187 insertions, 0 deletions
diff --git a/patches.suse/powerpc-pseries-memory-hotplug-Fix-return-value-type.patch b/patches.suse/powerpc-pseries-memory-hotplug-Fix-return-value-type.patch
new file mode 100644
index 0000000000..cbdad2434d
--- /dev/null
+++ b/patches.suse/powerpc-pseries-memory-hotplug-Fix-return-value-type.patch
@@ -0,0 +1,186 @@
+From b45e9d761ba2d60044b610297e3ef9f947ac157f Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Tue, 9 Oct 2018 21:59:13 +0800
+Subject: [PATCH] powerpc/pseries/memory-hotplug: Fix return value type of
+ find_aa_index
+
+References: bsc#1065729
+Patch-mainline: v4.20-rc1
+Git-commit: b45e9d761ba2d60044b610297e3ef9f947ac157f
+
+The variable 'aa_index' is defined as an unsigned value in
+update_lmb_associativity_index(), but find_aa_index() may return -1
+when dlpar_clone_property() fails. So change find_aa_index() to return
+a bool, which indicates whether 'aa_index' was found or not.
+
+[in 4.12 there is additional indirection so need to pass aa_index twice]
+
+Fixes: c05a5a40969e ("powerpc/pseries: Dynamic add entires to associativity lookup array")
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Reviewed-by: Nathan Fontenot nfont@linux.vnet.ibm.com>
+[mpe: Tweak changelog, rename is_found to just found]
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ .../platforms/pseries/hotplug-memory.c | 61 +++++++++----------
+ 1 file changed, 28 insertions(+), 33 deletions(-)
+
+--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
++++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
+@@ -101,11 +101,12 @@ static struct property *dlpar_clone_prop
+ return new_prop;
+ }
+
+-static u32 find_aa_index(struct device_node *dr_node,
+- struct property *ala_prop, const u32 *lmb_assoc)
++static bool find_aa_index(struct device_node *dr_node,
++ struct property *ala_prop,
++ const u32 *lmb_assoc, u32 *aa_index)
+ {
+- u32 *assoc_arrays;
+- u32 aa_index;
++ u32 *assoc_arrays, new_prop_size;
++ struct property *new_prop;
+ int aa_arrays, aa_array_entries, aa_array_sz;
+ int i, index;
+
+@@ -121,75 +122,68 @@ static u32 find_aa_index(struct device_n
+ aa_array_entries = be32_to_cpu(assoc_arrays[1]);
+ aa_array_sz = aa_array_entries * sizeof(u32);
+
+- aa_index = -1;
+ for (i = 0; i < aa_arrays; i++) {
+ index = (i * aa_array_entries) + 2;
+
+ if (memcmp(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz))
+ continue;
+
+- aa_index = i;
+- break;
++ *aa_index = i;
++ return true;
+ }
+
+- if (aa_index == -1) {
+- struct property *new_prop;
+- u32 new_prop_size;
+-
+- new_prop_size = ala_prop->length + aa_array_sz;
+- new_prop = dlpar_clone_property(ala_prop, new_prop_size);
+- if (!new_prop)
+- return -1;
+-
+- assoc_arrays = new_prop->value;
+-
+- /* increment the number of entries in the lookup array */
+- assoc_arrays[0] = cpu_to_be32(aa_arrays + 1);
+-
+- /* copy the new associativity into the lookup array */
+- index = aa_arrays * aa_array_entries + 2;
+- memcpy(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz);
+-
+- of_update_property(dr_node, new_prop);
+-
+- /*
+- * The associativity lookup array index for this lmb is
+- * number of entries - 1 since we added its associativity
+- * to the end of the lookup array.
+- */
+- aa_index = be32_to_cpu(assoc_arrays[0]) - 1;
+- }
++ new_prop_size = ala_prop->length + aa_array_sz;
++ new_prop = dlpar_clone_property(ala_prop, new_prop_size);
++ if (!new_prop)
++ return false;
++
++ assoc_arrays = new_prop->value;
++
++ /* increment the number of entries in the lookup array */
++ assoc_arrays[0] = cpu_to_be32(aa_arrays + 1);
+
+- return aa_index;
++ /* copy the new associativity into the lookup array */
++ index = aa_arrays * aa_array_entries + 2;
++ memcpy(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz);
++
++ of_update_property(dr_node, new_prop);
++
++ /*
++ * The associativity lookup array index for this lmb is
++ * number of entries - 1 since we added its associativity
++ * to the end of the lookup array.
++ */
++ *aa_index = be32_to_cpu(assoc_arrays[0]) - 1;
++ return true;
+ }
+
+-static u32 lookup_lmb_associativity_index(struct drmem_lmb *lmb)
++static u32 lookup_lmb_associativity_index(struct drmem_lmb *lmb, u32 *aa_index)
+ {
+ struct device_node *parent, *lmb_node, *dr_node;
+ struct property *ala_prop;
+ const u32 *lmb_assoc;
+- u32 aa_index;
++ bool found;
+
+ parent = of_find_node_by_path("/");
+ if (!parent)
+- return -ENODEV;
++ return false;
+
+ lmb_node = dlpar_configure_connector(cpu_to_be32(lmb->drc_index),
+ parent);
+ of_node_put(parent);
+ if (!lmb_node)
+- return -EINVAL;
++ return false;
+
+ lmb_assoc = of_get_property(lmb_node, "ibm,associativity", NULL);
+ if (!lmb_assoc) {
+ dlpar_free_cc_nodes(lmb_node);
+- return -ENODEV;
++ return false;
+ }
+
+ dr_node = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
+ if (!dr_node) {
+ dlpar_free_cc_nodes(lmb_node);
+- return -ENODEV;
++ return false;
+ }
+
+ ala_prop = of_find_property(dr_node, "ibm,associativity-lookup-arrays",
+@@ -197,26 +191,27 @@ static u32 lookup_lmb_associativity_inde
+ if (!ala_prop) {
+ of_node_put(dr_node);
+ dlpar_free_cc_nodes(lmb_node);
+- return -ENODEV;
++ return false;
+ }
+
+- aa_index = find_aa_index(dr_node, ala_prop, lmb_assoc);
++ found = find_aa_index(dr_node, ala_prop, lmb_assoc, aa_index);
+
+ dlpar_free_cc_nodes(lmb_node);
+- return aa_index;
++ return found;
+ }
+
+ static int dlpar_add_device_tree_lmb(struct drmem_lmb *lmb)
+ {
+ int rc, aa_index;
++ bool found;
+
+ lmb->flags |= DRCONF_MEM_ASSIGNED;
+
+- aa_index = lookup_lmb_associativity_index(lmb);
+- if (aa_index < 0) {
++ found = lookup_lmb_associativity_index(lmb, &aa_index);
++ if (!found) {
+ pr_err("Couldn't find associativity index for drc index %x\n",
+ lmb->drc_index);
+- return aa_index;
++ return -ENODEV;
+ }
+
+ lmb->aa_index = aa_index;
diff --git a/series.conf b/series.conf
index c89e369f46..7e938b5066 100644
--- a/series.conf
+++ b/series.conf
@@ -20381,6 +20381,7 @@
patches.suse/powerpc-process-Fix-sparse-address-space-warnings.patch
patches.suse/powerpc-boot-Expose-Kconfig-symbols-to-wrapper.patch
patches.suse/powerpc-boot-Fix-opal-console-in-boot-wrapper.patch
+ patches.suse/powerpc-pseries-memory-hotplug-Fix-return-value-type.patch
patches.suse/powerpc-pseries-mobility-Extend-start-stop-topology-.patch
patches.suse/powerpc-Detect-the-presence-of-big-cores-via-ibm-thr.patch
patches.suse/powerpc-Use-cpu_smallcore_sibling_mask-at-SMT-level-.patch