aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 13:41:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 13:41:33 -0500
commit3ff1b28caaff1d66d2be7e6eb7c56f78e9046fbb (patch)
tree32d75a6db7f4985d37a9cfb7f1a1270963cfa404 /tools
parent105cf3c8c6264dce4bcdab877feb8037bc4109b1 (diff)
parentee95f4059a833839bf52972191b2d4c3d3cec552 (diff)
Merge tag 'libnvdimm-for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm updates from Ross Zwisler: - Require struct page by default for filesystem DAX to remove a number of surprising failure cases. This includes failures with direct I/O, gdb and fork(2). - Add support for the new Platform Capabilities Structure added to the NFIT in ACPI 6.2a. This new table tells us whether the platform supports flushing of CPU and memory controller caches on unexpected power loss events. - Revamp vmem_altmap and dev_pagemap handling to clean up code and better support future future PCI P2P uses. - Deprecate the ND_IOCTL_SMART_THRESHOLD command whose payload has become out-of-sync with recent versions of the NVDIMM_FAMILY_INTEL spec, and instead rely on the generic ND_CMD_CALL approach used by the two other IOCTL families, NVDIMM_FAMILY_{HPE,MSFT}. - Enhance nfit_test so we can test some of the new things added in version 1.6 of the DSM specification. This includes testing firmware download and simulating the Last Shutdown State (LSS) status. * tag 'libnvdimm-for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: (37 commits) libnvdimm, namespace: remove redundant initialization of 'nd_mapping' acpi, nfit: fix register dimm error handling libnvdimm, namespace: make min namespace size 4K tools/testing/nvdimm: force nfit_test to depend on instrumented modules libnvdimm/nfit_test: adding support for unit testing enable LSS status libnvdimm/nfit_test: add firmware download emulation nfit-test: Add platform cap support from ACPI 6.2a to test libnvdimm: expose platform persistence attribute for nd_region acpi: nfit: add persistent memory control flag for nd_region acpi: nfit: Add support for detect platform CPU cache flush on power loss device-dax: Fix trailing semicolon libnvdimm, btt: fix uninitialized err_lock dax: require 'struct page' by default for filesystem dax ext2: auto disable dax instead of failing mount ext4: auto disable dax instead of failing mount mm, dax: introduce pfn_t_special() mm: Fix devm_memremap_pages() collision handling mm: Fix memory size alignment in devm_memremap_pages_release() memremap: merge find_dev_pagemap into get_dev_pagemap memremap: change devm_memremap_pages interface to use struct dev_pagemap ...
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/nvdimm/Kbuild4
-rw-r--r--tools/testing/nvdimm/acpi_nfit_test.c8
-rw-r--r--tools/testing/nvdimm/device_dax_test.c8
-rw-r--r--tools/testing/nvdimm/libnvdimm_test.c8
-rw-r--r--tools/testing/nvdimm/pmem_test.c8
-rw-r--r--tools/testing/nvdimm/test/iomap.c7
-rw-r--r--tools/testing/nvdimm/test/nfit.c498
-rw-r--r--tools/testing/nvdimm/test/nfit_test.h134
-rw-r--r--tools/testing/nvdimm/watermark.h21
9 files changed, 644 insertions, 52 deletions
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index db33b28c5ef3..0392153a0009 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -37,10 +37,12 @@ obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
37 37
38nfit-y := $(ACPI_SRC)/core.o 38nfit-y := $(ACPI_SRC)/core.o
39nfit-$(CONFIG_X86_MCE) += $(ACPI_SRC)/mce.o 39nfit-$(CONFIG_X86_MCE) += $(ACPI_SRC)/mce.o
40nfit-y += acpi_nfit_test.o
40nfit-y += config_check.o 41nfit-y += config_check.o
41 42
42nd_pmem-y := $(NVDIMM_SRC)/pmem.o 43nd_pmem-y := $(NVDIMM_SRC)/pmem.o
43nd_pmem-y += pmem-dax.o 44nd_pmem-y += pmem-dax.o
45nd_pmem-y += pmem_test.o
44nd_pmem-y += config_check.o 46nd_pmem-y += config_check.o
45 47
46nd_btt-y := $(NVDIMM_SRC)/btt.o 48nd_btt-y := $(NVDIMM_SRC)/btt.o
@@ -57,6 +59,7 @@ dax-y += config_check.o
57 59
58device_dax-y := $(DAX_SRC)/device.o 60device_dax-y := $(DAX_SRC)/device.o
59device_dax-y += dax-dev.o 61device_dax-y += dax-dev.o
62device_dax-y += device_dax_test.o
60device_dax-y += config_check.o 63device_dax-y += config_check.o
61 64
62dax_pmem-y := $(DAX_SRC)/pmem.o 65dax_pmem-y := $(DAX_SRC)/pmem.o
@@ -75,6 +78,7 @@ libnvdimm-$(CONFIG_ND_CLAIM) += $(NVDIMM_SRC)/claim.o
75libnvdimm-$(CONFIG_BTT) += $(NVDIMM_SRC)/btt_devs.o 78libnvdimm-$(CONFIG_BTT) += $(NVDIMM_SRC)/btt_devs.o
76libnvdimm-$(CONFIG_NVDIMM_PFN) += $(NVDIMM_SRC)/pfn_devs.o 79libnvdimm-$(CONFIG_NVDIMM_PFN) += $(NVDIMM_SRC)/pfn_devs.o
77libnvdimm-$(CONFIG_NVDIMM_DAX) += $(NVDIMM_SRC)/dax_devs.o 80libnvdimm-$(CONFIG_NVDIMM_DAX) += $(NVDIMM_SRC)/dax_devs.o
81libnvdimm-y += libnvdimm_test.o
78libnvdimm-y += config_check.o 82libnvdimm-y += config_check.o
79 83
80obj-m += test/ 84obj-m += test/
diff --git a/tools/testing/nvdimm/acpi_nfit_test.c b/tools/testing/nvdimm/acpi_nfit_test.c
new file mode 100644
index 000000000000..43521512e577
--- /dev/null
+++ b/tools/testing/nvdimm/acpi_nfit_test.c
@@ -0,0 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2018 Intel Corporation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/printk.h>
6#include "watermark.h"
7
8nfit_test_watermark(acpi_nfit);
diff --git a/tools/testing/nvdimm/device_dax_test.c b/tools/testing/nvdimm/device_dax_test.c
new file mode 100644
index 000000000000..24b17bf42429
--- /dev/null
+++ b/tools/testing/nvdimm/device_dax_test.c
@@ -0,0 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2018 Intel Corporation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/printk.h>
6#include "watermark.h"
7
8nfit_test_watermark(device_dax);
diff --git a/tools/testing/nvdimm/libnvdimm_test.c b/tools/testing/nvdimm/libnvdimm_test.c
new file mode 100644
index 000000000000..00ca30b23932
--- /dev/null
+++ b/tools/testing/nvdimm/libnvdimm_test.c
@@ -0,0 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2018 Intel Corporation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/printk.h>
6#include "watermark.h"
7
8nfit_test_watermark(libnvdimm);
diff --git a/tools/testing/nvdimm/pmem_test.c b/tools/testing/nvdimm/pmem_test.c
new file mode 100644
index 000000000000..fd38f92275cf
--- /dev/null
+++ b/tools/testing/nvdimm/pmem_test.c
@@ -0,0 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2018 Intel Corporation. All rights reserved.
3
4#include <linux/module.h>
5#include <linux/printk.h>
6#include "watermark.h"
7
8nfit_test_watermark(pmem);
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index e1f75a1914a1..ff9d3a5825e1 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -104,15 +104,14 @@ void *__wrap_devm_memremap(struct device *dev, resource_size_t offset,
104} 104}
105EXPORT_SYMBOL(__wrap_devm_memremap); 105EXPORT_SYMBOL(__wrap_devm_memremap);
106 106
107void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res, 107void *__wrap_devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap)
108 struct percpu_ref *ref, struct vmem_altmap *altmap)
109{ 108{
110 resource_size_t offset = res->start; 109 resource_size_t offset = pgmap->res.start;
111 struct nfit_test_resource *nfit_res = get_nfit_res(offset); 110 struct nfit_test_resource *nfit_res = get_nfit_res(offset);
112 111
113 if (nfit_res) 112 if (nfit_res)
114 return nfit_res->buf + offset - nfit_res->res.start; 113 return nfit_res->buf + offset - nfit_res->res.start;
115 return devm_memremap_pages(dev, res, ref, altmap); 114 return devm_memremap_pages(dev, pgmap);
116} 115}
117EXPORT_SYMBOL(__wrap_devm_memremap_pages); 116EXPORT_SYMBOL(__wrap_devm_memremap_pages);
118 117
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 7217b2b953b5..620fa78b3b1b 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -27,6 +27,7 @@
27#include <nfit.h> 27#include <nfit.h>
28#include <nd.h> 28#include <nd.h>
29#include "nfit_test.h" 29#include "nfit_test.h"
30#include "../watermark.h"
30 31
31/* 32/*
32 * Generate an NFIT table to describe the following topology: 33 * Generate an NFIT table to describe the following topology:
@@ -137,6 +138,14 @@ static u32 handle[] = {
137 138
138static unsigned long dimm_fail_cmd_flags[NUM_DCR]; 139static unsigned long dimm_fail_cmd_flags[NUM_DCR];
139 140
141struct nfit_test_fw {
142 enum intel_fw_update_state state;
143 u32 context;
144 u64 version;
145 u32 size_received;
146 u64 end_time;
147};
148
140struct nfit_test { 149struct nfit_test {
141 struct acpi_nfit_desc acpi_desc; 150 struct acpi_nfit_desc acpi_desc;
142 struct platform_device pdev; 151 struct platform_device pdev;
@@ -168,8 +177,11 @@ struct nfit_test {
168 spinlock_t lock; 177 spinlock_t lock;
169 } ars_state; 178 } ars_state;
170 struct device *dimm_dev[NUM_DCR]; 179 struct device *dimm_dev[NUM_DCR];
180 struct nd_intel_smart *smart;
181 struct nd_intel_smart_threshold *smart_threshold;
171 struct badrange badrange; 182 struct badrange badrange;
172 struct work_struct work; 183 struct work_struct work;
184 struct nfit_test_fw *fw;
173}; 185};
174 186
175static struct workqueue_struct *nfit_wq; 187static struct workqueue_struct *nfit_wq;
@@ -181,6 +193,226 @@ static struct nfit_test *to_nfit_test(struct device *dev)
181 return container_of(pdev, struct nfit_test, pdev); 193 return container_of(pdev, struct nfit_test, pdev);
182} 194}
183 195
196static int nd_intel_test_get_fw_info(struct nfit_test *t,
197 struct nd_intel_fw_info *nd_cmd, unsigned int buf_len,
198 int idx)
199{
200 struct device *dev = &t->pdev.dev;
201 struct nfit_test_fw *fw = &t->fw[idx];
202
203 dev_dbg(dev, "%s(nfit_test: %p nd_cmd: %p, buf_len: %u, idx: %d\n",
204 __func__, t, nd_cmd, buf_len, idx);
205
206 if (buf_len < sizeof(*nd_cmd))
207 return -EINVAL;
208
209 nd_cmd->status = 0;
210 nd_cmd->storage_size = INTEL_FW_STORAGE_SIZE;
211 nd_cmd->max_send_len = INTEL_FW_MAX_SEND_LEN;
212 nd_cmd->query_interval = INTEL_FW_QUERY_INTERVAL;
213 nd_cmd->max_query_time = INTEL_FW_QUERY_MAX_TIME;
214 nd_cmd->update_cap = 0;
215 nd_cmd->fis_version = INTEL_FW_FIS_VERSION;
216 nd_cmd->run_version = 0;
217 nd_cmd->updated_version = fw->version;
218
219 return 0;
220}
221
222static int nd_intel_test_start_update(struct nfit_test *t,
223 struct nd_intel_fw_start *nd_cmd, unsigned int buf_len,
224 int idx)
225{
226 struct device *dev = &t->pdev.dev;
227 struct nfit_test_fw *fw = &t->fw[idx];
228
229 dev_dbg(dev, "%s(nfit_test: %p nd_cmd: %p buf_len: %u idx: %d)\n",
230 __func__, t, nd_cmd, buf_len, idx);
231
232 if (buf_len < sizeof(*nd_cmd))
233 return -EINVAL;
234
235 if (fw->state != FW_STATE_NEW) {
236 /* extended status, FW update in progress */
237 nd_cmd->status = 0x10007;
238 return 0;
239 }
240
241 fw->state = FW_STATE_IN_PROGRESS;
242 fw->context++;
243 fw->size_received = 0;
244 nd_cmd->status = 0;
245 nd_cmd->context = fw->context;
246
247 dev_dbg(dev, "%s: context issued: %#x\n", __func__, nd_cmd->context);
248
249 return 0;
250}
251
252static int nd_intel_test_send_data(struct nfit_test *t,
253 struct nd_intel_fw_send_data *nd_cmd, unsigned int buf_len,
254 int idx)
255{
256 struct device *dev = &t->pdev.dev;
257 struct nfit_test_fw *fw = &t->fw[idx];
258 u32 *status = (u32 *)&nd_cmd->data[nd_cmd->length];
259
260 dev_dbg(dev, "%s(nfit_test: %p nd_cmd: %p buf_len: %u idx: %d)\n",
261 __func__, t, nd_cmd, buf_len, idx);
262
263 if (buf_len < sizeof(*nd_cmd))
264 return -EINVAL;
265
266
267 dev_dbg(dev, "%s: cmd->status: %#x\n", __func__, *status);
268 dev_dbg(dev, "%s: cmd->data[0]: %#x\n", __func__, nd_cmd->data[0]);
269 dev_dbg(dev, "%s: cmd->data[%u]: %#x\n", __func__, nd_cmd->length-1,
270 nd_cmd->data[nd_cmd->length-1]);
271
272 if (fw->state != FW_STATE_IN_PROGRESS) {
273 dev_dbg(dev, "%s: not in IN_PROGRESS state\n", __func__);
274 *status = 0x5;
275 return 0;
276 }
277
278 if (nd_cmd->context != fw->context) {
279 dev_dbg(dev, "%s: incorrect context: in: %#x correct: %#x\n",
280 __func__, nd_cmd->context, fw->context);
281 *status = 0x10007;
282 return 0;
283 }
284
285 /*
286 * check offset + len > size of fw storage
287 * check length is > max send length
288 */
289 if (nd_cmd->offset + nd_cmd->length > INTEL_FW_STORAGE_SIZE ||
290 nd_cmd->length > INTEL_FW_MAX_SEND_LEN) {
291 *status = 0x3;
292 dev_dbg(dev, "%s: buffer boundary violation\n", __func__);
293 return 0;
294 }
295
296 fw->size_received += nd_cmd->length;
297 dev_dbg(dev, "%s: copying %u bytes, %u bytes so far\n",
298 __func__, nd_cmd->length, fw->size_received);
299 *status = 0;
300 return 0;
301}
302
303static int nd_intel_test_finish_fw(struct nfit_test *t,
304 struct nd_intel_fw_finish_update *nd_cmd,
305 unsigned int buf_len, int idx)
306{
307 struct device *dev = &t->pdev.dev;
308 struct nfit_test_fw *fw = &t->fw[idx];
309
310 dev_dbg(dev, "%s(nfit_test: %p nd_cmd: %p buf_len: %u idx: %d)\n",
311 __func__, t, nd_cmd, buf_len, idx);
312
313 if (fw->state == FW_STATE_UPDATED) {
314 /* update already done, need cold boot */
315 nd_cmd->status = 0x20007;
316 return 0;
317 }
318
319 dev_dbg(dev, "%s: context: %#x ctrl_flags: %#x\n",
320 __func__, nd_cmd->context, nd_cmd->ctrl_flags);
321
322 switch (nd_cmd->ctrl_flags) {
323 case 0: /* finish */
324 if (nd_cmd->context != fw->context) {
325 dev_dbg(dev, "%s: incorrect context: in: %#x correct: %#x\n",
326 __func__, nd_cmd->context,
327 fw->context);
328 nd_cmd->status = 0x10007;
329 return 0;
330 }
331 nd_cmd->status = 0;
332 fw->state = FW_STATE_VERIFY;
333 /* set 1 second of time for firmware "update" */
334 fw->end_time = jiffies + HZ;
335 break;
336
337 case 1: /* abort */
338 fw->size_received = 0;
339 /* successfully aborted status */
340 nd_cmd->status = 0x40007;
341 fw->state = FW_STATE_NEW;
342 dev_dbg(dev, "%s: abort successful\n", __func__);
343 break;
344
345 default: /* bad control flag */
346 dev_warn(dev, "%s: unknown control flag: %#x\n",
347 __func__, nd_cmd->ctrl_flags);
348 return -EINVAL;
349 }
350
351 return 0;
352}
353
354static int nd_intel_test_finish_query(struct nfit_test *t,
355 struct nd_intel_fw_finish_query *nd_cmd,
356 unsigned int buf_len, int idx)
357{
358 struct device *dev = &t->pdev.dev;
359 struct nfit_test_fw *fw = &t->fw[idx];
360
361 dev_dbg(dev, "%s(nfit_test: %p nd_cmd: %p buf_len: %u idx: %d)\n",
362 __func__, t, nd_cmd, buf_len, idx);
363
364 if (buf_len < sizeof(*nd_cmd))
365 return -EINVAL;
366
367 if (nd_cmd->context != fw->context) {
368 dev_dbg(dev, "%s: incorrect context: in: %#x correct: %#x\n",
369 __func__, nd_cmd->context, fw->context);
370 nd_cmd->status = 0x10007;
371 return 0;
372 }
373
374 dev_dbg(dev, "%s context: %#x\n", __func__, nd_cmd->context);
375
376 switch (fw->state) {
377 case FW_STATE_NEW:
378 nd_cmd->updated_fw_rev = 0;
379 nd_cmd->status = 0;
380 dev_dbg(dev, "%s: new state\n", __func__);
381 break;
382
383 case FW_STATE_IN_PROGRESS:
384 /* sequencing error */
385 nd_cmd->status = 0x40007;
386 nd_cmd->updated_fw_rev = 0;
387 dev_dbg(dev, "%s: sequence error\n", __func__);
388 break;
389
390 case FW_STATE_VERIFY:
391 if (time_is_after_jiffies64(fw->end_time)) {
392 nd_cmd->updated_fw_rev = 0;
393 nd_cmd->status = 0x20007;
394 dev_dbg(dev, "%s: still verifying\n", __func__);
395 break;
396 }
397
398 dev_dbg(dev, "%s: transition out verify\n", __func__);
399 fw->state = FW_STATE_UPDATED;
400 /* we are going to fall through if it's "done" */
401 case FW_STATE_UPDATED:
402 nd_cmd->status = 0;
403 /* bogus test version */
404 fw->version = nd_cmd->updated_fw_rev =
405 INTEL_FW_FAKE_VERSION;
406 dev_dbg(dev, "%s: updated\n", __func__);
407 break;
408
409 default: /* we should never get here */
410 return -EINVAL;
411 }
412
413 return 0;
414}
415
184static int nfit_test_cmd_get_config_size(struct nd_cmd_get_config_size *nd_cmd, 416static int nfit_test_cmd_get_config_size(struct nd_cmd_get_config_size *nd_cmd,
185 unsigned int buf_len) 417 unsigned int buf_len)
186{ 418{
@@ -440,39 +672,66 @@ static int nfit_test_cmd_translate_spa(struct nvdimm_bus *bus,
440 return 0; 672 return 0;
441} 673}
442 674
443static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len) 675static int nfit_test_cmd_smart(struct nd_intel_smart *smart, unsigned int buf_len,
676 struct nd_intel_smart *smart_data)
444{ 677{
445 static const struct nd_smart_payload smart_data = {
446 .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
447 | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
448 | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
449 .health = ND_SMART_NON_CRITICAL_HEALTH,
450 .temperature = 23 * 16,
451 .spares = 75,
452 .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
453 .life_used = 5,
454 .shutdown_state = 0,
455 .vendor_size = 0,
456 };
457
458 if (buf_len < sizeof(*smart)) 678 if (buf_len < sizeof(*smart))
459 return -EINVAL; 679 return -EINVAL;
460 memcpy(smart->data, &smart_data, sizeof(smart_data)); 680 memcpy(smart, smart_data, sizeof(*smart));
461 return 0; 681 return 0;
462} 682}
463 683
464static int nfit_test_cmd_smart_threshold(struct nd_cmd_smart_threshold *smart_t, 684static int nfit_test_cmd_smart_threshold(
465 unsigned int buf_len) 685 struct nd_intel_smart_threshold *out,
686 unsigned int buf_len,
687 struct nd_intel_smart_threshold *smart_t)
466{ 688{
467 static const struct nd_smart_threshold_payload smart_t_data = {
468 .alarm_control = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
469 .temperature = 40 * 16,
470 .spares = 5,
471 };
472
473 if (buf_len < sizeof(*smart_t)) 689 if (buf_len < sizeof(*smart_t))
474 return -EINVAL; 690 return -EINVAL;
475 memcpy(smart_t->data, &smart_t_data, sizeof(smart_t_data)); 691 memcpy(out, smart_t, sizeof(*smart_t));
692 return 0;
693}
694
695static void smart_notify(struct device *bus_dev,
696 struct device *dimm_dev, struct nd_intel_smart *smart,
697 struct nd_intel_smart_threshold *thresh)
698{
699 dev_dbg(dimm_dev, "%s: alarm: %#x spares: %d (%d) mtemp: %d (%d) ctemp: %d (%d)\n",
700 __func__, thresh->alarm_control, thresh->spares,
701 smart->spares, thresh->media_temperature,
702 smart->media_temperature, thresh->ctrl_temperature,
703 smart->ctrl_temperature);
704 if (((thresh->alarm_control & ND_INTEL_SMART_SPARE_TRIP)
705 && smart->spares
706 <= thresh->spares)
707 || ((thresh->alarm_control & ND_INTEL_SMART_TEMP_TRIP)
708 && smart->media_temperature
709 >= thresh->media_temperature)
710 || ((thresh->alarm_control & ND_INTEL_SMART_CTEMP_TRIP)
711 && smart->ctrl_temperature
712 >= thresh->ctrl_temperature)) {
713 device_lock(bus_dev);
714 __acpi_nvdimm_notify(dimm_dev, 0x81);
715 device_unlock(bus_dev);
716 }
717}
718
719static int nfit_test_cmd_smart_set_threshold(
720 struct nd_intel_smart_set_threshold *in,
721 unsigned int buf_len,
722 struct nd_intel_smart_threshold *thresh,
723 struct nd_intel_smart *smart,
724 struct device *bus_dev, struct device *dimm_dev)
725{
726 unsigned int size;
727
728 size = sizeof(*in) - 4;
729 if (buf_len < size)
730 return -EINVAL;
731 memcpy(thresh->data, in, size);
732 in->status = 0;
733 smart_notify(bus_dev, dimm_dev, smart, thresh);
734
476 return 0; 735 return 0;
477} 736}
478 737
@@ -563,6 +822,52 @@ static int nfit_test_cmd_ars_inject_status(struct nfit_test *t,
563 return 0; 822 return 0;
564} 823}
565 824
825static int nd_intel_test_cmd_set_lss_status(struct nfit_test *t,
826 struct nd_intel_lss *nd_cmd, unsigned int buf_len)
827{
828 struct device *dev = &t->pdev.dev;
829
830 if (buf_len < sizeof(*nd_cmd))
831 return -EINVAL;
832
833 switch (nd_cmd->enable) {
834 case 0:
835 nd_cmd->status = 0;
836 dev_dbg(dev, "%s: Latch System Shutdown Status disabled\n",
837 __func__);
838 break;
839 case 1:
840 nd_cmd->status = 0;
841 dev_dbg(dev, "%s: Latch System Shutdown Status enabled\n",
842 __func__);
843 break;
844 default:
845 dev_warn(dev, "Unknown enable value: %#x\n", nd_cmd->enable);
846 nd_cmd->status = 0x3;
847 break;
848 }
849
850
851 return 0;
852}
853
854static int get_dimm(struct nfit_mem *nfit_mem, unsigned int func)
855{
856 int i;
857
858 /* lookup per-dimm data */
859 for (i = 0; i < ARRAY_SIZE(handle); i++)
860 if (__to_nfit_memdev(nfit_mem)->device_handle == handle[i])
861 break;
862 if (i >= ARRAY_SIZE(handle))
863 return -ENXIO;
864
865 if ((1 << func) & dimm_fail_cmd_flags[i])
866 return -EIO;
867
868 return i;
869}
870
566static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, 871static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
567 struct nvdimm *nvdimm, unsigned int cmd, void *buf, 872 struct nvdimm *nvdimm, unsigned int cmd, void *buf,
568 unsigned int buf_len, int *cmd_rc) 873 unsigned int buf_len, int *cmd_rc)
@@ -591,22 +896,57 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
591 func = call_pkg->nd_command; 896 func = call_pkg->nd_command;
592 if (call_pkg->nd_family != nfit_mem->family) 897 if (call_pkg->nd_family != nfit_mem->family)
593 return -ENOTTY; 898 return -ENOTTY;
899
900 i = get_dimm(nfit_mem, func);
901 if (i < 0)
902 return i;
903
904 switch (func) {
905 case ND_INTEL_ENABLE_LSS_STATUS:
906 return nd_intel_test_cmd_set_lss_status(t,
907 buf, buf_len);
908 case ND_INTEL_FW_GET_INFO:
909 return nd_intel_test_get_fw_info(t, buf,
910 buf_len, i - t->dcr_idx);
911 case ND_INTEL_FW_START_UPDATE:
912 return nd_intel_test_start_update(t, buf,
913 buf_len, i - t->dcr_idx);
914 case ND_INTEL_FW_SEND_DATA:
915 return nd_intel_test_send_data(t, buf,
916 buf_len, i - t->dcr_idx);
917 case ND_INTEL_FW_FINISH_UPDATE:
918 return nd_intel_test_finish_fw(t, buf,
919 buf_len, i - t->dcr_idx);
920 case ND_INTEL_FW_FINISH_QUERY:
921 return nd_intel_test_finish_query(t, buf,
922 buf_len, i - t->dcr_idx);
923 case ND_INTEL_SMART:
924 return nfit_test_cmd_smart(buf, buf_len,
925 &t->smart[i - t->dcr_idx]);
926 case ND_INTEL_SMART_THRESHOLD:
927 return nfit_test_cmd_smart_threshold(buf,
928 buf_len,
929 &t->smart_threshold[i -
930 t->dcr_idx]);
931 case ND_INTEL_SMART_SET_THRESHOLD:
932 return nfit_test_cmd_smart_set_threshold(buf,
933 buf_len,
934 &t->smart_threshold[i -
935 t->dcr_idx],
936 &t->smart[i - t->dcr_idx],
937 &t->pdev.dev, t->dimm_dev[i]);
938 default:
939 return -ENOTTY;
940 }
594 } 941 }
595 942
596 if (!test_bit(cmd, &cmd_mask) 943 if (!test_bit(cmd, &cmd_mask)
597 || !test_bit(func, &nfit_mem->dsm_mask)) 944 || !test_bit(func, &nfit_mem->dsm_mask))
598 return -ENOTTY; 945 return -ENOTTY;
599 946
600 /* lookup label space for the given dimm */ 947 i = get_dimm(nfit_mem, func);
601 for (i = 0; i < ARRAY_SIZE(handle); i++) 948 if (i < 0)
602 if (__to_nfit_memdev(nfit_mem)->device_handle == 949 return i;
603 handle[i])
604 break;
605 if (i >= ARRAY_SIZE(handle))
606 return -ENXIO;
607
608 if ((1 << func) & dimm_fail_cmd_flags[i])
609 return -EIO;
610 950
611 switch (func) { 951 switch (func) {
612 case ND_CMD_GET_CONFIG_SIZE: 952 case ND_CMD_GET_CONFIG_SIZE:
@@ -620,15 +960,6 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
620 rc = nfit_test_cmd_set_config_data(buf, buf_len, 960 rc = nfit_test_cmd_set_config_data(buf, buf_len,
621 t->label[i - t->dcr_idx]); 961 t->label[i - t->dcr_idx]);
622 break; 962 break;
623 case ND_CMD_SMART:
624 rc = nfit_test_cmd_smart(buf, buf_len);
625 break;
626 case ND_CMD_SMART_THRESHOLD:
627 rc = nfit_test_cmd_smart_threshold(buf, buf_len);
628 device_lock(&t->pdev.dev);
629 __acpi_nvdimm_notify(t->dimm_dev[i], 0x81);
630 device_unlock(&t->pdev.dev);
631 break;
632 default: 963 default:
633 return -ENOTTY; 964 return -ENOTTY;
634 } 965 }
@@ -872,6 +1203,44 @@ static const struct attribute_group *nfit_test_dimm_attribute_groups[] = {
872 NULL, 1203 NULL,
873}; 1204};
874 1205
1206static void smart_init(struct nfit_test *t)
1207{
1208 int i;
1209 const struct nd_intel_smart_threshold smart_t_data = {
1210 .alarm_control = ND_INTEL_SMART_SPARE_TRIP
1211 | ND_INTEL_SMART_TEMP_TRIP,
1212 .media_temperature = 40 * 16,
1213 .ctrl_temperature = 30 * 16,
1214 .spares = 5,
1215 };
1216 const struct nd_intel_smart smart_data = {
1217 .flags = ND_INTEL_SMART_HEALTH_VALID
1218 | ND_INTEL_SMART_SPARES_VALID
1219 | ND_INTEL_SMART_ALARM_VALID
1220 | ND_INTEL_SMART_USED_VALID
1221 | ND_INTEL_SMART_SHUTDOWN_VALID
1222 | ND_INTEL_SMART_MTEMP_VALID,
1223 .health = ND_INTEL_SMART_NON_CRITICAL_HEALTH,
1224 .media_temperature = 23 * 16,
1225 .ctrl_temperature = 30 * 16,
1226 .pmic_temperature = 40 * 16,
1227 .spares = 75,
1228 .alarm_flags = ND_INTEL_SMART_SPARE_TRIP
1229 | ND_INTEL_SMART_TEMP_TRIP,
1230 .ait_status = 1,
1231 .life_used = 5,
1232 .shutdown_state = 0,
1233 .vendor_size = 0,
1234 .shutdown_count = 100,
1235 };
1236
1237 for (i = 0; i < t->num_dcr; i++) {
1238 memcpy(&t->smart[i], &smart_data, sizeof(smart_data));
1239 memcpy(&t->smart_threshold[i], &smart_t_data,
1240 sizeof(smart_t_data));
1241 }
1242}
1243
875static int nfit_test0_alloc(struct nfit_test *t) 1244static int nfit_test0_alloc(struct nfit_test *t)
876{ 1245{
877 size_t nfit_size = sizeof(struct acpi_nfit_system_address) * NUM_SPA 1246 size_t nfit_size = sizeof(struct acpi_nfit_system_address) * NUM_SPA
@@ -881,7 +1250,8 @@ static int nfit_test0_alloc(struct nfit_test *t)
881 window_size) * NUM_DCR 1250 window_size) * NUM_DCR
882 + sizeof(struct acpi_nfit_data_region) * NUM_BDW 1251 + sizeof(struct acpi_nfit_data_region) * NUM_BDW
883 + (sizeof(struct acpi_nfit_flush_address) 1252 + (sizeof(struct acpi_nfit_flush_address)
884 + sizeof(u64) * NUM_HINTS) * NUM_DCR; 1253 + sizeof(u64) * NUM_HINTS) * NUM_DCR
1254 + sizeof(struct acpi_nfit_capabilities);
885 int i; 1255 int i;
886 1256
887 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); 1257 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma);
@@ -939,6 +1309,7 @@ static int nfit_test0_alloc(struct nfit_test *t)
939 return -ENOMEM; 1309 return -ENOMEM;
940 } 1310 }
941 1311
1312 smart_init(t);
942 return ars_state_init(&t->pdev.dev, &t->ars_state); 1313 return ars_state_init(&t->pdev.dev, &t->ars_state);
943} 1314}
944 1315
@@ -969,6 +1340,7 @@ static int nfit_test1_alloc(struct nfit_test *t)
969 if (!t->spa_set[1]) 1340 if (!t->spa_set[1])
970 return -ENOMEM; 1341 return -ENOMEM;
971 1342
1343 smart_init(t);
972 return ars_state_init(&t->pdev.dev, &t->ars_state); 1344 return ars_state_init(&t->pdev.dev, &t->ars_state);
973} 1345}
974 1346
@@ -993,6 +1365,7 @@ static void nfit_test0_setup(struct nfit_test *t)
993 struct acpi_nfit_control_region *dcr; 1365 struct acpi_nfit_control_region *dcr;
994 struct acpi_nfit_data_region *bdw; 1366 struct acpi_nfit_data_region *bdw;
995 struct acpi_nfit_flush_address *flush; 1367 struct acpi_nfit_flush_address *flush;
1368 struct acpi_nfit_capabilities *pcap;
996 unsigned int offset, i; 1369 unsigned int offset, i;
997 1370
998 /* 1371 /*
@@ -1500,8 +1873,16 @@ static void nfit_test0_setup(struct nfit_test *t)
1500 for (i = 0; i < NUM_HINTS; i++) 1873 for (i = 0; i < NUM_HINTS; i++)
1501 flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64); 1874 flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64);
1502 1875
1876 /* platform capabilities */
1877 pcap = nfit_buf + offset + flush_hint_size * 4;
1878 pcap->header.type = ACPI_NFIT_TYPE_CAPABILITIES;
1879 pcap->header.length = sizeof(*pcap);
1880 pcap->highest_capability = 1;
1881 pcap->capabilities = ACPI_NFIT_CAPABILITY_CACHE_FLUSH |
1882 ACPI_NFIT_CAPABILITY_MEM_FLUSH;
1883
1503 if (t->setup_hotplug) { 1884 if (t->setup_hotplug) {
1504 offset = offset + flush_hint_size * 4; 1885 offset = offset + flush_hint_size * 4 + sizeof(*pcap);
1505 /* dcr-descriptor4: blk */ 1886 /* dcr-descriptor4: blk */
1506 dcr = nfit_buf + offset; 1887 dcr = nfit_buf + offset;
1507 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 1888 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
@@ -1642,17 +2023,24 @@ static void nfit_test0_setup(struct nfit_test *t)
1642 set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_cmd_force_en); 2023 set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_cmd_force_en);
1643 set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); 2024 set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en);
1644 set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); 2025 set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en);
1645 set_bit(ND_CMD_SMART, &acpi_desc->dimm_cmd_force_en); 2026 set_bit(ND_INTEL_SMART, &acpi_desc->dimm_cmd_force_en);
2027 set_bit(ND_INTEL_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
2028 set_bit(ND_INTEL_SMART_SET_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
1646 set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_cmd_force_en); 2029 set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_cmd_force_en);
1647 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); 2030 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
1648 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); 2031 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
1649 set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); 2032 set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en);
1650 set_bit(ND_CMD_CALL, &acpi_desc->bus_cmd_force_en); 2033 set_bit(ND_CMD_CALL, &acpi_desc->bus_cmd_force_en);
1651 set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_cmd_force_en);
1652 set_bit(NFIT_CMD_TRANSLATE_SPA, &acpi_desc->bus_nfit_cmd_force_en); 2034 set_bit(NFIT_CMD_TRANSLATE_SPA, &acpi_desc->bus_nfit_cmd_force_en);
1653 set_bit(NFIT_CMD_ARS_INJECT_SET, &acpi_desc->bus_nfit_cmd_force_en); 2035 set_bit(NFIT_CMD_ARS_INJECT_SET, &acpi_desc->bus_nfit_cmd_force_en);
1654 set_bit(NFIT_CMD_ARS_INJECT_CLEAR, &acpi_desc->bus_nfit_cmd_force_en); 2036 set_bit(NFIT_CMD_ARS_INJECT_CLEAR, &acpi_desc->bus_nfit_cmd_force_en);
1655 set_bit(NFIT_CMD_ARS_INJECT_GET, &acpi_desc->bus_nfit_cmd_force_en); 2037 set_bit(NFIT_CMD_ARS_INJECT_GET, &acpi_desc->bus_nfit_cmd_force_en);
2038 set_bit(ND_INTEL_FW_GET_INFO, &acpi_desc->dimm_cmd_force_en);
2039 set_bit(ND_INTEL_FW_START_UPDATE, &acpi_desc->dimm_cmd_force_en);
2040 set_bit(ND_INTEL_FW_SEND_DATA, &acpi_desc->dimm_cmd_force_en);
2041 set_bit(ND_INTEL_FW_FINISH_UPDATE, &acpi_desc->dimm_cmd_force_en);
2042 set_bit(ND_INTEL_FW_FINISH_QUERY, &acpi_desc->dimm_cmd_force_en);
2043 set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en);
1656} 2044}
1657 2045
1658static void nfit_test1_setup(struct nfit_test *t) 2046static void nfit_test1_setup(struct nfit_test *t)
@@ -1750,6 +2138,7 @@ static void nfit_test1_setup(struct nfit_test *t)
1750 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); 2138 set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
1751 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); 2139 set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
1752 set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); 2140 set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en);
2141 set_bit(ND_INTEL_ENABLE_LSS_STATUS, &acpi_desc->dimm_cmd_force_en);
1753} 2142}
1754 2143
1755static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa, 2144static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa,
@@ -2054,10 +2443,18 @@ static int nfit_test_probe(struct platform_device *pdev)
2054 sizeof(struct nfit_test_dcr *), GFP_KERNEL); 2443 sizeof(struct nfit_test_dcr *), GFP_KERNEL);
2055 nfit_test->dcr_dma = devm_kcalloc(dev, num, 2444 nfit_test->dcr_dma = devm_kcalloc(dev, num,
2056 sizeof(dma_addr_t), GFP_KERNEL); 2445 sizeof(dma_addr_t), GFP_KERNEL);
2446 nfit_test->smart = devm_kcalloc(dev, num,
2447 sizeof(struct nd_intel_smart), GFP_KERNEL);
2448 nfit_test->smart_threshold = devm_kcalloc(dev, num,
2449 sizeof(struct nd_intel_smart_threshold),
2450 GFP_KERNEL);
2451 nfit_test->fw = devm_kcalloc(dev, num,
2452 sizeof(struct nfit_test_fw), GFP_KERNEL);
2057 if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label 2453 if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label
2058 && nfit_test->label_dma && nfit_test->dcr 2454 && nfit_test->label_dma && nfit_test->dcr
2059 && nfit_test->dcr_dma && nfit_test->flush 2455 && nfit_test->dcr_dma && nfit_test->flush
2060 && nfit_test->flush_dma) 2456 && nfit_test->flush_dma
2457 && nfit_test->fw)
2061 /* pass */; 2458 /* pass */;
2062 else 2459 else
2063 return -ENOMEM; 2460 return -ENOMEM;
@@ -2159,6 +2556,11 @@ static __init int nfit_test_init(void)
2159{ 2556{
2160 int rc, i; 2557 int rc, i;
2161 2558
2559 pmem_test();
2560 libnvdimm_test();
2561 acpi_nfit_test();
2562 device_dax_test();
2563
2162 nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm); 2564 nfit_test_setup(nfit_test_lookup, nfit_test_evaluate_dsm);
2163 2565
2164 nfit_wq = create_singlethread_workqueue("nfit"); 2566 nfit_wq = create_singlethread_workqueue("nfit");
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index 113b44675a71..428344519cdf 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -84,6 +84,140 @@ struct nd_cmd_ars_err_inj_stat {
84 } __packed record[0]; 84 } __packed record[0];
85} __packed; 85} __packed;
86 86
87#define ND_INTEL_SMART 1
88#define ND_INTEL_SMART_THRESHOLD 2
89#define ND_INTEL_ENABLE_LSS_STATUS 10
90#define ND_INTEL_FW_GET_INFO 12
91#define ND_INTEL_FW_START_UPDATE 13
92#define ND_INTEL_FW_SEND_DATA 14
93#define ND_INTEL_FW_FINISH_UPDATE 15
94#define ND_INTEL_FW_FINISH_QUERY 16
95#define ND_INTEL_SMART_SET_THRESHOLD 17
96
97#define ND_INTEL_SMART_HEALTH_VALID (1 << 0)
98#define ND_INTEL_SMART_SPARES_VALID (1 << 1)
99#define ND_INTEL_SMART_USED_VALID (1 << 2)
100#define ND_INTEL_SMART_MTEMP_VALID (1 << 3)
101#define ND_INTEL_SMART_CTEMP_VALID (1 << 4)
102#define ND_INTEL_SMART_SHUTDOWN_COUNT_VALID (1 << 5)
103#define ND_INTEL_SMART_AIT_STATUS_VALID (1 << 6)
104#define ND_INTEL_SMART_PTEMP_VALID (1 << 7)
105#define ND_INTEL_SMART_ALARM_VALID (1 << 9)
106#define ND_INTEL_SMART_SHUTDOWN_VALID (1 << 10)
107#define ND_INTEL_SMART_VENDOR_VALID (1 << 11)
108#define ND_INTEL_SMART_SPARE_TRIP (1 << 0)
109#define ND_INTEL_SMART_TEMP_TRIP (1 << 1)
110#define ND_INTEL_SMART_CTEMP_TRIP (1 << 2)
111#define ND_INTEL_SMART_NON_CRITICAL_HEALTH (1 << 0)
112#define ND_INTEL_SMART_CRITICAL_HEALTH (1 << 1)
113#define ND_INTEL_SMART_FATAL_HEALTH (1 << 2)
114
115struct nd_intel_smart {
116 __u32 status;
117 union {
118 struct {
119 __u32 flags;
120 __u8 reserved0[4];
121 __u8 health;
122 __u8 spares;
123 __u8 life_used;
124 __u8 alarm_flags;
125 __u16 media_temperature;
126 __u16 ctrl_temperature;
127 __u32 shutdown_count;
128 __u8 ait_status;
129 __u16 pmic_temperature;
130 __u8 reserved1[8];
131 __u8 shutdown_state;
132 __u32 vendor_size;
133 __u8 vendor_data[92];
134 } __packed;
135 __u8 data[128];
136 };
137} __packed;
138
139struct nd_intel_smart_threshold {
140 __u32 status;
141 union {
142 struct {
143 __u16 alarm_control;
144 __u8 spares;
145 __u16 media_temperature;
146 __u16 ctrl_temperature;
147 __u8 reserved[1];
148 } __packed;
149 __u8 data[8];
150 };
151} __packed;
152
153struct nd_intel_smart_set_threshold {
154 __u16 alarm_control;
155 __u8 spares;
156 __u16 media_temperature;
157 __u16 ctrl_temperature;
158 __u32 status;
159} __packed;
160
161#define INTEL_FW_STORAGE_SIZE 0x100000
162#define INTEL_FW_MAX_SEND_LEN 0xFFEC
163#define INTEL_FW_QUERY_INTERVAL 250000
164#define INTEL_FW_QUERY_MAX_TIME 3000000
165#define INTEL_FW_FIS_VERSION 0x0105
166#define INTEL_FW_FAKE_VERSION 0xffffffffabcd
167
168enum intel_fw_update_state {
169 FW_STATE_NEW = 0,
170 FW_STATE_IN_PROGRESS,
171 FW_STATE_VERIFY,
172 FW_STATE_UPDATED,
173};
174
175struct nd_intel_fw_info {
176 __u32 status;
177 __u32 storage_size;
178 __u32 max_send_len;
179 __u32 query_interval;
180 __u32 max_query_time;
181 __u8 update_cap;
182 __u8 reserved[3];
183 __u32 fis_version;
184 __u64 run_version;
185 __u64 updated_version;
186} __packed;
187
188struct nd_intel_fw_start {
189 __u32 status;
190 __u32 context;
191} __packed;
192
193/* this one has the output first because the variable input data size */
194struct nd_intel_fw_send_data {
195 __u32 context;
196 __u32 offset;
197 __u32 length;
198 __u8 data[0];
199/* this field is not declared due ot variable data from input */
200/* __u32 status; */
201} __packed;
202
203struct nd_intel_fw_finish_update {
204 __u8 ctrl_flags;
205 __u8 reserved[3];
206 __u32 context;
207 __u32 status;
208} __packed;
209
210struct nd_intel_fw_finish_query {
211 __u32 context;
212 __u32 status;
213 __u64 updated_fw_rev;
214} __packed;
215
216struct nd_intel_lss {
217 __u8 enable;
218 __u32 status;
219} __packed;
220
87union acpi_object; 221union acpi_object;
88typedef void *acpi_handle; 222typedef void *acpi_handle;
89 223
diff --git a/tools/testing/nvdimm/watermark.h b/tools/testing/nvdimm/watermark.h
new file mode 100644
index 000000000000..ed0528757bd4
--- /dev/null
+++ b/tools/testing/nvdimm/watermark.h
@@ -0,0 +1,21 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright(c) 2018 Intel Corporation. All rights reserved.
3#ifndef _TEST_NVDIMM_WATERMARK_H_
4#define _TEST_NVDIMM_WATERMARK_H_
5int pmem_test(void);
6int libnvdimm_test(void);
7int acpi_nfit_test(void);
8int device_dax_test(void);
9
10/*
11 * dummy routine for nfit_test to validate it is linking to the properly
12 * mocked module and not the standard one from the base tree.
13 */
14#define nfit_test_watermark(x) \
15int x##_test(void) \
16{ \
17 pr_debug("%s for nfit_test\n", KBUILD_MODNAME); \
18 return 0; \
19} \
20EXPORT_SYMBOL(x##_test)
21#endif /* _TEST_NVDIMM_WATERMARK_H_ */