2015-05-20 02:54:31 +00:00
|
|
|
/*
|
|
|
|
* libnvdimm - Non-volatile-memory Devices Subsystem
|
|
|
|
*
|
|
|
|
* Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*/
|
|
|
|
#ifndef __LIBNVDIMM_H__
|
|
|
|
#define __LIBNVDIMM_H__
|
2015-06-25 08:21:02 +00:00
|
|
|
#include <linux/kernel.h>
|
2015-06-08 18:27:06 +00:00
|
|
|
#include <linux/sizes.h>
|
|
|
|
#include <linux/types.h>
|
2015-04-25 07:56:17 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
/* when a dimm supports both PMEM and BLK access a label is required */
|
|
|
|
NDD_ALIASING = 1 << 0,
|
2015-06-24 00:08:34 +00:00
|
|
|
/* unarmed memory devices may not persist writes */
|
|
|
|
NDD_UNARMED = 1 << 1,
|
2015-06-08 18:27:06 +00:00
|
|
|
|
|
|
|
/* need to set a limit somewhere, but yes, this is likely overkill */
|
|
|
|
ND_IOCTL_MAX_BUFLEN = SZ_4M,
|
2016-02-17 21:08:58 +00:00
|
|
|
ND_CMD_MAX_ELEM = 5,
|
2016-04-11 22:02:28 +00:00
|
|
|
ND_CMD_MAX_ENVELOPE = 256,
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
ND_MAX_MAPPINGS = 32,
|
2015-05-01 17:34:01 +00:00
|
|
|
|
2015-08-24 23:20:23 +00:00
|
|
|
/* region flag indicating to direct-map persistent memory by default */
|
|
|
|
ND_REGION_PAGEMAP = 0,
|
|
|
|
|
2015-05-01 17:34:01 +00:00
|
|
|
/* mark newly adjusted resources as requiring a label update */
|
|
|
|
DPA_RESOURCE_ADJUSTED = 1 << 0,
|
2015-04-25 07:56:17 +00:00
|
|
|
};
|
|
|
|
|
2015-04-26 23:26:48 +00:00
|
|
|
extern struct attribute_group nvdimm_bus_attribute_group;
|
2015-06-08 18:27:06 +00:00
|
|
|
extern struct attribute_group nvdimm_attribute_group;
|
2015-05-31 18:41:48 +00:00
|
|
|
extern struct attribute_group nd_device_attribute_group;
|
2015-06-19 18:18:34 +00:00
|
|
|
extern struct attribute_group nd_numa_attribute_group;
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
extern struct attribute_group nd_region_attribute_group;
|
|
|
|
extern struct attribute_group nd_mapping_attribute_group;
|
2015-04-26 23:26:48 +00:00
|
|
|
|
2015-05-20 02:54:31 +00:00
|
|
|
struct nvdimm;
|
|
|
|
struct nvdimm_bus_descriptor;
|
|
|
|
typedef int (*ndctl_fn)(struct nvdimm_bus_descriptor *nd_desc,
|
|
|
|
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
|
2016-02-13 01:01:11 +00:00
|
|
|
unsigned int buf_len, int *cmd_rc);
|
2015-05-20 02:54:31 +00:00
|
|
|
|
|
|
|
struct nvdimm_bus_descriptor {
|
2015-04-26 23:26:48 +00:00
|
|
|
const struct attribute_group **attr_groups;
|
2016-04-28 23:17:07 +00:00
|
|
|
unsigned long cmd_mask;
|
2016-07-22 03:03:19 +00:00
|
|
|
struct module *module;
|
2015-05-20 02:54:31 +00:00
|
|
|
char *provider_name;
|
|
|
|
ndctl_fn ndctl;
|
2016-02-19 20:16:34 +00:00
|
|
|
int (*flush_probe)(struct nvdimm_bus_descriptor *nd_desc);
|
2016-02-23 05:50:31 +00:00
|
|
|
int (*clear_to_send)(struct nvdimm_bus_descriptor *nd_desc,
|
|
|
|
struct nvdimm *nvdimm, unsigned int cmd);
|
2015-05-20 02:54:31 +00:00
|
|
|
};
|
|
|
|
|
2015-06-08 18:27:06 +00:00
|
|
|
struct nd_cmd_desc {
|
|
|
|
int in_num;
|
|
|
|
int out_num;
|
|
|
|
u32 in_sizes[ND_CMD_MAX_ELEM];
|
|
|
|
int out_sizes[ND_CMD_MAX_ELEM];
|
|
|
|
};
|
|
|
|
|
2015-05-01 17:11:27 +00:00
|
|
|
struct nd_interleave_set {
|
|
|
|
u64 cookie;
|
2017-03-01 02:32:48 +00:00
|
|
|
/* compatibility with initial buggy Linux implementation */
|
|
|
|
u64 altcookie;
|
2015-05-01 17:11:27 +00:00
|
|
|
};
|
|
|
|
|
2016-09-19 23:38:50 +00:00
|
|
|
struct nd_mapping_desc {
|
|
|
|
struct nvdimm *nvdimm;
|
|
|
|
u64 start;
|
|
|
|
u64 size;
|
|
|
|
};
|
|
|
|
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
struct nd_region_desc {
|
|
|
|
struct resource *res;
|
2016-09-19 23:38:50 +00:00
|
|
|
struct nd_mapping_desc *mapping;
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
u16 num_mappings;
|
|
|
|
const struct attribute_group **attr_groups;
|
2015-05-01 17:11:27 +00:00
|
|
|
struct nd_interleave_set *nd_set;
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
void *provider_data;
|
nd_btt: atomic sector updates
BTT stands for Block Translation Table, and is a way to provide power
fail sector atomicity semantics for block devices that have the ability
to perform byte granularity IO. It relies on the capability of libnvdimm
namespace devices to do byte aligned IO.
The BTT works as a stacked blocked device, and reserves a chunk of space
from the backing device for its accounting metadata. It is a bio-based
driver because all IO is done synchronously, and there is no queuing or
asynchronous completions at either the device or the driver level.
The BTT uses 'lanes' to index into various 'on-disk' data structures,
and lanes also act as a synchronization mechanism in case there are more
CPUs than available lanes. We did a comparison between two lane lock
strategies - first where we kept an atomic counter around that tracked
which was the last lane that was used, and 'our' lane was determined by
atomically incrementing that. That way, for the nr_cpus > nr_lanes case,
theoretically, no CPU would be blocked waiting for a lane. The other
strategy was to use the cpu number we're scheduled on to and hash it to
a lane number. Theoretically, this could block an IO that could've
otherwise run using a different, free lane. But some fio workloads
showed that the direct cpu -> lane hash performed faster than tracking
'last lane' - my reasoning is the cache thrash caused by moving the
atomic variable made that approach slower than simply waiting out the
in-progress IO. This supports the conclusion that the driver can be a
very simple bio-based one that does synchronous IOs instead of queuing.
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Boaz Harrosh <boaz@plexistor.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
[jmoyer: fix nmi watchdog timeout in btt_map_init]
[jmoyer: move btt initialization to module load path]
[jmoyer: fix memory leak in the btt initialization path]
[jmoyer: Don't overwrite corrupted arenas]
Signed-off-by: Vishal Verma <vishal.l.verma@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2015-06-25 08:20:32 +00:00
|
|
|
int num_lanes;
|
2015-06-19 18:18:33 +00:00
|
|
|
int numa_node;
|
2015-08-24 23:20:23 +00:00
|
|
|
unsigned long flags;
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
};
|
|
|
|
|
2016-06-07 00:42:38 +00:00
|
|
|
struct device;
|
|
|
|
void *devm_nvdimm_memremap(struct device *dev, resource_size_t offset,
|
|
|
|
size_t size, unsigned long flags);
|
|
|
|
static inline void __iomem *devm_nvdimm_ioremap(struct device *dev,
|
|
|
|
resource_size_t offset, size_t size)
|
|
|
|
{
|
|
|
|
return (void __iomem *) devm_nvdimm_memremap(dev, offset, size, 0);
|
|
|
|
}
|
|
|
|
|
2015-06-08 18:27:06 +00:00
|
|
|
struct nvdimm_bus;
|
2015-05-31 19:02:11 +00:00
|
|
|
struct module;
|
2015-06-25 08:21:02 +00:00
|
|
|
struct device;
|
|
|
|
struct nd_blk_region;
|
|
|
|
struct nd_blk_region_desc {
|
|
|
|
int (*enable)(struct nvdimm_bus *nvdimm_bus, struct device *dev);
|
|
|
|
int (*do_io)(struct nd_blk_region *ndbr, resource_size_t dpa,
|
|
|
|
void *iobuf, u64 len, int rw);
|
|
|
|
struct nd_region_desc ndr_desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct nd_blk_region_desc *to_blk_region_desc(
|
|
|
|
struct nd_region_desc *ndr_desc)
|
|
|
|
{
|
|
|
|
return container_of(ndr_desc, struct nd_blk_region_desc, ndr_desc);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-25 02:21:43 +00:00
|
|
|
int nvdimm_bus_add_poison(struct nvdimm_bus *nvdimm_bus, u64 addr, u64 length);
|
2016-09-30 23:19:31 +00:00
|
|
|
void nvdimm_clear_from_poison_list(struct nvdimm_bus *nvdimm_bus,
|
|
|
|
phys_addr_t start, unsigned int len);
|
2016-07-22 03:03:19 +00:00
|
|
|
struct nvdimm_bus *nvdimm_bus_register(struct device *parent,
|
|
|
|
struct nvdimm_bus_descriptor *nfit_desc);
|
2015-05-20 02:54:31 +00:00
|
|
|
void nvdimm_bus_unregister(struct nvdimm_bus *nvdimm_bus);
|
2015-04-26 23:26:48 +00:00
|
|
|
struct nvdimm_bus *to_nvdimm_bus(struct device *dev);
|
2015-04-25 07:56:17 +00:00
|
|
|
struct nvdimm *to_nvdimm(struct device *dev);
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
struct nd_region *to_nd_region(struct device *dev);
|
2015-06-25 08:21:02 +00:00
|
|
|
struct nd_blk_region *to_nd_blk_region(struct device *dev);
|
2015-04-26 23:26:48 +00:00
|
|
|
struct nvdimm_bus_descriptor *to_nd_desc(struct nvdimm_bus *nvdimm_bus);
|
2016-07-24 04:51:42 +00:00
|
|
|
struct device *to_nvdimm_bus_dev(struct nvdimm_bus *nvdimm_bus);
|
2015-04-25 07:56:17 +00:00
|
|
|
const char *nvdimm_name(struct nvdimm *nvdimm);
|
2016-08-23 02:28:37 +00:00
|
|
|
struct kobject *nvdimm_kobj(struct nvdimm *nvdimm);
|
2016-04-28 23:17:07 +00:00
|
|
|
unsigned long nvdimm_cmd_mask(struct nvdimm *nvdimm);
|
2015-04-25 07:56:17 +00:00
|
|
|
void *nvdimm_provider_data(struct nvdimm *nvdimm);
|
|
|
|
struct nvdimm *nvdimm_create(struct nvdimm_bus *nvdimm_bus, void *provider_data,
|
2015-06-08 18:27:06 +00:00
|
|
|
const struct attribute_group **groups, unsigned long flags,
|
2016-06-08 00:00:04 +00:00
|
|
|
unsigned long cmd_mask, int num_flush,
|
|
|
|
struct resource *flush_wpq);
|
2015-06-08 18:27:06 +00:00
|
|
|
const struct nd_cmd_desc *nd_cmd_dimm_desc(int cmd);
|
|
|
|
const struct nd_cmd_desc *nd_cmd_bus_desc(int cmd);
|
|
|
|
u32 nd_cmd_in_size(struct nvdimm *nvdimm, int cmd,
|
|
|
|
const struct nd_cmd_desc *desc, int idx, void *buf);
|
|
|
|
u32 nd_cmd_out_size(struct nvdimm *nvdimm, int cmd,
|
|
|
|
const struct nd_cmd_desc *desc, int idx, const u32 *in_field,
|
2016-12-06 17:10:12 +00:00
|
|
|
const u32 *out_field, unsigned long remainder);
|
2015-05-31 18:41:48 +00:00
|
|
|
int nvdimm_bus_check_dimm_count(struct nvdimm_bus *nvdimm_bus, int dimm_count);
|
libnvdimm, nfit: regions (block-data-window, persistent memory, volatile memory)
A "region" device represents the maximum capacity of a BLK range (mmio
block-data-window(s)), or a PMEM range (DAX-capable persistent memory or
volatile memory), without regard for aliasing. Aliasing, in the
dimm-local address space (DPA), is resolved by metadata on a dimm to
designate which exclusive interface will access the aliased DPA ranges.
Support for the per-dimm metadata/label arrvies is in a subsequent
patch.
The name format of "region" devices is "regionN" where, like dimms, N is
a global ida index assigned at discovery time. This id is not reliable
across reboots nor in the presence of hotplug. Look to attributes of
the region or static id-data of the sub-namespace to generate a
persistent name. However, if the platform configuration does not change
it is reasonable to expect the same region id to be assigned at the next
boot.
"region"s have 2 generic attributes "size", and "mapping"s where:
- size: the BLK accessible capacity or the span of the
system physical address range in the case of PMEM.
- mappingN: a tuple describing a dimm's contribution to the region's
capacity in the format (<nmemX>,<dpa>,<size>). For a PMEM-region
there will be at least one mapping per dimm in the interleave set. For
a BLK-region there is only "mapping0" listing the starting DPA of the
BLK-region and the available DPA capacity of that space (matches "size"
above).
The max number of mappings per "region" is hard coded per the
constraints of sysfs attribute groups. That said the number of mappings
per region should never exceed the maximum number of possible dimms in
the system. If the current number turns out to not be enough then the
"mappings" attribute clarifies how many there are supposed to be. "32
should be enough for anybody...".
Cc: Neil Brown <neilb@suse.de>
Cc: <linux-acpi@vger.kernel.org>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Robert Moore <robert.moore@intel.com>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.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>
2015-06-10 00:13:14 +00:00
|
|
|
struct nd_region *nvdimm_pmem_region_create(struct nvdimm_bus *nvdimm_bus,
|
|
|
|
struct nd_region_desc *ndr_desc);
|
|
|
|
struct nd_region *nvdimm_blk_region_create(struct nvdimm_bus *nvdimm_bus,
|
|
|
|
struct nd_region_desc *ndr_desc);
|
|
|
|
struct nd_region *nvdimm_volatile_region_create(struct nvdimm_bus *nvdimm_bus,
|
|
|
|
struct nd_region_desc *ndr_desc);
|
2015-06-25 08:21:02 +00:00
|
|
|
void *nd_region_provider_data(struct nd_region *nd_region);
|
|
|
|
void *nd_blk_region_provider_data(struct nd_blk_region *ndbr);
|
|
|
|
void nd_blk_region_set_provider_data(struct nd_blk_region *ndbr, void *data);
|
|
|
|
struct nvdimm *nd_blk_region_to_dimm(struct nd_blk_region *ndbr);
|
|
|
|
unsigned int nd_region_acquire_lane(struct nd_region *nd_region);
|
|
|
|
void nd_region_release_lane(struct nd_region *nd_region, unsigned int lane);
|
2015-05-01 17:11:27 +00:00
|
|
|
u64 nd_fletcher64(void *addr, size_t len, bool le);
|
2016-07-08 02:44:50 +00:00
|
|
|
void nvdimm_flush(struct nd_region *nd_region);
|
|
|
|
int nvdimm_has_flush(struct nd_region *nd_region);
|
2015-05-20 02:54:31 +00:00
|
|
|
#endif /* __LIBNVDIMM_H__ */
|