libnvdimm, nfit: fix persistence domain reporting
The persistence domain is a point in the platform where once writes reach that destination the platform claims it will make them persistent relative to power loss. In the ACPI NFIT this is currently communicated as 2 bits in the "NFIT - Platform Capabilities Structure". The bits comprise a hierarchy, i.e. bit0 "CPU Cache Flush to NVDIMM Durability on Power Loss Capable" implies bit1 "Memory Controller Flush to NVDIMM Durability on Power Loss Capable". Commit96c3a23905
"libnvdimm: expose platform persistence attr..." shows the persistence domain as flags, but it's really an enumerated hierarchy. Fix this newly introduced user ABI to show the closest available persistence domain before userspace develops dependencies on seeing, or needing to develop code to tolerate, the raw NFIT flags communicated through the libnvdimm-generic region attribute. Fixes:96c3a23905
("libnvdimm: expose platform persistence attr...") Reviewed-by: Dave Jiang <dave.jiang@intel.com> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net> Cc: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
896196dc4e
commit
fe9a552e71
|
@ -2675,10 +2675,14 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
|
||||||
else
|
else
|
||||||
ndr_desc->numa_node = NUMA_NO_NODE;
|
ndr_desc->numa_node = NUMA_NO_NODE;
|
||||||
|
|
||||||
if(acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH)
|
/*
|
||||||
|
* Persistence domain bits are hierarchical, if
|
||||||
|
* ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
|
||||||
|
* ACPI_NFIT_CAPABILITY_MEM_FLUSH is implied.
|
||||||
|
*/
|
||||||
|
if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH)
|
||||||
set_bit(ND_REGION_PERSIST_CACHE, &ndr_desc->flags);
|
set_bit(ND_REGION_PERSIST_CACHE, &ndr_desc->flags);
|
||||||
|
else if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH)
|
||||||
if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH)
|
|
||||||
set_bit(ND_REGION_PERSIST_MEMCTRL, &ndr_desc->flags);
|
set_bit(ND_REGION_PERSIST_MEMCTRL, &ndr_desc->flags);
|
||||||
|
|
||||||
list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
|
list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {
|
||||||
|
|
|
@ -532,11 +532,13 @@ static ssize_t persistence_domain_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct nd_region *nd_region = to_nd_region(dev);
|
struct nd_region *nd_region = to_nd_region(dev);
|
||||||
unsigned long flags = nd_region->flags;
|
|
||||||
|
|
||||||
return sprintf(buf, "%s%s\n",
|
if (test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags))
|
||||||
flags & BIT(ND_REGION_PERSIST_CACHE) ? "cpu_cache " : "",
|
return sprintf(buf, "cpu_cache\n");
|
||||||
flags & BIT(ND_REGION_PERSIST_MEMCTRL) ? "memory_controller " : "");
|
else if (test_bit(ND_REGION_PERSIST_MEMCTRL, &nd_region->flags))
|
||||||
|
return sprintf(buf, "memory_controller\n");
|
||||||
|
else
|
||||||
|
return sprintf(buf, "\n");
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(persistence_domain);
|
static DEVICE_ATTR_RO(persistence_domain);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue