Skip to content

Commit fe9a552

Browse files
committed
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". Commit 96c3a23 "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: 96c3a23 ("libnvdimm: expose platform persistence attr...") Reviewed-by: Dave Jiang <[email protected]> Cc: "Rafael J. Wysocki" <[email protected]> Cc: Ross Zwisler <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 896196d commit fe9a552

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

drivers/acpi/nfit/core.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,10 +2675,14 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc,
26752675
else
26762676
ndr_desc->numa_node = NUMA_NO_NODE;
26772677

2678-
if(acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH)
2678+
/*
2679+
* Persistence domain bits are hierarchical, if
2680+
* ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then
2681+
* ACPI_NFIT_CAPABILITY_MEM_FLUSH is implied.
2682+
*/
2683+
if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH)
26792684
set_bit(ND_REGION_PERSIST_CACHE, &ndr_desc->flags);
2680-
2681-
if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH)
2685+
else if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH)
26822686
set_bit(ND_REGION_PERSIST_MEMCTRL, &ndr_desc->flags);
26832687

26842688
list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) {

drivers/nvdimm/region_devs.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,13 @@ static ssize_t persistence_domain_show(struct device *dev,
532532
struct device_attribute *attr, char *buf)
533533
{
534534
struct nd_region *nd_region = to_nd_region(dev);
535-
unsigned long flags = nd_region->flags;
536535

537-
return sprintf(buf, "%s%s\n",
538-
flags & BIT(ND_REGION_PERSIST_CACHE) ? "cpu_cache " : "",
539-
flags & BIT(ND_REGION_PERSIST_MEMCTRL) ? "memory_controller " : "");
536+
if (test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags))
537+
return sprintf(buf, "cpu_cache\n");
538+
else if (test_bit(ND_REGION_PERSIST_MEMCTRL, &nd_region->flags))
539+
return sprintf(buf, "memory_controller\n");
540+
else
541+
return sprintf(buf, "\n");
540542
}
541543
static DEVICE_ATTR_RO(persistence_domain);
542544

0 commit comments

Comments
 (0)