Re: [PATCH] libnvdimm, pmem: clarify the write+clear_poison+write flow
From: Verma, Vishal L
Date: Fri Apr 15 2016 - 12:58:26 EST
On Thu, 2016-04-14 at 19:40 -0700, Dan Williams wrote:
> The ACPI specification does not specify the state of data after a
> clear
> poison operation.ÂÂPotential future libnvdimm bus implementations for
> other architectures also might not specify or disagree on the state
> of
> data after clear poison.ÂÂClarify why we write twice.
>
> Reported-by: Jeff Moyer <jmoyer@xxxxxxxxxx>
> Reported-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
> Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> ---
> Âdrivers/nvdimm/pmem.c |ÂÂÂ14 ++++++++++++++
> Â1 file changed, 14 insertions(+)
Looks good, thanks!
Reviewed-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
>
> diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
> index c6befaa9c708..d9a0dbc2d023 100644
> --- a/drivers/nvdimm/pmem.c
> +++ b/drivers/nvdimm/pmem.c
> @@ -86,6 +86,20 @@ static int pmem_do_bvec(struct pmem_device *pmem,
> struct page *page,
> Â flush_dcache_page(page);
> Â }
> Â } else {
> + /*
> + Â* Note that we write the data both before and after
> + Â* clearing poison.ÂÂThe write before clear poison
> + Â* handles situations where the latest written data
> is
> + Â* preserved and the clear poison operation simply
> marks
> + Â* the address range as valid without changing the
> data.
> + Â* In this case application software can assume that
> an
> + Â* interrupted write will either return the new good
> + Â* data or an error.
> + Â*
> + Â* However, if pmem_clear_poison() leaves the data
> in an
> + Â* indeterminate state we need to perform the write
> + Â* after clear poison.
> + Â*/
> Â flush_dcache_page(page);
> Â memcpy_to_pmem(pmem_addr, mem + off, len);
> Â if (unlikely(bad_pmem)) {
>