Skip to content

Commit f3c9a1a

Browse files
committed
Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm fixes from Ross Zwisler: "Two fixes: - Fix memcpy_from_pmem() to fallback to memcpy() for architectures where CONFIG_ARCH_HAS_PMEM_API=n. - Add a comment explaining why we write data twice when clearing poison in pmem_do_bvec(). This has passed a boot test on an X86_32 config, which was the architecture where issue #1 above was first noticed" Dan Williams adds: "We're giving this multi-maintainer setup a shot, so expect libnvdimm pull requests from either Ross or I going forward" * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: libnvdimm, pmem: clarify the write+clear_poison+write flow pmem: fix BUG() error in pmem.h:48 on X86_32
2 parents 29dde7c + 0a370d2 commit f3c9a1a

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

drivers/nvdimm/pmem.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ static int pmem_do_bvec(struct pmem_device *pmem, struct page *page,
103103
flush_dcache_page(page);
104104
}
105105
} else {
106+
/*
107+
* Note that we write the data both before and after
108+
* clearing poison. The write before clear poison
109+
* handles situations where the latest written data is
110+
* preserved and the clear poison operation simply marks
111+
* the address range as valid without changing the data.
112+
* In this case application software can assume that an
113+
* interrupted write will either return the new good
114+
* data or an error.
115+
*
116+
* However, if pmem_clear_poison() leaves the data in an
117+
* indeterminate state we need to perform the write
118+
* after clear poison.
119+
*/
106120
flush_dcache_page(page);
107121
memcpy_to_pmem(pmem_addr, mem + off, len);
108122
if (unlikely(bad_pmem)) {

include/linux/pmem.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
7272
}
7373
#endif
7474

75+
static inline bool arch_has_pmem_api(void)
76+
{
77+
return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
78+
}
79+
80+
static inline int default_memcpy_from_pmem(void *dst, void __pmem const *src,
81+
size_t size)
82+
{
83+
memcpy(dst, (void __force *) src, size);
84+
return 0;
85+
}
86+
7587
/*
7688
* memcpy_from_pmem - read from persistent memory with error handling
7789
* @dst: destination buffer
@@ -83,12 +95,10 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
8395
static inline int memcpy_from_pmem(void *dst, void __pmem const *src,
8496
size_t size)
8597
{
86-
return arch_memcpy_from_pmem(dst, src, size);
87-
}
88-
89-
static inline bool arch_has_pmem_api(void)
90-
{
91-
return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
98+
if (arch_has_pmem_api())
99+
return arch_memcpy_from_pmem(dst, src, size);
100+
else
101+
return default_memcpy_from_pmem(dst, src, size);
92102
}
93103

94104
/**

0 commit comments

Comments
 (0)