* [PATCH] tools/testing/nvdimm: improve emulation of smart injection
@ 2018-07-30 22:11 Vishal Verma
2018-08-01 0:24 ` Dave Jiang
0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2018-07-30 22:11 UTC (permalink / raw)
To: linux-nvdimm
The emulation for smart injection commands for nfit neglected to check
the smart field validity flags before injecting to that field. This is
required as a way to distinguish un-injection vs. leave-alone.
The emulation was also missing support for un-injection entirely. To add
this support, first, fix the above flags check. Second, use the
'enable' field in the injection command to determine injection vs
un-injection. Third, move the smart initialization struct to be a global
static structure for the nfit_test module. Reference this to get the
smart 'defaults' when un-injecting a smart field.
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
tools/testing/nvdimm/test/nfit.c | 78 ++++++++++++++++++++++++----------------
1 file changed, 47 insertions(+), 31 deletions(-)
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index a012ab765083..cffc2c5a778d 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -142,6 +142,28 @@ static u32 handle[] = {
static unsigned long dimm_fail_cmd_flags[NUM_DCR];
static int dimm_fail_cmd_code[NUM_DCR];
+static const struct nd_intel_smart smart_def = {
+ .flags = ND_INTEL_SMART_HEALTH_VALID
+ | ND_INTEL_SMART_SPARES_VALID
+ | ND_INTEL_SMART_ALARM_VALID
+ | ND_INTEL_SMART_USED_VALID
+ | ND_INTEL_SMART_SHUTDOWN_VALID
+ | ND_INTEL_SMART_MTEMP_VALID
+ | ND_INTEL_SMART_CTEMP_VALID,
+ .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
+ .media_temperature = 23 * 16,
+ .ctrl_temperature = 25 * 16,
+ .pmic_temperature = 40 * 16,
+ .spares = 75,
+ .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
+ | ND_INTEL_SMART_TEMP_TRIP,
+ .ait_status = 1,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ .shutdown_count = 100,
+};
+
struct nfit_test_fw {
enum intel_fw_update_state state;
u32 context;
@@ -752,15 +774,30 @@ static int nfit_test_cmd_smart_inject(
if (buf_len != sizeof(*inj))
return -EINVAL;
- if (inj->mtemp_enable)
- smart->media_temperature = inj->media_temperature;
- if (inj->spare_enable)
- smart->spares = inj->spares;
- if (inj->fatal_enable)
- smart->health = ND_INTEL_SMART_FATAL_HEALTH;
- if (inj->unsafe_shutdown_enable) {
- smart->shutdown_state = 1;
- smart->shutdown_count++;
+ if (inj->flags & ND_INTEL_SMART_INJECT_MTEMP) {
+ if (inj->mtemp_enable)
+ smart->media_temperature = inj->media_temperature;
+ else
+ smart->media_temperature = smart_def.media_temperature;
+ }
+ if (inj->flags & ND_INTEL_SMART_INJECT_SPARE) {
+ if (inj->spare_enable)
+ smart->spares = inj->spares;
+ else
+ smart->spares = smart_def.spares;
+ }
+ if (inj->flags & ND_INTEL_SMART_INJECT_FATAL) {
+ if (inj->fatal_enable)
+ smart->health = ND_INTEL_SMART_FATAL_HEALTH;
+ else
+ smart->health = ND_INTEL_SMART_NON_CRITICAL_HEALTH;
+ }
+ if (inj->flags & ND_INTEL_SMART_INJECT_SHUTDOWN) {
+ if (inj->unsafe_shutdown_enable) {
+ smart->shutdown_state = 1;
+ smart->shutdown_count++;
+ } else
+ smart->shutdown_state = 0;
}
inj->status = 0;
smart_notify(bus_dev, dimm_dev, smart, thresh);
@@ -1317,30 +1354,9 @@ static void smart_init(struct nfit_test *t)
.ctrl_temperature = 30 * 16,
.spares = 5,
};
- const struct nd_intel_smart smart_data = {
- .flags = ND_INTEL_SMART_HEALTH_VALID
- | ND_INTEL_SMART_SPARES_VALID
- | ND_INTEL_SMART_ALARM_VALID
- | ND_INTEL_SMART_USED_VALID
- | ND_INTEL_SMART_SHUTDOWN_VALID
- | ND_INTEL_SMART_MTEMP_VALID
- | ND_INTEL_SMART_CTEMP_VALID,
- .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
- .media_temperature = 23 * 16,
- .ctrl_temperature = 25 * 16,
- .pmic_temperature = 40 * 16,
- .spares = 75,
- .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
- | ND_INTEL_SMART_TEMP_TRIP,
- .ait_status = 1,
- .life_used = 5,
- .shutdown_state = 0,
- .vendor_size = 0,
- .shutdown_count = 100,
- };
for (i = 0; i < t->num_dcr; i++) {
- memcpy(&t->smart[i], &smart_data, sizeof(smart_data));
+ memcpy(&t->smart[i], &smart_def, sizeof(smart_def));
memcpy(&t->smart_threshold[i], &smart_t_data,
sizeof(smart_t_data));
}
--
2.14.4
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/testing/nvdimm: improve emulation of smart injection
2018-07-30 22:11 [PATCH] tools/testing/nvdimm: improve emulation of smart injection Vishal Verma
@ 2018-08-01 0:24 ` Dave Jiang
0 siblings, 0 replies; 2+ messages in thread
From: Dave Jiang @ 2018-08-01 0:24 UTC (permalink / raw)
To: Vishal Verma, linux-nvdimm
On 7/30/2018 3:11 PM, Vishal Verma wrote:
> The emulation for smart injection commands for nfit neglected to check
> the smart field validity flags before injecting to that field. This is
> required as a way to distinguish un-injection vs. leave-alone.
>
> The emulation was also missing support for un-injection entirely. To add
> this support, first, fix the above flags check. Second, use the
> 'enable' field in the injection command to determine injection vs
> un-injection. Third, move the smart initialization struct to be a global
> static structure for the nfit_test module. Reference this to get the
> smart 'defaults' when un-injecting a smart field.
>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
applied
> ---
> tools/testing/nvdimm/test/nfit.c | 78 ++++++++++++++++++++++++----------------
> 1 file changed, 47 insertions(+), 31 deletions(-)
>
> diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
> index a012ab765083..cffc2c5a778d 100644
> --- a/tools/testing/nvdimm/test/nfit.c
> +++ b/tools/testing/nvdimm/test/nfit.c
> @@ -142,6 +142,28 @@ static u32 handle[] = {
> static unsigned long dimm_fail_cmd_flags[NUM_DCR];
> static int dimm_fail_cmd_code[NUM_DCR];
>
> +static const struct nd_intel_smart smart_def = {
> + .flags = ND_INTEL_SMART_HEALTH_VALID
> + | ND_INTEL_SMART_SPARES_VALID
> + | ND_INTEL_SMART_ALARM_VALID
> + | ND_INTEL_SMART_USED_VALID
> + | ND_INTEL_SMART_SHUTDOWN_VALID
> + | ND_INTEL_SMART_MTEMP_VALID
> + | ND_INTEL_SMART_CTEMP_VALID,
> + .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
> + .media_temperature = 23 * 16,
> + .ctrl_temperature = 25 * 16,
> + .pmic_temperature = 40 * 16,
> + .spares = 75,
> + .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
> + | ND_INTEL_SMART_TEMP_TRIP,
> + .ait_status = 1,
> + .life_used = 5,
> + .shutdown_state = 0,
> + .vendor_size = 0,
> + .shutdown_count = 100,
> +};
> +
> struct nfit_test_fw {
> enum intel_fw_update_state state;
> u32 context;
> @@ -752,15 +774,30 @@ static int nfit_test_cmd_smart_inject(
> if (buf_len != sizeof(*inj))
> return -EINVAL;
>
> - if (inj->mtemp_enable)
> - smart->media_temperature = inj->media_temperature;
> - if (inj->spare_enable)
> - smart->spares = inj->spares;
> - if (inj->fatal_enable)
> - smart->health = ND_INTEL_SMART_FATAL_HEALTH;
> - if (inj->unsafe_shutdown_enable) {
> - smart->shutdown_state = 1;
> - smart->shutdown_count++;
> + if (inj->flags & ND_INTEL_SMART_INJECT_MTEMP) {
> + if (inj->mtemp_enable)
> + smart->media_temperature = inj->media_temperature;
> + else
> + smart->media_temperature = smart_def.media_temperature;
> + }
> + if (inj->flags & ND_INTEL_SMART_INJECT_SPARE) {
> + if (inj->spare_enable)
> + smart->spares = inj->spares;
> + else
> + smart->spares = smart_def.spares;
> + }
> + if (inj->flags & ND_INTEL_SMART_INJECT_FATAL) {
> + if (inj->fatal_enable)
> + smart->health = ND_INTEL_SMART_FATAL_HEALTH;
> + else
> + smart->health = ND_INTEL_SMART_NON_CRITICAL_HEALTH;
> + }
> + if (inj->flags & ND_INTEL_SMART_INJECT_SHUTDOWN) {
> + if (inj->unsafe_shutdown_enable) {
> + smart->shutdown_state = 1;
> + smart->shutdown_count++;
> + } else
> + smart->shutdown_state = 0;
> }
> inj->status = 0;
> smart_notify(bus_dev, dimm_dev, smart, thresh);
> @@ -1317,30 +1354,9 @@ static void smart_init(struct nfit_test *t)
> .ctrl_temperature = 30 * 16,
> .spares = 5,
> };
> - const struct nd_intel_smart smart_data = {
> - .flags = ND_INTEL_SMART_HEALTH_VALID
> - | ND_INTEL_SMART_SPARES_VALID
> - | ND_INTEL_SMART_ALARM_VALID
> - | ND_INTEL_SMART_USED_VALID
> - | ND_INTEL_SMART_SHUTDOWN_VALID
> - | ND_INTEL_SMART_MTEMP_VALID
> - | ND_INTEL_SMART_CTEMP_VALID,
> - .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
> - .media_temperature = 23 * 16,
> - .ctrl_temperature = 25 * 16,
> - .pmic_temperature = 40 * 16,
> - .spares = 75,
> - .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
> - | ND_INTEL_SMART_TEMP_TRIP,
> - .ait_status = 1,
> - .life_used = 5,
> - .shutdown_state = 0,
> - .vendor_size = 0,
> - .shutdown_count = 100,
> - };
>
> for (i = 0; i < t->num_dcr; i++) {
> - memcpy(&t->smart[i], &smart_data, sizeof(smart_data));
> + memcpy(&t->smart[i], &smart_def, sizeof(smart_def));
> memcpy(&t->smart_threshold[i], &smart_t_data,
> sizeof(smart_t_data));
> }
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-01 0:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-30 22:11 [PATCH] tools/testing/nvdimm: improve emulation of smart injection Vishal Verma
2018-08-01 0:24 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).