]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
x86, dax, libnvdimm: remove wb_cache_pmem() indirection
authorDan Williams <dan.j.williams@intel.com>
Tue, 30 May 2017 05:40:44 +0000 (22:40 -0700)
committerDan Williams <dan.j.williams@intel.com>
Thu, 15 Jun 2017 21:35:24 +0000 (14:35 -0700)
With all handling of the CONFIG_ARCH_HAS_PMEM_API case being moved to
libnvdimm and the pmem driver directly we do not need to provide global
wrappers and fallbacks in the CONFIG_ARCH_HAS_PMEM_API=n case. The pmem
driver will simply not link to arch_wb_cache_pmem() in that case.  Same
as before, pmem flushing is only defined for x86_64, via
clean_cache_range(), but it is straightforward to add other archs in the
future.

arch_wb_cache_pmem() is an exported function since the pmem module needs
to find it, but it is privately declared in drivers/nvdimm/pmem.h because
there are no consumers outside of the pmem driver.

Cc: <x86@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Oliver O'Halloran <oohall@gmail.com>
Cc: Matthew Wilcox <mawilcox@microsoft.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
arch/x86/include/asm/pmem.h
arch/x86/lib/usercopy_64.c
drivers/nvdimm/pmem.c
drivers/nvdimm/pmem.h
include/linux/pmem.h

index f4c119d253f3b462b11ac25948e995b475824b93..4759a179aa52069591c4620615acd80fdb0e484b 100644 (file)
@@ -44,27 +44,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
                BUG();
 }
 
-/**
- * arch_wb_cache_pmem - write back a cache range with CLWB
- * @vaddr:     virtual start address
- * @size:      number of bytes to write back
- *
- * Write back a cache range using the CLWB (cache line write back)
- * instruction. Note that @size is internally rounded up to be cache
- * line size aligned.
- */
-static inline void arch_wb_cache_pmem(void *addr, size_t size)
-{
-       u16 x86_clflush_size = boot_cpu_data.x86_clflush_size;
-       unsigned long clflush_mask = x86_clflush_size - 1;
-       void *vend = addr + size;
-       void *p;
-
-       for (p = (void *)((unsigned long)addr & ~clflush_mask);
-            p < vend; p += x86_clflush_size)
-               clwb(p);
-}
-
 static inline void arch_invalidate_pmem(void *addr, size_t size)
 {
        clflush_cache_range(addr, size);
index f42d2fd86ca3949257b8af5102e9ae422ecb3f5e..75d3776123cc0f8ee4d79dc2c07e17c431a950dd 100644 (file)
@@ -97,6 +97,12 @@ static void clean_cache_range(void *addr, size_t size)
                clwb(p);
 }
 
+void arch_wb_cache_pmem(void *addr, size_t size)
+{
+       clean_cache_range(addr, size);
+}
+EXPORT_SYMBOL_GPL(arch_wb_cache_pmem);
+
 long __copy_user_flushcache(void *dst, const void __user *src, unsigned size)
 {
        unsigned long flushed, dest = (unsigned long) dst;
index 823b07774244431261c82eab49d5816f39b26d56..3b87702d46bb1eb5a16bf34a79313505b56e8f5d 100644 (file)
@@ -245,7 +245,7 @@ static size_t pmem_copy_from_iter(struct dax_device *dax_dev, pgoff_t pgoff,
 static void pmem_dax_flush(struct dax_device *dax_dev, pgoff_t pgoff,
                void *addr, size_t size)
 {
-       wb_cache_pmem(addr, size);
+       arch_wb_cache_pmem(addr, size);
 }
 
 static const struct dax_operations pmem_dax_ops = {
index 7f4dbd72a90a34fac4d57d18b5606373ce61112e..c4b3371c7f88392c719e4a5aa1ea75213f853d90 100644 (file)
@@ -5,6 +5,14 @@
 #include <linux/pfn_t.h>
 #include <linux/fs.h>
 
+#ifdef CONFIG_ARCH_HAS_PMEM_API
+void arch_wb_cache_pmem(void *addr, size_t size);
+#else
+static inline void arch_wb_cache_pmem(void *addr, size_t size)
+{
+}
+#endif
+
 /* this definition is in it's own header for tools/testing/nvdimm to consume */
 struct pmem_device {
        /* One contiguous memory region per device */
index 772bd02a5b52fadd236738f327bc455546d71a41..33ae761f010a0788bc8d0a0185e4963d8da68aad 100644 (file)
@@ -31,11 +31,6 @@ static inline void arch_memcpy_to_pmem(void *dst, const void *src, size_t n)
        BUG();
 }
 
-static inline void arch_wb_cache_pmem(void *addr, size_t size)
-{
-       BUG();
-}
-
 static inline void arch_invalidate_pmem(void *addr, size_t size)
 {
        BUG();
@@ -80,18 +75,4 @@ static inline void invalidate_pmem(void *addr, size_t size)
        if (arch_has_pmem_api())
                arch_invalidate_pmem(addr, size);
 }
-
-/**
- * wb_cache_pmem - write back processor cache for PMEM memory range
- * @addr:      virtual start address
- * @size:      number of bytes to write back
- *
- * Write back the processor cache range starting at 'addr' for 'size' bytes.
- * See blkdev_issue_flush() note for memcpy_to_pmem().
- */
-static inline void wb_cache_pmem(void *addr, size_t size)
-{
-       if (arch_has_pmem_api())
-               arch_wb_cache_pmem(addr, size);
-}
 #endif /* __PMEM_H__ */