Commit 0e5962b2 authored by Daniel Henrique Barboza's avatar Daniel Henrique Barboza Committed by Michael Ellerman

powerpc/pseries: fail quicker in dlpar_memory_add_by_ic()

The validation done at the start of dlpar_memory_add_by_ic() is an all
of nothing scenario - if any LMBs in the range is marked as RESERVED we
can fail right away.

We then can remove the 'lmbs_available' var and its check with
'lmbs_to_add' since the whole LMB range was already validated in the
previous step.
Signed-off-by: default avatarDaniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210622133923.295373-4-danielhb413@gmail.com
parent c2aaddcc
...@@ -796,7 +796,6 @@ static int dlpar_memory_add_by_index(u32 drc_index) ...@@ -796,7 +796,6 @@ static int dlpar_memory_add_by_index(u32 drc_index)
static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index)
{ {
struct drmem_lmb *lmb, *start_lmb, *end_lmb; struct drmem_lmb *lmb, *start_lmb, *end_lmb;
int lmbs_available = 0;
int rc; int rc;
pr_info("Attempting to hot-add %u LMB(s) at index %x\n", pr_info("Attempting to hot-add %u LMB(s) at index %x\n",
...@@ -811,14 +810,13 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) ...@@ -811,14 +810,13 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index)
/* Validate that the LMBs in this range are not reserved */ /* Validate that the LMBs in this range are not reserved */
for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
if (lmb->flags & DRCONF_MEM_RESERVED) /* Fail immediately if the whole range can't be hot-added */
break; if (lmb->flags & DRCONF_MEM_RESERVED) {
pr_err("Memory at %llx (drc index %x) is reserved\n",
lmbs_available++; lmb->base_addr, lmb->drc_index);
}
if (lmbs_available < lmbs_to_add)
return -EINVAL; return -EINVAL;
}
}
for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) {
if (lmb->flags & DRCONF_MEM_ASSIGNED) if (lmb->flags & DRCONF_MEM_ASSIGNED)
......
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