]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
8 years agodevres: add devm_memremap
Christoph Hellwig [Tue, 11 Aug 2015 03:07:07 +0000 (23:07 -0400)]
devres: add devm_memremap

Orabug: 22913653

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 7d3dcf26a6559fa82af3f53e2c8b163cec95fdaf)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoarch: introduce memremap()
Dan Williams [Tue, 11 Aug 2015 03:07:06 +0000 (23:07 -0400)]
arch: introduce memremap()

Orabug: 22913653

Existing users of ioremap_cache() are mapping memory that is known in
advance to not have i/o side effects.  These users are forced to cast
away the __iomem annotation, or otherwise neglect to fix the sparse
errors thrown when dereferencing pointers to this memory.  Provide
memremap() as a non __iomem annotated ioremap_*() in the case when
ioremap is otherwise a pointer to cacheable memory. Empirically,
ioremap_<cacheable-type>() call sites are seeking memory-like semantics
(e.g.  speculative reads, and prefetching permitted).

memremap() is a break from the ioremap implementation pattern of adding
a new memremap_<type>() for each mapping type and having silent
compatibility fall backs.  Instead, the implementation defines flags
that are passed to the central memremap() and if a mapping type is not
supported by an arch memremap returns NULL.

We introduce a memremap prototype as a trivial wrapper of
ioremap_cache() and ioremap_wt().  Later, once all ioremap_cache() and
ioremap_wt() usage has been removed from drivers we teach archs to
implement arch_memremap() with the ability to strictly enforce the
mapping type.

Cc: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 92281dee825f6d2eb07c441437e4196a44b0861c)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agopmem: convert to generic memremap
Dan Williams [Wed, 12 Aug 2015 22:42:56 +0000 (18:42 -0400)]
pmem: convert to generic memremap

Orabug: 22913653

Kill arch_memremap_pmem() and just let the architecture specify the
flags to be passed to memremap().  Default to writethrough by default.

Suggested-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit e836a256e8fd579c9d7a3685f22981225a1ca451)

Conflict:

include/linux/pmem.h

8 years agomm: enhance region_is_ram() to region_intersects()
Dan Williams [Tue, 11 Aug 2015 03:07:05 +0000 (23:07 -0400)]
mm: enhance region_is_ram() to region_intersects()

Orabug: 22913653

region_is_ram() is used to prevent the establishment of aliased mappings
to physical "System RAM" with incompatible cache settings.  However, it
uses "-1" to indicate both "unknown" memory ranges (ranges not described
by platform firmware) and "mixed" ranges (where the parameters describe
a range that partially overlaps "System RAM").

Fix this up by explicitly tracking the "unknown" vs "mixed" resource
cases and returning REGION_INTERSECTS, REGION_MIXED, or REGION_DISJOINT.
This re-write also adds support for detecting when the requested region
completely eclipses all of a resource.  Note, the implementation treats
overlaps between "unknown" and the requested memory type as
REGION_INTERSECTS.

Finally, other memory types can be passed in by name, for now the only
usage "System RAM".

Suggested-by: Luis R. Rodriguez <mcgrof@suse.com>
Reviewed-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 124fe20d94630b6f173dae5eb815e6e6e350c72d)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonvdimm: change to use generic kvfree()
yalin wang [Thu, 27 Aug 2015 23:35:48 +0000 (19:35 -0400)]
nvdimm: change to use generic kvfree()

Orabug: 22913653

Signed-off-by: yalin wang <yalin.wang2010@gmail.com>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit a06a7576526e10a99ea7721533e7f2df3e26baad)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, e820: make CONFIG_X86_PMEM_LEGACY a tristate option
Dan Williams [Wed, 19 Aug 2015 04:34:34 +0000 (00:34 -0400)]
libnvdimm, e820: make CONFIG_X86_PMEM_LEGACY a tristate option

Orabug: 22913653

We currently register a platform device for e820 type-12 memory and
register a nvdimm bus beneath it.  Registering the platform device
triggers the device-core machinery to probe for a driver, but that
search currently comes up empty.  Building the nvdimm-bus registration
into the e820_pmem platform device registration in this way forces
libnvdimm to be built-in.  Instead, convert the built-in portion of
CONFIG_X86_PMEM_LEGACY to simply register a platform device and move the
rest of the logic to the driver for e820_pmem, for the following
reasons:

1/ Letting e820_pmem support be a module allows building and testing
   libnvdimm.ko changes without rebooting

2/ All the normal policy around modules can be applied to e820_pmem
   (unbind to disable and/or blacklisting the module from loading by
   default)

3/ Moving the driver to a generic location and converting it to scan
   "iomem_resource" rather than "e820.map" means any other architecture can
   take advantage of this simple nvdimm resource discovery mechanism by
   registering a resource named "Persistent Memory (legacy)"

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 7a67832c7e44c20935c5d6f2264035a0f7bf0d8f)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, btt: write and validate parent_uuid
Vishal Verma [Wed, 29 Jul 2015 20:58:09 +0000 (14:58 -0600)]
libnvdimm, btt: write and validate parent_uuid

Orabug: 22913653

When a BTT is instantiated on a namespace it must validate the namespace
uuid matches the 'parent_uuid' stored in the btt superblock. This
property enforces that changing the namespace UUID invalidates all
former BTT instances on that storage. For "IO namespaces" that don't
have a label or UUID, the parent_uuid is set to zero, and this
validation is skipped. For such cases, old BTTs have to be invalidated
by forcing the namespace to raw mode, and overwriting the BTT info
blocks.

Based on a patch by Dan Williams <dan.j.williams@intel.com>

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 6ec689542b5bc516187917d49b112847dfb75b0b)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, btt: consolidate arena validation
Vishal Verma [Wed, 29 Jul 2015 20:58:08 +0000 (14:58 -0600)]
libnvdimm, btt: consolidate arena validation

Orabug: 22913653

Use arena_is_valid as a common routine for checking the validity of an
info block from both discover_arenas, and nd_btt_probe.

As a result, don't check for validity of the BTT's UUID, and lbasize.
The checksum in the BTT info block guarantees self-consistency, and when
we're called from nd_btt_probe, we don't have a valid uuid or lbasize
available to check against.

Also cleanup to return a bool instead of an int.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit ab45e7632717b811e0786e46ca5ad279cb731b66)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, btt: clean up internal interfaces
Vishal Verma [Wed, 29 Jul 2015 20:58:07 +0000 (14:58 -0600)]
libnvdimm, btt: clean up internal interfaces

Orabug: 22913653

Consolidate the parameters passed to arena_is_valid into just nd_btt,
and an info block to increase re-usability.

Similarly, btt_arena_write_layout doesn't need to be passed a uuid, as
it can be obtained from arena->nd_btt.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit fbde1414acc0440024083bf0c391b259bcfc4826)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonvdimm: fix inline function return type warning
Randy Dunlap [Tue, 28 Jul 2015 19:27:01 +0000 (12:27 -0700)]
nvdimm: fix inline function return type warning

Orabug: 22913653

Fix multiple build warnings when CONFIG_BTT is not enabled:

In file included from ../drivers/nvdimm/bus.c:29:0:
../drivers/nvdimm/nd.h:169:15: warning: return type defaults to 'int' [-Wreturn-type]
 static inline nd_btt_probe(struct nd_namespace_common *ndns, void *drvdata)
               ^

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: linux-nvdimm@lists.01.org
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f6ef5a2a50816b58e3126206de13d0b9fdf89df5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit: Don't check _STA on NVDIMM devices
Linda Knippers [Wed, 22 Jul 2015 20:17:22 +0000 (16:17 -0400)]
nfit: Don't check _STA on NVDIMM devices

Orabug: 22913653

The _STA only applies to the root device, not the individual NVDIMMS,
so don't check here. NVDIMM device state flags are checked elsewhere.

Signed-off-by: Linda Knippers <linda.knippers@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 60e95f43fc8573e81f54b0c1e0bc542c2260d956)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, pmem: Change pmem physical sector size to PAGE_SIZE
Vishal Verma [Thu, 23 Jul 2015 17:58:48 +0000 (11:58 -0600)]
libnvdimm, pmem: Change pmem physical sector size to PAGE_SIZE

Orabug: 22913653

Based on a patch: c8fa317 brd: Request from fdisk 4k alignment by Boaz
Harrosh, allow fdisk to create properly aligned partitions for DAX. This
will also cause mkfs.ext4 to emit a warning if using a file system block
size of less than PAGE_SIZE.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Matthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Elliott, Robert <Elliott@hp.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Acked-by: Boaz Harrosh <boaz@plexistor.com>
Acked-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 6b47496a6fc81816e7edaf8224dfb88e402a05f5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: Add DSM support for Address Range Scrub commands
Vishal Verma [Thu, 9 Jul 2015 19:25:36 +0000 (13:25 -0600)]
libnvdimm: Add DSM support for Address Range Scrub commands

Orabug: 22913653

Add support for the three ARS DSM commands:
- Query ARS Capabilities - Queries the firmware to check if a given
  range supports scrub, and if so, which type (persistent vs. volatile)
- Start ARS - Starts a scrub for a given range/type
- Query ARS Status - Checks status of a previously started scrub, and
  provides the error logs if any.

  The commands are described by the example DSM spec at:
  http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

Also add these commands to the nfit_test test framework, and return
canned data.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 39c686b862cdb2049b90e095b6c6c727b2a7ab60)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: Update name of the ars_status_record mask field
Vishal Verma [Thu, 9 Jul 2015 19:25:35 +0000 (13:25 -0600)]
libnvdimm: Update name of the ars_status_record mask field

Orabug: 22913653

The spec suggests that this is a simple 'length' field, not a mask.
Update the name accordingly.

Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit ec92777f2ba93c00387b8fe53780c25adc57c744)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, btt: sparse fix
Dan Williams [Sat, 11 Jul 2015 14:02:46 +0000 (10:02 -0400)]
libnvdimm, btt: sparse fix

Orabug: 22913653

Fix:
drivers/nvdimm/btt.c:635:29: warning: restricted __le64 degrades to integer

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 5e32940621eb62064d98f42c9889db71b0368bde)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit: Clarify memory device state flags strings
Toshi Kani [Wed, 26 Aug 2015 16:20:23 +0000 (10:20 -0600)]
nfit: Clarify memory device state flags strings

Orabug: 22913653

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@hp.com>
Signed-off-by: Toshi Kani <toshi.kani@hp.com>
[ross: rename 'not_arm' to 'not_armed']
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
[djbw: defer adding bit5, HEALTH_ENABLED, for now]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 402bae597ec68b84498432f5a0069f28bfb807d6)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit, nd_blk: BLK status register is only 32 bits
Ross Zwisler [Thu, 20 Aug 2015 22:27:38 +0000 (16:27 -0600)]
nfit, nd_blk: BLK status register is only 32 bits

Orabug: 22913653

Only read 32 bits for the BLK status register in read_blk_stat().

The format and size of this register is defined in the
"NVDIMM Driver Writer's guide":

http://pmem.io/documents/NVDIMM_Driver_Writers_Guide.pdf

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reported-by: Nicholas Moulin <nicholas.w.moulin@linux.intel.com>
Tested-by: Nicholas Moulin <nicholas.w.moulin@linux.intel.com>
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit de4a196c02a2a2631b516d90da6e8d052ccb07e8)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: call dax_fault on read page faults for DAX
Dave Chinner [Wed, 29 Jul 2015 01:48:00 +0000 (11:48 +1000)]
xfs: call dax_fault on read page faults for DAX

Orabug: 22913653

When modifying the patch series to handle the XFS MMAP_LOCK nesting
of page faults, I botched the conversion of the read page fault
path, and so it is only every calling through the page cache. Re-add
the necessary __dax_fault() call for such files.

Because the get_blocks callback on read faults may not set up the
mapping buffer correctly to allow unwritten extent completion to be
run, we need to allow callers of __dax_fault() to pass a null
complete_unwritten() callback. The DAX code always zeros the
unwritten page when it is read faulted so there are no stale data
exposure issues with not doing the conversion. The only downside
will be the potential for increased CPU overhead on repeated read
faults of the same page. If this proves to be a problem, then the
filesystem needs to fix it's get_block callback and provide a
convert_unwritten() callback to the read fault path.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit b2442c5a7fe92cca08437070c8a45a7aa0d1703e)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agomm: Fix bugs in region_is_ram()
Toshi Kani [Thu, 16 Jul 2015 23:23:16 +0000 (17:23 -0600)]
mm: Fix bugs in region_is_ram()

Orabug: 22913653

region_is_ram() looks up the iomem_resource table to check if
a target range is in RAM.  However, it always returns with -1
due to invalid range checks. It always breaks the loop at the
first entry of the table.

Another issue is that it compares p->flags and flags, but it always
fails. flags is declared as int, which makes it as a negative value
with IORESOURCE_BUSY (0x80000000) set while p->flags is unsigned long.

Fix the range check and flags so that region_is_ram() works as
advertised.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: Mike Travis <travis@sgi.com>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Roland Dreier <roland@purestorage.com>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1437088996-28511-4-git-send-email-toshi.kani@hp.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
(cherry picked from commit 8c38de992be9aed0b34c4fab8f972c83d3b00dc4)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agox86/mm: Remove region_is_ram() call from ioremap
Toshi Kani [Thu, 16 Jul 2015 23:23:15 +0000 (17:23 -0600)]
x86/mm: Remove region_is_ram() call from ioremap

Orabug: 22913653

__ioremap_caller() calls region_is_ram() to walk through the
iomem_resource table to check if a target range is in RAM, which was
added to improve the lookup performance over page_is_ram() (commit
906e36c5c717 "x86: use optimized ioresource lookup in ioremap
function"). page_is_ram() was no longer used when this change was
added, though.

__ioremap_caller() then calls walk_system_ram_range(), which had
replaced page_is_ram() to improve the lookup performance (commit
c81c8a1eeede "x86, ioremap: Speed up check for RAM pages").

Since both checks walk through the same iomem_resource table for
the same purpose, there is no need to call both functions.

Aside of that walk_system_ram_range() is the only useful check at the
moment because region_is_ram() always returns -1 due to an
implementation bug. That bug in region_is_ram() cannot be fixed
without breaking existing ioremap callers, which rely on the subtle
difference of walk_system_ram_range() versus non page aligned ranges.

Once these offending callers are fixed we can use region_is_ram() and
remove walk_system_ram_range().

[ tglx: Massaged changelog ]

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: Roland Dreier <roland@purestorage.com>
Cc: Mike Travis <travis@sgi.com>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/1437088996-28511-3-git-send-email-toshi.kani@hp.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit 9a58eebe1ace609bedf8c5a65e70a097459f5696)

Conflict:

arch/x86/mm/ioremap.c

8 years agolibnvdimm: fix namespace seed creation
Dan Williams [Sat, 25 Jul 2015 03:42:34 +0000 (23:42 -0400)]
libnvdimm: fix namespace seed creation

Orabug: 22913653

A new BLK namespace "seed" device is created whenever the current seed
is successfully probed.  However, if that namespace is assigned to a BTT
it may never directly experience a successful probe as it is a
subordinate device to a BTT configuration.

The effect of the current code is that no new namespaces can be
instantiated, after the seed namespace, to consume available BLK DPA
capacity.  Fix this by treating a successful BTT probe event as a
successful probe event for the backing namespace.

Reported-by: Nicholas Moulin <nicholas.w.moulin@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 8ca243536d21ae2d08f61b1c5af4ac3d4bb697e4)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit: add support for NVDIMM "latch" flag
Ross Zwisler [Fri, 10 Jul 2015 17:06:14 +0000 (11:06 -0600)]
nfit: add support for NVDIMM "latch" flag

Orabug: 22913653

Add support in the NFIT BLK I/O path for the "latch" flag
defined in the "Get Block NVDIMM Flags" _DSM function:

http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

This flag requires the driver to read back the command register after it
is written in the block I/O path.  This ensures that the hardware has
fully processed the new command and moved the aperture appropriately.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f0f2c072cf530d5b8890be5051cc8b36b0c54cce)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit: update block I/O path to use PMEM API
Ross Zwisler [Fri, 10 Jul 2015 17:06:13 +0000 (11:06 -0600)]
nfit: update block I/O path to use PMEM API

Orabug: 22913653

Update the nfit block I/O path to use the new PMEM API and to adhere to
the read/write flows outlined in the "NVDIMM Block Window Driver
Writer's Guide":

http://pmem.io/documents/NVDIMM_Driver_Writers_Guide.pdf

This includes adding support for targeted NVDIMM flushes called "flush
hints" in the ACPI 6.0 specification:

http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf

For performance and media durability the mapping for a BLK aperture is
moved to a write-combining mapping which is consistent with
memcpy_to_pmem() and wmb_blk().

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit c2ad29540cb913bd9e526fae77c35c7fb45f24a3)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agotools/testing/nvdimm: add mock acpi_nfit_flush_address entries to nfit_test
Dan Williams [Fri, 10 Jul 2015 18:07:03 +0000 (14:07 -0400)]
tools/testing/nvdimm: add mock acpi_nfit_flush_address entries to nfit_test

Orabug: 22913653

In preparation for fixing the BLK path to properly use "directed
pcommit" enable the unit test infrastructure to emit mock "flush"
tables.  Writes to these flush addresses trigger a memory controller to
flush its internal buffers to persistent media, similar to the x86
"pcommit" instruction.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 9d27a87ec9e1317d368b1e5e3f4808078baa8c4c)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agotools/testing/nvdimm: fix return code for unimplemented commands
Dan Williams [Fri, 10 Jul 2015 17:06:12 +0000 (11:06 -0600)]
tools/testing/nvdimm: fix return code for unimplemented commands

Orabug: 22913653

The implementation for the new "DIMM Flags" DSM relies on the -ENOTTY
return code to indicate that the flags are unimplimented and to fall
back to a safe default.  As is the -ENXIO error code erroneoously
indicates to fail enabling a BLK region.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f7ec83684af020c961d7fab801f8e3ef7ce5de33)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agotools/testing/nvdimm: mock ioremap_wt
Dan Williams [Fri, 10 Jul 2015 17:06:11 +0000 (11:06 -0600)]
tools/testing/nvdimm: mock ioremap_wt

Orabug: 22913653

In the 4.2-rc1 merge the default_memremap_pmem() implementation switched
from ioremap_nocache() to ioremap_wt().  Add it to the list of mocked
routines to restore the ability to run the unit tests.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit b1b2e6235a44174151fa3bb22657f74972635618)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agopmem: add maintainer for include/linux/pmem.h
Ross Zwisler [Fri, 10 Jul 2015 17:06:10 +0000 (11:06 -0600)]
pmem: add maintainer for include/linux/pmem.h

Orabug: 22913653

The file include/linux/pmem.h was recently created to hold the PMEM API,
and is logically part of the PMEM driver.  Add an entry for this file to
MAINTAINERS.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit b864bc17f1c326783f2388057e15d3e153125ab9)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonfit: fix smatch "use after null check" report
Dan Williams [Tue, 30 Jun 2015 20:09:39 +0000 (16:09 -0400)]
nfit: fix smatch "use after null check" report

Orabug: 22913653

drivers/acpi/nfit.c:1224 acpi_nfit_blk_region_enable()
         error: we previously assumed 'nfit_mem' could be null (see line 1223)

drivers/acpi/nfit.c
  1222          nfit_mem = nvdimm_provider_data(nvdimm);
  1223          if (!nfit_mem || !nfit_mem->dcr || !nfit_mem->bdw) {
                     ^^^^^^^^
Check.

  1224                  dev_dbg(dev, "%s: missing%s%s%s\n", __func__,
  1225                                  nfit_mem ? "" : " nfit_mem",
  1226                                  nfit_mem->dcr ? "" : " dcr",
                                        ^^^^^^^^^^^^^
Unchecked dereference.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 193ccca43850d2355e7690a93ab9d7d78d38f905)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agonvdimm: Fix return value of nvdimm_bus_init() if class_create() fails
Axel Lin [Sun, 28 Jun 2015 09:00:57 +0000 (17:00 +0800)]
nvdimm: Fix return value of nvdimm_bus_init() if class_create() fails

Orabug: 22913653

Return proper error if class_create() fails.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit daa1dee405d7d3d3e816b84a692e838a5647a02a)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: smatch cleanups in __nd_ioctl
Dan Williams [Tue, 30 Jun 2015 18:10:09 +0000 (14:10 -0400)]
libnvdimm: smatch cleanups in __nd_ioctl

Orabug: 22913653

Drop use of access_ok() since we are already using copy_{to|from}_user()
which do their own access_ok().

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit af834d457d9ed69e14836b63d0da198fdd2ec706)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agosparse: fix misplaced __pmem definition
Dan Williams [Tue, 30 Jun 2015 16:07:17 +0000 (12:07 -0400)]
sparse: fix misplaced __pmem definition

Orabug: 22913653

Move the definition of __pmem outside of CONFIG_SPARSE_RCU_POINTER to fix:

drivers/nvdimm/pmem.c:198:17: sparse: too many arguments for function __builtin_expect
drivers/nvdimm/pmem.c:36:33: sparse: expected ; at end of declaration
drivers/nvdimm/pmem.c:48:21: sparse: void declaration

...due to __pmem failing to be defined in some configurations when
CONFIG_SPARSE_RCU_POINTER=y.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 31f02455455d405320e2f749696bef4e02903b35)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodax: bdev_direct_access() may sleep
Matthew Wilcox [Fri, 3 Jul 2015 14:40:43 +0000 (10:40 -0400)]
dax: bdev_direct_access() may sleep

Orabug: 22913653

The brd driver is the only in-tree driver that may sleep currently.
After some discussion on linux-fsdevel, we decided that any driver
may choose to sleep in its ->direct_access method.  To ensure that all
callers of bdev_direct_access() are prepared for this, add a call
to might_sleep().

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
(cherry picked from commit 43c3dd08da890e458f670b4fc0630513fb405620)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoblock: Add support for DAX reads/writes to block devices
Matthew Wilcox [Fri, 3 Jul 2015 14:40:42 +0000 (10:40 -0400)]
block: Add support for DAX reads/writes to block devices

Orabug: 22913653

If a block device supports the ->direct_access methods, bypass the normal
DIO path and use DAX to go straight to memcpy() instead of allocating
a DIO and a BIO.

Includes support for the DIO_SKIP_DIO_COUNT flag in DAX, as is done in
do_blockdev_direct_IO().

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
(cherry picked from commit bbab37ddc20bae4709bca8745c128c4f46fe63c5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodax: Use copy_from_iter_nocache
Matthew Wilcox [Fri, 3 Jul 2015 14:40:39 +0000 (10:40 -0400)]
dax: Use copy_from_iter_nocache

Orabug: 22913653

When userspace does a write, there's no need for the written data to
pollute the CPU cache.  This matches the original XIP code.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
(cherry picked from commit 872eb127e3a6cddcfca1410bb808d9b9bc773dc1)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodax: Add block size note to documentation
Matthew Wilcox [Fri, 3 Jul 2015 14:40:38 +0000 (10:40 -0400)]
dax: Add block size note to documentation

Orabug: 22913653

For block devices which are small enough, mkfs will default to creating
a filesystem with block sizes smaller than page size.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
(cherry picked from commit 44f4c054cae646a9296da05cdfe7d6e786f73d46)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: saner xfs_trans_commit interface
Christoph Hellwig [Thu, 4 Jun 2015 03:48:08 +0000 (13:48 +1000)]
xfs: saner xfs_trans_commit interface

The flags argument to xfs_trans_commit is not useful for most callers, as
a commit of a transaction without a permanent log reservation must pass
0 here, and all callers for a transaction with a permanent log reservation
except for xfs_trans_roll must pass XFS_TRANS_RELEASE_LOG_RES.  So remove
the flags argument from the public xfs_trans_commit interfaces, and
introduce low-level __xfs_trans_commit variant just for xfs_trans_roll
that regrants a log reservation instead of releasing it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit 70393313dd0b26a6a79e2737b6dff1f1937b936d)

Conflict:

fs/xfs/xfs_attr_inactive.c

8 years agoxfs: remove the flags argument to xfs_trans_cancel
Christoph Hellwig [Thu, 4 Jun 2015 03:47:56 +0000 (13:47 +1000)]
xfs: remove the flags argument to xfs_trans_cancel

Orabug: 22913653

xfs_trans_cancel takes two flags arguments: XFS_TRANS_RELEASE_LOG_RES and
XFS_TRANS_ABORT.  Both of them are a direct product of the transaction
state, and can be deducted:

 - any dirty transaction needs XFS_TRANS_ABORT to be properly canceled,
   and XFS_TRANS_ABORT is a noop for a transaction that is not dirty.
 - any transaction with a permanent log reservation needs
   XFS_TRANS_RELEASE_LOG_RES to be properly canceled, and passing
   XFS_TRANS_RELEASE_LOG_RES for a transaction without a permanent
   log reservation is invalid.

So just remove the flags argument and do the right thing.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit 4906e21545814e4129595118287a2f1415483c0b)

Conflict:

fs/xfs/xfs_attr_inactive.c

8 years agoxfs: pass a boolean flag to xfs_trans_free_items
Christoph Hellwig [Thu, 4 Jun 2015 03:47:43 +0000 (13:47 +1000)]
xfs: pass a boolean flag to xfs_trans_free_items

Orabug: 22913653

The flags value always was 0 or XFS_TRANS_ABORT.  Switch to a bool
parameter to allow further cleanups.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit eacb24e73424bdae4aa139ddd459f86ec46f0ad0)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: switch remaining xfs_trans_dup users to xfs_trans_roll
Christoph Hellwig [Thu, 4 Jun 2015 03:47:29 +0000 (13:47 +1000)]
xfs: switch remaining xfs_trans_dup users to xfs_trans_roll

Orabug: 22913653

We have three remaining callers of xfs_trans_dup:

 - xfs_itruncate_extents which open codes xfs_trans_roll
 - xfs_bmap_finish doesn't have an xfs_inode argument and thus leaves
   attaching them to it's callers, but otherwise is identical to
   xfs_trans_roll
 - xfs_dir_ialloc looks at the log reservations in the old xfs_trans
   structure instead of the log reservation parameters, but otherwise
   is identical to xfs_trans_roll.

By allowing a NULL xfs_inode argument to xfs_trans_roll we can switch
these three remaining users over to xfs_trans_roll and mark xfs_trans_dup
static.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 2e6db6c4c1f71823472651f162f0b355f5b7951e)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: add initial DAX support
Dave Chinner [Wed, 3 Jun 2015 23:19:18 +0000 (09:19 +1000)]
xfs: add initial DAX support

Orabug: 22913653

Add initial DAX support to XFS. To do this we need a new mount
option to turn DAX on filesystem, and we need to propagate this into
the inode flags whenever an inode is instantiated so that the
per-inode checks throughout the code Do The Right Thing.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit cbe4dab119f211ff6642d617f541087894e99e4f)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: add DAX IO path support
Dave Chinner [Wed, 3 Jun 2015 23:19:15 +0000 (09:19 +1000)]
xfs: add DAX IO path support

Orabug: 22913653

DAX does not do buffered IO (can't buffer direct access!) and hence
all read/write IO is vectored through the direct IO path.  Hence we
need to add the DAX IO path callouts to the direct IO
infrastructure.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 6e1ba0bcb84b3f97616feb07c27f974509ba57be)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: add DAX truncate support
Dave Chinner [Wed, 3 Jun 2015 23:19:10 +0000 (09:19 +1000)]
xfs: add DAX truncate support

Orabug: 22913653

When we truncate a DAX file, we need to call through the DAX page
truncation path rather than through block_truncate_page() so that
mappings and block zeroing are all handled correctly. Otherwise,
truncate does not need to change.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 9969441f9f86a8a7de8c36514fa789e5f5d83145)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: add DAX block zeroing support
Dave Chinner [Wed, 3 Jun 2015 23:19:08 +0000 (09:19 +1000)]
xfs: add DAX block zeroing support

Orabug: 22913653

Add initial support for DAX block zeroing operations to XFS. DAX
cannot use buffered IO through the page cache for zeroing, nor do we
need to issue IO for uncached block zeroing. In both cases, we can
simply call out to the dax block zeroing function.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 4f69f578a87d39c20b1ff70005a125e4594c3de8)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoxfs: add DAX file operations support
Dave Chinner [Wed, 3 Jun 2015 23:18:53 +0000 (09:18 +1000)]
xfs: add DAX file operations support

Orabug: 22913653

Add the initial support for DAX file operations to XFS. This
includes the necessary block allocation and mmap page fault hooks
for DAX to function.

Note that there are changes to the splice interfaces to ensure that
for DAX splice avoids direct page cache manipulations and instead
takes the DAX IO paths for read/write operations.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit 6b698edeeef00c127d73501b386590299f01327a)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodax: expose __dax_fault for filesystems with locking constraints
Dave Chinner [Wed, 3 Jun 2015 23:18:18 +0000 (09:18 +1000)]
dax: expose __dax_fault for filesystems with locking constraints

Orabug: 22913653

Some filesystems cannot call dax_fault() directly because they have
different locking and/or allocation constraints in the page fault IO
path. To handle this, we need to follow the same model as the
generic block_page_mkwrite code, where the internals are exposed via
__block_page_mkwrite() so that filesystems can wrap the correct
locking and operations around the outside.

This is loosely based on a patch originally from Matthew Willcox.
Unlike the original patch, it does not change ext4 code, error
returns or unwritten extent conversion handling.  It also adds a
__dax_mkwrite() wrapper for .page_mkwrite implementations to do the
right thing, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit ce5c5d554dc47a4fb4360c84b72231fea081e7a0)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodax: don't abuse get_block mapping for endio callbacks
Dave Chinner [Wed, 3 Jun 2015 23:18:18 +0000 (09:18 +1000)]
dax: don't abuse get_block mapping for endio callbacks

Orabug: 22913653

dax_fault() currently relies on the get_block callback to attach an
io completion callback to the mapping buffer head so that it can
run unwritten extent conversion after zeroing allocated blocks.

Instead of this hack, pass the conversion callback directly into
dax_fault() similar to the get_block callback. When the filesystem
allocates unwritten extents, it will set the buffer_unwritten()
flag, and hence the dax_fault code can call the completion function
in the contexts where it is necessary without overloading the
mapping buffer head.

Note: The changes to ext4 to use this interface are suspect at best.
In fact, the way ext4 did this end_io assignment in the first place
looks suspect because it only set a completion callback when there
wasn't already some other write() call taking place on the same
inode. The ext4 end_io code looks rather intricate and fragile with
all it's reference counting and passing to different contexts for
modification via inode private pointers that aren't protected by
locks...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
(cherry picked from commit e842f2903908934187af7232fb5b21da527d1757)

Conflict:

fs/ext4/inode.c

8 years agoxfs: mmap lock needs to be inside freeze protection
Dave Chinner [Wed, 3 Jun 2015 23:18:18 +0000 (09:18 +1000)]
xfs: mmap lock needs to be inside freeze protection

Orabug: 22913653

Lock ordering for the new mmap lock needs to be:

mmap_sem
  sb_start_pagefault
    i_mmap_lock
      page lock
        <fault processsing>

Right now xfs_vm_page_mkwrite gets this the wrong way around,
While technically it cannot deadlock due to the current freeze
ordering, it's still a landmine that might explode if we change
anything in future. Hence we need to nest the locks correctly.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
(cherry picked from commit ec56b1f1fdc69599963574ce94cc5693d535dd64)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoarch, x86: pmem api for ensuring durability of persistent memory updates
Ross Zwisler [Thu, 25 Jun 2015 07:08:39 +0000 (03:08 -0400)]
arch, x86: pmem api for ensuring durability of persistent memory updates

Orabug: 22913653

Based on an original patch by Ross Zwisler [1].

Writes to persistent memory have the potential to be posted to cpu
cache, cpu write buffers, and platform write buffers (memory controller)
before being committed to persistent media.  Provide apis,
memcpy_to_pmem(), wmb_pmem(), and memremap_pmem(), to write data to
pmem and assert that it is durable in PMEM (a persistent linear address
range).  A '__pmem' attribute is added so sparse can track proper usage
of pointers to pmem.

This continues the status quo of pmem being x86 only for 4.2, but
reworks to ioremap, and wider implementation of memremap() will enable
other archs in 4.3.

[1]: https://lists.01.org/pipermail/linux-nvdimm/2015-May/000932.html

Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
[djbw: various reworks]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 61031952f4c89dba1065f7a5b9419badb112554c)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: Add sysfs numa_node to NVDIMM devices
Toshi Kani [Fri, 19 Jun 2015 18:18:34 +0000 (12:18 -0600)]
libnvdimm: Add sysfs numa_node to NVDIMM devices

Orabug: 22913653

Add support of sysfs 'numa_node' to I/O-related NVDIMM devices
under /sys/bus/nd/devices, regionN, namespaceN.0, and bttN.x.

An example of numa_node values on a 2-socket system with a single
NVDIMM range on each socket is shown below.
  /sys/bus/nd/devices
  |-- btt0.0/numa_node:0
  |-- btt1.0/numa_node:1
  |-- btt1.1/numa_node:1
  |-- namespace0.0/numa_node:0
  |-- namespace1.0/numa_node:1
  |-- region0/numa_node:0
  |-- region1/numa_node:1

These numa_node files are then linked under the block class of
their device names.
  /sys/class/block/pmem0/device/numa_node:0
  /sys/class/block/pmem1s/device/numa_node:1

This enables numactl(8) to accept 'block:' and 'file:' paths of
pmem and btt devices as shown in the examples below.
  numactl --preferred block:pmem0 --show
  numactl --preferred file:/dev/pmem1s --show

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 74ae66c3b14ffa94c8d2dea201cdf8e6203d13d5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: Set numa_node to NVDIMM devices
Toshi Kani [Fri, 19 Jun 2015 18:18:33 +0000 (12:18 -0600)]
libnvdimm: Set numa_node to NVDIMM devices

Orabug: 22913653

ACPI NFIT table has System Physical Address Range Structure entries that
describe a proximity ID of each range when ACPI_NFIT_PROXIMITY_VALID is
set in the flags.

Change acpi_nfit_register_region() to map a proximity ID to its node ID,
and set it to a new numa_node field of nd_region_desc, which is then
conveyed to the nd_region device.

The device core arranges for btt and namespace devices to inherit their
node from their parent region.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
[djbw: move set_dev_node() from region.c to bus.c]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 41d7a6d637e1440f5410cb43c25a3c41255540c5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoacpi: Add acpi_map_pxm_to_online_node()
Toshi Kani [Fri, 19 Jun 2015 23:14:15 +0000 (17:14 -0600)]
acpi: Add acpi_map_pxm_to_online_node()

Orabug: 22913653

The kernel initializes CPU & memory's NUMA topology from ACPI
SRAT table.  Some other ACPI tables, such as NFIT and DMAR, also
contain proximity IDs for their device's NUMA topology.  This
information can be used to improve performance of these devices.

This patch introduces acpi_map_pxm_to_online_node(), which is
similar to acpi_map_pxm_to_node(), but always returns an online
node.  When the mapped node from a given proximity ID is offline,
it looks up the node distance table and returns the nearest
online node.

ACPI device drivers, which are called after the NUMA initialization
has completed in the kernel, can call this interface to obtain their
device NUMA topology from ACPI tables.  Such drivers do not have to
deal with offline nodes.  A node may be offline when a device
proximity ID is unique, SRAT memory entry does not exist, or NUMA is
disabled, ex. "numa=off" on x86.

This patch also moves the pxm range check from acpi_get_node() to
acpi_map_pxm_to_node().

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 99759869faf15471cfce251bc138848d8af7d162)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit: handle unarmed dimms, mark namespaces read-only
Dan Williams [Wed, 24 Jun 2015 00:08:34 +0000 (20:08 -0400)]
libnvdimm, nfit: handle unarmed dimms, mark namespaces read-only

Orabug: 22913653

Upon detection of an unarmed dimm in a region, arrange for descendant
BTT, PMEM, or BLK instances to be read-only.  A dimm is primarily marked
"unarmed" via flags passed by platform firmware (NFIT).

The flags in the NFIT memory device sub-structure indicate the state of
the data on the nvdimm relative to its energy source or last "flush to
persistence".  For the most part there is nothing the driver can do but
advertise the state of these flags in sysfs and emit a message if
firmware indicates that the contents of the device may be corrupted.
However, for the case of ACPI_NFIT_MEM_ARMED, the driver can arrange for
the block devices incorporating that nvdimm to be marked read-only.
This is a safe default as the data is still available and new writes are
held off until the administrator either forces read-write mode, or the
energy source becomes armed.

A 'read_only' attribute is added to REGION devices to allow for
overriding the default read-only policy of all descendant block devices.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 581388209405902b56d055f644b4dd124a206112)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agopmem: flag pmem block devices as non-rotational
Dan Williams [Sat, 16 May 2015 16:28:54 +0000 (12:28 -0400)]
pmem: flag pmem block devices as non-rotational

Orabug: 22913653

...since they are effectively SSDs as far as userspace is concerned.

Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 0f51c4fa7f60838a87cd45e8ba144dddcd4c066c)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: enable iostat
Dan Williams [Sat, 16 May 2015 16:28:53 +0000 (12:28 -0400)]
libnvdimm: enable iostat

Orabug: 22913653

This is disabled by default as the overhead is prohibitive, but if the
user takes the action to turn it on we'll oblige.

Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f0dc089ce217e7b98e0d2077c548ff08129e7911)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agopmem: make_request cleanups
Dan Williams [Sat, 16 May 2015 16:28:51 +0000 (12:28 -0400)]
pmem: make_request cleanups

Orabug: 22913653

Various cleanups:

1/ Kill the BUG_ON since we've already told the block layer we don't
   support DISCARD on all these drivers.

2/ Kill the 'rw' variable, no need to cache it.

3/ Kill the local 'sector' variable.  bio_for_each_segment() is already
   advancing the iterator's sector number by the bio_vec length.

4/ Kill the check for accessing past the end of device
   generic_make_request_checks() already does that.

Suggested-by: Christoph Hellwig <hch@lst.de>
[hch: kill access past end of the device check]
Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit edc870e54696beb9f3835ecb41a4e1c84ee4584d)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, pmem: fix up max_hw_sectors
Dan Williams [Sat, 16 May 2015 16:28:50 +0000 (12:28 -0400)]
libnvdimm, pmem: fix up max_hw_sectors

Orabug: 22913653

There is no hardware limit to enforce on the size of the i/o that can be passed
to an nvdimm block device, so set it to UINT_MAX.

Reviewed-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 43d3fa3a0491168ad769d20d5cbae45492509d43)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, blk: add support for blk integrity
Vishal Verma [Thu, 25 Jun 2015 08:22:39 +0000 (04:22 -0400)]
libnvdimm, blk: add support for blk integrity

Orabug: 22913653

Support multiple block sizes (sector + metadata) for nd_blk in the
same way as done for the BTT. Add the idea of an 'internal' lbasize,
which is properly aligned and padded, and store metadata in this space.

Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit fcae695737fca0849c18db814d9d8de05c0fd2a2)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, btt: add support for blk integrity
Vishal Verma [Thu, 25 Jun 2015 08:21:52 +0000 (04:21 -0400)]
libnvdimm, btt: add support for blk integrity

Orabug: 22913653

Support multiple block sizes (sector + metadata) using the blk integrity
framework. This registers a new integrity template that defines the
protection information tuple size based on the configured metadata size,
and simply acts as a passthrough for protection information generated by
another layer. The metadata is written to the storage as-is, and read back
with each sector.

Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 41cd8b70c37ace40077c8d6ec0b74b983178c192)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agofs/block_dev.c: skip rw_page if bdev has integrity
Vishal Verma [Tue, 12 May 2015 17:48:53 +0000 (13:48 -0400)]
fs/block_dev.c: skip rw_page if bdev has integrity

Orabug: 22913653

If a block device has bio integrity enabled, rw_page will bypass the
integrity payload, which is undesirable. Skip rw_page if this is the
case.

Currently brd and zram provide rw_page, and the proposed 'nd' drivers
will too.

Cc: Jens Axboe <axboe@fb.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Suggested-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f68eb1e71a92765ffd8eb68466a41b48f2fbba04)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: Non-Volatile Devices
Dan Williams [Thu, 25 Jun 2015 08:48:19 +0000 (04:48 -0400)]
libnvdimm: Non-Volatile Devices

Orabug: 22913653

Maintainer information and documentation for drivers/nvdimm

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Greg KH <gregkh@linuxfoundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit bc30196f715ed3a94d050ef8bc465e567a6050be)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agotools/testing/nvdimm: libnvdimm unit test infrastructure
Dan Williams [Wed, 17 Jun 2015 21:23:32 +0000 (17:23 -0400)]
tools/testing/nvdimm: libnvdimm unit test infrastructure

Orabug: 22913653

'libnvdimm' is the first driver sub-system in the kernel to implement
mocking for unit test coverage.  The nfit_test module gets built as an
external module and arranges for external module replacements of nfit,
libnvdimm, nd_pmem, and nd_blk.  These replacements use the linker
--wrap option to redirect calls to ioremap() + request_mem_region() to
custom defined unit test resources.  The end result is a fully
functional nvdimm_bus, as far as userspace is concerned, but with the
capability to perform otherwise destructive tests on emulated resources.

Q: Why not use QEMU for this emulation?
QEMU is not suitable for unit testing.  QEMU's role is to faithfully
emulate the platform.  A unit test's role is to unfaithfully implement
the platform with the goal of triggering bugs in the corners of the
sub-system implementation.  As bugs are discovered in platforms, or the
sub-system itself, the unit tests are extended to backstop a fix with a
reproducer unit test.

Another problem with QEMU is that it would require coordination of 3
software projects instead of 2 (kernel + libndctl [1]) to maintain and
execute the tests.  The chances for bit rot and the difficulty of
getting the tests running goes up non-linearly the more components
involved.

Q: Why submit this to the kernel tree instead of external modules in
   libndctl?
Simple, to alleviate the same risk that out-of-tree external modules
face.  Updates to drivers/nvdimm/ can be immediately evaluated to see if
they have any impact on tools/testing/nvdimm/.

Q: What are the negative implications of merging this?
It is a unique maintenance burden because the purpose of mocking an
interface to enable a unit test is to purposefully short circuit the
semantics of a routine to enable testing.  For example
__wrap_ioremap_cache() fakes the pmem driver into "ioremap()'ing" a test
resource buffer allocated by dma_alloc_coherent().  The future
maintenance burden hits when someone changes the semantics of
ioremap_cache() and wonders what the implications are for the unit test.

[1]: https://github.com/pmem/ndctl

Cc: <linux-acpi@vger.kernel.org>
Cc: Lv Zheng <lv.zheng@intel.com>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 6bc756193ff61bf5e7b3cfedfbb0873bf40f8055)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory
Ross Zwisler [Thu, 25 Jun 2015 08:21:02 +0000 (04:21 -0400)]
libnvdimm, nfit, nd_blk: driver for BLK-mode access persistent memory

Orabug: 22913653

The libnvdimm implementation handles allocating dimm address space (DPA)
between PMEM and BLK mode interfaces.  After DPA has been allocated from
a BLK-region to a BLK-namespace the nd_blk driver attaches to handle I/O
as a struct bio based block device. Unlike PMEM, BLK is required to
handle platform specific details like mmio register formats and memory
controller interleave.  For this reason the libnvdimm generic nd_blk
driver calls back into the bus provider to carry out the I/O.

This initial implementation handles the BLK interface defined by the
ACPI 6 NFIT [1] and the NVDIMM DSM Interface Example [2] composed from
DCR (dimm control region), BDW (block data window), IDT (interleave
descriptor) NFIT structures and the hardware register format.
[1]: http://www.uefi.org/sites/default/files/resources/ACPI_6.0.pdf
[2]: http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 047fc8a1f9a6330eacc80374dff087e20dc2304b)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agond_btt: atomic sector updates
Vishal Verma [Thu, 25 Jun 2015 08:20:32 +0000 (04:20 -0400)]
nd_btt: atomic sector updates

Orabug: 22913653

BTT stands for Block Translation Table, and is a way to provide power
fail sector atomicity semantics for block devices that have the ability
to perform byte granularity IO. It relies on the capability of libnvdimm
namespace devices to do byte aligned IO.

The BTT works as a stacked blocked device, and reserves a chunk of space
from the backing device for its accounting metadata. It is a bio-based
driver because all IO is done synchronously, and there is no queuing or
asynchronous completions at either the device or the driver level.

The BTT uses 'lanes' to index into various 'on-disk' data structures,
and lanes also act as a synchronization mechanism in case there are more
CPUs than available lanes. We did a comparison between two lane lock
strategies - first where we kept an atomic counter around that tracked
which was the last lane that was used, and 'our' lane was determined by
atomically incrementing that. That way, for the nr_cpus > nr_lanes case,
theoretically, no CPU would be blocked waiting for a lane. The other
strategy was to use the cpu number we're scheduled on to and hash it to
a lane number. Theoretically, this could block an IO that could've
otherwise run using a different, free lane. But some fio workloads
showed that the direct cpu -> lane hash performed faster than tracking
'last lane' - my reasoning is the cache thrash caused by moving the
atomic variable made that approach slower than simply waiting out the
in-progress IO. This supports the conclusion that the driver can be a
very simple bio-based one that does synchronous IOs instead of queuing.

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
[jmoyer: fix nmi watchdog timeout in btt_map_init]
[jmoyer: move btt initialization to module load path]
[jmoyer: fix memory leak in the btt initialization path]
[jmoyer: Don't overwrite corrupted arenas]
Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 5212e11fde4d40fa627668b4f2222d20db488f71)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: infrastructure for btt devices
Dan Williams [Thu, 25 Jun 2015 08:20:04 +0000 (04:20 -0400)]
libnvdimm: infrastructure for btt devices

Orabug: 22913653

NVDIMM namespaces, in addition to accepting "struct bio" based requests,
also have the capability to perform byte-aligned accesses.  By default
only the bio/block interface is used.  However, if another driver can
make effective use of the byte-aligned capability it can claim namespace
interface and use the byte-aligned ->rw_bytes() interface.

The BTT driver is the initial first consumer of this mechanism to allow
adding atomic sector update semantics to a pmem or blk namespace.  This
patch is the sysfs infrastructure to allow configuring a BTT instance
for a namespace.  Enabling that BTT and performing i/o is in a
subsequent patch.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 8c2f7e8658df1d3b7cbfa62706941d14c715823a)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: write blk label set
Dan Williams [Sat, 30 May 2015 16:35:36 +0000 (12:35 -0400)]
libnvdimm: write blk label set

Orabug: 22913653

After 'uuid', 'size', 'sector_size', and optionally 'alt_name' have been
set to valid values the labels on the dimm can be updated.  The
difference with the pmem case is that blk namespaces are limited to one
dimm and can cover discontiguous ranges in dpa space.

Also, after allocating label slots, it is useful for userspace to know
how many slots are left.  Export this information in sysfs.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 0ba1c634892b3590779803a701bcb82e8c32cc7a)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: write pmem label set
Dan Williams [Sat, 30 May 2015 16:36:02 +0000 (12:36 -0400)]
libnvdimm: write pmem label set

Orabug: 22913653

After 'uuid', 'size', and optionally 'alt_name' have been set to valid
values the labels on the dimms can be updated.

Write procedure is:
1/ Allocate and write new labels in the "next" index
2/ Free the old labels in the working copy
3/ Write the bitmap and the label space on the dimm
4/ Write the index to make the update valid

Label ranges directly mirror the dpa resource values for the given
label_id of the namespace.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit f524bf271a5cf12a44253194abcf8b6688ff5b9d)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: blk labels and namespace instantiation
Dan Williams [Fri, 1 May 2015 17:34:01 +0000 (13:34 -0400)]
libnvdimm: blk labels and namespace instantiation

Orabug: 22913653

A blk label set describes a namespace comprised of one or more
discontiguous dpa ranges on a single dimm.  They may alias with one or
more pmem interleave sets that include the given dimm.

This is the runtime/volatile configuration infrastructure for sysfs
manipulation of 'alt_name', 'uuid', 'size', and 'sector_size'.  A later
patch will make these settings persistent by writing back the label(s).

Unlike pmem namespaces, multiple blk namespaces can be created per
region.  Once a blk namespace has been created a new seed device
(unconfigured child of a parent blk region) is instantiated.  As long as
a region has 'available_size' != 0 new child namespaces may be created.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 1b40e09a1232de537b193fa1b6b3ef16d3a1e397)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: pmem label sets and namespace instantiation.
Dan Williams [Wed, 17 Jun 2015 21:14:46 +0000 (17:14 -0400)]
libnvdimm: pmem label sets and namespace instantiation.

Orabug: 22913653

A complete label set is a PMEM-label per-dimm per-interleave-set where
all the UUIDs match and the interleave set cookie matches the hosting
interleave set.

Present sysfs attributes for manipulation of a PMEM-namespace's
'alt_name', 'uuid', and 'size' attributes.  A later patch will make
these settings persistent by writing back the label.

Note that PMEM allocations grow forwards from the start of an interleave
set (lowest dimm-physical-address (DPA)).  BLK-namespaces that alias
with a PMEM interleave set will grow allocations backward from the
highest DPA.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit bf9bccc14c05dae8caba29df6187c731710f5380)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: namespace indices: read and validate
Dan Williams [Tue, 9 Jun 2015 20:09:36 +0000 (16:09 -0400)]
libnvdimm: namespace indices: read and validate

Orabug: 22913653

This on media label format [1] consists of two index blocks followed by
an array of labels.  None of these structures are ever updated in place.
A sequence number tracks the current active index and the next one to
write, while labels are written to free slots.

    +------------+
    |            |
    |  nsindex0  |
    |            |
    +------------+
    |            |
    |  nsindex1  |
    |            |
    +------------+
    |   label0   |
    +------------+
    |   label1   |
    +------------+
    |            |
     ....nslot...
    |            |
    +------------+
    |   labelN   |
    +------------+

After reading valid labels, store the dpa ranges they claim into
per-dimm resource trees.

[1]: http://pmem.io/documents/NVDIMM_Namespace_Spec.pdf

Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 4a826c83db4edc040da3a66dbefd53f0cfcf457d)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit: add interleave-set state-tracking infrastructure
Dan Williams [Fri, 1 May 2015 17:11:27 +0000 (13:11 -0400)]
libnvdimm, nfit: add interleave-set state-tracking infrastructure

Orabug: 22913653

On platforms that have firmware support for reading/writing per-dimm
label space, a portion of the dimm may be accessible via an interleave
set PMEM mapping in addition to the dimm's BLK (block-data-window
aperture(s)) interface.  A label, stored in a "configuration data
region" on the dimm, disambiguates which dimm addresses are accessed
through which exclusive interface.

Add infrastructure that allows the kernel to block modifications to a
label in the set while any member dimm is active.  Note that this is
meant only for enforcing "no modifications of active labels" via the
coarse ioctl command.  Adding/deleting namespaces from an active
interleave set is always possible via sysfs.

Another aspect of tracking interleave sets is tracking their integrity
when DIMMs in a set are physically re-ordered.  For this purpose we
generate an "interleave-set cookie" that can be recorded in a label and
validated against the current configuration.  It is the bus provider
implementation's responsibility to calculate the interleave set cookie
and attach it to a given region.

Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit eaf961536e1622ad21247ac8d44acd48ba65566e)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, pmem: add libnvdimm support to the pmem driver
Dan Williams [Tue, 9 Jun 2015 19:33:45 +0000 (15:33 -0400)]
libnvdimm, pmem: add libnvdimm support to the pmem driver

Orabug: 22913653

nd_pmem attaches to persistent memory regions and namespaces emitted by
the libnvdimm subsystem, and, same as the original pmem driver, presents
the system-physical-address range as a block device.

The existing e820-type-12 to pmem setup is converted to an nvdimm_bus
that emits an nd_namespace_io device.

Note that the X in 'pmemX' is now derived from the parent region.  This
provides some stability to the pmem devices names from boot-to-boot.
The minor numbers are also more predictable by passing 0 to
alloc_disk().

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 9f53f9fa4ad1d8bddd4d14359cdabc531aedffe8)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, pmem: move pmem to drivers/nvdimm/
Dan Williams [Tue, 9 Jun 2015 18:13:37 +0000 (14:13 -0400)]
libnvdimm, pmem: move pmem to drivers/nvdimm/

Orabug: 22913653

Prepare the pmem driver to consume PMEM namespaces emitted by regions of
an nvdimm_bus instance.  No functional change.

Acked-by: Christoph Hellwig <hch@lst.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: support for legacy (non-aliasing) nvdimms
Dan Williams [Sun, 31 May 2015 19:02:11 +0000 (15:02 -0400)]
libnvdimm: support for legacy (non-aliasing) nvdimms

Orabug: 22913653

The libnvdimm region driver is an intermediary driver that translates
non-volatile "region"s into "namespace" sub-devices that are surfaced by
persistent memory block-device drivers (PMEM and BLK).

ACPI 6 introduces the concept that a given nvdimm may simultaneously
offer multiple access modes to its media through direct PMEM load/store
access, or windowed BLK mode.  Existing nvdimms mostly implement a PMEM
interface, some offer a BLK-like mode, but never both as ACPI 6 defines.
If an nvdimm is single interfaced, then there is no need for dimm
metadata labels.  For these devices we can take the region boundaries
directly to create a child namespace device (nd_namespace_io).

Acked-by: Christoph Hellwig <hch@lst.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 3d88002e4a7bd40f355550284c6cd140e6fe29dc)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
Dan Williams [Wed, 10 Jun 2015 00:13:14 +0000 (20:13 -0400)]
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)

Orabug: 22913653

A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing.  Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.

The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time.  This id is not reliable
across reboots nor in the presence of hotplug.  Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name.  However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.

"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
  system physical address range in the case of PMEM.

- mappingN: a tuple describing a dimm's contribution to the region's
  capacity in the format (<nmemX>,<dpa>,<size>).  For a PMEM-region
  there will be at least one mapping per dimm in the interleave set.  For
  a BLK-region there is only "mapping0" listing the starting DPA of the
  BLK-region and the available DPA capacity of that space (matches "size"
  above).

The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups.  That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system.  If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".

Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 1f7df6f88b9245a7f2d0f8ecbc97dc88c8d0d8e1)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nvdimm: dimm driver and base libnvdimm device-driver infrastructure
Dan Williams [Sun, 31 May 2015 18:41:48 +0000 (14:41 -0400)]
libnvdimm, nvdimm: dimm driver and base libnvdimm device-driver infrastructure

Orabug: 22913653

* Implement the device-model infrastructure for loading modules and
  attaching drivers to nvdimm devices.  This is a simple association of a
  nd-device-type number with a driver that has a bitmask of supported
  device types.  To facilitate userspace bind/unbind operations 'modalias'
  and 'devtype', that also appear in the uevent, are added as generic
  sysfs attributes for all nvdimm devices.  The reason for the device-type
  number is to support sub-types within a given parent devtype, be it a
  vendor-specific sub-type or otherwise.

* The first consumer of this infrastructure is the driver
  for dimm devices.  It simply uses control messages to retrieve and
  store the configuration-data image (label set) from each dimm.

Note: nd_device_register() arranges for asynchronous registration of
      nvdimm bus devices by default.

Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Neil Brown <neilb@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 4d88a97aa9e8cfa6460aab119c5da60ad2267423)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: control (ioctl) messages for nvdimm_bus and nvdimm devices
Dan Williams [Mon, 8 Jun 2015 18:27:06 +0000 (14:27 -0400)]
libnvdimm: control (ioctl) messages for nvdimm_bus and nvdimm devices

Orabug: 22913653

Most discovery/configuration of the nvdimm-subsystem is done via sysfs
attributes.  However, some nvdimm_bus instances, particularly the
ACPI.NFIT bus, define a small set of messages that can be passed to the
platform.  For convenience we derive the initial libnvdimm-ioctl command
formats directly from the NFIT DSM Interface Example formats.

    ND_CMD_SMART: media health and diagnostics
    ND_CMD_GET_CONFIG_SIZE: size of the label space
    ND_CMD_GET_CONFIG_DATA: read label space
    ND_CMD_SET_CONFIG_DATA: write label space
    ND_CMD_VENDOR: vendor-specific command passthrough
    ND_CMD_ARS_CAP: report address-range-scrubbing capabilities
    ND_CMD_ARS_START: initiate scrubbing
    ND_CMD_ARS_STATUS: report on scrubbing state
    ND_CMD_SMART_THRESHOLD: configure alarm thresholds for smart events

If a platform later defines different commands than this set it is
straightforward to extend support to those formats.

Most of the commands target a specific dimm.  However, the
address-range-scrubbing commands target the bus.  The 'commands'
attribute in sysfs of an nvdimm_bus, or nvdimm, enumerate the supported
commands for that object.

Cc: <linux-acpi@vger.kernel.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reported-by: Nicholas Moulin <nicholas.w.moulin@linux.intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 62232e45f4a265abb43f0acf16e58f5d0b6e1ec9)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit: dimm/memory-devices
Dan Williams [Sat, 25 Apr 2015 07:56:17 +0000 (03:56 -0400)]
libnvdimm, nfit: dimm/memory-devices

Orabug: 22913653

Enable nvdimm devices to be registered on a nvdimm_bus.  The kernel
assigned device id for nvdimm devicesis dynamic.  If userspace needs a
more static identifier it should consult a provider-specific attribute.
In the case where NFIT is the provider, the 'nmemX/nfit/handle' or
'nmemX/nfit/serial' attributes may be used for this purpose.

Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit e6dfb2de47768efe8cc37c9a1863d2aff81440fb)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm: control character device and nvdimm_bus sysfs attributes
Dan Williams [Sun, 26 Apr 2015 23:26:48 +0000 (19:26 -0400)]
libnvdimm: control character device and nvdimm_bus sysfs attributes

Orabug: 22913653

The control device for a nvdimm_bus is registered as an "nd" class
device.  The expectation is that there will usually only be one "nd" bus
registered under /sys/class/nd.  However, we allow for the possibility
of multiple buses and they will listed in discovery order as
ndctl0...ndctlN.  This character device hosts the ioctl for passing
control messages.  The initial command set has a 1:1 correlation with
the commands listed in the by the "NFIT DSM Example" document [1], but
this scheme is extensible to future command sets.

Note, nd_ioctl() and the backing ->ndctl() implementation are defined in
a subsequent patch.  This is simply the initial registrations and sysfs
attributes.

[1]: http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf

Cc: Neil Brown <neilb@suse.de>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: <linux-acpi@vger.kernel.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 45def22c1fab85764646746ce38d45b2f3281fa5)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agolibnvdimm, nfit: initial libnvdimm infrastructure and NFIT support
Dan Williams [Wed, 20 May 2015 02:54:31 +0000 (22:54 -0400)]
libnvdimm, nfit: initial libnvdimm infrastructure and NFIT support

Orabug: 22913653

A struct nvdimm_bus is the anchor device for registering nvdimm
resources and interfaces, for example, a character control device,
nvdimm devices, and I/O region devices.  The ACPI NFIT (NVDIMM Firmware
Interface Table) is one possible platform description for such
non-volatile memory resources in a system.  The nfit.ko driver attaches
to the "ACPI0012" device that indicates the presence of the NFIT and
parses the table to register a struct nvdimm_bus instance.

Cc: <linux-acpi@vger.kernel.org>
Cc: Lv Zheng <lv.zheng@intel.com>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit b94d5230d06eb930be82e67fb1a9a58271e78297)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoe820, efi: add ACPI 6.0 persistent memory types
Dan Williams [Fri, 3 Apr 2015 16:05:28 +0000 (12:05 -0400)]
e820, efi: add ACPI 6.0 persistent memory types

Orabug: 22913653

ACPI 6.0 formalizes e820-type-7 and efi-type-14 as persistent memory.
Mark it "reserved" and allow it to be claimed by a persistent memory
device driver.

This definition is in addition to the Linux kernel's existing type-12
definition that was recently added in support of shipping platforms with
NVDIMM support that predate ACPI 6.0 (which now classifies type-12 as
OEM reserved).

Note, /proc/iomem can be consulted for differentiating legacy
"Persistent Memory (legacy)" E820_PRAM vs standard "Persistent Memory"
E820_PMEM.

Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matthew Wilcox <willy@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Tested-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit ad5fb870c486d932a1749d7853dd70f436a7e03f)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoACPICA: Fix for ill-formed GUID strings for NFIT tables.
Bob Moore [Mon, 25 May 2015 00:15:35 +0000 (08:15 +0800)]
ACPICA: Fix for ill-formed GUID strings for NFIT tables.

Orabug: 22913653

ACPICA commit 60052949ba2aa7377106870da69b237193d10dc1

Error in transcription from the ACPI spec.

Link: https://github.com/acpica/acpica/commit/60052949
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit f3b6ced236259a87829b829e8e542ff53bfb9a4f)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoACPICA: acpihelp: Update for new NFIT table GUIDs.
Bob Moore [Mon, 25 May 2015 00:15:27 +0000 (08:15 +0800)]
ACPICA: acpihelp: Update for new NFIT table GUIDs.

Orabug: 22913653

ACPICA commit 83727bed8f715685a63a9f668e73c60496a06054

Add original UUIDs/GUIDs to the acuuid.h file.
Cleanup acpihelp output for UUIDs/GUIDs.

Link: https://github.com/acpica/acpica/commit/83727bed
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 6c0d14680e247849cdb870c995a332781bdb93f2)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoACPICA: ACPI 6.0: Add support for NFIT table.
Bob Moore [Thu, 21 May 2015 02:31:58 +0000 (10:31 +0800)]
ACPICA: ACPI 6.0: Add support for NFIT table.

Orabug: 22913653

ACPICA commit e4e17ca361373e9b81494bb4ca697a12cef3cba6

NVDIMM Firmware Interface Table.

Link: https://github.com/acpica/acpica/commit/e4e17ca3
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 04f8e38497b02cd5596ff9af278e62cd057fff68)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agodrivers/block/pmem: Map NVDIMM in Write-Through mode
Toshi Kani [Thu, 4 Jun 2015 16:55:21 +0000 (18:55 +0200)]
drivers/block/pmem: Map NVDIMM in Write-Through mode

Orabug: 22913653

The pmem driver maps NVDIMM uncacheable so that we don't lose
data which hasn't reached non-volatile storage in the case of a
crash. Change this to Write-Through mode which provides uncached
writes but cached reads, thus improving read performance.

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Elliott@hp.com
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: arnd@arndb.de
Cc: hch@lst.de
Cc: hmh@hmh.eng.br
Cc: jgross@suse.com
Cc: konrad.wilk@oracle.com
Cc: linux-mm <linux-mm@kvack.org>
Cc: linux-nvdimm@lists.01.org
Cc: stefan.bader@canonical.com
Cc: yigal@plexistor.com
Link: http://lkml.kernel.org/r/1433436928-31903-14-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit 957561ec0fa8a701f60ca6a0f40cc46f5c554920)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agox86/mm, asm-generic: Add ioremap_wt() for creating Write-Through mappings
Toshi Kani [Thu, 4 Jun 2015 16:55:15 +0000 (18:55 +0200)]
x86/mm, asm-generic: Add ioremap_wt() for creating Write-Through mappings

Orabug: 22913653

Add ioremap_wt() for creating Write-Through mappings on x86. It
follows the same model as ioremap_wc() for multi-arch support.
Define ARCH_HAS_IOREMAP_WT in the x86 version of io.h to
indicate that ioremap_wt() is implemented on x86.

Also update the PAT documentation file to cover ioremap_wt().

Signed-off-by: Toshi Kani <toshi.kani@hp.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Elliott@hp.com
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luis R. Rodriguez <mcgrof@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: arnd@arndb.de
Cc: hch@lst.de
Cc: hmh@hmh.eng.br
Cc: jgross@suse.com
Cc: konrad.wilk@oracle.com
Cc: linux-mm <linux-mm@kvack.org>
Cc: linux-nvdimm@lists.01.org
Cc: stefan.bader@canonical.com
Cc: yigal@plexistor.com
Link: http://lkml.kernel.org/r/1433436928-31903-8-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
(cherry picked from commit d838270e2516db11084bed4e294017eb7b646a75)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
8 years agoMerge branch topic/uek-4.1/upstream-cherry-picks of git://ca-git.us.oracle.com/linux...
Chuck Anderson [Wed, 28 Sep 2016 00:34:50 +0000 (17:34 -0700)]
Merge branch topic/uek-4.1/upstream-cherry-picks of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoperf/x86/intel/cqm: Do not access cpu_data() from CPU_UP_PREPARE handler
Matt Fleming [Thu, 6 Aug 2015 12:12:43 +0000 (13:12 +0100)]
perf/x86/intel/cqm: Do not access cpu_data() from CPU_UP_PREPARE handler

Tony reports that booting his 144-cpu machine with maxcpus=10 triggers
the following WARN_ON():

[   21.045727] WARNING: CPU: 8 PID: 647 at arch/x86/kernel/cpu/perf_event_intel_cqm.c:1267 intel_cqm_cpu_prepare+0x75/0x90()
[   21.045744] CPU: 8 PID: 647 Comm: systemd-udevd Not tainted 4.2.0-rc4 #1
[   21.045745] Hardware name: Intel Corporation BRICKLAND/BRICKLAND, BIOS BRHSXSD1.86B.0066.R00.1506021730 06/02/2015
[   21.045747]  0000000000000000 0000000082771b09 ffff880856333ba8 ffffffff81669b67
[   21.045748]  0000000000000000 0000000000000000 ffff880856333be8 ffffffff8107b02a
[   21.045750]  ffff88085b789800 ffff88085f68a020 ffffffff819e2470 000000000000000a
[   21.045750] Call Trace:
[   21.045757]  [<ffffffff81669b67>] dump_stack+0x45/0x57
[   21.045759]  [<ffffffff8107b02a>] warn_slowpath_common+0x8a/0xc0
[   21.045761]  [<ffffffff8107b15a>] warn_slowpath_null+0x1a/0x20
[   21.045762]  [<ffffffff81036725>] intel_cqm_cpu_prepare+0x75/0x90
[   21.045764]  [<ffffffff81036872>] intel_cqm_cpu_notifier+0x42/0x160
[   21.045767]  [<ffffffff8109a33d>] notifier_call_chain+0x4d/0x80
[   21.045769]  [<ffffffff8109a44e>] __raw_notifier_call_chain+0xe/0x10
[   21.045770]  [<ffffffff8107b538>] _cpu_up+0xe8/0x190
[   21.045771]  [<ffffffff8107b65a>] cpu_up+0x7a/0xa0
[   21.045774]  [<ffffffff8165e920>] cpu_subsys_online+0x40/0x90
[   21.045777]  [<ffffffff81433b37>] device_online+0x67/0x90
[   21.045778]  [<ffffffff81433bea>] online_store+0x8a/0xa0
[   21.045782]  [<ffffffff81430e78>] dev_attr_store+0x18/0x30
[   21.045785]  [<ffffffff8126b6ba>] sysfs_kf_write+0x3a/0x50
[   21.045786]  [<ffffffff8126ad40>] kernfs_fop_write+0x120/0x170
[   21.045789]  [<ffffffff811f0b77>] __vfs_write+0x37/0x100
[   21.045791]  [<ffffffff811f38b8>] ? __sb_start_write+0x58/0x110
[   21.045795]  [<ffffffff81296d2d>] ? security_file_permission+0x3d/0xc0
[   21.045796]  [<ffffffff811f1279>] vfs_write+0xa9/0x190
[   21.045797]  [<ffffffff811f2075>] SyS_write+0x55/0xc0
[   21.045800]  [<ffffffff81067300>] ? do_page_fault+0x30/0x80
[   21.045804]  [<ffffffff816709ae>] entry_SYSCALL_64_fastpath+0x12/0x71
[   21.045805] ---[ end trace fe228b836d8af405 ]---

The root cause is that CPU_UP_PREPARE is completely the wrong notifier
action from which to access cpu_data(), because smp_store_cpu_info()
won't have been executed by the target CPU at that point, which in turn
means that ->x86_cache_max_rmid and ->x86_cache_occ_scale haven't been
filled out.

Instead let's invoke our handler from CPU_STARTING and rename it
appropriately.

Reported-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: Kanaka Juvva <kanaka.d.juvva@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vikas Shivappa <vikas.shivappa@intel.com>
Link: http://lkml.kernel.org/r/1438863163-14083-1-git-send-email-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Orabug: 24745516
(cherry picked from commit d7a702f0b1033cf402fef65bd6395072738f0844)
Acked-by: Chuck Anderson <chuck.anderson@oracle.com>
8 years agoMerge branch topic/uek-4.1/kernel-generic of git://ca-git.us.oracle.com/linux-uek...
Chuck Anderson [Wed, 28 Sep 2016 00:02:09 +0000 (17:02 -0700)]
Merge branch topic/uek-4.1/kernel-generic of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoMerge branch 'topic/uek-4.1/drivers' of git://ca-git.us.oracle.com/linux-uek into...
Chuck Anderson [Wed, 28 Sep 2016 00:01:31 +0000 (17:01 -0700)]
Merge branch 'topic/uek-4.1/drivers' of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoAllow mce to reset instead of panic on UE
Ashok Vairavan [Tue, 27 Sep 2016 02:50:51 +0000 (19:50 -0700)]
Allow mce to reset instead of panic on UE

The intent of this patch is to ensure that the mce stack is not
put in the panic stack trace when the kernel reboots due to the
Uncorrectable Error. The mce stack in the panic trace confuses
the administrator and falsely implicates mce module as a culprit.
Hence a synchronization flag is added to machine restart the system
when it experience uncorrectable error.

Orabug: 24745271

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Dan Duval <dan.duval@oracle.com>
8 years agomptsas: add TUR with retries to ensure LUNs complete initialization
Dan Duval [Fri, 2 Sep 2016 16:56:30 +0000 (12:56 -0400)]
mptsas: add TUR with retries to ensure LUNs complete initialization

Orabug: 24745062

Earlier versions of the mptsas driver included a mechanism for
executing, and if necessary retrying, SCSI TEST UNIT READY commands
to ensure that devices complete their initialization during device
discovery.  This functionality, present in UEK2, was never sent
upstream, and was lost when UEK4 was initiated.

We have been seeing flash devices returning errors, or simply
disappearing, during alter cell validate configuration operations
on Exadata systems.  Giving the flash disks time to initialize
after (re-) discovery appears to resolve this issue.

This commit simply restores the missing functionality.

Signed-off-by: Dan Duval <dan.duval@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
8 years agoMerge branch topic/uek-4.1/sparc of git://ca-git.us.oracle.com/linux-uek into uek...
Chuck Anderson [Fri, 23 Sep 2016 00:52:50 +0000 (17:52 -0700)]
Merge branch topic/uek-4.1/sparc of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoMerge branch 'topic/uek-4.1/drivers' of git://ca-git.us.oracle.com/linux-uek into...
Chuck Anderson [Tue, 20 Sep 2016 23:06:28 +0000 (16:06 -0700)]
Merge branch 'topic/uek-4.1/drivers' of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agonvme: refactor nvme_queue_rq
Christoph Hellwig [Fri, 16 Oct 2015 05:58:38 +0000 (07:58 +0200)]
nvme: refactor nvme_queue_rq

This "backports" the structure I've used for the fabrics driver.  It
mostly started out as a cleanup so that I could actually understand
the code, but I think it also qualifies as a micro-optimization due
to the reduced time we hold q_lock and disable interrupts.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Orabug: 24691685
mainline commit ba1ca37ea4e320c108c356eb8c91ac652afc57dd
Conflicts:
    Adding GFP_ATOMIC to nvme_setup_prps and replacing
REQ_TYPE_DRV_PRIV with REQ_TYPE_SPECIAL

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agoMerge branch topic/uek-4.1/rpm-build of git://ca-git.us.oracle.com/linux-uek into...
Chuck Anderson [Tue, 20 Sep 2016 05:16:55 +0000 (22:16 -0700)]
Merge branch topic/uek-4.1/rpm-build of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoMerge branch topic/uek-4.1/kernel-generic of git://ca-git.us.oracle.com/linux-uek...
Chuck Anderson [Tue, 20 Sep 2016 05:15:47 +0000 (22:15 -0700)]
Merge branch topic/uek-4.1/kernel-generic of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agoMerge branch topic/uek-4.1/upstream-cherry-picks of git://ca-git.us.oracle.com/linux...
Chuck Anderson [Tue, 20 Sep 2016 05:13:49 +0000 (22:13 -0700)]
Merge branch topic/uek-4.1/upstream-cherry-picks of git://ca-git.us.oracle.com/linux-uek into uek/uek-4.1

8 years agouek-rpm nano: fix permissions on mod-sign.sh and find-provides
Ashok Vairavan [Tue, 20 Sep 2016 05:09:12 +0000 (22:09 -0700)]
uek-rpm nano: fix permissions on mod-sign.sh and find-provides

Orabug: 24691953

uek-rpm/ol6-nano/mod-sign.sh and uek-rpm/ol6-nano/find-provides need to be 0755.

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agouek-rpm nano: modify uek-rpm/ol6-nano/ files for ueknano builds v1
Ashok Vairavan [Tue, 20 Sep 2016 05:02:54 +0000 (22:02 -0700)]
uek-rpm nano: modify uek-rpm/ol6-nano/ files for ueknano builds v1

Orabug: 24691953

Modify uek-rpm/ol6-nano/ files for ueknano builds to minimize the size
of the UEK kernel RPM.

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
8 years agouek-rpm framework for ol6-nano builds.
Ashok Vairavan [Tue, 20 Sep 2016 04:51:52 +0000 (21:51 -0700)]
uek-rpm framework for ol6-nano builds.

Orabug: 24691953

ueknano is stripped down version of uek-4.1. It has only
necessary modules needed for Exadata systems. The reason to spin off
nano kernels is to reduce the size of Exadata kernels.

Create files in uek-rpm/ol6-nano/

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>