aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Murphy <robin.murphy@arm.com>2017-08-31 07:27:09 -0400
committerDan Williams <dan.j.williams@intel.com>2017-08-31 18:05:10 -0400
commit5deb67f77a266010e2c10fb124b7516d0d258ce8 (patch)
tree23d02b63d21e943145f2720460b32b301fefbca4
parentd9b83c7569536e3255992491737d9f895640ea18 (diff)
libnvdimm, nd_blk: remove mmio_flush_range()
mmio_flush_range() suffers from a lack of clearly-defined semantics, and is somewhat ambiguous to port to other architectures where the scope of the writeback implied by "flush" and ordering might matter, but MMIO would tend to imply non-cacheable anyway. Per the rationale in 67a3e8fe9015 ("nd_blk: change aperture mapping from WC to WB"), the only existing use is actually to invalidate clean cache lines for ARCH_MEMREMAP_PMEM type mappings *without* writeback. Since the recent cleanup of the pmem API, that also now happens to be the exact purpose of arch_invalidate_pmem(), which would be a far more well-defined tool for the job. Rather than risk potentially inconsistent implementations of mmio_flush_range() for the sake of one callsite, streamline things by removing it entirely and instead move the ARCH_MEMREMAP_PMEM related definitions up to the libnvdimm level, so they can be shared by NFIT as well. This allows NFIT to be enabled for arm64. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/include/asm/cacheflush.h2
-rw-r--r--drivers/acpi/nfit/Kconfig2
-rw-r--r--drivers/acpi/nfit/core.c2
-rw-r--r--drivers/nvdimm/pmem.h14
-rw-r--r--include/linux/libnvdimm.h15
-rw-r--r--lib/Kconfig3
-rw-r--r--tools/testing/nvdimm/test/nfit.c4
8 files changed, 19 insertions, 24 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 781521b7cf9e..5f3b756ec0d3 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -53,7 +53,6 @@ config X86
53 select ARCH_HAS_FORTIFY_SOURCE 53 select ARCH_HAS_FORTIFY_SOURCE
54 select ARCH_HAS_GCOV_PROFILE_ALL 54 select ARCH_HAS_GCOV_PROFILE_ALL
55 select ARCH_HAS_KCOV if X86_64 55 select ARCH_HAS_KCOV if X86_64
56 select ARCH_HAS_MMIO_FLUSH
57 select ARCH_HAS_PMEM_API if X86_64 56 select ARCH_HAS_PMEM_API if X86_64
58 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64 57 select ARCH_HAS_UACCESS_FLUSHCACHE if X86_64
59 select ARCH_HAS_SET_MEMORY 58 select ARCH_HAS_SET_MEMORY
diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
index 8b4140f6724f..cb9a1af109b4 100644
--- a/arch/x86/include/asm/cacheflush.h
+++ b/arch/x86/include/asm/cacheflush.h
@@ -7,6 +7,4 @@
7 7
8void clflush_cache_range(void *addr, unsigned int size); 8void clflush_cache_range(void *addr, unsigned int size);
9 9
10#define mmio_flush_range(addr, size) clflush_cache_range(addr, size)
11
12#endif /* _ASM_X86_CACHEFLUSH_H */ 10#endif /* _ASM_X86_CACHEFLUSH_H */
diff --git a/drivers/acpi/nfit/Kconfig b/drivers/acpi/nfit/Kconfig
index 6d3351452ea2..929ba4da0b30 100644
--- a/drivers/acpi/nfit/Kconfig
+++ b/drivers/acpi/nfit/Kconfig
@@ -2,7 +2,7 @@ config ACPI_NFIT
2 tristate "ACPI NVDIMM Firmware Interface Table (NFIT)" 2 tristate "ACPI NVDIMM Firmware Interface Table (NFIT)"
3 depends on PHYS_ADDR_T_64BIT 3 depends on PHYS_ADDR_T_64BIT
4 depends on BLK_DEV 4 depends on BLK_DEV
5 depends on ARCH_HAS_MMIO_FLUSH 5 depends on ARCH_HAS_PMEM_API
6 select LIBNVDIMM 6 select LIBNVDIMM
7 help 7 help
8 Infrastructure to probe ACPI 6 compliant platforms for 8 Infrastructure to probe ACPI 6 compliant platforms for
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index 03105648f9b1..c20124a6eb49 100644
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1964,7 +1964,7 @@ static int acpi_nfit_blk_single_io(struct nfit_blk *nfit_blk,
1964 memcpy_flushcache(mmio->addr.aperture + offset, iobuf + copied, c); 1964 memcpy_flushcache(mmio->addr.aperture + offset, iobuf + copied, c);
1965 else { 1965 else {
1966 if (nfit_blk->dimm_flags & NFIT_BLK_READ_FLUSH) 1966 if (nfit_blk->dimm_flags & NFIT_BLK_READ_FLUSH)
1967 mmio_flush_range((void __force *) 1967 arch_invalidate_pmem((void __force *)
1968 mmio->addr.aperture + offset, c); 1968 mmio->addr.aperture + offset, c);
1969 1969
1970 memcpy(iobuf + copied, mmio->addr.aperture + offset, c); 1970 memcpy(iobuf + copied, mmio->addr.aperture + offset, c);
diff --git a/drivers/nvdimm/pmem.h b/drivers/nvdimm/pmem.h
index 5434321cad67..c5917f040fa7 100644
--- a/drivers/nvdimm/pmem.h
+++ b/drivers/nvdimm/pmem.h
@@ -5,20 +5,6 @@
5#include <linux/pfn_t.h> 5#include <linux/pfn_t.h>
6#include <linux/fs.h> 6#include <linux/fs.h>
7 7
8#ifdef CONFIG_ARCH_HAS_PMEM_API
9#define ARCH_MEMREMAP_PMEM MEMREMAP_WB
10void arch_wb_cache_pmem(void *addr, size_t size);
11void arch_invalidate_pmem(void *addr, size_t size);
12#else
13#define ARCH_MEMREMAP_PMEM MEMREMAP_WT
14static inline void arch_wb_cache_pmem(void *addr, size_t size)
15{
16}
17static inline void arch_invalidate_pmem(void *addr, size_t size)
18{
19}
20#endif
21
22/* this definition is in it's own header for tools/testing/nvdimm to consume */ 8/* this definition is in it's own header for tools/testing/nvdimm to consume */
23struct pmem_device { 9struct pmem_device {
24 /* One contiguous memory region per device */ 10 /* One contiguous memory region per device */
diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
index 9b8d81a7b80e..3eaad2fbf284 100644
--- a/include/linux/libnvdimm.h
+++ b/include/linux/libnvdimm.h
@@ -174,4 +174,19 @@ u64 nd_fletcher64(void *addr, size_t len, bool le);
174void nvdimm_flush(struct nd_region *nd_region); 174void nvdimm_flush(struct nd_region *nd_region);
175int nvdimm_has_flush(struct nd_region *nd_region); 175int nvdimm_has_flush(struct nd_region *nd_region);
176int nvdimm_has_cache(struct nd_region *nd_region); 176int nvdimm_has_cache(struct nd_region *nd_region);
177
178#ifdef CONFIG_ARCH_HAS_PMEM_API
179#define ARCH_MEMREMAP_PMEM MEMREMAP_WB
180void arch_wb_cache_pmem(void *addr, size_t size);
181void arch_invalidate_pmem(void *addr, size_t size);
182#else
183#define ARCH_MEMREMAP_PMEM MEMREMAP_WT
184static inline void arch_wb_cache_pmem(void *addr, size_t size)
185{
186}
187static inline void arch_invalidate_pmem(void *addr, size_t size)
188{
189}
190#endif
191
177#endif /* __LIBNVDIMM_H__ */ 192#endif /* __LIBNVDIMM_H__ */
diff --git a/lib/Kconfig b/lib/Kconfig
index 6762529ad9e4..527da69e3be1 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -559,9 +559,6 @@ config ARCH_HAS_PMEM_API
559config ARCH_HAS_UACCESS_FLUSHCACHE 559config ARCH_HAS_UACCESS_FLUSHCACHE
560 bool 560 bool
561 561
562config ARCH_HAS_MMIO_FLUSH
563 bool
564
565config STACKDEPOT 562config STACKDEPOT
566 bool 563 bool
567 select STACKTRACE 564 select STACKTRACE
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 4c2fa98ef39d..d20791c3f499 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -1546,8 +1546,8 @@ static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,
1546 else { 1546 else {
1547 memcpy(iobuf, mmio->addr.base + dpa, len); 1547 memcpy(iobuf, mmio->addr.base + dpa, len);
1548 1548
1549 /* give us some some coverage of the mmio_flush_range() API */ 1549 /* give us some some coverage of the arch_invalidate_pmem() API */
1550 mmio_flush_range(mmio->addr.base + dpa, len); 1550 arch_invalidate_pmem(mmio->addr.base + dpa, len);
1551 } 1551 }
1552 nd_region_release_lane(nd_region, lane); 1552 nd_region_release_lane(nd_region, lane);
1553 1553