Message ID | 20210622133923.295373-4-danielhb413@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | powerpc/pseries: cleanups for dlpar_memory_add* functions | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (7f030e9d57b8ff6025bde4162f42378e6081126a) |
snowpatch_ozlabs/build-ppc64le | success | Build succeeded |
snowpatch_ozlabs/build-ppc64be | success | Build succeeded |
snowpatch_ozlabs/build-ppc64e | success | Build succeeded |
snowpatch_ozlabs/build-pmac32 | success | Build succeeded |
snowpatch_ozlabs/checkpatch | warning | total: 0 errors, 0 warnings, 1 checks, 28 lines checked |
snowpatch_ozlabs/needsstable | success | Patch has no Fixes tags |
Le 22/06/2021 à 15:39, Daniel Henrique Barboza a écrit : > 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. Reviewed-by: Laurent Dufour <ldufour@linux.ibm.com> > Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> > --- > arch/powerpc/platforms/pseries/hotplug-memory.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c > index c0a03e1537cb..377d852f5a9a 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c > @@ -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) > { > struct drmem_lmb *lmb, *start_lmb, *end_lmb; > - int lmbs_available = 0; > int rc; > > pr_info("Attempting to hot-add %u LMB(s) at index %x\n", > @@ -811,15 +810,14 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) > > /* Validate that the LMBs in this range are not reserved */ > for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { > - if (lmb->flags & DRCONF_MEM_RESERVED) > - break; > - > - lmbs_available++; > + /* Fail immediately if the whole range can't be hot-added */ > + if (lmb->flags & DRCONF_MEM_RESERVED) { > + pr_err("Memory at %llx (drc index %x) is reserved\n", > + lmb->base_addr, lmb->drc_index); > + return -EINVAL; > + } > } > > - if (lmbs_available < lmbs_to_add) > - return -EINVAL; > - > for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { > if (lmb->flags & DRCONF_MEM_ASSIGNED) > continue; >
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index c0a03e1537cb..377d852f5a9a 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -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) { struct drmem_lmb *lmb, *start_lmb, *end_lmb; - int lmbs_available = 0; int rc; pr_info("Attempting to hot-add %u LMB(s) at index %x\n", @@ -811,15 +810,14 @@ static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index) /* Validate that the LMBs in this range are not reserved */ for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { - if (lmb->flags & DRCONF_MEM_RESERVED) - break; - - lmbs_available++; + /* Fail immediately if the whole range can't be hot-added */ + if (lmb->flags & DRCONF_MEM_RESERVED) { + pr_err("Memory at %llx (drc index %x) is reserved\n", + lmb->base_addr, lmb->drc_index); + return -EINVAL; + } } - if (lmbs_available < lmbs_to_add) - return -EINVAL; - for_each_drmem_lmb_in_range(lmb, start_lmb, end_lmb) { if (lmb->flags & DRCONF_MEM_ASSIGNED) continue;
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: Daniel Henrique Barboza <danielhb413@gmail.com> --- arch/powerpc/platforms/pseries/hotplug-memory.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)