]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm/nvdimm: add is_ioremap_addr and use that to check ioremap address
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fri, 12 Jul 2019 03:52:08 +0000 (20:52 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2019 07:13:05 +0000 (09:13 +0200)
commit 9bd3bb6703d8c0a5fb8aec8e3287bd55b7341dcd upstream.

Architectures like powerpc use different address range to map ioremap
and vmalloc range.  The memunmap() check used by the nvdimm layer was
wrongly using is_vmalloc_addr() to check for ioremap range which fails
for ppc64.  This result in ppc64 not freeing the ioremap mapping.  The
side effect of this is an unbind failure during module unload with
papr_scm nvdimm driver

Link: http://lkml.kernel.org/r/20190701134038.14165-1-aneesh.kumar@linux.ibm.com
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fixes: b5beae5e224f ("powerpc/pseries: Add driver for PAPR SCM regions")
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/include/asm/pgtable.h
include/linux/mm.h
kernel/iomem.c

index 505550fb293566d76c0fddebcc2ecf0c5ed0fc05..22f53f9c40713edeb690a9bd745f8631dae50dc4 100644 (file)
@@ -137,6 +137,20 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p)
 }
 #endif
 
+#ifdef CONFIG_PPC64
+#define is_ioremap_addr is_ioremap_addr
+static inline bool is_ioremap_addr(const void *x)
+{
+#ifdef CONFIG_MMU
+       unsigned long addr = (unsigned long)x;
+
+       return addr >= IOREMAP_BASE && addr < IOREMAP_END;
+#else
+       return false;
+#endif
+}
+#endif /* CONFIG_PPC64 */
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_PGTABLE_H */
index 6b10c21630f54bdd14ddd6efa1510777165ec558..ab6bf81311a8fc871b765d3e74f131ac67ec909b 100644 (file)
@@ -590,6 +590,11 @@ static inline bool is_vmalloc_addr(const void *x)
        return false;
 #endif
 }
+
+#ifndef is_ioremap_addr
+#define is_ioremap_addr(x) is_vmalloc_addr(x)
+#endif
+
 #ifdef CONFIG_MMU
 extern int is_vmalloc_or_module_addr(const void *x);
 #else
index f7525e14ebc6f15ec1718d0e610586a88798738d..98950b84c50cfcef01f66029612b7ccae7cdaef1 100644 (file)
@@ -121,7 +121,7 @@ EXPORT_SYMBOL(memremap);
 
 void memunmap(void *addr)
 {
-       if (is_vmalloc_addr(addr))
+       if (is_ioremap_addr(addr))
                iounmap((void __iomem *) addr);
 }
 EXPORT_SYMBOL(memunmap);