Skip to content

Commit 674d8bd

Browse files
davejiangdjbw
authored andcommitted
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 <[email protected]> Reviewed-by: Vishal Verma <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent bfbaa95 commit 674d8bd

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tools/testing/nvdimm/test/nfit.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,35 @@ static int nfit_test_cmd_ars_inject_status(struct nfit_test *t,
821821
return 0;
822822
}
823823

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+
824853
static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
825854
{
826855
int i;
@@ -872,6 +901,9 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
872901
return i;
873902

874903
switch (func) {
904+
case ND_INTEL_ENABLE_LSS_STATUS:
905+
return nd_intel_test_cmd_set_lss_status(t,
906+
buf, buf_len);
875907
case ND_INTEL_FW_GET_INFO:
876908
return nd_intel_test_get_fw_info(t, buf,
877909
buf_len, i - t->dcr_idx);
@@ -1997,6 +2029,7 @@ static void nfit_test0_setup(struct nfit_test *t)
19972029
set_bit(ND_INTEL_FW_SEND_DATA, &acpi_desc->dimm_cmd_force_en);
19982030
set_bit(ND_INTEL_FW_FINISH_UPDATE, &acpi_desc->dimm_cmd_force_en);
19992031
set_bit(ND_INTEL_FW_FINISH_QUERY, &acpi_desc->dimm_cmd_force_en);
2032+
set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en);
20002033
}
20012034

20022035
static void nfit_test1_setup(struct nfit_test *t)
@@ -2094,6 +2127,7 @@ static void nfit_test1_setup(struct nfit_test *t)
20942127
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
20952128
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
20962129
set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en);
2130+
set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en);
20972131
}
20982132

20992133
static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,

tools/testing/nvdimm/test/nfit_test.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct nd_cmd_ars_err_inj_stat {
8686

8787
#define ND_INTEL_SMART 1
8888
#define ND_INTEL_SMART_THRESHOLD 2
89+
#define ND_INTEL_ENABLE_LSS_STATUS 10
8990
#define ND_INTEL_FW_GET_INFO 12
9091
#define ND_INTEL_FW_START_UPDATE 13
9192
#define ND_INTEL_FW_SEND_DATA 14
@@ -212,6 +213,11 @@ struct nd_intel_fw_finish_query {
212213
__u64 updated_fw_rev;
213214
} __packed;
214215

216+
struct nd_intel_lss {
217+
__u8 enable;
218+
__u32 status;
219+
} __packed;
220+
215221
union acpi_object;
216222
typedef void *acpi_handle;
217223

0 commit comments

Comments
 (0)