[PATCH v4 20/21] nfit-test: manufactured NFITs for interface development

2015-05-27 Thread Dan Williams
Manually create and register NFITs to describe 2 topologies.  Topology1
is an advanced plausible configuration for BLK/PMEM aliased NVDIMMs.
Topology2 is an example configuration for current platforms that only
ship with a persistent address range.

 Kernel provider "nfit_test.0" produces an NFIT with the following attributes:

  (a)   (b)   DIMM   BLK-REGION
   +---++++
 +--+  |   pm0.0   | blk2.0 | pm1.0  | blk2.1 |0  region2
 | imc0 +--+- - - region0- - - ++++
 +--+---+  |   pm0.0   | blk3.0 | pm1.0  | blk3.1 |1  region3
|  +---+vv+
 +--+---+   | |
 | cpu0 | region1
 +--+---+   | |
|  +^^+
 +--+---+  |   blk4.0   | pm1.0  | blk4.0 |2  region4
 | imc1 +--+|++
 +--+  |   blk5.0   | pm1.0  | blk5.0 |3  region5
   ++++

 *) In this layout we have four dimms and two memory controllers in one
socket.  Each unique interface ("block" or "pmem") to DPA space
is identified by a region device with a dynamically assigned id.

 *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
A single "pmem" namespace is created in the REGION0-"spa"-range
that spans dimm0 and dimm1 with a user-specified name of "pm0.0".
Some of that interleaved "spa" range is reclaimed as "bdw"
accessed space starting at offset (a) into each dimm.  In that
reclaimed space we create two "bdw" "namespaces" from REGION2 and
REGION3 where "blk2.0" and "blk3.0" are just human readable names
that could be set to any user-desired name in the label.

 *) In the last portion of dimm0 and dimm1 we have an interleaved
"spa" range, REGION1, that spans those two dimms as well as dimm2
and dimm3.  Some of REGION1 allocated to a "pmem" namespace named
"pm1.0" the rest is reclaimed in 4 "bdw" namespaces (for each
dimm in the interleave set), "blk2.1", "blk3.1", "blk4.0", and
"blk5.0".

 *) The portion of dimm2 and dimm3 that do not participate in the
REGION1 interleaved "spa" range (i.e. the DPA address below
offset (b) are also included in the "blk4.0" and "blk5.0"
namespaces.  Note, that this example shows that "bdw" namespaces
don't need to be contiguous in DPA-space.

 Kernel provider "nfit_test.1" produces an NFIT with the following attributes:

 region2
 +-+
 |-|
 ||   pm2.0   ||
 |-|
 +-+

 *) Describes a simple system-physical-address range with no backing
dimm or interleave description.

Cc: 
Cc: Lv Zheng 
Cc: Robert Moore 
Cc: Rafael J. Wysocki 
Signed-off-by: Dan Williams 
---
 drivers/acpi/nfit.c   |6 
 drivers/acpi/nfit.h   |   12 
 drivers/block/nd/Kconfig  |   22 +
 drivers/block/nd/Makefile |9 
 drivers/block/nd/test/Makefile|5 
 drivers/block/nd/test/iomap.c |  151 +
 drivers/block/nd/test/nfit.c  | 1171 +
 drivers/block/nd/test/nfit_test.h |   28 +
 8 files changed, 1402 insertions(+), 2 deletions(-)
 create mode 100644 drivers/block/nd/test/Makefile
 create mode 100644 drivers/block/nd/test/iomap.c
 create mode 100644 drivers/block/nd/test/nfit.c
 create mode 100644 drivers/block/nd/test/nfit_test.h

diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index ec2d4a6c6054..c31d0ae87293 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -29,10 +29,11 @@ MODULE_PARM_DESC(force_enable_dimms, "Ignore _STA (ACPI 
DIMM device) status");
 
 static u8 nfit_uuid[NFIT_UUID_MAX][16];
 
-static const u8 *to_nfit_uuid(enum nfit_uuids id)
+const u8 *to_nfit_uuid(enum nfit_uuids id)
 {
return nfit_uuid[id];
 }
+EXPORT_SYMBOL(to_nfit_uuid);
 
 static struct acpi_nfit_desc *to_acpi_nfit_desc(struct nd_bus_descriptor 
*nd_desc)
 {
@@ -1330,7 +1331,7 @@ static int acpi_nfit_register_regions(struct 
acpi_nfit_desc *acpi_desc)
return 0;
 }
 
-static int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz)
+int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz)
 {
struct device *dev = acpi_desc->dev;
const void *end;
@@ -1369,6 +1370,7 @@ static int acpi_nfit_init(struct acpi_nfit_desc 
*acpi_desc, acpi_size sz)
 
return acpi_nfit_register_regions(acpi_desc);
 }
+EXPORT_SYMBOL_GPL(acpi_nfit_init);
 
 static int acpi_nfit_add(struct acpi_device *adev)
 {
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index 1fc49cc51d4a..880e7b3a9da0 100644
--- a/drivers/acpi/nfit.h
+++ 

[PATCH v4 20/21] nfit-test: manufactured NFITs for interface development

2015-05-27 Thread Dan Williams
Manually create and register NFITs to describe 2 topologies.  Topology1
is an advanced plausible configuration for BLK/PMEM aliased NVDIMMs.
Topology2 is an example configuration for current platforms that only
ship with a persistent address range.

 Kernel provider nfit_test.0 produces an NFIT with the following attributes:

  (a)   (b)   DIMM   BLK-REGION
   +---++++
 +--+  |   pm0.0   | blk2.0 | pm1.0  | blk2.1 |0  region2
 | imc0 +--+- - - region0- - - ++++
 +--+---+  |   pm0.0   | blk3.0 | pm1.0  | blk3.1 |1  region3
|  +---+vv+
 +--+---+   | |
 | cpu0 | region1
 +--+---+   | |
|  +^^+
 +--+---+  |   blk4.0   | pm1.0  | blk4.0 |2  region4
 | imc1 +--+|++
 +--+  |   blk5.0   | pm1.0  | blk5.0 |3  region5
   ++++

 *) In this layout we have four dimms and two memory controllers in one
socket.  Each unique interface (block or pmem) to DPA space
is identified by a region device with a dynamically assigned id.

 *) The first portion of dimm0 and dimm1 are interleaved as REGION0.
A single pmem namespace is created in the REGION0-spa-range
that spans dimm0 and dimm1 with a user-specified name of pm0.0.
Some of that interleaved spa range is reclaimed as bdw
accessed space starting at offset (a) into each dimm.  In that
reclaimed space we create two bdw namespaces from REGION2 and
REGION3 where blk2.0 and blk3.0 are just human readable names
that could be set to any user-desired name in the label.

 *) In the last portion of dimm0 and dimm1 we have an interleaved
spa range, REGION1, that spans those two dimms as well as dimm2
and dimm3.  Some of REGION1 allocated to a pmem namespace named
pm1.0 the rest is reclaimed in 4 bdw namespaces (for each
dimm in the interleave set), blk2.1, blk3.1, blk4.0, and
blk5.0.

 *) The portion of dimm2 and dimm3 that do not participate in the
REGION1 interleaved spa range (i.e. the DPA address below
offset (b) are also included in the blk4.0 and blk5.0
namespaces.  Note, that this example shows that bdw namespaces
don't need to be contiguous in DPA-space.

 Kernel provider nfit_test.1 produces an NFIT with the following attributes:

 region2
 +-+
 |-|
 ||   pm2.0   ||
 |-|
 +-+

 *) Describes a simple system-physical-address range with no backing
dimm or interleave description.

Cc: linux-a...@vger.kernel.org
Cc: Lv Zheng lv.zh...@intel.com
Cc: Robert Moore robert.mo...@intel.com
Cc: Rafael J. Wysocki rafael.j.wyso...@intel.com
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/acpi/nfit.c   |6 
 drivers/acpi/nfit.h   |   12 
 drivers/block/nd/Kconfig  |   22 +
 drivers/block/nd/Makefile |9 
 drivers/block/nd/test/Makefile|5 
 drivers/block/nd/test/iomap.c |  151 +
 drivers/block/nd/test/nfit.c  | 1171 +
 drivers/block/nd/test/nfit_test.h |   28 +
 8 files changed, 1402 insertions(+), 2 deletions(-)
 create mode 100644 drivers/block/nd/test/Makefile
 create mode 100644 drivers/block/nd/test/iomap.c
 create mode 100644 drivers/block/nd/test/nfit.c
 create mode 100644 drivers/block/nd/test/nfit_test.h

diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
index ec2d4a6c6054..c31d0ae87293 100644
--- a/drivers/acpi/nfit.c
+++ b/drivers/acpi/nfit.c
@@ -29,10 +29,11 @@ MODULE_PARM_DESC(force_enable_dimms, Ignore _STA (ACPI 
DIMM device) status);
 
 static u8 nfit_uuid[NFIT_UUID_MAX][16];
 
-static const u8 *to_nfit_uuid(enum nfit_uuids id)
+const u8 *to_nfit_uuid(enum nfit_uuids id)
 {
return nfit_uuid[id];
 }
+EXPORT_SYMBOL(to_nfit_uuid);
 
 static struct acpi_nfit_desc *to_acpi_nfit_desc(struct nd_bus_descriptor 
*nd_desc)
 {
@@ -1330,7 +1331,7 @@ static int acpi_nfit_register_regions(struct 
acpi_nfit_desc *acpi_desc)
return 0;
 }
 
-static int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz)
+int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz)
 {
struct device *dev = acpi_desc-dev;
const void *end;
@@ -1369,6 +1370,7 @@ static int acpi_nfit_init(struct acpi_nfit_desc 
*acpi_desc, acpi_size sz)
 
return acpi_nfit_register_regions(acpi_desc);
 }
+EXPORT_SYMBOL_GPL(acpi_nfit_init);
 
 static int acpi_nfit_add(struct acpi_device *adev)
 {
diff --git a/drivers/acpi/nfit.h b/drivers/acpi/nfit.h
index