summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorVishal Verma <vishal.l.verma@intel.com>2018-02-08 16:24:04 -0500
committerDan Williams <dan.j.williams@intel.com>2018-04-05 23:11:19 -0400
commit4cf260fc409c73f6e40b3e8061a0cb925703d7ee (patch)
tree742ca7c76d5fc9ef586d0024cfd0e50d87be3704 /tools
parent14c73f997a5e060c6887a80c143021a58975c92a (diff)
libnvdimm, testing: Add emulation for smart injection commands
Add support for the smart injection command in the nvdimm unit test framework. This allows for directly injecting to smart fields and flags that are supported in the injection command. If the injected values are past the threshold, then an acpi notification is also triggered. Cc: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/nvdimm/test/nfit.c38
-rw-r--r--tools/testing/nvdimm/test/nfit_test.h16
2 files changed, 53 insertions, 1 deletions
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index d785235ba04e..e83c24625fe4 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -711,7 +711,9 @@ static void smart_notify(struct device *bus_dev,
711 >= thresh->media_temperature) 711 >= thresh->media_temperature)
712 || ((thresh->alarm_control & ND_INTEL_SMART_CTEMP_TRIP) 712 || ((thresh->alarm_control & ND_INTEL_SMART_CTEMP_TRIP)
713 && smart->ctrl_temperature 713 && smart->ctrl_temperature
714 >= thresh->ctrl_temperature)) { 714 >= thresh->ctrl_temperature)
715 || (smart->health != ND_INTEL_SMART_NON_CRITICAL_HEALTH)
716 || (smart->shutdown_state != 0)) {
715 device_lock(bus_dev); 717 device_lock(bus_dev);
716 __acpi_nvdimm_notify(dimm_dev, 0x81); 718 __acpi_nvdimm_notify(dimm_dev, 0x81);
717 device_unlock(bus_dev); 719 device_unlock(bus_dev);
@@ -737,6 +739,32 @@ static int nfit_test_cmd_smart_set_threshold(
737 return 0; 739 return 0;
738} 740}
739 741
742static int nfit_test_cmd_smart_inject(
743 struct nd_intel_smart_inject *inj,
744 unsigned int buf_len,
745 struct nd_intel_smart_threshold *thresh,
746 struct nd_intel_smart *smart,
747 struct device *bus_dev, struct device *dimm_dev)
748{
749 if (buf_len != sizeof(*inj))
750 return -EINVAL;
751
752 if (inj->mtemp_enable)
753 smart->media_temperature = inj->media_temperature;
754 if (inj->spare_enable)
755 smart->spares = inj->spares;
756 if (inj->fatal_enable)
757 smart->health = ND_INTEL_SMART_FATAL_HEALTH;
758 if (inj->unsafe_shutdown_enable) {
759 smart->shutdown_state = 1;
760 smart->shutdown_count++;
761 }
762 inj->status = 0;
763 smart_notify(bus_dev, dimm_dev, smart, thresh);
764
765 return 0;
766}
767
740static void uc_error_notify(struct work_struct *work) 768static void uc_error_notify(struct work_struct *work)
741{ 769{
742 struct nfit_test *t = container_of(work, typeof(*t), work); 770 struct nfit_test *t = container_of(work, typeof(*t), work);
@@ -937,6 +965,13 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
937 t->dcr_idx], 965 t->dcr_idx],
938 &t->smart[i - t->dcr_idx], 966 &t->smart[i - t->dcr_idx],
939 &t->pdev.dev, t->dimm_dev[i]); 967 &t->pdev.dev, t->dimm_dev[i]);
968 case ND_INTEL_SMART_INJECT:
969 return nfit_test_cmd_smart_inject(buf,
970 buf_len,
971 &t->smart_threshold[i -
972 t->dcr_idx],
973 &t->smart[i - t->dcr_idx],
974 &t->pdev.dev, t->dimm_dev[i]);
940 default: 975 default:
941 return -ENOTTY; 976 return -ENOTTY;
942 } 977 }
@@ -2066,6 +2101,7 @@ static void nfit_test0_setup(struct nfit_test *t)
2066 set_bit(ND_INTEL_SMART, &acpi_desc->dimm_cmd_force_en); 2101 set_bit(ND_INTEL_SMART, &acpi_desc->dimm_cmd_force_en);
2067 set_bit(ND_INTEL_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en); 2102 set_bit(ND_INTEL_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
2068 set_bit(ND_INTEL_SMART_SET_THRESHOLD, &acpi_desc->dimm_cmd_force_en); 2103 set_bit(ND_INTEL_SMART_SET_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
2104 set_bit(ND_INTEL_SMART_INJECT, &acpi_desc->dimm_cmd_force_en);
2069 set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_cmd_force_en); 2105 set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_cmd_force_en);
2070 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); 2106 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
2071 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); 2107 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index 428344519cdf..33752e06ff8d 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -93,6 +93,7 @@ struct nd_cmd_ars_err_inj_stat {
93#define ND_INTEL_FW_FINISH_UPDATE 15 93#define ND_INTEL_FW_FINISH_UPDATE 15
94#define ND_INTEL_FW_FINISH_QUERY 16 94#define ND_INTEL_FW_FINISH_QUERY 16
95#define ND_INTEL_SMART_SET_THRESHOLD 17 95#define ND_INTEL_SMART_SET_THRESHOLD 17
96#define ND_INTEL_SMART_INJECT 18
96 97
97#define ND_INTEL_SMART_HEALTH_VALID (1 << 0) 98#define ND_INTEL_SMART_HEALTH_VALID (1 << 0)
98#define ND_INTEL_SMART_SPARES_VALID (1 << 1) 99#define ND_INTEL_SMART_SPARES_VALID (1 << 1)
@@ -111,6 +112,10 @@ struct nd_cmd_ars_err_inj_stat {
111#define ND_INTEL_SMART_NON_CRITICAL_HEALTH (1 << 0) 112#define ND_INTEL_SMART_NON_CRITICAL_HEALTH (1 << 0)
112#define ND_INTEL_SMART_CRITICAL_HEALTH (1 << 1) 113#define ND_INTEL_SMART_CRITICAL_HEALTH (1 << 1)
113#define ND_INTEL_SMART_FATAL_HEALTH (1 << 2) 114#define ND_INTEL_SMART_FATAL_HEALTH (1 << 2)
115#define ND_INTEL_SMART_INJECT_MTEMP (1 << 0)
116#define ND_INTEL_SMART_INJECT_SPARE (1 << 1)
117#define ND_INTEL_SMART_INJECT_FATAL (1 << 2)
118#define ND_INTEL_SMART_INJECT_SHUTDOWN (1 << 3)
114 119
115struct nd_intel_smart { 120struct nd_intel_smart {
116 __u32 status; 121 __u32 status;
@@ -158,6 +163,17 @@ struct nd_intel_smart_set_threshold {
158 __u32 status; 163 __u32 status;
159} __packed; 164} __packed;
160 165
166struct nd_intel_smart_inject {
167 __u64 flags;
168 __u8 mtemp_enable;
169 __u16 media_temperature;
170 __u8 spare_enable;
171 __u8 spares;
172 __u8 fatal_enable;
173 __u8 unsafe_shutdown_enable;
174 __u32 status;
175} __packed;
176
161#define INTEL_FW_STORAGE_SIZE 0x100000 177#define INTEL_FW_STORAGE_SIZE 0x100000
162#define INTEL_FW_MAX_SEND_LEN 0xFFEC 178#define INTEL_FW_MAX_SEND_LEN 0xFFEC
163#define INTEL_FW_QUERY_INTERVAL 250000 179#define INTEL_FW_QUERY_INTERVAL 250000