Re: [Linux-nvdimm] [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-28 Thread Dan Williams
On Tue, Apr 28, 2015 at 5:56 AM, Christoph Hellwig  wrote:
> On Sat, Apr 18, 2015 at 12:37:09PM -0700, Dan Williams wrote:
>> At this point in the patch series I agree, but in later patches we
>> take advantage of nd bus services.  "[PATCH 15/21] nd: pmem label sets
>> and namespace instantiation" adds support for labeled pmem namespaces,
>> and in "[PATCH 19/21] nd: infrastructure for btt devices" we make pmem
>> capable of hosting btt instances.
>
> Thats fine, but still doesn't require moving it around.

I ended up not moving it in v2.  Let me know if the updated rationale
makes sense.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Linux-nvdimm] [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-28 Thread Christoph Hellwig
On Sat, Apr 18, 2015 at 12:37:09PM -0700, Dan Williams wrote:
> At this point in the patch series I agree, but in later patches we
> take advantage of nd bus services.  "[PATCH 15/21] nd: pmem label sets
> and namespace instantiation" adds support for labeled pmem namespaces,
> and in "[PATCH 19/21] nd: infrastructure for btt devices" we make pmem
> capable of hosting btt instances.

Thats fine, but still doesn't require moving it around.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Linux-nvdimm] [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-28 Thread Christoph Hellwig
On Sat, Apr 18, 2015 at 12:37:09PM -0700, Dan Williams wrote:
 At this point in the patch series I agree, but in later patches we
 take advantage of nd bus services.  [PATCH 15/21] nd: pmem label sets
 and namespace instantiation adds support for labeled pmem namespaces,
 and in [PATCH 19/21] nd: infrastructure for btt devices we make pmem
 capable of hosting btt instances.

Thats fine, but still doesn't require moving it around.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [Linux-nvdimm] [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-28 Thread Dan Williams
On Tue, Apr 28, 2015 at 5:56 AM, Christoph Hellwig h...@infradead.org wrote:
 On Sat, Apr 18, 2015 at 12:37:09PM -0700, Dan Williams wrote:
 At this point in the patch series I agree, but in later patches we
 take advantage of nd bus services.  [PATCH 15/21] nd: pmem label sets
 and namespace instantiation adds support for labeled pmem namespaces,
 and in [PATCH 19/21] nd: infrastructure for btt devices we make pmem
 capable of hosting btt instances.

 Thats fine, but still doesn't require moving it around.

I ended up not moving it in v2.  Let me know if the updated rationale
makes sense.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-18 Thread Dan Williams
On Fri, Apr 17, 2015 at 11:38 PM, Christoph Hellwig  wrote:
> On Fri, Apr 17, 2015 at 09:36:18PM -0400, Dan Williams wrote:
>> nd_pmem attaches to persistent memory regions and namespaces emitted by
>> the nd subsystem, and, same as the original pmem driver, presents the
>> system-physical-address range as a block device.
>
> I don't think there is any need to move the driver around.

At this point in the patch series I agree, but in later patches we
take advantage of nd bus services.  "[PATCH 15/21] nd: pmem label sets
and namespace instantiation" adds support for labeled pmem namespaces,
and in "[PATCH 19/21] nd: infrastructure for btt devices" we make pmem
capable of hosting btt instances.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-18 Thread Christoph Hellwig
On Fri, Apr 17, 2015 at 09:36:18PM -0400, Dan Williams wrote:
> nd_pmem attaches to persistent memory regions and namespaces emitted by
> the nd subsystem, and, same as the original pmem driver, presents the
> system-physical-address range as a block device.

I don't think there is any need to move the driver around.  Also please split
the addition of the ida allocation from adding the new probe methods.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-18 Thread Dan Williams
On Fri, Apr 17, 2015 at 11:38 PM, Christoph Hellwig h...@lst.de wrote:
 On Fri, Apr 17, 2015 at 09:36:18PM -0400, Dan Williams wrote:
 nd_pmem attaches to persistent memory regions and namespaces emitted by
 the nd subsystem, and, same as the original pmem driver, presents the
 system-physical-address range as a block device.

 I don't think there is any need to move the driver around.

At this point in the patch series I agree, but in later patches we
take advantage of nd bus services.  [PATCH 15/21] nd: pmem label sets
and namespace instantiation adds support for labeled pmem namespaces,
and in [PATCH 19/21] nd: infrastructure for btt devices we make pmem
capable of hosting btt instances.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-18 Thread Christoph Hellwig
On Fri, Apr 17, 2015 at 09:36:18PM -0400, Dan Williams wrote:
 nd_pmem attaches to persistent memory regions and namespaces emitted by
 the nd subsystem, and, same as the original pmem driver, presents the
 system-physical-address range as a block device.

I don't think there is any need to move the driver around.  Also please split
the addition of the ida allocation from adding the new probe methods.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-17 Thread Dan Williams
nd_pmem attaches to persistent memory regions and namespaces emitted by
the nd subsystem, and, same as the original pmem driver, presents the
system-physical-address range as a block device.

Cc: Andy Lutomirski 
Cc: Boaz Harrosh 
Cc: H. Peter Anvin 
Cc: Jens Axboe 
Cc: Ingo Molnar 
Cc: Christoph Hellwig 
Signed-off-by: Dan Williams 
---
 drivers/block/Kconfig |   11 ---
 drivers/block/Makefile|1 -
 drivers/block/nd/Kconfig  |   17 +++
 drivers/block/nd/Makefile |3 ++
 drivers/block/nd/pmem.c   |   72 +++--
 5 files changed, 83 insertions(+), 21 deletions(-)
 rename drivers/block/{pmem.c => nd/pmem.c} (81%)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index dfe40e5ca9bd..1cef4ffb16c5 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -406,17 +406,6 @@ config BLK_DEV_RAM_DAX
  and will prevent RAM block device backing store memory from being
  allocated from highmem (only a problem for highmem systems).
 
-config BLK_DEV_PMEM
-   tristate "Persistent memory block device support"
-   help
- Saying Y here will allow you to use a contiguous range of reserved
- memory as one or more persistent block devices.
-
- To compile this driver as a module, choose M here: the module will be
- called 'pmem'.
-
- If unsure, say N.
-
 config CDROM_PKTCDVD
tristate "Packet writing on CD/DVD media"
depends on !UML
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 18b27bb9cd2d..3a2f15be66a3 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -14,7 +14,6 @@ obj-$(CONFIG_PS3_VRAM)+= ps3vram.o
 obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
 obj-$(CONFIG_AMIGA_Z2RAM)  += z2ram.o
 obj-$(CONFIG_BLK_DEV_RAM)  += brd.o
-obj-$(CONFIG_BLK_DEV_PMEM) += pmem.o
 obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
 obj-$(CONFIG_BLK_CPQ_DA)   += cpqarray.o
 obj-$(CONFIG_BLK_CPQ_CISS_DA)  += cciss.o
diff --git a/drivers/block/nd/Kconfig b/drivers/block/nd/Kconfig
index 6c15d10bf4e0..38eae5f0ae4b 100644
--- a/drivers/block/nd/Kconfig
+++ b/drivers/block/nd/Kconfig
@@ -72,4 +72,21 @@ config NFIT_TEST
 
  Say N unless you are doing development of the 'nd' subsystem.
 
+config BLK_DEV_PMEM
+   tristate "PMEM: Persistent memory block device support"
+   depends on ND_CORE || X86_PMEM_LEGACY
+   default ND_CORE
+   help
+ Memory ranges for PMEM are described by either an NFIT
+ (NVDIMM Firmware Interface Table, see CONFIG_NFIT_ACPI), a
+ non-standard OEM-specific E820 memory type (type-12, see
+ CONFIG_X86_PMEM_LEGACY), or it is manually specified by the
+ 'memmap=nn[KMG]!ss[KMG]' kernel command line (see
+ Documentation/kernel-parameters.txt).  This driver converts
+ these persistent memory ranges into block devices that are
+ capable of DAX (direct-access) file system mappings.  See
+ Documentation/blockdev/nd.txt for more details.
+
+ Say Y if you want to use a NVDIMM described by NFIT
+
 endif
diff --git a/drivers/block/nd/Makefile b/drivers/block/nd/Makefile
index 769ddc34f974..c0194d52e5ad 100644
--- a/drivers/block/nd/Makefile
+++ b/drivers/block/nd/Makefile
@@ -16,6 +16,7 @@ endif
 
 obj-$(CONFIG_ND_CORE) += nd.o
 obj-$(CONFIG_NFIT_ACPI) += nd_acpi.o
+obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
 
 nd_acpi-y := acpi.o
 
@@ -26,3 +27,5 @@ nd-y += dimm.o
 nd-y += region_devs.o
 nd-y += region.o
 nd-y += namespace_devs.o
+
+nd_pmem-y := pmem.o
diff --git a/drivers/block/pmem.c b/drivers/block/nd/pmem.c
similarity index 81%
rename from drivers/block/pmem.c
rename to drivers/block/nd/pmem.c
index eabf4a8d0085..cd83a9a98d89 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/nd/pmem.c
@@ -1,7 +1,7 @@
 /*
  * Persistent Memory Driver
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014-2015, Intel Corporation.
  * Copyright (c) 2015, Christoph Hellwig .
  * Copyright (c) 2015, Boaz Harrosh .
  *
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define PMEM_MINORS16
 
@@ -34,10 +35,11 @@ struct pmem_device {
phys_addr_t phys_addr;
void*virt_addr;
size_t  size;
+   int id;
 };
 
 static int pmem_major;
-static atomic_t pmem_index;
+static DEFINE_IDA(pmem_ida);
 
 static void pmem_do_bvec(struct pmem_device *pmem, struct page *page,
unsigned int len, unsigned int off, int rw,
@@ -122,20 +124,26 @@ static struct pmem_device *pmem_alloc(struct device *dev, 
struct resource *res)
 {
struct pmem_device *pmem;
struct gendisk *disk;
-   int idx, err;
+   int err;
 
err = -ENOMEM;
pmem = kzalloc(sizeof(*pmem), GFP_KERNEL);
if (!pmem)
goto out;
 
+   pmem->id = ida_simple_get(_ida, 0, 0, GFP_KERNEL);
+   

[PATCH 12/21] nd_pmem: add NFIT support to the pmem driver

2015-04-17 Thread Dan Williams
nd_pmem attaches to persistent memory regions and namespaces emitted by
the nd subsystem, and, same as the original pmem driver, presents the
system-physical-address range as a block device.

Cc: Andy Lutomirski l...@amacapital.net
Cc: Boaz Harrosh b...@plexistor.com
Cc: H. Peter Anvin h...@zytor.com
Cc: Jens Axboe ax...@fb.com
Cc: Ingo Molnar mi...@kernel.org
Cc: Christoph Hellwig h...@lst.de
Signed-off-by: Dan Williams dan.j.willi...@intel.com
---
 drivers/block/Kconfig |   11 ---
 drivers/block/Makefile|1 -
 drivers/block/nd/Kconfig  |   17 +++
 drivers/block/nd/Makefile |3 ++
 drivers/block/nd/pmem.c   |   72 +++--
 5 files changed, 83 insertions(+), 21 deletions(-)
 rename drivers/block/{pmem.c = nd/pmem.c} (81%)

diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index dfe40e5ca9bd..1cef4ffb16c5 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -406,17 +406,6 @@ config BLK_DEV_RAM_DAX
  and will prevent RAM block device backing store memory from being
  allocated from highmem (only a problem for highmem systems).
 
-config BLK_DEV_PMEM
-   tristate Persistent memory block device support
-   help
- Saying Y here will allow you to use a contiguous range of reserved
- memory as one or more persistent block devices.
-
- To compile this driver as a module, choose M here: the module will be
- called 'pmem'.
-
- If unsure, say N.
-
 config CDROM_PKTCDVD
tristate Packet writing on CD/DVD media
depends on !UML
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 18b27bb9cd2d..3a2f15be66a3 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -14,7 +14,6 @@ obj-$(CONFIG_PS3_VRAM)+= ps3vram.o
 obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
 obj-$(CONFIG_AMIGA_Z2RAM)  += z2ram.o
 obj-$(CONFIG_BLK_DEV_RAM)  += brd.o
-obj-$(CONFIG_BLK_DEV_PMEM) += pmem.o
 obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
 obj-$(CONFIG_BLK_CPQ_DA)   += cpqarray.o
 obj-$(CONFIG_BLK_CPQ_CISS_DA)  += cciss.o
diff --git a/drivers/block/nd/Kconfig b/drivers/block/nd/Kconfig
index 6c15d10bf4e0..38eae5f0ae4b 100644
--- a/drivers/block/nd/Kconfig
+++ b/drivers/block/nd/Kconfig
@@ -72,4 +72,21 @@ config NFIT_TEST
 
  Say N unless you are doing development of the 'nd' subsystem.
 
+config BLK_DEV_PMEM
+   tristate PMEM: Persistent memory block device support
+   depends on ND_CORE || X86_PMEM_LEGACY
+   default ND_CORE
+   help
+ Memory ranges for PMEM are described by either an NFIT
+ (NVDIMM Firmware Interface Table, see CONFIG_NFIT_ACPI), a
+ non-standard OEM-specific E820 memory type (type-12, see
+ CONFIG_X86_PMEM_LEGACY), or it is manually specified by the
+ 'memmap=nn[KMG]!ss[KMG]' kernel command line (see
+ Documentation/kernel-parameters.txt).  This driver converts
+ these persistent memory ranges into block devices that are
+ capable of DAX (direct-access) file system mappings.  See
+ Documentation/blockdev/nd.txt for more details.
+
+ Say Y if you want to use a NVDIMM described by NFIT
+
 endif
diff --git a/drivers/block/nd/Makefile b/drivers/block/nd/Makefile
index 769ddc34f974..c0194d52e5ad 100644
--- a/drivers/block/nd/Makefile
+++ b/drivers/block/nd/Makefile
@@ -16,6 +16,7 @@ endif
 
 obj-$(CONFIG_ND_CORE) += nd.o
 obj-$(CONFIG_NFIT_ACPI) += nd_acpi.o
+obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
 
 nd_acpi-y := acpi.o
 
@@ -26,3 +27,5 @@ nd-y += dimm.o
 nd-y += region_devs.o
 nd-y += region.o
 nd-y += namespace_devs.o
+
+nd_pmem-y := pmem.o
diff --git a/drivers/block/pmem.c b/drivers/block/nd/pmem.c
similarity index 81%
rename from drivers/block/pmem.c
rename to drivers/block/nd/pmem.c
index eabf4a8d0085..cd83a9a98d89 100644
--- a/drivers/block/pmem.c
+++ b/drivers/block/nd/pmem.c
@@ -1,7 +1,7 @@
 /*
  * Persistent Memory Driver
  *
- * Copyright (c) 2014, Intel Corporation.
+ * Copyright (c) 2014-2015, Intel Corporation.
  * Copyright (c) 2015, Christoph Hellwig h...@lst.de.
  * Copyright (c) 2015, Boaz Harrosh b...@plexistor.com.
  *
@@ -23,6 +23,7 @@
 #include linux/module.h
 #include linux/moduleparam.h
 #include linux/slab.h
+#include linux/nd.h
 
 #define PMEM_MINORS16
 
@@ -34,10 +35,11 @@ struct pmem_device {
phys_addr_t phys_addr;
void*virt_addr;
size_t  size;
+   int id;
 };
 
 static int pmem_major;
-static atomic_t pmem_index;
+static DEFINE_IDA(pmem_ida);
 
 static void pmem_do_bvec(struct pmem_device *pmem, struct page *page,
unsigned int len, unsigned int off, int rw,
@@ -122,20 +124,26 @@ static struct pmem_device *pmem_alloc(struct device *dev, 
struct resource *res)
 {
struct pmem_device *pmem;
struct gendisk *disk;
-   int idx, err;
+   int