Skip to content

Commit 9bd3bb6

Browse files
kvaneeshtorvalds
authored andcommitted
mm/nvdimm: add is_ioremap_addr and use that to check ioremap address
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: b5beae5 ("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>
1 parent 2c012a4 commit 9bd3bb6

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

‎arch/powerpc/include/asm/pgtable.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ static inline void pte_frag_set(mm_context_t *ctx, void *p)
140140
}
141141
#endif
142142

143+
#ifdef CONFIG_PPC64
144+
#define is_ioremap_addr is_ioremap_addr
145+
static inline bool is_ioremap_addr(const void *x)
146+
{
147+
#ifdef CONFIG_MMU
148+
unsigned long addr = (unsigned long)x;
149+
150+
return addr >= IOREMAP_BASE && addr < IOREMAP_END;
151+
#else
152+
return false;
153+
#endif
154+
}
155+
#endif /* CONFIG_PPC64 */
156+
143157
#endif /* __ASSEMBLY__ */
144158

145159
#endif /* _ASM_POWERPC_PGTABLE_H */

‎include/linux/mm.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,11 @@ static inline bool is_vmalloc_addr(const void *x)
633633
return false;
634634
#endif
635635
}
636+
637+
#ifndef is_ioremap_addr
638+
#define is_ioremap_addr(x) is_vmalloc_addr(x)
639+
#endif
640+
636641
#ifdef CONFIG_MMU
637642
extern int is_vmalloc_or_module_addr(const void *x);
638643
#else

‎kernel/iomem.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ EXPORT_SYMBOL(memremap);
121121

122122
void memunmap(void *addr)
123123
{
124-
if (is_vmalloc_addr(addr))
124+
if (is_ioremap_addr(addr))
125125
iounmap((void __iomem *) addr);
126126
}
127127
EXPORT_SYMBOL(memunmap);

0 commit comments

Comments
 (0)