Skip to content

Commit 50f558a

Browse files
santoshsdjbw
authored andcommitted
ndtest: Add papr health related flags
sysfs attibutes to show health related flags are added. Signed-off-by: Santosh Sivaraj <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 14ccef1 commit 50f558a

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

tools/testing/nvdimm/test/ndtest.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ static struct ndtest_dimm dimm_group2[] = {
8686
.uuid_str = "ca0817e2-b618-11ea-9db3-507b9ddc0f72",
8787
.physical_id = 0,
8888
.num_formats = 1,
89+
.flags = PAPR_PMEM_UNARMED | PAPR_PMEM_EMPTY |
90+
PAPR_PMEM_SAVE_FAILED | PAPR_PMEM_SHUTDOWN_DIRTY |
91+
PAPR_PMEM_HEALTH_FATAL,
8992
},
9093
};
9194

@@ -789,6 +792,40 @@ static umode_t ndtest_nvdimm_attr_visible(struct kobject *kobj,
789792
return a->mode;
790793
}
791794

795+
static ssize_t flags_show(struct device *dev,
796+
struct device_attribute *attr, char *buf)
797+
{
798+
struct nvdimm *nvdimm = to_nvdimm(dev);
799+
struct ndtest_dimm *dimm = nvdimm_provider_data(nvdimm);
800+
struct seq_buf s;
801+
u64 flags;
802+
803+
flags = dimm->flags;
804+
805+
seq_buf_init(&s, buf, PAGE_SIZE);
806+
if (flags & PAPR_PMEM_UNARMED_MASK)
807+
seq_buf_printf(&s, "not_armed ");
808+
809+
if (flags & PAPR_PMEM_BAD_SHUTDOWN_MASK)
810+
seq_buf_printf(&s, "flush_fail ");
811+
812+
if (flags & PAPR_PMEM_BAD_RESTORE_MASK)
813+
seq_buf_printf(&s, "restore_fail ");
814+
815+
if (flags & PAPR_PMEM_SAVE_MASK)
816+
seq_buf_printf(&s, "save_fail ");
817+
818+
if (flags & PAPR_PMEM_SMART_EVENT_MASK)
819+
seq_buf_printf(&s, "smart_notify ");
820+
821+
822+
if (seq_buf_used(&s))
823+
seq_buf_printf(&s, "\n");
824+
825+
return seq_buf_used(&s);
826+
}
827+
static DEVICE_ATTR_RO(flags);
828+
792829
static struct attribute *ndtest_nvdimm_attributes[] = {
793830
&dev_attr_nvdimm_show_handle.attr,
794831
&dev_attr_vendor.attr,
@@ -799,6 +836,7 @@ static struct attribute *ndtest_nvdimm_attributes[] = {
799836
&dev_attr_formats.attr,
800837
&dev_attr_format.attr,
801838
&dev_attr_format1.attr,
839+
&dev_attr_flags.attr,
802840
NULL,
803841
};
804842

@@ -824,6 +862,9 @@ static int ndtest_dimm_register(struct ndtest_priv *priv,
824862
set_bit(NDD_LABELING, &dimm_flags);
825863
}
826864

865+
if (dimm->flags & PAPR_PMEM_UNARMED_MASK)
866+
set_bit(NDD_UNARMED, &dimm_flags);
867+
827868
dimm->nvdimm = nvdimm_create(priv->bus, dimm,
828869
ndtest_nvdimm_attribute_groups, dimm_flags,
829870
NDTEST_SCM_DIMM_CMD_MASK, 0, NULL);

tools/testing/nvdimm/test/ndtest.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@
55
#include <linux/platform_device.h>
66
#include <linux/libnvdimm.h>
77

8+
/* SCM device is unable to persist memory contents */
9+
#define PAPR_PMEM_UNARMED (1ULL << (63 - 0))
10+
/* SCM device failed to persist memory contents */
11+
#define PAPR_PMEM_SHUTDOWN_DIRTY (1ULL << (63 - 1))
12+
/* SCM device contents are not persisted from previous IPL */
13+
#define PAPR_PMEM_EMPTY (1ULL << (63 - 3))
14+
#define PAPR_PMEM_HEALTH_CRITICAL (1ULL << (63 - 4))
15+
/* SCM device will be garded off next IPL due to failure */
16+
#define PAPR_PMEM_HEALTH_FATAL (1ULL << (63 - 5))
17+
/* SCM contents cannot persist due to current platform health status */
18+
#define PAPR_PMEM_HEALTH_UNHEALTHY (1ULL << (63 - 6))
19+
20+
/* Bits status indicators for health bitmap indicating unarmed dimm */
21+
#define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED | \
22+
PAPR_PMEM_HEALTH_UNHEALTHY)
23+
24+
#define PAPR_PMEM_SAVE_FAILED (1ULL << (63 - 10))
25+
26+
/* Bits status indicators for health bitmap indicating unflushed dimm */
27+
#define PAPR_PMEM_BAD_SHUTDOWN_MASK (PAPR_PMEM_SHUTDOWN_DIRTY)
28+
29+
/* Bits status indicators for health bitmap indicating unrestored dimm */
30+
#define PAPR_PMEM_BAD_RESTORE_MASK (PAPR_PMEM_EMPTY)
31+
32+
/* Bit status indicators for smart event notification */
33+
#define PAPR_PMEM_SMART_EVENT_MASK (PAPR_PMEM_HEALTH_CRITICAL | \
34+
PAPR_PMEM_HEALTH_FATAL | \
35+
PAPR_PMEM_HEALTH_UNHEALTHY)
36+
37+
#define PAPR_PMEM_SAVE_MASK (PAPR_PMEM_SAVE_FAILED)
38+
839
struct ndtest_config;
940

1041
struct ndtest_priv {

0 commit comments

Comments
 (0)