libnvdimm: Add of_node to region and bus descriptors
Subsystems (4)
Oliver O'Halloran
maintainerPATCH 3/4 doc/devicetree: Persistent memory region bindings
In reply to Oliver O'HalloranAdd device-tree binding documentation for the nvdimm region driver.
---
v2: Changed name from nvdimm-region to pmem-region.
Cleaned up the example binding and fixed the overlapping regions. Added support for multiple regions in a single reg.
--- .../devicetree/bindings/pmem/pmem-region.txt | 80 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/pmem/pmem-region.txt
Documentation/devicetree/bindings/pmem/pmem-region.txt new file +80 -0
@@ -0,0 +1,80 @@ +Device-tree bindings for persistent memory regions +----------------------------------------------------- + +Persistent memory refers to a class of memory devices that are: + + a) Usable as main system memory (i.e. cacheable), and + b) Retain their contents across power failure. + +Given b) it is best to think of persistent memory as a kind of memory mapped +storage device. To ensure data integrity the operating system needs to manage +persistent regions separately to the normal memory pool. To aid with that this +binding provides a standardised interface for discovering where persistent +memory regions exist inside the physical address space. + +Bindings for the region nodes: +----------------------------- + +Required properties: + - compatible = "pmem-region" + + - reg = <base, size>; + The system physical address range of this nvdimm region. + + If the reg property contains multiple address ranges + each address range will be treated as though it was specified + in a separate device node. Having multiple address ranges in a + node implies no special relationship between the two ranges. + +Optional properties: + - Any relevant NUMA assocativity properties for the target platform. + + - A "volatile" property indicating that this region is actually in + normal DRAM and does not require cache flushes after each write. + + If this property is absent then the OS must assume that the region + is backed by non-volatile memory. + +A complete example: +-------------------- + +Here we define three 4KB regions: + + a) A volatile region at 0x5000 on numa node 0, + b) A non-volatile region at 0x6000, and + c) A non-volatile region at 0x8000. + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + platform { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + /* + * This node specifies one non-volatile region spanning from + * 0x5000 to 0x5fff. + */ + pmem@5000 { + compatible = "pmem-region"; + reg = <0x00005000 0x00001000>; + numa-node-id = <0>; + volatile; + }; + + /* + * This node specifies two 4KB regions that are backed by + * volatile (normal) memory. + */ + pmem@6000 { + compatible = "pmem-region"; + reg = <0x00006000 0x00001000 0x00008000 0x00001000>; + }; + }; +}; +
MAINTAINERS +1 -0
@@ -8041,6 +8041,7 @@ L: [email protected] Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ S: Supported F: drivers/nvdimm/of_pmem.c +F: Documentation/devicetree/bindings/pmem/pmem-region.txt LIBNVDIMM: NON-VOLATILE MEMORY DEVICE SUBSYSTEM M: Dan Williams <[email protected]>
Signature · 1 line
2.9.5
Oliver O'Halloran
maintainerPATCH 1/4 libnvdimm: Add of_node to region and bus descriptors
We want to be able to cross reference the region and bus devices with the device tree node that they were spawned from. libNVDIMM handles creating the actual devices for these internally, so we need to pass in a pointer to the relevant node in the descriptor.
--- drivers/nvdimm/bus.c | 1 + drivers/nvdimm/region_devs.c | 1 + include/linux/libnvdimm.h | 3 +++ 3 files changed, 5 insertions(+)
drivers/nvdimm/bus.c +1 -0
@@ -358,6 +358,7 @@ struct nvdimm_bus *nvdimm_bus_register(struct device *parent, nvdimm_bus->dev.release = nvdimm_bus_release; nvdimm_bus->dev.groups = nd_desc->attr_groups; nvdimm_bus->dev.bus = &nvdimm_bus_type; + nvdimm_bus->dev.of_node = nd_desc->of_node;dev_set_name (&nvdimm_bus->dev,"ndbus%d" , nvdimm_bus->id); rc =device_register (&nvdimm_bus->dev);if (rc) {
drivers/nvdimm/region_devs.c +1 -0
@@ -1005,6 +1005,7 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus, dev->parent = &nvdimm_bus->dev; dev->type = dev_type; dev->groups = ndr_desc->attr_groups; + dev->of_node = ndr_desc->of_node; nd_region->ndr_size =resource_size (ndr_desc->res); nd_region->ndr_start = ndr_desc->res->start;nd_device_register (dev);
include/linux/libnvdimm.h +3 -0
@@ -76,12 +76,14 @@ typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, unsigned int cmd, void *buf, unsigned int buf_len, int *cmd_rc); +struct device_node ;struct nvdimm_bus_descriptor {const struct attribute_group **attr_groups;unsigned long bus_dsm_mask;unsigned long cmd_mask;struct module *module;char *provider_name; +struct device_node *of_node;ndctl_fn ndctl;int (*flush_probe)(struct nvdimm_bus_descriptor *nd_desc); int (*clear_to_send)(struct nvdimm_bus_descriptor *nd_desc,
@@ -123,6 +125,7 @@ struct nd_region_desc {int num_lanes;int numa_node;unsigned long flags; +struct device_node *of_node; };struct device ;
Signature · 1 line
2.9.5
Oliver O'Halloran
maintainerPATCH 2/4 libnvdimm: Add device-tree based driver
This patch adds peliminary device-tree bindings for persistent memory regions. The driver registers a libnvdimm bus for each pmem-region node and each address range under the node is converted to a region within that bus.
---
v2: Made each bus have a separate node rather having a shared bus.
Renamed to of_pmem rather than of_nvdimm.
Changed log level of happy-path messages to debug.
--- MAINTAINERS | 7 +++ drivers/nvdimm/Kconfig | 10 ++++ drivers/nvdimm/Makefile | 1 + drivers/nvdimm/of_pmem.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 drivers/nvdimm/of_pmem.c
MAINTAINERS +7 -0
@@ -8035,6 +8035,13 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ S: Supported F: drivers/nvdimm/pmem* +LIBNVDIMM: DEVICETREE BINDINGS +M: Oliver O'Halloran <[email protected]> +L: [email protected] +Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ +S: Supported +F: drivers/nvdimm/of_pmem.c + LIBNVDIMM: NON-VOLATILE MEMORY DEVICE SUBSYSTEM M: Dan Williams <[email protected]> L: [email protected]
drivers/nvdimm/Kconfig +10 -0
@@ -102,4 +102,14 @@ config NVDIMM_DAX Select Y if unsure +config OF_PMEM + tristate "Device-tree support for persistent memory regions" + depends on OF + default LIBNVDIMM + help + Allows regions of persistent memory to be described in the + device-tree. + + Select Y if unsure. + endif
drivers/nvdimm/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o obj-$(CONFIG_ND_BTT) += nd_btt.o obj-$(CONFIG_ND_BLK) += nd_blk.o obj-$(CONFIG_X86_PMEM_LEGACY) += nd_e820.o +obj-$(CONFIG_OF_PMEM) += of_pmem.o nd_pmem-y := pmem.o
drivers/nvdimm/of_pmem.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.9.5
Oliver O'Halloran
maintainerPATCH 4/4 powerpc/powernv: Create platform devs for nvdimm buses
In reply to Oliver O'HalloranScan the devicetree for an nvdimm-bus compatible and create a platform device for them.
--- arch/powerpc/platforms/powernv/opal.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/powernv/opal.c +3 -0
@@ -821,6 +821,9 @@ static int __init opal_init(void)/* Create i2c platform devices */ opal_pdev_init ("ibm,opal-i2c" ); +/* Handle non-volatile memory devices */ +opal_pdev_init ("pmem-region" ); +/* Setup a heatbeat thread if requested by OPAL */ opal_init_heartbeat ();
Signature · 1 line
2.9.5
kbuild test robot
build botRe: [PATCH 2/4] libnvdimm: Add device-tree based driver
In reply to Oliver O'HalloranI love your patch! Yet something to improve:
Hi Oliver,
I love your patch! Yet something to improve:
[auto build test ERROR on linux-nvdimm/libnvdimm-for-next]
[also build test ERROR on v4.16 next-20180403]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Oliver-O-Halloran/libnvdimm-Add-of_node-to-region-and-bus-descriptors/20180404-015544 base: https://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git libnvdimm-for-next config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64
All errors (new ones prefixed by >>):
ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined!
>> ERROR: "of_node_to_nid" [drivers/nvdimm/of_pmem.ko] undefined!
ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation