libnvdimm: Add of_node to region and bus descriptors
Subsystems (4)
Oliver O'Halloran
maintainerPATCH v3 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
@@ -1014,6 +1014,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 · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
A message that is not in the archive (sent off-list or not yet received): 20180406052116.31483-1-oohall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH v3 3/4 doc/devicetree: Persistent memory region bindings
Add 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.
v3: Removed platform bus boilerplate from the example.
Changed description of the volatile and reg properties to make them more clear.
--- .../devicetree/bindings/pmem/pmem-region.txt | 65 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 66 insertions(+) create mode 100644 Documentation/devicetree/bindings/pmem/pmem-region.txt
Documentation/devicetree/bindings/pmem/pmem-region.txt new file +65 -0
@@ -0,0 +1,65 @@ +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 reg property should specificy an address range that is + translatable to a system physical address range. This address + range should be mappable as normal system memory would be + (i.e cacheable). + + 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. + + - volatile; This property indicates that this region is actually + backed by non-persistent memory. This lets the OS know that it + may skip the cache flushes required to ensure data is made + persistent after a write. + + If this property is absent then the OS must assume that the region + is backed by non-volatile memory. + +Examples: +-------------------- + + /* + * This node specifies one 4KB region spanning from + * 0x5000 to 0x5fff that is backed by non-volatile memory. + */ + pmem@5000 { + compatible = "pmem-region"; + reg = <0x00005000 0x00001000>; + }; + + /* + * This node specifies two 4KB regions that are backed by + * volatile (normal) memory. + */ + pmem@6000 { + compatible = "pmem-region"; + reg = < 0x00006000 0x00001000 + 0x00008000 0x00001000 >; + volatile; + }; +
MAINTAINERS +1 -0
@@ -8020,6 +8020,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
A message that is not in the archive (sent off-list or not yet received): 20180406052116.31483-3-oohall-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Michael Ellerman
Acked-byRe: [PATCH v3 3/4] doc/devicetree: Persistent memory region bindings
Quoted 11 lines · Oliver O'Halloran
Add device-tree binding documentation for the nvdimm region driver.
Signed-off-by Oliver O'Halloran <[email protected]>---
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.
v3: Removed platform bus boilerplate from the example.
Changed description of the volatile and reg properties to make them more clear.
Thanks.
cheers
Oliver O'Halloran
maintainerPATCH v3 2/4 libnvdimm: Add device-tree based driver
In reply to Oliver O'HalloranThis 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.
v3: Replaced of_nd_region_* prefix with of_pmem_region_* to make
the driver specific parts more distinct from the libnvdimm parts.
--- 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
@@ -8014,6 +8014,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 · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Oliver O'Halloran
maintainerPATCH v3 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 · 6 lines
2.9.5 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 7 lines · Oliver O'Halloran
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.
Signed-off-by Oliver O'Halloran <[email protected]>Acked-by Dan Williams <[email protected]>
These look good to me. I'll get them applied today and let them soak over the weekend for a pull request on Monday.
If anyone wants to add Acks or Reviews I can append them to the merge tag. If there are any NAKs please speak up now, but as far as I know there are no pending device-tree design concerns.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Balbir Singh
Acked-byQuoted 9 lines · Dan Williams
Quoted 7 lines · Oliver O'Halloran
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.
Signed-off-by Oliver O'Halloran <[email protected]>Acked-by Dan Williams <[email protected]>
Quoted 6 lines
These look good to me. I'll get them applied today and let them soak over the weekend for a pull request on Monday.
If anyone wants to add Acks or Reviews I can append them to the merge tag. If there are any NAKs please speak up now, but as far as I know there are no pending device-tree design concerns.
Hi, Dan
I can ack Oliver's work, will do so in each patch
Overall
Balbir Singh
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm