aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2016-07-24 11:05:44 -0400
committerDan Williams <dan.j.williams@intel.com>2016-07-24 11:05:44 -0400
commit0606263f24f3d64960de742c55894190b5df903b (patch)
tree673894f227c1a761f601ad7bdc1ceef003bb85cb /tools
parenta72255983f12f31f0c8d8275fb1a781546cfacb7 (diff)
parentd4c5725d57323e2348940fcc6416072671a9b432 (diff)
Merge branch 'for-4.8/libnvdimm' into libnvdimm-for-next
Diffstat (limited to 'tools')
-rw-r--r--tools/objtool/arch/x86/insn/x86-opcode-map.txt2
-rw-r--r--tools/perf/arch/x86/tests/insn-x86-dat-32.c2
-rw-r--r--tools/perf/arch/x86/tests/insn-x86-dat-64.c2
-rw-r--r--tools/perf/arch/x86/tests/insn-x86-dat-src.c4
-rw-r--r--tools/perf/util/intel-pt-decoder/x86-opcode-map.txt2
-rw-r--r--tools/testing/nvdimm/Kbuild10
-rw-r--r--tools/testing/nvdimm/config_check.c1
-rw-r--r--tools/testing/nvdimm/pmem-dax.c54
-rw-r--r--tools/testing/nvdimm/test/Kbuild2
-rw-r--r--tools/testing/nvdimm/test/iomap.c38
-rw-r--r--tools/testing/nvdimm/test/nfit.c199
-rw-r--r--tools/testing/nvdimm/test/nfit_test.h2
12 files changed, 170 insertions, 148 deletions
diff --git a/tools/objtool/arch/x86/insn/x86-opcode-map.txt b/tools/objtool/arch/x86/insn/x86-opcode-map.txt
index d388de72eaca..28632ee68377 100644
--- a/tools/objtool/arch/x86/insn/x86-opcode-map.txt
+++ b/tools/objtool/arch/x86/insn/x86-opcode-map.txt
@@ -947,7 +947,7 @@ GrpTable: Grp15
9474: XSAVE 9474: XSAVE
9485: XRSTOR | lfence (11B) 9485: XRSTOR | lfence (11B)
9496: XSAVEOPT | clwb (66) | mfence (11B) 9496: XSAVEOPT | clwb (66) | mfence (11B)
9507: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B) 9507: clflush | clflushopt (66) | sfence (11B)
951EndTable 951EndTable
952 952
953GrpTable: Grp16 953GrpTable: Grp16
diff --git a/tools/perf/arch/x86/tests/insn-x86-dat-32.c b/tools/perf/arch/x86/tests/insn-x86-dat-32.c
index 3b491cfe204e..38a48daed154 100644
--- a/tools/perf/arch/x86/tests/insn-x86-dat-32.c
+++ b/tools/perf/arch/x86/tests/insn-x86-dat-32.c
@@ -654,5 +654,3 @@
654"0f c7 1d 78 56 34 12 \txrstors 0x12345678",}, 654"0f c7 1d 78 56 34 12 \txrstors 0x12345678",},
655{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "", 655{{0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 8, 0, "", "",
656"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%eax,%ecx,8)",}, 656"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%eax,%ecx,8)",},
657{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
658"66 0f ae f8 \tpcommit ",},
diff --git a/tools/perf/arch/x86/tests/insn-x86-dat-64.c b/tools/perf/arch/x86/tests/insn-x86-dat-64.c
index 4fe7cce179c4..1f11ea85b60f 100644
--- a/tools/perf/arch/x86/tests/insn-x86-dat-64.c
+++ b/tools/perf/arch/x86/tests/insn-x86-dat-64.c
@@ -764,5 +764,3 @@
764"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%rax,%rcx,8)",}, 764"0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%rax,%rcx,8)",},
765{{0x41, 0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "", 765{{0x41, 0x0f, 0xc7, 0x9c, 0xc8, 0x78, 0x56, 0x34, 0x12, }, 9, 0, "", "",
766"41 0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%r8,%rcx,8)",}, 766"41 0f c7 9c c8 78 56 34 12 \txrstors 0x12345678(%r8,%rcx,8)",},
767{{0x66, 0x0f, 0xae, 0xf8, }, 4, 0, "", "",
768"66 0f ae f8 \tpcommit ",},
diff --git a/tools/perf/arch/x86/tests/insn-x86-dat-src.c b/tools/perf/arch/x86/tests/insn-x86-dat-src.c
index 41b1b1c62660..033b8a6fdab9 100644
--- a/tools/perf/arch/x86/tests/insn-x86-dat-src.c
+++ b/tools/perf/arch/x86/tests/insn-x86-dat-src.c
@@ -866,10 +866,6 @@ int main(void)
866 866
867#endif /* #ifndef __x86_64__ */ 867#endif /* #ifndef __x86_64__ */
868 868
869 /* pcommit */
870
871 asm volatile("pcommit");
872
873 /* Following line is a marker for the awk script - do not change */ 869 /* Following line is a marker for the awk script - do not change */
874 asm volatile("rdtsc"); /* Stop here */ 870 asm volatile("rdtsc"); /* Stop here */
875 871
diff --git a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt b/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
index d388de72eaca..28632ee68377 100644
--- a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
+++ b/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt
@@ -947,7 +947,7 @@ GrpTable: Grp15
9474: XSAVE 9474: XSAVE
9485: XRSTOR | lfence (11B) 9485: XRSTOR | lfence (11B)
9496: XSAVEOPT | clwb (66) | mfence (11B) 9496: XSAVEOPT | clwb (66) | mfence (11B)
9507: clflush | clflushopt (66) | sfence (11B) | pcommit (66),(11B) 9507: clflush | clflushopt (66) | sfence (11B)
951EndTable 951EndTable
952 952
953GrpTable: Grp16 953GrpTable: Grp16
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index 785985677159..ad6dd0543019 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -11,12 +11,14 @@ ldflags-y += --wrap=__devm_release_region
11ldflags-y += --wrap=__request_region 11ldflags-y += --wrap=__request_region
12ldflags-y += --wrap=__release_region 12ldflags-y += --wrap=__release_region
13ldflags-y += --wrap=devm_memremap_pages 13ldflags-y += --wrap=devm_memremap_pages
14ldflags-y += --wrap=phys_to_pfn_t 14ldflags-y += --wrap=insert_resource
15ldflags-y += --wrap=remove_resource
15 16
16DRIVERS := ../../../drivers 17DRIVERS := ../../../drivers
17NVDIMM_SRC := $(DRIVERS)/nvdimm 18NVDIMM_SRC := $(DRIVERS)/nvdimm
18ACPI_SRC := $(DRIVERS)/acpi 19ACPI_SRC := $(DRIVERS)/acpi/nfit
19DAX_SRC := $(DRIVERS)/dax 20DAX_SRC := $(DRIVERS)/dax
21ccflags-y := -I$(src)/$(NVDIMM_SRC)/
20 22
21obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o 23obj-$(CONFIG_LIBNVDIMM) += libnvdimm.o
22obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o 24obj-$(CONFIG_BLK_DEV_PMEM) += nd_pmem.o
@@ -27,10 +29,12 @@ obj-$(CONFIG_ACPI_NFIT) += nfit.o
27obj-$(CONFIG_DEV_DAX) += dax.o 29obj-$(CONFIG_DEV_DAX) += dax.o
28obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o 30obj-$(CONFIG_DEV_DAX_PMEM) += dax_pmem.o
29 31
30nfit-y := $(ACPI_SRC)/nfit.o 32nfit-y := $(ACPI_SRC)/core.o
33nfit-$(CONFIG_X86_MCE) += $(ACPI_SRC)/mce.o
31nfit-y += config_check.o 34nfit-y += config_check.o
32 35
33nd_pmem-y := $(NVDIMM_SRC)/pmem.o 36nd_pmem-y := $(NVDIMM_SRC)/pmem.o
37nd_pmem-y += pmem-dax.o
34nd_pmem-y += config_check.o 38nd_pmem-y += config_check.o
35 39
36nd_btt-y := $(NVDIMM_SRC)/btt.o 40nd_btt-y := $(NVDIMM_SRC)/btt.o
diff --git a/tools/testing/nvdimm/config_check.c b/tools/testing/nvdimm/config_check.c
index adf18bfeca00..878daf3429e8 100644
--- a/tools/testing/nvdimm/config_check.c
+++ b/tools/testing/nvdimm/config_check.c
@@ -10,6 +10,7 @@ void check(void)
10 BUILD_BUG_ON(!IS_MODULE(CONFIG_LIBNVDIMM)); 10 BUILD_BUG_ON(!IS_MODULE(CONFIG_LIBNVDIMM));
11 BUILD_BUG_ON(!IS_MODULE(CONFIG_BLK_DEV_PMEM)); 11 BUILD_BUG_ON(!IS_MODULE(CONFIG_BLK_DEV_PMEM));
12 BUILD_BUG_ON(!IS_MODULE(CONFIG_ND_BTT)); 12 BUILD_BUG_ON(!IS_MODULE(CONFIG_ND_BTT));
13 BUILD_BUG_ON(!IS_MODULE(CONFIG_ND_PFN));
13 BUILD_BUG_ON(!IS_MODULE(CONFIG_ND_BLK)); 14 BUILD_BUG_ON(!IS_MODULE(CONFIG_ND_BLK));
14 BUILD_BUG_ON(!IS_MODULE(CONFIG_ACPI_NFIT)); 15 BUILD_BUG_ON(!IS_MODULE(CONFIG_ACPI_NFIT));
15 BUILD_BUG_ON(!IS_MODULE(CONFIG_DEV_DAX)); 16 BUILD_BUG_ON(!IS_MODULE(CONFIG_DEV_DAX));
diff --git a/tools/testing/nvdimm/pmem-dax.c b/tools/testing/nvdimm/pmem-dax.c
new file mode 100644
index 000000000000..c9b8c48f85fc
--- /dev/null
+++ b/tools/testing/nvdimm/pmem-dax.c
@@ -0,0 +1,54 @@
1/*
2 * Copyright (c) 2014-2016, Intel Corporation.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 */
13#include "test/nfit_test.h"
14#include <linux/blkdev.h>
15#include <pmem.h>
16#include <nd.h>
17
18long pmem_direct_access(struct block_device *bdev, sector_t sector,
19 void **kaddr, pfn_t *pfn, long size)
20{
21 struct pmem_device *pmem = bdev->bd_queue->queuedata;
22 resource_size_t offset = sector * 512 + pmem->data_offset;
23
24 if (unlikely(is_bad_pmem(&pmem->bb, sector, size)))
25 return -EIO;
26
27 /*
28 * Limit dax to a single page at a time given vmalloc()-backed
29 * in the nfit_test case.
30 */
31 if (get_nfit_res(pmem->phys_addr + offset)) {
32 struct page *page;
33
34 *kaddr = pmem->virt_addr + offset;
35 page = vmalloc_to_page(pmem->virt_addr + offset);
36 *pfn = page_to_pfn_t(page);
37 dev_dbg_ratelimited(disk_to_dev(bdev->bd_disk)->parent,
38 "%s: sector: %#llx pfn: %#lx\n", __func__,
39 (unsigned long long) sector, page_to_pfn(page));
40
41 return PAGE_SIZE;
42 }
43
44 *kaddr = pmem->virt_addr + offset;
45 *pfn = phys_to_pfn_t(pmem->phys_addr + offset, pmem->pfn_flags);
46
47 /*
48 * If badblocks are present, limit known good range to the
49 * requested range.
50 */
51 if (unlikely(pmem->bb.count))
52 return size;
53 return pmem->size - pmem->pfn_pad - offset;
54}
diff --git a/tools/testing/nvdimm/test/Kbuild b/tools/testing/nvdimm/test/Kbuild
index 9241064970fe..d32f25bba42a 100644
--- a/tools/testing/nvdimm/test/Kbuild
+++ b/tools/testing/nvdimm/test/Kbuild
@@ -1,5 +1,5 @@
1ccflags-y := -I$(src)/../../../../drivers/nvdimm/ 1ccflags-y := -I$(src)/../../../../drivers/nvdimm/
2ccflags-y += -I$(src)/../../../../drivers/acpi/ 2ccflags-y += -I$(src)/../../../../drivers/acpi/nfit/
3 3
4obj-m += nfit_test.o 4obj-m += nfit_test.o
5obj-m += nfit_test_iomap.o 5obj-m += nfit_test_iomap.o
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index c842095f2801..c29f8dca9e67 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -10,11 +10,13 @@
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details. 11 * General Public License for more details.
12 */ 12 */
13#include <linux/memremap.h>
13#include <linux/rculist.h> 14#include <linux/rculist.h>
14#include <linux/export.h> 15#include <linux/export.h>
15#include <linux/ioport.h> 16#include <linux/ioport.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/pfn_t.h>
18#include <linux/io.h> 20#include <linux/io.h>
19#include <linux/mm.h> 21#include <linux/mm.h>
20#include "nfit_test.h" 22#include "nfit_test.h"
@@ -52,7 +54,7 @@ static struct nfit_test_resource *__get_nfit_res(resource_size_t resource)
52 return NULL; 54 return NULL;
53} 55}
54 56
55static struct nfit_test_resource *get_nfit_res(resource_size_t resource) 57struct nfit_test_resource *get_nfit_res(resource_size_t resource)
56{ 58{
57 struct nfit_test_resource *res; 59 struct nfit_test_resource *res;
58 60
@@ -62,6 +64,7 @@ static struct nfit_test_resource *get_nfit_res(resource_size_t resource)
62 64
63 return res; 65 return res;
64} 66}
67EXPORT_SYMBOL(get_nfit_res);
65 68
66void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size, 69void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size,
67 void __iomem *(*fallback_fn)(resource_size_t, unsigned long)) 70 void __iomem *(*fallback_fn)(resource_size_t, unsigned long))
@@ -97,10 +100,6 @@ void *__wrap_devm_memremap(struct device *dev, resource_size_t offset,
97} 100}
98EXPORT_SYMBOL(__wrap_devm_memremap); 101EXPORT_SYMBOL(__wrap_devm_memremap);
99 102
100#ifdef __HAVE_ARCH_PTE_DEVMAP
101#include <linux/memremap.h>
102#include <linux/pfn_t.h>
103
104void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res, 103void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res,
105 struct percpu_ref *ref, struct vmem_altmap *altmap) 104 struct percpu_ref *ref, struct vmem_altmap *altmap)
106{ 105{
@@ -122,19 +121,6 @@ pfn_t __wrap_phys_to_pfn_t(phys_addr_t addr, unsigned long flags)
122 return phys_to_pfn_t(addr, flags); 121 return phys_to_pfn_t(addr, flags);
123} 122}
124EXPORT_SYMBOL(__wrap_phys_to_pfn_t); 123EXPORT_SYMBOL(__wrap_phys_to_pfn_t);
125#else
126/* to be removed post 4.5-rc1 */
127void *__wrap_devm_memremap_pages(struct device *dev, struct resource *res)
128{
129 resource_size_t offset = res->start;
130 struct nfit_test_resource *nfit_res = get_nfit_res(offset);
131
132 if (nfit_res)
133 return nfit_res->buf + offset - nfit_res->res->start;
134 return devm_memremap_pages(dev, res);
135}
136EXPORT_SYMBOL(__wrap_devm_memremap_pages);
137#endif
138 124
139void *__wrap_memremap(resource_size_t offset, size_t size, 125void *__wrap_memremap(resource_size_t offset, size_t size,
140 unsigned long flags) 126 unsigned long flags)
@@ -229,6 +215,22 @@ struct resource *__wrap___request_region(struct resource *parent,
229} 215}
230EXPORT_SYMBOL(__wrap___request_region); 216EXPORT_SYMBOL(__wrap___request_region);
231 217
218int __wrap_insert_resource(struct resource *parent, struct resource *res)
219{
220 if (get_nfit_res(res->start))
221 return 0;
222 return insert_resource(parent, res);
223}
224EXPORT_SYMBOL(__wrap_insert_resource);
225
226int __wrap_remove_resource(struct resource *res)
227{
228 if (get_nfit_res(res->start))
229 return 0;
230 return remove_resource(res);
231}
232EXPORT_SYMBOL(__wrap_remove_resource);
233
232struct resource *__wrap___devm_request_region(struct device *dev, 234struct resource *__wrap___devm_request_region(struct device *dev,
233 struct resource *parent, resource_size_t start, 235 struct resource *parent, resource_size_t start,
234 resource_size_t n, const char *name) 236 resource_size_t n, const char *name)
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index c919866853a0..5404efa578a3 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -98,11 +98,13 @@
98enum { 98enum {
99 NUM_PM = 3, 99 NUM_PM = 3,
100 NUM_DCR = 5, 100 NUM_DCR = 5,
101 NUM_HINTS = 8,
101 NUM_BDW = NUM_DCR, 102 NUM_BDW = NUM_DCR,
102 NUM_SPA = NUM_PM + NUM_DCR + NUM_BDW, 103 NUM_SPA = NUM_PM + NUM_DCR + NUM_BDW,
103 NUM_MEM = NUM_DCR + NUM_BDW + 2 /* spa0 iset */ + 4 /* spa1 iset */, 104 NUM_MEM = NUM_DCR + NUM_BDW + 2 /* spa0 iset */ + 4 /* spa1 iset */,
104 DIMM_SIZE = SZ_32M, 105 DIMM_SIZE = SZ_32M,
105 LABEL_SIZE = SZ_128K, 106 LABEL_SIZE = SZ_128K,
107 SPA_VCD_SIZE = SZ_4M,
106 SPA0_SIZE = DIMM_SIZE, 108 SPA0_SIZE = DIMM_SIZE,
107 SPA1_SIZE = DIMM_SIZE*2, 109 SPA1_SIZE = DIMM_SIZE*2,
108 SPA2_SIZE = DIMM_SIZE, 110 SPA2_SIZE = DIMM_SIZE,
@@ -470,11 +472,7 @@ static void release_nfit_res(void *data)
470 list_del(&nfit_res->list); 472 list_del(&nfit_res->list);
471 spin_unlock(&nfit_test_lock); 473 spin_unlock(&nfit_test_lock);
472 474
473 if (is_vmalloc_addr(nfit_res->buf)) 475 vfree(nfit_res->buf);
474 vfree(nfit_res->buf);
475 else
476 dma_free_coherent(nfit_res->dev, resource_size(res),
477 nfit_res->buf, res->start);
478 kfree(res); 476 kfree(res);
479 kfree(nfit_res); 477 kfree(nfit_res);
480} 478}
@@ -507,9 +505,7 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
507 505
508 return nfit_res->buf; 506 return nfit_res->buf;
509 err: 507 err:
510 if (buf && !is_vmalloc_addr(buf)) 508 if (buf)
511 dma_free_coherent(dev, size, buf, *dma);
512 else if (buf)
513 vfree(buf); 509 vfree(buf);
514 kfree(res); 510 kfree(res);
515 kfree(nfit_res); 511 kfree(nfit_res);
@@ -524,15 +520,6 @@ static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma)
524 return __test_alloc(t, size, dma, buf); 520 return __test_alloc(t, size, dma, buf);
525} 521}
526 522
527static void *test_alloc_coherent(struct nfit_test *t, size_t size,
528 dma_addr_t *dma)
529{
530 struct device *dev = &t->pdev.dev;
531 void *buf = dma_alloc_coherent(dev, size, dma, GFP_KERNEL);
532
533 return __test_alloc(t, size, dma, buf);
534}
535
536static struct nfit_test_resource *nfit_test_lookup(resource_size_t addr) 523static struct nfit_test_resource *nfit_test_lookup(resource_size_t addr)
537{ 524{
538 int i; 525 int i;
@@ -584,7 +571,8 @@ static int nfit_test0_alloc(struct nfit_test *t)
584 + offsetof(struct acpi_nfit_control_region, 571 + offsetof(struct acpi_nfit_control_region,
585 window_size) * NUM_DCR 572 window_size) * NUM_DCR
586 + sizeof(struct acpi_nfit_data_region) * NUM_BDW 573 + sizeof(struct acpi_nfit_data_region) * NUM_BDW
587 + sizeof(struct acpi_nfit_flush_address) * NUM_DCR; 574 + (sizeof(struct acpi_nfit_flush_address)
575 + sizeof(u64) * NUM_HINTS) * NUM_DCR;
588 int i; 576 int i;
589 577
590 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); 578 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma);
@@ -592,15 +580,15 @@ static int nfit_test0_alloc(struct nfit_test *t)
592 return -ENOMEM; 580 return -ENOMEM;
593 t->nfit_size = nfit_size; 581 t->nfit_size = nfit_size;
594 582
595 t->spa_set[0] = test_alloc_coherent(t, SPA0_SIZE, &t->spa_set_dma[0]); 583 t->spa_set[0] = test_alloc(t, SPA0_SIZE, &t->spa_set_dma[0]);
596 if (!t->spa_set[0]) 584 if (!t->spa_set[0])
597 return -ENOMEM; 585 return -ENOMEM;
598 586
599 t->spa_set[1] = test_alloc_coherent(t, SPA1_SIZE, &t->spa_set_dma[1]); 587 t->spa_set[1] = test_alloc(t, SPA1_SIZE, &t->spa_set_dma[1]);
600 if (!t->spa_set[1]) 588 if (!t->spa_set[1])
601 return -ENOMEM; 589 return -ENOMEM;
602 590
603 t->spa_set[2] = test_alloc_coherent(t, SPA0_SIZE, &t->spa_set_dma[2]); 591 t->spa_set[2] = test_alloc(t, SPA0_SIZE, &t->spa_set_dma[2]);
604 if (!t->spa_set[2]) 592 if (!t->spa_set[2])
605 return -ENOMEM; 593 return -ENOMEM;
606 594
@@ -614,7 +602,8 @@ static int nfit_test0_alloc(struct nfit_test *t)
614 return -ENOMEM; 602 return -ENOMEM;
615 sprintf(t->label[i], "label%d", i); 603 sprintf(t->label[i], "label%d", i);
616 604
617 t->flush[i] = test_alloc(t, 8, &t->flush_dma[i]); 605 t->flush[i] = test_alloc(t, sizeof(u64) * NUM_HINTS,
606 &t->flush_dma[i]);
618 if (!t->flush[i]) 607 if (!t->flush[i])
619 return -ENOMEM; 608 return -ENOMEM;
620 } 609 }
@@ -630,7 +619,7 @@ static int nfit_test0_alloc(struct nfit_test *t)
630 619
631static int nfit_test1_alloc(struct nfit_test *t) 620static int nfit_test1_alloc(struct nfit_test *t)
632{ 621{
633 size_t nfit_size = sizeof(struct acpi_nfit_system_address) 622 size_t nfit_size = sizeof(struct acpi_nfit_system_address) * 2
634 + sizeof(struct acpi_nfit_memory_map) 623 + sizeof(struct acpi_nfit_memory_map)
635 + offsetof(struct acpi_nfit_control_region, window_size); 624 + offsetof(struct acpi_nfit_control_region, window_size);
636 625
@@ -639,15 +628,31 @@ static int nfit_test1_alloc(struct nfit_test *t)
639 return -ENOMEM; 628 return -ENOMEM;
640 t->nfit_size = nfit_size; 629 t->nfit_size = nfit_size;
641 630
642 t->spa_set[0] = test_alloc_coherent(t, SPA2_SIZE, &t->spa_set_dma[0]); 631 t->spa_set[0] = test_alloc(t, SPA2_SIZE, &t->spa_set_dma[0]);
643 if (!t->spa_set[0]) 632 if (!t->spa_set[0])
644 return -ENOMEM; 633 return -ENOMEM;
645 634
635 t->spa_set[1] = test_alloc(t, SPA_VCD_SIZE, &t->spa_set_dma[1]);
636 if (!t->spa_set[1])
637 return -ENOMEM;
638
646 return ars_state_init(&t->pdev.dev, &t->ars_state); 639 return ars_state_init(&t->pdev.dev, &t->ars_state);
647} 640}
648 641
642static void dcr_common_init(struct acpi_nfit_control_region *dcr)
643{
644 dcr->vendor_id = 0xabcd;
645 dcr->device_id = 0;
646 dcr->revision_id = 1;
647 dcr->valid_fields = 1;
648 dcr->manufacturing_location = 0xa;
649 dcr->manufacturing_date = cpu_to_be16(2016);
650}
651
649static void nfit_test0_setup(struct nfit_test *t) 652static void nfit_test0_setup(struct nfit_test *t)
650{ 653{
654 const int flush_hint_size = sizeof(struct acpi_nfit_flush_address)
655 + (sizeof(u64) * NUM_HINTS);
651 struct acpi_nfit_desc *acpi_desc; 656 struct acpi_nfit_desc *acpi_desc;
652 struct acpi_nfit_memory_map *memdev; 657 struct acpi_nfit_memory_map *memdev;
653 void *nfit_buf = t->nfit_buf; 658 void *nfit_buf = t->nfit_buf;
@@ -655,7 +660,7 @@ static void nfit_test0_setup(struct nfit_test *t)
655 struct acpi_nfit_control_region *dcr; 660 struct acpi_nfit_control_region *dcr;
656 struct acpi_nfit_data_region *bdw; 661 struct acpi_nfit_data_region *bdw;
657 struct acpi_nfit_flush_address *flush; 662 struct acpi_nfit_flush_address *flush;
658 unsigned int offset; 663 unsigned int offset, i;
659 664
660 /* 665 /*
661 * spa0 (interleave first half of dimm0 and dimm1, note storage 666 * spa0 (interleave first half of dimm0 and dimm1, note storage
@@ -972,9 +977,7 @@ static void nfit_test0_setup(struct nfit_test *t)
972 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 977 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
973 dcr->header.length = sizeof(struct acpi_nfit_control_region); 978 dcr->header.length = sizeof(struct acpi_nfit_control_region);
974 dcr->region_index = 0+1; 979 dcr->region_index = 0+1;
975 dcr->vendor_id = 0xabcd; 980 dcr_common_init(dcr);
976 dcr->device_id = 0;
977 dcr->revision_id = 1;
978 dcr->serial_number = ~handle[0]; 981 dcr->serial_number = ~handle[0];
979 dcr->code = NFIT_FIC_BLK; 982 dcr->code = NFIT_FIC_BLK;
980 dcr->windows = 1; 983 dcr->windows = 1;
@@ -989,9 +992,7 @@ static void nfit_test0_setup(struct nfit_test *t)
989 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 992 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
990 dcr->header.length = sizeof(struct acpi_nfit_control_region); 993 dcr->header.length = sizeof(struct acpi_nfit_control_region);
991 dcr->region_index = 1+1; 994 dcr->region_index = 1+1;
992 dcr->vendor_id = 0xabcd; 995 dcr_common_init(dcr);
993 dcr->device_id = 0;
994 dcr->revision_id = 1;
995 dcr->serial_number = ~handle[1]; 996 dcr->serial_number = ~handle[1];
996 dcr->code = NFIT_FIC_BLK; 997 dcr->code = NFIT_FIC_BLK;
997 dcr->windows = 1; 998 dcr->windows = 1;
@@ -1006,9 +1007,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1006 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 1007 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
1007 dcr->header.length = sizeof(struct acpi_nfit_control_region); 1008 dcr->header.length = sizeof(struct acpi_nfit_control_region);
1008 dcr->region_index = 2+1; 1009 dcr->region_index = 2+1;
1009 dcr->vendor_id = 0xabcd; 1010 dcr_common_init(dcr);
1010 dcr->device_id = 0;
1011 dcr->revision_id = 1;
1012 dcr->serial_number = ~handle[2]; 1011 dcr->serial_number = ~handle[2];
1013 dcr->code = NFIT_FIC_BLK; 1012 dcr->code = NFIT_FIC_BLK;
1014 dcr->windows = 1; 1013 dcr->windows = 1;
@@ -1023,9 +1022,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1023 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 1022 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
1024 dcr->header.length = sizeof(struct acpi_nfit_control_region); 1023 dcr->header.length = sizeof(struct acpi_nfit_control_region);
1025 dcr->region_index = 3+1; 1024 dcr->region_index = 3+1;
1026 dcr->vendor_id = 0xabcd; 1025 dcr_common_init(dcr);
1027 dcr->device_id = 0;
1028 dcr->revision_id = 1;
1029 dcr->serial_number = ~handle[3]; 1026 dcr->serial_number = ~handle[3];
1030 dcr->code = NFIT_FIC_BLK; 1027 dcr->code = NFIT_FIC_BLK;
1031 dcr->windows = 1; 1028 dcr->windows = 1;
@@ -1042,9 +1039,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1042 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1039 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1043 window_size); 1040 window_size);
1044 dcr->region_index = 4+1; 1041 dcr->region_index = 4+1;
1045 dcr->vendor_id = 0xabcd; 1042 dcr_common_init(dcr);
1046 dcr->device_id = 0;
1047 dcr->revision_id = 1;
1048 dcr->serial_number = ~handle[0]; 1043 dcr->serial_number = ~handle[0];
1049 dcr->code = NFIT_FIC_BYTEN; 1044 dcr->code = NFIT_FIC_BYTEN;
1050 dcr->windows = 0; 1045 dcr->windows = 0;
@@ -1056,9 +1051,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1056 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1051 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1057 window_size); 1052 window_size);
1058 dcr->region_index = 5+1; 1053 dcr->region_index = 5+1;
1059 dcr->vendor_id = 0xabcd; 1054 dcr_common_init(dcr);
1060 dcr->device_id = 0;
1061 dcr->revision_id = 1;
1062 dcr->serial_number = ~handle[1]; 1055 dcr->serial_number = ~handle[1];
1063 dcr->code = NFIT_FIC_BYTEN; 1056 dcr->code = NFIT_FIC_BYTEN;
1064 dcr->windows = 0; 1057 dcr->windows = 0;
@@ -1070,9 +1063,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1070 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1063 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1071 window_size); 1064 window_size);
1072 dcr->region_index = 6+1; 1065 dcr->region_index = 6+1;
1073 dcr->vendor_id = 0xabcd; 1066 dcr_common_init(dcr);
1074 dcr->device_id = 0;
1075 dcr->revision_id = 1;
1076 dcr->serial_number = ~handle[2]; 1067 dcr->serial_number = ~handle[2];
1077 dcr->code = NFIT_FIC_BYTEN; 1068 dcr->code = NFIT_FIC_BYTEN;
1078 dcr->windows = 0; 1069 dcr->windows = 0;
@@ -1084,9 +1075,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1084 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1075 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1085 window_size); 1076 window_size);
1086 dcr->region_index = 7+1; 1077 dcr->region_index = 7+1;
1087 dcr->vendor_id = 0xabcd; 1078 dcr_common_init(dcr);
1088 dcr->device_id = 0;
1089 dcr->revision_id = 1;
1090 dcr->serial_number = ~handle[3]; 1079 dcr->serial_number = ~handle[3];
1091 dcr->code = NFIT_FIC_BYTEN; 1080 dcr->code = NFIT_FIC_BYTEN;
1092 dcr->windows = 0; 1081 dcr->windows = 0;
@@ -1141,45 +1130,47 @@ static void nfit_test0_setup(struct nfit_test *t)
1141 /* flush0 (dimm0) */ 1130 /* flush0 (dimm0) */
1142 flush = nfit_buf + offset; 1131 flush = nfit_buf + offset;
1143 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 1132 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
1144 flush->header.length = sizeof(struct acpi_nfit_flush_address); 1133 flush->header.length = flush_hint_size;
1145 flush->device_handle = handle[0]; 1134 flush->device_handle = handle[0];
1146 flush->hint_count = 1; 1135 flush->hint_count = NUM_HINTS;
1147 flush->hint_address[0] = t->flush_dma[0]; 1136 for (i = 0; i < NUM_HINTS; i++)
1137 flush->hint_address[i] = t->flush_dma[0] + i * sizeof(u64);
1148 1138
1149 /* flush1 (dimm1) */ 1139 /* flush1 (dimm1) */
1150 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 1; 1140 flush = nfit_buf + offset + flush_hint_size * 1;
1151 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 1141 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
1152 flush->header.length = sizeof(struct acpi_nfit_flush_address); 1142 flush->header.length = flush_hint_size;
1153 flush->device_handle = handle[1]; 1143 flush->device_handle = handle[1];
1154 flush->hint_count = 1; 1144 flush->hint_count = NUM_HINTS;
1155 flush->hint_address[0] = t->flush_dma[1]; 1145 for (i = 0; i < NUM_HINTS; i++)
1146 flush->hint_address[i] = t->flush_dma[1] + i * sizeof(u64);
1156 1147
1157 /* flush2 (dimm2) */ 1148 /* flush2 (dimm2) */
1158 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 2; 1149 flush = nfit_buf + offset + flush_hint_size * 2;
1159 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 1150 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
1160 flush->header.length = sizeof(struct acpi_nfit_flush_address); 1151 flush->header.length = flush_hint_size;
1161 flush->device_handle = handle[2]; 1152 flush->device_handle = handle[2];
1162 flush->hint_count = 1; 1153 flush->hint_count = NUM_HINTS;
1163 flush->hint_address[0] = t->flush_dma[2]; 1154 for (i = 0; i < NUM_HINTS; i++)
1155 flush->hint_address[i] = t->flush_dma[2] + i * sizeof(u64);
1164 1156
1165 /* flush3 (dimm3) */ 1157 /* flush3 (dimm3) */
1166 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 3; 1158 flush = nfit_buf + offset + flush_hint_size * 3;
1167 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 1159 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
1168 flush->header.length = sizeof(struct acpi_nfit_flush_address); 1160 flush->header.length = flush_hint_size;
1169 flush->device_handle = handle[3]; 1161 flush->device_handle = handle[3];
1170 flush->hint_count = 1; 1162 flush->hint_count = NUM_HINTS;
1171 flush->hint_address[0] = t->flush_dma[3]; 1163 for (i = 0; i < NUM_HINTS; i++)
1164 flush->hint_address[i] = t->flush_dma[3] + i * sizeof(u64);
1172 1165
1173 if (t->setup_hotplug) { 1166 if (t->setup_hotplug) {
1174 offset = offset + sizeof(struct acpi_nfit_flush_address) * 4; 1167 offset = offset + flush_hint_size * 4;
1175 /* dcr-descriptor4: blk */ 1168 /* dcr-descriptor4: blk */
1176 dcr = nfit_buf + offset; 1169 dcr = nfit_buf + offset;
1177 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION; 1170 dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
1178 dcr->header.length = sizeof(struct acpi_nfit_control_region); 1171 dcr->header.length = sizeof(struct acpi_nfit_control_region);
1179 dcr->region_index = 8+1; 1172 dcr->region_index = 8+1;
1180 dcr->vendor_id = 0xabcd; 1173 dcr_common_init(dcr);
1181 dcr->device_id = 0;
1182 dcr->revision_id = 1;
1183 dcr->serial_number = ~handle[4]; 1174 dcr->serial_number = ~handle[4];
1184 dcr->code = NFIT_FIC_BLK; 1175 dcr->code = NFIT_FIC_BLK;
1185 dcr->windows = 1; 1176 dcr->windows = 1;
@@ -1196,9 +1187,7 @@ static void nfit_test0_setup(struct nfit_test *t)
1196 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1187 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1197 window_size); 1188 window_size);
1198 dcr->region_index = 9+1; 1189 dcr->region_index = 9+1;
1199 dcr->vendor_id = 0xabcd; 1190 dcr_common_init(dcr);
1200 dcr->device_id = 0;
1201 dcr->revision_id = 1;
1202 dcr->serial_number = ~handle[4]; 1191 dcr->serial_number = ~handle[4];
1203 dcr->code = NFIT_FIC_BYTEN; 1192 dcr->code = NFIT_FIC_BYTEN;
1204 dcr->windows = 0; 1193 dcr->windows = 0;
@@ -1300,10 +1289,12 @@ static void nfit_test0_setup(struct nfit_test *t)
1300 /* flush3 (dimm4) */ 1289 /* flush3 (dimm4) */
1301 flush = nfit_buf + offset; 1290 flush = nfit_buf + offset;
1302 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS; 1291 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
1303 flush->header.length = sizeof(struct acpi_nfit_flush_address); 1292 flush->header.length = flush_hint_size;
1304 flush->device_handle = handle[4]; 1293 flush->device_handle = handle[4];
1305 flush->hint_count = 1; 1294 flush->hint_count = NUM_HINTS;
1306 flush->hint_address[0] = t->flush_dma[4]; 1295 for (i = 0; i < NUM_HINTS; i++)
1296 flush->hint_address[i] = t->flush_dma[4]
1297 + i * sizeof(u64);
1307 } 1298 }
1308 1299
1309 post_ars_status(&t->ars_state, t->spa_set_dma[0], SPA0_SIZE); 1300 post_ars_status(&t->ars_state, t->spa_set_dma[0], SPA0_SIZE);
@@ -1339,7 +1330,16 @@ static void nfit_test1_setup(struct nfit_test *t)
1339 spa->address = t->spa_set_dma[0]; 1330 spa->address = t->spa_set_dma[0];
1340 spa->length = SPA2_SIZE; 1331 spa->length = SPA2_SIZE;
1341 1332
1342 offset += sizeof(*spa); 1333 /* virtual cd region */
1334 spa = nfit_buf + sizeof(*spa);
1335 spa->header.type = ACPI_NFIT_TYPE_SYSTEM_ADDRESS;
1336 spa->header.length = sizeof(*spa);
1337 memcpy(spa->range_guid, to_nfit_uuid(NFIT_SPA_VCD), 16);
1338 spa->range_index = 0;
1339 spa->address = t->spa_set_dma[1];
1340 spa->length = SPA_VCD_SIZE;
1341
1342 offset += sizeof(*spa) * 2;
1343 /* mem-region0 (spa0, dimm0) */ 1343 /* mem-region0 (spa0, dimm0) */
1344 memdev = nfit_buf + offset; 1344 memdev = nfit_buf + offset;
1345 memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP; 1345 memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
@@ -1365,9 +1365,7 @@ static void nfit_test1_setup(struct nfit_test *t)
1365 dcr->header.length = offsetof(struct acpi_nfit_control_region, 1365 dcr->header.length = offsetof(struct acpi_nfit_control_region,
1366 window_size); 1366 window_size);
1367 dcr->region_index = 0+1; 1367 dcr->region_index = 0+1;
1368 dcr->vendor_id = 0xabcd; 1368 dcr_common_init(dcr);
1369 dcr->device_id = 0;
1370 dcr->revision_id = 1;
1371 dcr->serial_number = ~0; 1369 dcr->serial_number = ~0;
1372 dcr->code = NFIT_FIC_BYTE; 1370 dcr->code = NFIT_FIC_BYTE;
1373 dcr->windows = 0; 1371 dcr->windows = 0;
@@ -1462,20 +1460,16 @@ static int nfit_test_probe(struct platform_device *pdev)
1462 nfit_test->setup(nfit_test); 1460 nfit_test->setup(nfit_test);
1463 acpi_desc = &nfit_test->acpi_desc; 1461 acpi_desc = &nfit_test->acpi_desc;
1464 acpi_nfit_desc_init(acpi_desc, &pdev->dev); 1462 acpi_nfit_desc_init(acpi_desc, &pdev->dev);
1465 acpi_desc->nfit = nfit_test->nfit_buf;
1466 acpi_desc->blk_do_io = nfit_test_blk_do_io; 1463 acpi_desc->blk_do_io = nfit_test_blk_do_io;
1467 nd_desc = &acpi_desc->nd_desc; 1464 nd_desc = &acpi_desc->nd_desc;
1468 nd_desc->provider_name = NULL; 1465 nd_desc->provider_name = NULL;
1466 nd_desc->module = THIS_MODULE;
1469 nd_desc->ndctl = nfit_test_ctl; 1467 nd_desc->ndctl = nfit_test_ctl;
1470 acpi_desc->nvdimm_bus = nvdimm_bus_register(&pdev->dev, nd_desc);
1471 if (!acpi_desc->nvdimm_bus)
1472 return -ENXIO;
1473 1468
1474 rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_size); 1469 rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_buf,
1475 if (rc) { 1470 nfit_test->nfit_size);
1476 nvdimm_bus_unregister(acpi_desc->nvdimm_bus); 1471 if (rc)
1477 return rc; 1472 return rc;
1478 }
1479 1473
1480 if (nfit_test->setup != nfit_test0_setup) 1474 if (nfit_test->setup != nfit_test0_setup)
1481 return 0; 1475 return 0;
@@ -1483,22 +1477,16 @@ static int nfit_test_probe(struct platform_device *pdev)
1483 nfit_test->setup_hotplug = 1; 1477 nfit_test->setup_hotplug = 1;
1484 nfit_test->setup(nfit_test); 1478 nfit_test->setup(nfit_test);
1485 1479
1486 rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_size); 1480 rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_buf,
1487 if (rc) { 1481 nfit_test->nfit_size);
1488 nvdimm_bus_unregister(acpi_desc->nvdimm_bus); 1482 if (rc)
1489 return rc; 1483 return rc;
1490 }
1491 1484
1492 return 0; 1485 return 0;
1493} 1486}
1494 1487
1495static int nfit_test_remove(struct platform_device *pdev) 1488static int nfit_test_remove(struct platform_device *pdev)
1496{ 1489{
1497 struct nfit_test *nfit_test = to_nfit_test(&pdev->dev);
1498 struct acpi_nfit_desc *acpi_desc = &nfit_test->acpi_desc;
1499
1500 nvdimm_bus_unregister(acpi_desc->nvdimm_bus);
1501
1502 return 0; 1490 return 0;
1503} 1491}
1504 1492
@@ -1523,12 +1511,6 @@ static struct platform_driver nfit_test_driver = {
1523 .id_table = nfit_test_id, 1511 .id_table = nfit_test_id,
1524}; 1512};
1525 1513
1526#ifdef CONFIG_CMA_SIZE_MBYTES
1527#define CMA_SIZE_MBYTES CONFIG_CMA_SIZE_MBYTES
1528#else
1529#define CMA_SIZE_MBYTES 0
1530#endif
1531
1532static __init int nfit_test_init(void) 1514static __init int nfit_test_init(void)
1533{ 1515{
1534 int rc, i; 1516 int rc, i;
@@ -1538,7 +1520,6 @@ static __init int nfit_test_init(void)
1538 for (i = 0; i < NUM_NFITS; i++) { 1520 for (i = 0; i < NUM_NFITS; i++) {
1539 struct nfit_test *nfit_test; 1521 struct nfit_test *nfit_test;
1540 struct platform_device *pdev; 1522 struct platform_device *pdev;
1541 static int once;
1542 1523
1543 nfit_test = kzalloc(sizeof(*nfit_test), GFP_KERNEL); 1524 nfit_test = kzalloc(sizeof(*nfit_test), GFP_KERNEL);
1544 if (!nfit_test) { 1525 if (!nfit_test) {
@@ -1577,20 +1558,6 @@ static __init int nfit_test_init(void)
1577 goto err_register; 1558 goto err_register;
1578 1559
1579 instances[i] = nfit_test; 1560 instances[i] = nfit_test;
1580
1581 if (!once++) {
1582 dma_addr_t dma;
1583 void *buf;
1584
1585 buf = dma_alloc_coherent(&pdev->dev, SZ_128M, &dma,
1586 GFP_KERNEL);
1587 if (!buf) {
1588 rc = -ENOMEM;
1589 dev_warn(&pdev->dev, "need 128M of free cma\n");
1590 goto err_register;
1591 }
1592 dma_free_coherent(&pdev->dev, SZ_128M, buf, dma);
1593 }
1594 } 1561 }
1595 1562
1596 rc = platform_driver_register(&nfit_test_driver); 1563 rc = platform_driver_register(&nfit_test_driver);
diff --git a/tools/testing/nvdimm/test/nfit_test.h b/tools/testing/nvdimm/test/nfit_test.h
index 96c5e16d7db9..9f18e2a4a862 100644
--- a/tools/testing/nvdimm/test/nfit_test.h
+++ b/tools/testing/nvdimm/test/nfit_test.h
@@ -12,6 +12,7 @@
12 */ 12 */
13#ifndef __NFIT_TEST_H__ 13#ifndef __NFIT_TEST_H__
14#define __NFIT_TEST_H__ 14#define __NFIT_TEST_H__
15#include <linux/list.h>
15 16
16struct nfit_test_resource { 17struct nfit_test_resource {
17 struct list_head list; 18 struct list_head list;
@@ -26,4 +27,5 @@ void __iomem *__wrap_ioremap_nocache(resource_size_t offset,
26void __wrap_iounmap(volatile void __iomem *addr); 27void __wrap_iounmap(volatile void __iomem *addr);
27void nfit_test_setup(nfit_test_lookup_fn lookup); 28void nfit_test_setup(nfit_test_lookup_fn lookup);
28void nfit_test_teardown(void); 29void nfit_test_teardown(void);
30struct nfit_test_resource *get_nfit_res(resource_size_t resource);
29#endif 31#endif