aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvdimm
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-05-19 22:54:31 -0400
committerDan Williams <dan.j.williams@intel.com>2015-06-24 21:24:10 -0400
commitb94d5230d06eb930be82e67fb1a9a58271e78297 (patch)
tree62ed0e06a81e434dbcbb50a36002bad4eb00b1a1 /drivers/nvdimm
parentad5fb870c486d932a1749d7853dd70f436a7e03f (diff)
libnvdimm, nfit: initial libnvdimm infrastructure and NFIT support
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>
Diffstat (limited to 'drivers/nvdimm')
-rw-r--r--drivers/nvdimm/Kconfig15
-rw-r--r--drivers/nvdimm/Makefile3
-rw-r--r--drivers/nvdimm/core.c69
-rw-r--r--drivers/nvdimm/nd-core.h23
4 files changed, 110 insertions, 0 deletions
diff --git a/drivers/nvdimm/Kconfig b/drivers/nvdimm/Kconfig
new file mode 100644
index 000000000000..92933551f846
--- /dev/null
+++ b/drivers/nvdimm/Kconfig
@@ -0,0 +1,15 @@
1config LIBNVDIMM
2 tristate "NVDIMM (Non-Volatile Memory Device) Support"
3 depends on PHYS_ADDR_T_64BIT
4 depends on BLK_DEV
5 help
6 Generic support for non-volatile memory devices including
7 ACPI-6-NFIT defined resources. On platforms that define an
8 NFIT, or otherwise can discover NVDIMM resources, a libnvdimm
9 bus is registered to advertise PMEM (persistent memory)
10 namespaces (/dev/pmemX) and BLK (sliding mmio window(s))
11 namespaces (/dev/ndX). A PMEM namespace refers to a memory
12 resource that may span multiple DIMMs and support DAX (see
13 CONFIG_DAX). A BLK namespace refers to an NVDIMM control
14 region which exposes an mmio register set for windowed
15 access mode to non-volatile memory.
diff --git a/drivers/nvdimm/Makefile b/drivers/nvdimm/Makefile
new file mode 100644
index 000000000000..10bc7af47992
--- /dev/null
+++ b/drivers/nvdimm/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
2
3libnvdimm-y := core.o
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
new file mode 100644
index 000000000000..c578a49867ac
--- /dev/null
+++ b/drivers/nvdimm/core.c
@@ -0,0 +1,69 @@
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13#include <linux/libnvdimm.h>
14#include <linux/export.h>
15#include <linux/module.h>
16#include <linux/device.h>
17#include <linux/slab.h>
18#include "nd-core.h"
19
20static DEFINE_IDA(nd_ida);
21
22static void nvdimm_bus_release(struct device *dev)
23{
24 struct nvdimm_bus *nvdimm_bus;
25
26 nvdimm_bus = container_of(dev, struct nvdimm_bus, dev);
27 ida_simple_remove(&nd_ida, nvdimm_bus->id);
28 kfree(nvdimm_bus);
29}
30
31struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
32 struct nvdimm_bus_descriptor *nd_desc)
33{
34 struct nvdimm_bus *nvdimm_bus;
35 int rc;
36
37 nvdimm_bus = kzalloc(sizeof(*nvdimm_bus), GFP_KERNEL);
38 if (!nvdimm_bus)
39 return NULL;
40 nvdimm_bus->id = ida_simple_get(&nd_ida, 0, 0, GFP_KERNEL);
41 if (nvdimm_bus->id < 0) {
42 kfree(nvdimm_bus);
43 return NULL;
44 }
45 nvdimm_bus->nd_desc = nd_desc;
46 nvdimm_bus->dev.parent = parent;
47 nvdimm_bus->dev.release = nvdimm_bus_release;
48 dev_set_name(&nvdimm_bus->dev, "ndbus%d", nvdimm_bus->id);
49 rc = device_register(&nvdimm_bus->dev);
50 if (rc) {
51 dev_dbg(&nvdimm_bus->dev, "registration failed: %d\n", rc);
52 put_device(&nvdimm_bus->dev);
53 return NULL;
54 }
55
56 return nvdimm_bus;
57}
58EXPORT_SYMBOL_GPL(nvdimm_bus_register);
59
60void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus)
61{
62 if (!nvdimm_bus)
63 return;
64 device_unregister(&nvdimm_bus->dev);
65}
66EXPORT_SYMBOL_GPL(nvdimm_bus_unregister);
67
68MODULE_LICENSE("GPL v2");
69MODULE_AUTHOR("Intel Corporation");
diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h
new file mode 100644
index 000000000000..291b2fdcd96b
--- /dev/null
+++ b/drivers/nvdimm/nd-core.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 */
13#ifndef __ND_CORE_H__
14#define __ND_CORE_H__
15#include <linux/libnvdimm.h>
16#include <linux/device.h>
17
18struct nvdimm_bus {
19 struct nvdimm_bus_descriptor *nd_desc;
20 struct device dev;
21 int id;
22};
23#endif /* __ND_CORE_H__ */