Commit f1101766 authored by Dan Williams's avatar Dan Williams

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: default avatarKeith Busch <keith.busch@intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 0ead1118
......@@ -1721,7 +1721,7 @@ static bool acpi_nvdimm_has_method(struct acpi_device *adev, char *method)
return false;
}
static void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
__weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
{
struct nd_intel_smart smart = { 0 };
union acpi_object in_buf = {
......@@ -1785,8 +1785,11 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc,
nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en;
nfit_mem->family = NVDIMM_FAMILY_INTEL;
adev = to_acpi_dev(acpi_desc);
if (!adev)
if (!adev) {
/* unit test case */
populate_shutdown_status(nfit_mem);
return 0;
}
adev_dimm = acpi_find_child_device(adev, device_handle, false);
nfit_mem->adev = adev_dimm;
......
......@@ -22,6 +22,7 @@ NVDIMM_SRC := $(DRIVERS)/nvdimm
ACPI_SRC := $(DRIVERS)/acpi/nfit
DAX_SRC := $(DRIVERS)/dax
ccflags-y := -I$(src)/$(NVDIMM_SRC)/
ccflags-y += -I$(src)/$(ACPI_SRC)/
obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
......
......@@ -4,5 +4,13 @@
#include <linux/module.h>
#include <linux/printk.h>
#include "watermark.h"
#include <nfit.h>
nfit_test_watermark(acpi_nfit);
/* strong / override definition of nfit_intel_shutdown_status */
void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem)
{
set_bit(NFIT_MEM_DIRTY_COUNT, &nfit_mem->flags);
nfit_mem->dirty_shutdown = 42;
}
......@@ -149,6 +149,7 @@ static const struct nd_intel_smart smart_def = {
| ND_INTEL_SMART_ALARM_VALID
| ND_INTEL_SMART_USED_VALID
| ND_INTEL_SMART_SHUTDOWN_VALID
| ND_INTEL_SMART_SHUTDOWN_COUNT_VALID
| ND_INTEL_SMART_MTEMP_VALID
| ND_INTEL_SMART_CTEMP_VALID,
.health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
......@@ -161,8 +162,8 @@ static const struct nd_intel_smart smart_def = {
.ait_status = 1,
.life_used = 5,
.shutdown_state = 0,
.shutdown_count = 42,
.vendor_size = 0,
.shutdown_count = 100,
};
struct nfit_test_fw {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment