Commit b45e9d76 authored by YueHaibing's avatar YueHaibing Committed by Michael Ellerman

powerpc/pseries/memory-hotplug: Fix return value type of find_aa_index

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.

Fixes: c05a5a40 ("powerpc/pseries: Dynamic add entires to associativity lookup array")
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Reviewed-by: Nathan Fontenot nfont@linux.vnet.ibm.com>
[mpe: Tweak changelog, rename is_found to just found]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent b90484ec
...@@ -101,11 +101,12 @@ static struct property *dlpar_clone_property(struct property *prop, ...@@ -101,11 +101,12 @@ static struct property *dlpar_clone_property(struct property *prop,
return new_prop; return new_prop;
} }
static u32 find_aa_index(struct device_node *dr_node, static bool find_aa_index(struct device_node *dr_node,
struct property *ala_prop, const u32 *lmb_assoc) struct property *ala_prop,
const u32 *lmb_assoc, u32 *aa_index)
{ {
u32 *assoc_arrays; u32 *assoc_arrays, new_prop_size;
u32 aa_index; struct property *new_prop;
int aa_arrays, aa_array_entries, aa_array_sz; int aa_arrays, aa_array_entries, aa_array_sz;
int i, index; int i, index;
...@@ -121,25 +122,20 @@ static u32 find_aa_index(struct device_node *dr_node, ...@@ -121,25 +122,20 @@ static u32 find_aa_index(struct device_node *dr_node,
aa_array_entries = be32_to_cpu(assoc_arrays[1]); aa_array_entries = be32_to_cpu(assoc_arrays[1]);
aa_array_sz = aa_array_entries * sizeof(u32); aa_array_sz = aa_array_entries * sizeof(u32);
aa_index = -1;
for (i = 0; i < aa_arrays; i++) { for (i = 0; i < aa_arrays; i++) {
index = (i * aa_array_entries) + 2; index = (i * aa_array_entries) + 2;
if (memcmp(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz)) if (memcmp(&assoc_arrays[index], &lmb_assoc[1], aa_array_sz))
continue; continue;
aa_index = i; *aa_index = i;
break; 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_size = ala_prop->length + aa_array_sz;
new_prop = dlpar_clone_property(ala_prop, new_prop_size); new_prop = dlpar_clone_property(ala_prop, new_prop_size);
if (!new_prop) if (!new_prop)
return -1; return false;
assoc_arrays = new_prop->value; assoc_arrays = new_prop->value;
...@@ -157,10 +153,8 @@ static u32 find_aa_index(struct device_node *dr_node, ...@@ -157,10 +153,8 @@ static u32 find_aa_index(struct device_node *dr_node,
* number of entries - 1 since we added its associativity * number of entries - 1 since we added its associativity
* to the end of the lookup array. * to the end of the lookup array.
*/ */
aa_index = be32_to_cpu(assoc_arrays[0]) - 1; *aa_index = be32_to_cpu(assoc_arrays[0]) - 1;
} return true;
return aa_index;
} }
static int update_lmb_associativity_index(struct drmem_lmb *lmb) static int update_lmb_associativity_index(struct drmem_lmb *lmb)
...@@ -169,6 +163,7 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) ...@@ -169,6 +163,7 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb)
struct property *ala_prop; struct property *ala_prop;
const u32 *lmb_assoc; const u32 *lmb_assoc;
u32 aa_index; u32 aa_index;
bool found;
parent = of_find_node_by_path("/"); parent = of_find_node_by_path("/");
if (!parent) if (!parent)
...@@ -200,11 +195,11 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) ...@@ -200,11 +195,11 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb)
return -ENODEV; return -ENODEV;
} }
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); dlpar_free_cc_nodes(lmb_node);
if (aa_index < 0) { if (!found) {
pr_err("Could not find LMB associativity\n"); pr_err("Could not find LMB associativity\n");
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment