[PATCH v2 00/25] replace ioremap_{cache|wt} with memremap
by Dan Williams
Changes since v1 [1]:
1/ Drop the attempt at unifying ioremap() prototypes, just focus on
converting ioremap_cache and ioremap_wt over to memremap (Christoph)
2/ Drop the unrelated cleanups to use %pa in __ioremap_caller (Thomas)
3/ Add support for memremap() attempts on "System RAM" to simply return
the kernel virtual address for that range. ARM depends on this
functionality in ioremap_cache() and ACPI was open coding a similar
solution. (Mark)
4/ Split the conversions of ioremap_{cache|wt} into separate patches per
driver / arch.
5/ Fix bisection breakage and other reports from 0day-kbuild
---
While developing the pmem driver we noticed that the __iomem annotation
on the return value from ioremap_cache() was being mishandled by several
callers. We also observed that all of the call sites expected to be
able to treat the return value from ioremap_cache() as normal
(non-__iomem) pointer to memory.
This patchset takes the opportunity to clean up the above confusion as
well as a few issues with the ioremap_{cache|wt} interface, including:
1/ Eliminating the possibility of function prototypes differing between
architectures by defining a central memremap() prototype that takes
flags to determine the mapping type.
2/ Returning NULL rather than falling back silently to a different
mapping-type. This allows drivers to be stricter about the
mapping-type fallbacks that are permissible.
[1]: http://marc.info/?l=linux-arm-kernel&m=143735199029255&w=2
---
Dan Williams (22):
mm: enhance region_is_ram() to distinguish 'unknown' vs 'mixed'
arch, drivers: don't include <asm/io.h> directly, use <linux/io.h> instead
cleanup IORESOURCE_CACHEABLE vs ioremap()
intel_iommu: fix leaked ioremap mapping
arch: introduce memremap()
arm: switch from ioremap_cache to memremap
x86: switch from ioremap_cache to memremap
gma500: switch from acpi_os_ioremap to ioremap
i915: switch from acpi_os_ioremap to ioremap
acpi: switch from ioremap_cache to memremap
toshiba laptop: replace ioremap_cache with ioremap
memconsole: fix __iomem mishandling, switch to memremap
visorbus: switch from ioremap_cache to memremap
intel-iommu: switch from ioremap_cache to memremap
libnvdimm, pmem: switch from ioremap_cache to memremap
pxa2xx-flash: switch from ioremap_cache to memremap
sfi: switch from ioremap_cache to memremap
fbdev: switch from ioremap_wt to memremap
pmem: switch from ioremap_wt to memremap
arch: remove ioremap_cache, replace with arch_memremap
arch: remove ioremap_wt, replace with arch_memremap
pmem: convert to generic memremap
Toshi Kani (3):
mm, x86: Fix warning in ioremap RAM check
mm, x86: Remove region_is_ram() call from ioremap
mm: Fix bugs in region_is_ram()
arch/arc/include/asm/io.h | 1
arch/arm/Kconfig | 1
arch/arm/include/asm/io.h | 13 +++-
arch/arm/include/asm/xen/page.h | 4 +
arch/arm/mach-clps711x/board-cdb89712.c | 2 -
arch/arm/mach-shmobile/pm-rcar.c | 2 -
arch/arm/mm/ioremap.c | 12 +++-
arch/arm/mm/nommu.c | 11 ++-
arch/arm64/Kconfig | 1
arch/arm64/include/asm/acpi.h | 10 +--
arch/arm64/include/asm/dmi.h | 8 +--
arch/arm64/include/asm/io.h | 8 ++-
arch/arm64/kernel/efi.c | 9 ++-
arch/arm64/kernel/smp_spin_table.c | 19 +++---
arch/arm64/mm/ioremap.c | 20 ++----
arch/avr32/include/asm/io.h | 1
arch/frv/Kconfig | 1
arch/frv/include/asm/io.h | 17 ++---
arch/frv/mm/kmap.c | 6 ++
arch/ia64/Kconfig | 1
arch/ia64/include/asm/io.h | 11 +++
arch/ia64/kernel/cyclone.c | 2 -
arch/m32r/include/asm/io.h | 1
arch/m68k/Kconfig | 1
arch/m68k/include/asm/io_mm.h | 14 +---
arch/m68k/include/asm/io_no.h | 12 ++--
arch/m68k/include/asm/raw_io.h | 4 +
arch/m68k/mm/kmap.c | 17 +++++
arch/m68k/mm/sun3kmap.c | 6 ++
arch/metag/include/asm/io.h | 3 -
arch/microblaze/include/asm/io.h | 1
arch/mn10300/include/asm/io.h | 1
arch/nios2/include/asm/io.h | 1
arch/powerpc/kernel/pci_of_scan.c | 2 -
arch/s390/include/asm/io.h | 1
arch/sh/Kconfig | 1
arch/sh/include/asm/io.h | 20 ++++--
arch/sh/mm/ioremap.c | 10 +++
arch/sparc/include/asm/io_32.h | 1
arch/sparc/include/asm/io_64.h | 1
arch/sparc/kernel/pci.c | 3 -
arch/tile/include/asm/io.h | 1
arch/x86/Kconfig | 1
arch/x86/include/asm/efi.h | 3 +
arch/x86/include/asm/io.h | 17 +++--
arch/x86/kernel/crash_dump_64.c | 6 +-
arch/x86/kernel/kdebugfs.c | 8 +--
arch/x86/kernel/ksysfs.c | 28 ++++-----
arch/x86/mm/ioremap.c | 76 ++++++++++--------------
arch/xtensa/Kconfig | 1
arch/xtensa/include/asm/io.h | 9 ++-
drivers/acpi/apei/einj.c | 9 ++-
drivers/acpi/apei/erst.c | 6 +-
drivers/acpi/nvs.c | 6 +-
drivers/acpi/osl.c | 70 ++++++----------------
drivers/char/toshiba.c | 2 -
drivers/firmware/google/memconsole.c | 7 +-
drivers/gpu/drm/gma500/opregion.c | 2 -
drivers/gpu/drm/i915/intel_opregion.c | 2 -
drivers/iommu/intel-iommu.c | 10 ++-
drivers/iommu/intel_irq_remapping.c | 4 +
drivers/isdn/icn/icn.h | 2 -
drivers/mtd/devices/slram.c | 2 -
drivers/mtd/maps/pxa2xx-flash.c | 4 +
drivers/mtd/nand/diskonchip.c | 2 -
drivers/mtd/onenand/generic.c | 2 -
drivers/nvdimm/Kconfig | 2 -
drivers/pci/probe.c | 3 -
drivers/pnp/manager.c | 2 -
drivers/scsi/aic94xx/aic94xx_init.c | 7 --
drivers/scsi/arcmsr/arcmsr_hba.c | 5 --
drivers/scsi/mvsas/mv_init.c | 15 +----
drivers/scsi/sun3x_esp.c | 2 -
drivers/sfi/sfi_core.c | 4 +
drivers/staging/comedi/drivers/ii_pci20kc.c | 1
drivers/staging/unisys/visorbus/visorchannel.c | 16 +++--
drivers/staging/unisys/visorbus/visorchipset.c | 17 +++--
drivers/tty/serial/8250/8250_core.c | 2 -
drivers/video/fbdev/Kconfig | 2 -
drivers/video/fbdev/amifb.c | 5 +-
drivers/video/fbdev/atafb.c | 5 +-
drivers/video/fbdev/hpfb.c | 6 +-
drivers/video/fbdev/ocfb.c | 1
drivers/video/fbdev/s1d13xxxfb.c | 3 -
drivers/video/fbdev/stifb.c | 1
include/acpi/acpi_io.h | 6 +-
include/asm-generic/io.h | 8 ---
include/asm-generic/iomap.h | 4 -
include/linux/io-mapping.h | 2 -
include/linux/io.h | 9 +++
include/linux/mtd/map.h | 2 -
include/linux/pmem.h | 26 +++++---
include/video/vga.h | 2 -
kernel/Makefile | 2 +
kernel/memremap.c | 74 +++++++++++++++++++++++
kernel/resource.c | 43 +++++++-------
lib/Kconfig | 5 +-
lib/devres.c | 13 +---
lib/pci_iomap.c | 7 +-
tools/testing/nvdimm/Kbuild | 4 +
tools/testing/nvdimm/test/iomap.c | 34 ++++++++---
101 files changed, 482 insertions(+), 398 deletions(-)
create mode 100644 kernel/memremap.c
4 years, 10 months
[PATCH v2 0/9] initial struct page support for pmem
by Dan Williams
Changes since v1 [1]:
1/ Several simplifications from Christoph including dropping the __pfn_t
dependency, and merging ZONE_DEVICE into the base arch_add_memory()
implementation.
2/ Drop the deeper changes to the memory hotplug code that enabled
allocating the backing 'struct page' array from pmem (struct
vmem_altmap). This functionality is still needed when large capacity
PMEM devices arrive. However, for now we can take this simple step to
enable struct page mapping in RAM and enable it by default for small
capacity CONFIG_X86_PMEM_LEGACY devices.
3/ A rework of the PMEM api to allow usage of the non-temporal
memcpy_to_pmem() implementation even on platforms without pcommit
instruction support.
[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-August/001809.html
---
When we last left this debate [2] it was becoming clear that the
'page-less' approach left too many I/O scenarios off the table. The
page-less enabling is still useful for avoiding the overhead of struct
page where it is not needed, but in the end, page-backed persistent
memory seems to be a requirement. We confirmed as much at the recently
concluded Persistent Memory Microconference at Linux Plumbers.
Whereas the initial RFC of this functionality enabled userspace to pick
whether struct page is allocated from RAM or PMEM. This new version
only enables RAM-backed for now. This is suitable for existing NVDIMM
devices and a starting point to incrementally build "allocate struct
page from PMEM" support.
[2]: https://lists.01.org/pipermail/linux-nvdimm/2015-May/000748.html
---
Christoph Hellwig (2):
mm: move __phys_to_pfn and __pfn_to_phys to asm/generic/memory_model.h
add devm_memremap_pages
Dan Williams (7):
dax: drop size parameter to ->direct_access()
mm: ZONE_DEVICE for "device memory"
x86, pmem: push fallback handling to arch code
libnvdimm, pfn: 'struct page' provider infrastructure
libnvdimm, pmem: 'struct page' for pmem
libnvdimm, pmem: direct map legacy pmem by default
devm_memremap_pages: protect against pmem device unbind
arch/arm/include/asm/memory.h | 6 -
arch/arm64/include/asm/memory.h | 6 -
arch/ia64/mm/init.c | 4
arch/powerpc/mm/mem.c | 4
arch/powerpc/sysdev/axonram.c | 2
arch/s390/mm/init.c | 2
arch/sh/mm/init.c | 5 -
arch/tile/mm/init.c | 2
arch/unicore32/include/asm/memory.h | 6 -
arch/x86/include/asm/io.h | 2
arch/x86/include/asm/pmem.h | 41 ++++
arch/x86/mm/init_32.c | 4
arch/x86/mm/init_64.c | 4
drivers/acpi/nfit.c | 2
drivers/block/brd.c | 6 -
drivers/nvdimm/Kconfig | 23 ++
drivers/nvdimm/Makefile | 2
drivers/nvdimm/btt.c | 6 -
drivers/nvdimm/btt_devs.c | 172 +-----------------
drivers/nvdimm/claim.c | 201 +++++++++++++++++++++
drivers/nvdimm/e820.c | 1
drivers/nvdimm/namespace_devs.c | 62 +++++-
drivers/nvdimm/nd-core.h | 9 +
drivers/nvdimm/nd.h | 59 ++++++
drivers/nvdimm/pfn.h | 35 ++++
drivers/nvdimm/pfn_devs.c | 337 +++++++++++++++++++++++++++++++++++
drivers/nvdimm/pmem.c | 220 +++++++++++++++++++++--
drivers/nvdimm/region.c | 2
drivers/nvdimm/region_devs.c | 20 ++
drivers/s390/block/dcssblk.c | 4
fs/block_dev.c | 2
include/asm-generic/memory_model.h | 6 +
include/asm-generic/pmem.h | 72 +++++++
include/linux/blkdev.h | 2
include/linux/io.h | 57 ++++++
include/linux/libnvdimm.h | 4
include/linux/memory_hotplug.h | 5 -
include/linux/mmzone.h | 23 ++
include/linux/pmem.h | 73 +-------
kernel/memremap.c | 136 ++++++++++++++
mm/Kconfig | 17 ++
mm/memory_hotplug.c | 14 +
mm/page_alloc.c | 3
tools/testing/nvdimm/Kbuild | 3
tools/testing/nvdimm/test/iomap.c | 13 +
45 files changed, 1369 insertions(+), 310 deletions(-)
create mode 100644 drivers/nvdimm/claim.c
create mode 100644 drivers/nvdimm/pfn.h
create mode 100644 drivers/nvdimm/pfn_devs.c
create mode 100644 include/asm-generic/pmem.h
5 years, 5 months
[PATCH 0/2] fix regression in direct I/O to pmem devices
by Jeff Moyer
Linda Knippers noticed that commit bbab37ddc20b (block: Add support
for DAX reads/writes to block devices) caused a regression in mkfs.xfs.
Further investigation also uncovered issues related to misaligned
partitions. This patch set addresses the two issues.
[PATCH 1/2] dax: fix O_DIRECT I/O to the last block of a blockdev
[PATCH 2/2] blockdev: don't set S_DAX for misaligned partitions
fs/block_dev.c | 7 +++++++
fs/dax.c | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
5 years, 5 months
[PATCH] dax, pmem: add support for msync
by Ross Zwisler
For DAX msync we just need to flush the given range using
wb_cache_pmem(), which is now a public part of the PMEM API.
The inclusion of <linux/dax.h> in fs/dax.c was done to make checkpatch
happy. Previously it was complaining about a bunch of undeclared
functions that could be made static.
Signed-off-by: Ross Zwisler <ross.zwisler(a)linux.intel.com>
---
This patch is based on libnvdimm-for-next from our NVDIMM tree:
https://git.kernel.org/cgit/linux/kernel/git/nvdimm/nvdimm.git/
with some DAX patches on top. The baseline tree can be found here:
https://github.com/01org/prd/tree/dax_msync
---
arch/x86/include/asm/pmem.h | 13 +++++++------
fs/dax.c | 17 +++++++++++++++++
include/linux/dax.h | 1 +
include/linux/pmem.h | 22 +++++++++++++++++++++-
mm/msync.c | 10 +++++++++-
5 files changed, 55 insertions(+), 8 deletions(-)
diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h
index d8ce3ec..85c07b2 100644
--- a/arch/x86/include/asm/pmem.h
+++ b/arch/x86/include/asm/pmem.h
@@ -67,18 +67,19 @@ static inline void arch_wmb_pmem(void)
}
/**
- * __arch_wb_cache_pmem - write back a cache range with CLWB
- * @vaddr: virtual start address
+ * arch_wb_cache_pmem - write back a cache range with CLWB
+ * @addr: virtual start address
* @size: number of bytes to write back
*
* Write back a cache range using the CLWB (cache line write back)
* instruction. This function requires explicit ordering with an
- * arch_wmb_pmem() call. This API is internal to the x86 PMEM implementation.
+ * arch_wmb_pmem() call.
*/
-static inline void __arch_wb_cache_pmem(void *vaddr, size_t size)
+static inline void arch_wb_cache_pmem(void __pmem *addr, size_t size)
{
u16 x86_clflush_size = boot_cpu_data.x86_clflush_size;
unsigned long clflush_mask = x86_clflush_size - 1;
+ void *vaddr = (void __force *)addr;
void *vend = vaddr + size;
void *p;
@@ -115,7 +116,7 @@ static inline size_t arch_copy_from_iter_pmem(void __pmem *addr, size_t bytes,
len = copy_from_iter_nocache(vaddr, bytes, i);
if (__iter_needs_pmem_wb(i))
- __arch_wb_cache_pmem(vaddr, bytes);
+ arch_wb_cache_pmem(addr, bytes);
return len;
}
@@ -138,7 +139,7 @@ static inline void arch_clear_pmem(void __pmem *addr, size_t size)
else
memset(vaddr, 0, size);
- __arch_wb_cache_pmem(vaddr, size);
+ arch_wb_cache_pmem(addr, size);
}
static inline bool __arch_has_wmb_pmem(void)
diff --git a/fs/dax.c b/fs/dax.c
index fbe18b8..ed6aec1 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -17,6 +17,7 @@
#include <linux/atomic.h>
#include <linux/blkdev.h>
#include <linux/buffer_head.h>
+#include <linux/dax.h>
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/highmem.h>
@@ -25,6 +26,7 @@
#include <linux/mutex.h>
#include <linux/pmem.h>
#include <linux/sched.h>
+#include <linux/sizes.h>
#include <linux/uio.h>
#include <linux/vmstat.h>
@@ -753,3 +755,18 @@ int dax_truncate_page(struct inode *inode, loff_t from, get_block_t get_block)
return dax_zero_page_range(inode, from, length, get_block);
}
EXPORT_SYMBOL_GPL(dax_truncate_page);
+
+void dax_sync_range(unsigned long addr, size_t len)
+{
+ while (len) {
+ size_t chunk_len = min_t(size_t, SZ_1G, len);
+
+ wb_cache_pmem((void __pmem *)addr, chunk_len);
+ len -= chunk_len;
+ addr += chunk_len;
+ if (len)
+ cond_resched();
+ }
+ wmb_pmem();
+}
+EXPORT_SYMBOL_GPL(dax_sync_range);
diff --git a/include/linux/dax.h b/include/linux/dax.h
index b415e52..504b33f 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -14,6 +14,7 @@ int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t,
dax_iodone_t);
int __dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t,
dax_iodone_t);
+void dax_sync_range(unsigned long addr, size_t len);
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
int dax_pmd_fault(struct vm_area_struct *, unsigned long addr, pmd_t *,
unsigned int flags, get_block_t, dax_iodone_t);
diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index 85f810b3..aa29ebb 100644
--- a/include/linux/pmem.h
+++ b/include/linux/pmem.h
@@ -53,12 +53,18 @@ static inline void arch_clear_pmem(void __pmem *addr, size_t size)
{
BUG();
}
+
+static inline void arch_wb_cache_pmem(void __pmem *addr, size_t size)
+{
+ BUG();
+}
#endif
/*
* Architectures that define ARCH_HAS_PMEM_API must provide
* implementations for arch_memcpy_to_pmem(), arch_wmb_pmem(),
- * arch_copy_from_iter_pmem(), arch_clear_pmem() and arch_has_wmb_pmem().
+ * arch_copy_from_iter_pmem(), arch_clear_pmem(), arch_wb_cache_pmem()
+ * and arch_has_wmb_pmem().
*/
static inline void memcpy_from_pmem(void *dst, void __pmem const *src, size_t size)
{
@@ -202,4 +208,18 @@ static inline void clear_pmem(void __pmem *addr, size_t size)
else
default_clear_pmem(addr, size);
}
+
+/**
+ * wb_cache_pmem - write back a range of cache lines
+ * @vaddr: virtual start address
+ * @size: number of bytes to write back
+ *
+ * Write back the cache lines starting at 'vaddr' for 'size' bytes.
+ * This function requires explicit ordering with an wmb_pmem() call.
+ */
+static inline void wb_cache_pmem(void __pmem *addr, size_t size)
+{
+ if (arch_has_pmem_api())
+ arch_wb_cache_pmem(addr, size);
+}
#endif /* __PMEM_H__ */
diff --git a/mm/msync.c b/mm/msync.c
index bb04d53..2a4739c 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -7,6 +7,7 @@
/*
* The msync() system call.
*/
+#include <linux/dax.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/mman.h>
@@ -59,6 +60,7 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
for (;;) {
struct file *file;
loff_t fstart, fend;
+ unsigned long range_len;
/* Still start < end. */
error = -ENOMEM;
@@ -77,10 +79,16 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
error = -EBUSY;
goto out_unlock;
}
+
+ range_len = min(end, vma->vm_end) - start;
+
+ if (vma_is_dax(vma))
+ dax_sync_range(start, range_len);
+
file = vma->vm_file;
fstart = (start - vma->vm_start) +
((loff_t)vma->vm_pgoff << PAGE_SHIFT);
- fend = fstart + (min(end, vma->vm_end) - start) - 1;
+ fend = fstart + range_len - 1;
start = vma->vm_end;
if ((flags & MS_SYNC) && file &&
(vma->vm_flags & VM_SHARED)) {
--
2.1.0
5 years, 5 months
[PATCH]: acpica/nfit: Rename not-armed bit definition
by Toshi Kani
ACPI 6.0 NFIT Memory Device State Flags in Table 5-129 defines
bit 3 as follows.
Bit [3] set to 1 to indicate that the Memory Device is observed
to be not armed prior to OSPM hand off. A Memory Device is
considered armed if it is able to accept persistent writes.
This bit is currently defined as ACPI_NFIT_MEM_ARMED, which can be
confusing as if the Memory Device is armed when this bit is set.
Change the name to ACPI_NFIT_MEM_NOT_ARMED per the spec.
Signed-off-by: Toshi Kani <toshi.kani(a)hp.com>
Cc: Bob Moore <robert.moore(a)intel.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
---
This patch is based on the linus's tree.
---
drivers/acpi/nfit.c | 6 +++---
drivers/acpi/nfit.h | 2 +-
include/acpi/actbl1.h | 2 +-
tools/testing/nvdimm/test/nfit.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index cf0fd96..4596e0a 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -705,7 +705,7 @@ static ssize_t flags_show(struct device *dev,
flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save_fail " : "",
flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore_fail " : "",
flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush_fail " : "",
- flags & ACPI_NFIT_MEM_ARMED ? "not_armed " : "",
+ flags & ACPI_NFIT_MEM_NOT_ARMED ? "not_armed " : "",
flags & ACPI_NFIT_MEM_HEALTH_OBSERVED ? "smart_event " : "");
}
static DEVICE_ATTR_RO(flags);
@@ -830,7 +830,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
flags |= NDD_ALIASING;
mem_flags = __to_nfit_memdev(nfit_mem)->flags;
- if (mem_flags & ACPI_NFIT_MEM_ARMED)
+ if (mem_flags & ACPI_NFIT_MEM_NOT_ARMED)
flags |= NDD_UNARMED;
rc = acpi_nfit_add_dimm(acpi_desc, nfit_mem, device_handle);
@@ -854,7 +854,7 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
mem_flags & ACPI_NFIT_MEM_SAVE_FAILED ? " save_fail" : "",
mem_flags & ACPI_NFIT_MEM_RESTORE_FAILED ? " restore_fail":"",
mem_flags & ACPI_NFIT_MEM_FLUSH_FAILED ? " flush_fail" : "",
- mem_flags & ACPI_NFIT_MEM_ARMED ? " not_armed" : "");
+ mem_flags & ACPI_NFIT_MEM_NOT_ARMED ? " not_armed" : "");
}
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index 79b6d83..90505e3 100644
--- a/drivers/acpi/nfit.h
+++ b/drivers/acpi/nfit.h
@@ -24,7 +24,7 @@
#define UUID_NFIT_DIMM "4309ac30-0d11-11e4-9191-0800200c9a66"
#define ACPI_NFIT_MEM_FAILED_MASK (ACPI_NFIT_MEM_SAVE_FAILED \
| ACPI_NFIT_MEM_RESTORE_FAILED | ACPI_NFIT_MEM_FLUSH_FAILED \
- | ACPI_NFIT_MEM_ARMED)
+ | ACPI_NFIT_MEM_NOT_ARMED)
enum nfit_uuids {
NFIT_SPA_VOLATILE,
diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h
index fcd5709..238754e 100644
--- a/include/acpi/actbl1.h
+++ b/include/acpi/actbl1.h
@@ -1012,7 +1012,7 @@ struct acpi_nfit_memory_map {
#define ACPI_NFIT_MEM_SAVE_FAILED (1) /* 00: Last SAVE to Memory Device failed */
#define ACPI_NFIT_MEM_RESTORE_FAILED (1<<1) /* 01: Last RESTORE from Memory Device failed */
#define ACPI_NFIT_MEM_FLUSH_FAILED (1<<2) /* 02: Platform flush failed */
-#define ACPI_NFIT_MEM_ARMED (1<<3) /* 03: Memory Device observed to be not armed */
+#define ACPI_NFIT_MEM_NOT_ARMED (1<<3) /* 03: Memory Device observed to be not armed */
#define ACPI_NFIT_MEM_HEALTH_OBSERVED (1<<4) /* 04: Memory Device observed SMART/health events */
#define ACPI_NFIT_MEM_HEALTH_ENABLED (1<<5) /* 05: SMART/health events enabled */
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index d0bdae4..ed271ba 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -917,7 +917,7 @@ static void nfit_test1_setup(struct nfit_test *t)
memdev->interleave_ways = 1;
memdev->flags = ACPI_NFIT_MEM_SAVE_FAILED | ACPI_NFIT_MEM_RESTORE_FAILED
| ACPI_NFIT_MEM_FLUSH_FAILED | ACPI_NFIT_MEM_HEALTH_OBSERVED
- | ACPI_NFIT_MEM_ARMED;
+ | ACPI_NFIT_MEM_NOT_ARMED;
offset += sizeof(*memdev);
/* dcr-descriptor0 */
5 years, 6 months
[PATCH] pmem, nfit: Fix ARCH_MEMREMAP_PMEM handling on x86_32
by Toshi Kani
ARCH_MEMREMAP_PMEM is defined on x86_64 only per ARCH_HAS_PMEM_API.
The following compile error in __nfit_spa_map() was observed on
x86_32 as it refers ARCH_MEMREMAP_PMEM without #ifdef.
drivers/acpi/nfit.c:1205:8: error: 'ARCH_MEMREMAP_PMEM'
undeclared (first use in this function)
Fix it by defining ARCH_MEMREMAP_PMEM to MEMREMAP_WT in <linux/pmem.h>
when CONFIG_ARCH_HAS_PMEM_API is not set, i.e. x86_32.
Remove '#ifdef ARCH_MEMREMAP_PMEM's that are no longer necessary
with this change.
Also remove the redundant definition of ARCH_MEMREMAP_PMEM in
<asm/pmem.h>.
Signed-off-by: Toshi Kani <toshi.kani(a)hp.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Ross Zwisler <ross.zwisler(a)linux.intel.com>
Cc: Christoph Hellwig <hch(a)lst.de>
----
Apply on top of libnvdimm-for-next of the nvdimm tree.
---
arch/x86/include/asm/pmem.h | 2 --
drivers/nvdimm/namespace_devs.c | 4 ----
include/linux/pmem.h | 6 +-----
3 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/arch/x86/include/asm/pmem.h b/arch/x86/include/asm/pmem.h
index 5c8c753..5111f1f 100644
--- a/arch/x86/include/asm/pmem.h
+++ b/arch/x86/include/asm/pmem.h
@@ -18,8 +18,6 @@
#include <asm/cpufeature.h>
#include <asm/special_insns.h>
-#define ARCH_MEMREMAP_PMEM MEMREMAP_WB
-
#ifdef CONFIG_ARCH_HAS_PMEM_API
#define ARCH_MEMREMAP_PMEM MEMREMAP_WB
/**
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 0955b2c..6b40e1c 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -90,11 +90,7 @@ bool pmem_should_map_pages(struct device *dev)
if (is_nd_pfn(dev) || is_nd_btt(dev))
return false;
-#ifdef ARCH_MEMREMAP_PMEM
return ARCH_MEMREMAP_PMEM == MEMREMAP_WB;
-#else
- return false;
-#endif
}
EXPORT_SYMBOL(pmem_should_map_pages);
diff --git a/include/linux/pmem.h b/include/linux/pmem.h
index ebf95a6..04eefc6 100644
--- a/include/linux/pmem.h
+++ b/include/linux/pmem.h
@@ -19,6 +19,7 @@
#ifdef CONFIG_ARCH_HAS_PMEM_API
#include <asm/pmem.h>
#else
+#define ARCH_MEMREMAP_PMEM MEMREMAP_WT
/*
* These are simply here to enable compilation, all call sites gate
* calling these symbols with arch_has_pmem_api() and redirect to the
@@ -129,13 +130,8 @@ static inline void default_clear_pmem(void __pmem *addr, size_t size)
static inline void __pmem *memremap_pmem(struct device *dev,
resource_size_t offset, unsigned long size)
{
-#ifdef ARCH_MEMREMAP_PMEM
return (void __pmem *) devm_memremap(dev, offset, size,
ARCH_MEMREMAP_PMEM);
-#else
- return (void __pmem *) devm_memremap(dev, offset, size,
- MEMREMAP_WT);
-#endif
}
/**
5 years, 6 months
[PATCH] nfit: Fix undefined mmio_flush_range on x86_32
by Toshi Kani
The following compile error was observed on x86_32 since nfit.c
relies on <asm/pmem.h> to include <asm/cacheflush.h>, which only
works when CONFIG_ARCH_HAS_PMEM_API is set on x86_64.
drivers/acpi/nfit.c:1085:5: error: implicit declaration of
function 'mmio_flush_range' [-Werror=implicit-function-declaration]
Change nfit.c to include <asm/cacheflush.h> directly for now.
Signed-off-by: Toshi Kani <toshi.kani(a)hp.com>
Cc: Dan Williams <dan.j.williams(a)intel.com>
Cc: Ross Zwisler <ross.zwisler(a)linux.intel.com>
---
Apply on top of libnvdimm-for-next of the nvdimm tree.
This is a temporary fix and please feel free to replace it with
a better solution.
---
drivers/acpi/nfit.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index 82d07e8..f61e69f 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -20,6 +20,7 @@
#include <linux/sort.h>
#include <linux/pmem.h>
#include <linux/io.h>
+#include <asm/cacheflush.h>
#include "nfit.h"
/*
5 years, 6 months
[GIT PULL] libnvdimm ABI fixup for 4.2
by Williams, Dan J
Hi Linus, please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes
...to receive one final fix for 4.2.
I pushed back on this change quite hard given the late date, that it
appears to be purely cosmetic, sysfs is not necessarily meant to be a
user friendly UI, and the kernel interprets the reversed polarity of the
ACPI_NFIT_MEM_ARMED flag correctly. When this flag is set, the energy
source of an NVDIMM is not armed and any new writes to the DIMM may not
be preserved.
However, Bob Moore warned me that it is important to get these things
named correctly wherever they appear otherwise we run the risk of a less
than cautious firmware engineer implementing the polarity the wrong way.
Once a mistake like that escapes into production platforms the flag
becomes useless and we need to move to a new bit position.
Bob has agreed to take a change through ACPICA to rename
ACPI_NFIT_MEM_ARMED to ACPI_NFIT_MEM_NOT_ARMED, and the patch below from
Toshi brings the sysfs representation of these flags in line with their
respective polarities.
Please pull for 4.2 as this is the first kernel to expose the ACPI NFIT
sysfs representation, and this is likely a kernel that firmware
developers will be using for checking out their NVDIMM enabling.
The following changes since commit de4a196c02a2a2631b516d90da6e8d052ccb07e8:
nfit, nd_blk: BLK status register is only 32 bits (2015-08-25 19:42:01 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm libnvdimm-fixes
for you to fetch changes up to 402bae597ec68b84498432f5a0069f28bfb807d6:
nfit: Clarify memory device state flags strings (2015-08-27 14:35:58 -0400)
----------------------------------------------------------------
Toshi Kani (1):
nfit: Clarify memory device state flags strings
drivers/acpi/nfit.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
commit 402bae597ec68b84498432f5a0069f28bfb807d6
Author: Toshi Kani <toshi.kani(a)hp.com>
Date: Wed Aug 26 10:20:23 2015 -0600
nfit: Clarify memory device state flags strings
ACPI 6.0 NFIT Memory Device State Flags in Table 5-129 defines
NVDIMM status as follows. These bits indicate multiple info,
such as failures, pending event, and capability.
Bit [0] set to 1 to indicate that the previous SAVE to the
Memory Device failed.
Bit [1] set to 1 to indicate that the last RESTORE from the
Memory Device failed.
Bit [2] set to 1 to indicate that platform flush of data to
Memory Device failed. As a result, the restored data content
may be inconsistent even if SAVE and RESTORE do not indicate
failure.
Bit [3] set to 1 to indicate that the Memory Device is observed
to be not armed prior to OSPM hand off. A Memory Device is
considered armed if it is able to accept persistent writes.
Bit [4] set to 1 to indicate that the Memory Device observed
SMART and health events prior to OSPM handoff.
/sys/bus/nd/devices/nmemX/nfit/flags shows this flags info.
The output strings associated with the bits are "save", "restore",
"smart", etc., which can be confusing as they may be interpreted
as positive status, i.e. save succeeded.
Change also the dev_info() message in acpi_nfit_register_dimms()
to be consistent with the sysfs flags strings.
Reported-by: Robert Elliott <elliott(a)hp.com>
Signed-off-by: Toshi Kani <toshi.kani(a)hp.com>
[ross: rename 'not_arm' to 'not_armed']
Cc: Ross Zwisler <ross.zwisler(a)linux.intel.com>
[djbw: defer adding bit5, HEALTH_ENABLED, for now]
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index bb29e56276bd..cf0fd96a7602 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -702,11 +702,11 @@ static ssize_t flags_show(struct device *dev,
u16 flags = to_nfit_memdev(dev)->flags;
return sprintf(buf, "%s%s%s%s%s\n",
- flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save " : "",
- flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore " : "",
- flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush " : "",
- flags & ACPI_NFIT_MEM_ARMED ? "arm " : "",
- flags & ACPI_NFIT_MEM_HEALTH_OBSERVED ? "smart " : "");
+ flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save_fail " : "",
+ flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore_fail " : "",
+ flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush_fail " : "",
+ flags & ACPI_NFIT_MEM_ARMED ? "not_armed " : "",
+ flags & ACPI_NFIT_MEM_HEALTH_OBSERVED ? "smart_event " : "");
}
static DEVICE_ATTR_RO(flags);
@@ -849,12 +849,12 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc)
if ((mem_flags & ACPI_NFIT_MEM_FAILED_MASK) == 0)
continue;
- dev_info(acpi_desc->dev, "%s: failed: %s%s%s%s\n",
+ dev_info(acpi_desc->dev, "%s flags:%s%s%s%s\n",
nvdimm_name(nvdimm),
- mem_flags & ACPI_NFIT_MEM_SAVE_FAILED ? "save " : "",
- mem_flags & ACPI_NFIT_MEM_RESTORE_FAILED ? "restore " : "",
- mem_flags & ACPI_NFIT_MEM_FLUSH_FAILED ? "flush " : "",
- mem_flags & ACPI_NFIT_MEM_ARMED ? "arm " : "");
+ mem_flags & ACPI_NFIT_MEM_SAVE_FAILED ? " save_fail" : "",
+ mem_flags & ACPI_NFIT_MEM_RESTORE_FAILED ? " restore_fail":"",
+ mem_flags & ACPI_NFIT_MEM_FLUSH_FAILED ? " flush_fail" : "",
+ mem_flags & ACPI_NFIT_MEM_ARMED ? " not_armed" : "");
}
5 years, 6 months
[PATCH v3] change aperture mapping from WC to WB
by Ross Zwisler
The patch formerly known as `nd_blk: add support for "read flush" DSM flag'.
I changed the patch title and updated the description to place more emphasis on
the real purpose of the change, which is to move the BLK aperture mapping to
WB. Really the implementation of the "read flush" flag was just to enable this
mapping change.
Ross Zwisler (1):
nd_blk: change aperture mapping from WC to WB
arch/x86/Kconfig | 1 +
arch/x86/include/asm/cacheflush.h | 2 ++
arch/x86/include/asm/io.h | 2 --
arch/x86/include/asm/pmem.h | 2 ++
drivers/acpi/Kconfig | 1 +
drivers/acpi/nfit.c | 55 ++++++++++++++++++++++-----------------
drivers/acpi/nfit.h | 16 ++++++++----
lib/Kconfig | 3 +++
tools/testing/nvdimm/Kbuild | 2 ++
tools/testing/nvdimm/test/iomap.c | 30 +++++++++++++++++++--
tools/testing/nvdimm/test/nfit.c | 10 ++++---
11 files changed, 88 insertions(+), 36 deletions(-)
--
2.1.0
5 years, 6 months
[PATCH 0/2]: acpi, nfit: Clarify memory device state flags
by Toshi Kani
ACPI 6.0 NFIT Memory Device State Flags in Table 5-129 defines
NVDIMM status. User can check the NVDIMM status from sysfs and
dmesg output, but the output can be confusing at this point.
Patch 01 clarifies the output strings from the sysfs and dmesg.
Patch 02 clarifies the define name of not-arm bit in the flags.
This patchset is based on libnvdimm-pending of the nvdimm tree.
---
Toshi Kani (2):
1/2 nfit: Clarify memory device state flags strings
2/2 acpica/nfit: Rename not-armed bit definition
---
drivers/acpi/nfit.c | 25 +++++++++++++------------
drivers/acpi/nfit.h | 2 +-
include/acpi/actbl1.h | 2 +-
tools/testing/nvdimm/test/nfit.c | 2 +-
4 files changed, 16 insertions(+), 15 deletions(-)
5 years, 6 months