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

libnvdimm/nfit_test: adding support for unit testing enable LSS status

Adding support code to simulate the enabling of LSS status in support of
the Intel DSM v1.6 Function Index 10: Enable Latch System Shutdown Status.
This is only for testing of libndctl support for LSS enable. The actual
functionality requires a reboot and therefore is not simulated. The enable
value is not recorded in nfit_test since there's no DSM to actually query
the current status of the LSS enable.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Dave Jiang and committed by
Dan Williams
674d8bde bfbaa952

+40
+34
tools/testing/nvdimm/test/nfit.c
··· 821 821 return 0; 822 822 } 823 823 824 + static int nd_intel_test_cmd_set_lss_status(struct nfit_test *t, 825 + struct nd_intel_lss *nd_cmd, unsigned int buf_len) 826 + { 827 + struct device *dev = &t->pdev.dev; 828 + 829 + if (buf_len < sizeof(*nd_cmd)) 830 + return -EINVAL; 831 + 832 + switch (nd_cmd->enable) { 833 + case 0: 834 + nd_cmd->status = 0; 835 + dev_dbg(dev, "%s: Latch System Shutdown Status disabled\n", 836 + __func__); 837 + break; 838 + case 1: 839 + nd_cmd->status = 0; 840 + dev_dbg(dev, "%s: Latch System Shutdown Status enabled\n", 841 + __func__); 842 + break; 843 + default: 844 + dev_warn(dev, "Unknown enable value: %#x\n", nd_cmd->enable); 845 + nd_cmd->status = 0x3; 846 + break; 847 + } 848 + 849 + 850 + return 0; 851 + } 852 + 824 853 static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func) 825 854 { 826 855 int i; ··· 901 872 return i; 902 873 903 874 switch (func) { 875 + case ND_INTEL_ENABLE_LSS_STATUS: 876 + return nd_intel_test_cmd_set_lss_status(t, 877 + buf, buf_len); 904 878 case ND_INTEL_FW_GET_INFO: 905 879 return nd_intel_test_get_fw_info(t, buf, 906 880 buf_len, i - t->dcr_idx); ··· 2029 1997 set_bit(ND_INTEL_FW_SEND_DATA, &acpi_desc->dimm_cmd_force_en); 2030 1998 set_bit(ND_INTEL_FW_FINISH_UPDATE, &acpi_desc->dimm_cmd_force_en); 2031 1999 set_bit(ND_INTEL_FW_FINISH_QUERY, &acpi_desc->dimm_cmd_force_en); 2000 + set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en); 2032 2001 } 2033 2002 2034 2003 static void nfit_test1_setup(struct nfit_test *t) ··· 2127 2094 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); 2128 2095 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); 2129 2096 set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); 2097 + set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en); 2130 2098 } 2131 2099 2132 2100 static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,
+6
tools/testing/nvdimm/test/nfit_test.h
··· 86 86 87 87 #define ND_INTEL_SMART 1 88 88 #define ND_INTEL_SMART_THRESHOLD 2 89 + #define ND_INTEL_ENABLE_LSS_STATUS 10 89 90 #define ND_INTEL_FW_GET_INFO 12 90 91 #define ND_INTEL_FW_START_UPDATE 13 91 92 #define ND_INTEL_FW_SEND_DATA 14 ··· 211 210 __u32 context; 212 211 __u32 status; 213 212 __u64 updated_fw_rev; 213 + } __packed; 214 + 215 + struct nd_intel_lss { 216 + __u8 enable; 217 + __u32 status; 214 218 } __packed; 215 219 216 220 union acpi_object;