Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <keith.busch@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

+16 -3
+5 -2
drivers/acpi/nfit/core.c
··· 1721 1721 return false; 1722 1722 } 1723 1723 1724 - static void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem) 1724 + __weak void nfit_intel_shutdown_status(struct nfit_mem *nfit_mem) 1725 1725 { 1726 1726 struct nd_intel_smart smart = { 0 }; 1727 1727 union acpi_object in_buf = { ··· 1785 1785 nfit_mem->dsm_mask = acpi_desc->dimm_cmd_force_en; 1786 1786 nfit_mem->family = NVDIMM_FAMILY_INTEL; 1787 1787 adev = to_acpi_dev(acpi_desc); 1788 - if (!adev) 1788 + if (!adev) { 1789 + /* unit test case */ 1790 + populate_shutdown_status(nfit_mem); 1789 1791 return 0; 1792 + } 1790 1793 1791 1794 adev_dimm = acpi_find_child_device(adev, device_handle, false); 1792 1795 nfit_mem->adev = adev_dimm;
+1
tools/testing/nvdimm/Kbuild
··· 22 22 ACPI_SRC := $(DRIVERS)/acpi/nfit 23 23 DAX_SRC := $(DRIVERS)/dax 24 24 ccflags-y := -I$(src)/$(NVDIMM_SRC)/ 25 + ccflags-y += -I$(src)/$(ACPI_SRC)/ 25 26 26 27 obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o 27 28 obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
+8
tools/testing/nvdimm/acpi_nfit_test.c
··· 4 4 #include <linux/module.h> 5 5 #include <linux/printk.h> 6 6 #include "watermark.h" 7 + #include <nfit.h> 7 8 8 9 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 + }
+2 -1
tools/testing/nvdimm/test/nfit.c
··· 149 149 | ND_INTEL_SMART_ALARM_VALID 150 150 | ND_INTEL_SMART_USED_VALID 151 151 | ND_INTEL_SMART_SHUTDOWN_VALID 152 + | ND_INTEL_SMART_SHUTDOWN_COUNT_VALID 152 153 | ND_INTEL_SMART_MTEMP_VALID 153 154 | ND_INTEL_SMART_CTEMP_VALID, 154 155 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH, ··· 162 161 .ait_status = 1, 163 162 .life_used = 5, 164 163 .shutdown_state = 0, 164 + .shutdown_count = 42, 165 165 .vendor_size = 0, 166 - .shutdown_count = 100, 167 166 }; 168 167 169 168 struct nfit_test_fw {