public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pmem: fix BUG() error in pmem.h:48 on X86_32
@ 2016-04-13  0:10 Toshi Kani
  2016-04-13  5:24 ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Toshi Kani @ 2016-04-13  0:10 UTC (permalink / raw)
  To: dan.j.williams; +Cc: ross.zwisler, linux-nvdimm, linux-kernel, Toshi Kani

After 'commit fc0c2028135c ("x86, pmem: use memcpy_mcsafe()
for memcpy_from_pmem()")', probing a PMEM device hits the BUG()
error below on X86_32 kernel.

 kernel BUG at include/linux/pmem.h:48!

memcpy_from_pmem() calls arch_memcpy_from_pmem(), which is
unimplemented since CONFIG_ARCH_HAS_PMEM_API is undefined on
X86_32.

Fix the BUG() error by adding default_memcpy_from_pmem().

Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
---
 include/linux/pmem.h |   22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index ac6d872..57d146f 100644
--- a/include/linux/pmem.h
+++ b/include/linux/pmem.h
@@ -72,6 +72,18 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
 }
 #endif
 
+static inline bool arch_has_pmem_api(void)
+{
+	return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
+}
+
+static inline int default_memcpy_from_pmem(void *dst, void __pmem const *src,
+		size_t size)
+{
+	memcpy(dst, (void __force *) src, size);
+	return 0;
+}
+
 /*
  * memcpy_from_pmem - read from persistent memory with error handling
  * @dst: destination buffer
@@ -83,12 +95,10 @@ static inline void arch_invalidate_pmem(void __pmem *addr, size_t size)
 static inline int memcpy_from_pmem(void *dst, void __pmem const *src,
 		size_t size)
 {
-	return arch_memcpy_from_pmem(dst, src, size);
-}
-
-static inline bool arch_has_pmem_api(void)
-{
-	return IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API);
+	if (arch_has_pmem_api())
+		return arch_memcpy_from_pmem(dst, src, size);
+	else
+		return default_memcpy_from_pmem(dst, src, size);
 }
 
 /**

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmem: fix BUG() error in pmem.h:48 on X86_32
  2016-04-13  0:10 [PATCH] pmem: fix BUG() error in pmem.h:48 on X86_32 Toshi Kani
@ 2016-04-13  5:24 ` Dan Williams
  2016-04-13 17:19   ` Ross Zwisler
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Williams @ 2016-04-13  5:24 UTC (permalink / raw)
  To: Toshi Kani
  Cc: Ross Zwisler, linux-nvdimm@lists.01.org,
	linux-kernel@vger.kernel.org

On Tue, Apr 12, 2016 at 5:10 PM, Toshi Kani <toshi.kani@hpe.com> wrote:
> After 'commit fc0c2028135c ("x86, pmem: use memcpy_mcsafe()
> for memcpy_from_pmem()")', probing a PMEM device hits the BUG()
> error below on X86_32 kernel.
>
>  kernel BUG at include/linux/pmem.h:48!
>
> memcpy_from_pmem() calls arch_memcpy_from_pmem(), which is
> unimplemented since CONFIG_ARCH_HAS_PMEM_API is undefined on
> X86_32.
>
> Fix the BUG() error by adding default_memcpy_from_pmem().
>
> Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>

Whoops, I'll add a 32-bit boot test to my release criteria.  Thanks Toshi!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] pmem: fix BUG() error in pmem.h:48 on X86_32
  2016-04-13  5:24 ` Dan Williams
@ 2016-04-13 17:19   ` Ross Zwisler
  0 siblings, 0 replies; 3+ messages in thread
From: Ross Zwisler @ 2016-04-13 17:19 UTC (permalink / raw)
  To: Dan Williams
  Cc: Toshi Kani, Ross Zwisler, linux-nvdimm@lists.01.org,
	linux-kernel@vger.kernel.org

On Tue, Apr 12, 2016 at 10:24:25PM -0700, Dan Williams wrote:
> On Tue, Apr 12, 2016 at 5:10 PM, Toshi Kani <toshi.kani@hpe.com> wrote:
> > After 'commit fc0c2028135c ("x86, pmem: use memcpy_mcsafe()
> > for memcpy_from_pmem()")', probing a PMEM device hits the BUG()
> > error below on X86_32 kernel.
> >
> >  kernel BUG at include/linux/pmem.h:48!
> >
> > memcpy_from_pmem() calls arch_memcpy_from_pmem(), which is
> > unimplemented since CONFIG_ARCH_HAS_PMEM_API is undefined on
> > X86_32.
> >
> > Fix the BUG() error by adding default_memcpy_from_pmem().
> >
> > Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> 
> Whoops, I'll add a 32-bit boot test to my release criteria.  Thanks Toshi!

Yep, this patch looks correct to me.

Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-13 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-13  0:10 [PATCH] pmem: fix BUG() error in pmem.h:48 on X86_32 Toshi Kani
2016-04-13  5:24 ` Dan Williams
2016-04-13 17:19   ` Ross Zwisler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox