On Thu, Mar 16, 2017 at 3:59 PM, Dave Jiang <dave.ji...@intel.com> wrote: > Providing mechanism to clear poison list via the ndctl ND_CMD_CLEAR_ERROR > call. We will update the poison list and also the badblocks at region level > if the region is in dax mode or in pmem mode and not active. > > Signed-off-by: Dave Jiang <dave.ji...@intel.com> > Reviewed-by: Johannes Thumshirn <jthumsh...@suse.de> > --- > drivers/acpi/nfit/core.c | 24 ++++++++++++++ > drivers/acpi/nfit/nfit.h | 2 + > drivers/nvdimm/bus.c | 64 > ++++++++++++++++++++++++++++++++++---- > drivers/nvdimm/core.c | 17 ++++++++-- > drivers/nvdimm/region.c | 25 +++++++++++++++ > include/linux/libnvdimm.h | 7 ++++ > tools/testing/nvdimm/test/nfit.c | 21 +++++++----- > 7 files changed, 139 insertions(+), 21 deletions(-) > > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c > index e7b05df..706eccd 100644 > --- a/drivers/acpi/nfit/core.c > +++ b/drivers/acpi/nfit/core.c > @@ -94,6 +94,28 @@ static struct acpi_device *to_acpi_dev(struct > acpi_nfit_desc *acpi_desc) > return to_acpi_device(acpi_desc->dev); > } > > +void acpi_nfit_forget_poison(struct nvdimm_bus_descriptor *nd_desc, > + unsigned int cmd, void *buf) > +{ > + struct acpi_nfit_desc *acpi_desc = to_acpi_nfit_desc(nd_desc); > + struct nvdimm_bus *nvdimm_bus = acpi_desc->nvdimm_bus; > + struct nd_cmd_clear_error *clear_err = buf; > + struct resource res; > + > + if (!nvdimm_bus || !clear_err->cleared) > + return; > + > + /* clearing the poison list we keep track of */ > + __nvdimm_forget_poison(nvdimm_bus, clear_err->address, > + clear_err->cleared); > + > + /* now sync the badblocks lists from the poison list */ > + res.start = clear_err->address; > + res.end = clear_err->address + clear_err->cleared - 1; > + __nvdimm_bus_badblocks_clear(nvdimm_bus, &res); > +} > +EXPORT_SYMBOL_GPL(acpi_nfit_forget_poison); > + > static int xlat_bus_status(void *buf, unsigned int cmd, u32 status) > { > struct nd_cmd_clear_error *clear_err; > @@ -353,6 +375,8 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, > struct nvdimm *nvdimm, > } > > xlat_rc = xlat_status(nvdimm, buf, cmd, fw_status); > + if (!nvdimm && cmd == ND_CMD_CLEAR_ERROR && xlat_rc >= 0) > + acpi_nfit_forget_poison(nd_desc, cmd, buf);
I think this needs to move out to __nd_ioctl(), otherwise we'll be calling this in response to a kernel internal ND_CMD_CLEAR_ERROR. This should only be invoked for external clear error. This also means we don't need the previous patch to unconditionally retrieve xlat_rc. Instead we can just have __nd_ioctl() provide a valid cmd_rc parameter rather than NULL. _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm