Skip to content

Commit

Permalink
pmem: fix BUG() error in pmem.h:48 on X86_32
Browse files Browse the repository at this point in the history
After 'commit fc0c202 ("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().

Acked-by: Dan Williams <[email protected]>
Signed-off-by: Toshi Kani <[email protected]>
Signed-off-by: Ross Zwisler <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Ross Zwisler <[email protected]>
  • Loading branch information
toshikani authored and Ross Zwisler committed Apr 14, 2016
1 parent bf16200 commit cba2e47
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions include/linux/pmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit cba2e47

Please sign in to comment.