Skip to content

Commit f110176

Browse files
committed
tools/testing/nvdimm: Populate dirty shutdown data
Allow the unit tests to verify the retrieval of the dirty shutdown count via smart commands, and allow the driver-load-time retrieval of the smart health payload to be simulated by nfit_test. Reviewed-by: Keith Busch <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent 0ead111 commit f110176

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

drivers/acpi/nfit/core.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ static bool acpi_nvdimm_has_method(struct acpi_device *adev, char *method)
17211721
return false;
17221722
}
17231723

1724-
static void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
1724+
__weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
17251725
{
17261726
struct nd_intel_smart smart = { 0 };
17271727
union acpi_object in_buf = {
@@ -1785,8 +1785,11 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
17851785
nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en;
17861786
nfit_mem->family = NVDIMM_FAMILY_INTEL;
17871787
adev = to_acpi_dev(acpi_desc);
1788-
if (!adev)
1788+
if (!adev) {
1789+
/* unit test case */
1790+
populate_shutdown_status(nfit_mem);
17891791
return 0;
1792+
}
17901793

17911794
adev_dimm = acpi_find_child_device(adev, device_handle, false);
17921795
nfit_mem->adev = adev_dimm;

tools/testing/nvdimm/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ NVDIMM_SRC := $(DRIVERS)/nvdimm
2222
ACPI_SRC := $(DRIVERS)/acpi/nfit
2323
DAX_SRC := $(DRIVERS)/dax
2424
ccflags-y := -I$(src)/$(NVDIMM_SRC)/
25+
ccflags-y += -I$(src)/$(ACPI_SRC)/
2526

2627
obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
2728
obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o

tools/testing/nvdimm/acpi_nfit_test.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@
44
#include <linux/module.h>
55
#include <linux/printk.h>
66
#include "watermark.h"
7+
#include <nfit.h>
78

89
nfit_test_watermark(acpi_nfit);
10+
11+
/* strong / override definition of nfit_intel_shutdown_status */
12+
void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
13+
{
14+
set_bit(NFIT_MEM_DIRTY_COUNT, &nfit_mem->flags);
15+
nfit_mem->dirty_shutdown = 42;
16+
}

tools/testing/nvdimm/test/nfit.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ static const struct nd_intel_smart smart_def = {
149149
| ND_INTEL_SMART_ALARM_VALID
150150
| ND_INTEL_SMART_USED_VALID
151151
| ND_INTEL_SMART_SHUTDOWN_VALID
152+
| ND_INTEL_SMART_SHUTDOWN_COUNT_VALID
152153
| ND_INTEL_SMART_MTEMP_VALID
153154
| ND_INTEL_SMART_CTEMP_VALID,
154155
.health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
@@ -161,8 +162,8 @@ static const struct nd_intel_smart smart_def = {
161162
.ait_status = 1,
162163
.life_used = 5,
163164
.shutdown_state = 0,
165+
.shutdown_count = 42,
164166
.vendor_size = 0,
165-
.shutdown_count = 100,
166167
};
167168

168169
struct nfit_test_fw {

0 commit comments

Comments
 (0)