summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2015-07-10 14:07:03 -0400
committerDan Williams <dan.j.williams@intel.com>2015-07-10 14:07:03 -0400
commit9d27a87ec9e1317d368b1e5e3f4808078baa8c4c (patch)
tree8b1bfc29445dadd61368385dcd1a16add9e3bbb7
parentf7ec83684af020c961d7fab801f8e3ef7ce5de33 (diff)
tools/testing/nvdimm: add mock acpi_nfit_flush_address entries to nfit_test
In preparation for fixing the BLK path to properly use "directed pcommit" enable the unit test infrastructure to emit mock "flush" tables. Writes to these flush addresses trigger a memory controller to flush its internal buffers to persistent media, similar to the x86 "pcommit" instruction. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--tools/testing/nvdimm/Kbuild2
-rw-r--r--tools/testing/nvdimm/test/iomap.c21
-rw-r--r--tools/testing/nvdimm/test/nfit.c50
3 files changed, 71 insertions, 2 deletions
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild
index 8e020601c773..f56914c7929b 100644
--- a/tools/testing/nvdimm/Kbuild
+++ b/tools/testing/nvdimm/Kbuild
@@ -1,4 +1,6 @@
1ldflags-y += --wrap=ioremap_wt 1ldflags-y += --wrap=ioremap_wt
2ldflags-y += --wrap=ioremap_wc
3ldflags-y += --wrap=devm_ioremap_nocache
2ldflags-y += --wrap=ioremap_cache 4ldflags-y += --wrap=ioremap_cache
3ldflags-y += --wrap=ioremap_nocache 5ldflags-y += --wrap=ioremap_nocache
4ldflags-y += --wrap=iounmap 6ldflags-y += --wrap=iounmap
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index 9f21b150396b..64bfaa50831c 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -65,6 +65,21 @@ void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size,
65 return fallback_fn(offset, size); 65 return fallback_fn(offset, size);
66} 66}
67 67
68void __iomem *__wrap_devm_ioremap_nocache(struct device *dev,
69 resource_size_t offset, unsigned long size)
70{
71 struct nfit_test_resource *nfit_res;
72
73 rcu_read_lock();
74 nfit_res = get_nfit_res(offset);
75 rcu_read_unlock();
76 if (nfit_res)
77 return (void __iomem *) nfit_res->buf + offset
78 - nfit_res->res->start;
79 return devm_ioremap_nocache(dev, offset, size);
80}
81EXPORT_SYMBOL(__wrap_devm_ioremap_nocache);
82
68void __iomem *__wrap_ioremap_cache(resource_size_t offset, unsigned long size) 83void __iomem *__wrap_ioremap_cache(resource_size_t offset, unsigned long size)
69{ 84{
70 return __nfit_test_ioremap(offset, size, ioremap_cache); 85 return __nfit_test_ioremap(offset, size, ioremap_cache);
@@ -83,6 +98,12 @@ void __iomem *__wrap_ioremap_wt(resource_size_t offset, unsigned long size)
83} 98}
84EXPORT_SYMBOL(__wrap_ioremap_wt); 99EXPORT_SYMBOL(__wrap_ioremap_wt);
85 100
101void __iomem *__wrap_ioremap_wc(resource_size_t offset, unsigned long size)
102{
103 return __nfit_test_ioremap(offset, size, ioremap_wc);
104}
105EXPORT_SYMBOL(__wrap_ioremap_wc);
106
86void __wrap_iounmap(volatile void __iomem *addr) 107void __wrap_iounmap(volatile void __iomem *addr)
87{ 108{
88 struct nfit_test_resource *nfit_res; 109 struct nfit_test_resource *nfit_res;
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 092d4724fe16..d0bdae40ccc9 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -128,6 +128,8 @@ struct nfit_test {
128 int num_pm; 128 int num_pm;
129 void **dimm; 129 void **dimm;
130 dma_addr_t *dimm_dma; 130 dma_addr_t *dimm_dma;
131 void **flush;
132 dma_addr_t *flush_dma;
131 void **label; 133 void **label;
132 dma_addr_t *label_dma; 134 dma_addr_t *label_dma;
133 void **spa_set; 135 void **spa_set;
@@ -331,7 +333,8 @@ static int nfit_test0_alloc(struct nfit_test *t)
331 + sizeof(struct acpi_nfit_system_address) * NUM_SPA 333 + sizeof(struct acpi_nfit_system_address) * NUM_SPA
332 + sizeof(struct acpi_nfit_memory_map) * NUM_MEM 334 + sizeof(struct acpi_nfit_memory_map) * NUM_MEM
333 + sizeof(struct acpi_nfit_control_region) * NUM_DCR 335 + sizeof(struct acpi_nfit_control_region) * NUM_DCR
334 + sizeof(struct acpi_nfit_data_region) * NUM_BDW; 336 + sizeof(struct acpi_nfit_data_region) * NUM_BDW
337 + sizeof(struct acpi_nfit_flush_address) * NUM_DCR;
335 int i; 338 int i;
336 339
337 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); 340 t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma);
@@ -356,6 +359,10 @@ static int nfit_test0_alloc(struct nfit_test *t)
356 if (!t->label[i]) 359 if (!t->label[i])
357 return -ENOMEM; 360 return -ENOMEM;
358 sprintf(t->label[i], "label%d", i); 361 sprintf(t->label[i], "label%d", i);
362
363 t->flush[i] = test_alloc(t, 8, &t->flush_dma[i]);
364 if (!t->flush[i])
365 return -ENOMEM;
359 } 366 }
360 367
361 for (i = 0; i < NUM_DCR; i++) { 368 for (i = 0; i < NUM_DCR; i++) {
@@ -408,6 +415,7 @@ static void nfit_test0_setup(struct nfit_test *t)
408 struct acpi_nfit_system_address *spa; 415 struct acpi_nfit_system_address *spa;
409 struct acpi_nfit_control_region *dcr; 416 struct acpi_nfit_control_region *dcr;
410 struct acpi_nfit_data_region *bdw; 417 struct acpi_nfit_data_region *bdw;
418 struct acpi_nfit_flush_address *flush;
411 unsigned int offset; 419 unsigned int offset;
412 420
413 nfit_test_init_header(nfit_buf, size); 421 nfit_test_init_header(nfit_buf, size);
@@ -831,6 +839,39 @@ static void nfit_test0_setup(struct nfit_test *t)
831 bdw->capacity = DIMM_SIZE; 839 bdw->capacity = DIMM_SIZE;
832 bdw->start_address = 0; 840 bdw->start_address = 0;
833 841
842 offset = offset + sizeof(struct acpi_nfit_data_region) * 4;
843 /* flush0 (dimm0) */
844 flush = nfit_buf + offset;
845 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
846 flush->header.length = sizeof(struct acpi_nfit_flush_address);
847 flush->device_handle = handle[0];
848 flush->hint_count = 1;
849 flush->hint_address[0] = t->flush_dma[0];
850
851 /* flush1 (dimm1) */
852 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 1;
853 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
854 flush->header.length = sizeof(struct acpi_nfit_flush_address);
855 flush->device_handle = handle[1];
856 flush->hint_count = 1;
857 flush->hint_address[0] = t->flush_dma[1];
858
859 /* flush2 (dimm2) */
860 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 2;
861 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
862 flush->header.length = sizeof(struct acpi_nfit_flush_address);
863 flush->device_handle = handle[2];
864 flush->hint_count = 1;
865 flush->hint_address[0] = t->flush_dma[2];
866
867 /* flush3 (dimm3) */
868 flush = nfit_buf + offset + sizeof(struct acpi_nfit_flush_address) * 3;
869 flush->header.type = ACPI_NFIT_TYPE_FLUSH_ADDRESS;
870 flush->header.length = sizeof(struct acpi_nfit_flush_address);
871 flush->device_handle = handle[3];
872 flush->hint_count = 1;
873 flush->hint_address[0] = t->flush_dma[3];
874
834 acpi_desc = &t->acpi_desc; 875 acpi_desc = &t->acpi_desc;
835 set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en); 876 set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
836 set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en); 877 set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
@@ -933,6 +974,10 @@ static int nfit_test_probe(struct platform_device *pdev)
933 GFP_KERNEL); 974 GFP_KERNEL);
934 nfit_test->dimm_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t), 975 nfit_test->dimm_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t),
935 GFP_KERNEL); 976 GFP_KERNEL);
977 nfit_test->flush = devm_kcalloc(dev, num, sizeof(void *),
978 GFP_KERNEL);
979 nfit_test->flush_dma = devm_kcalloc(dev, num, sizeof(dma_addr_t),
980 GFP_KERNEL);
936 nfit_test->label = devm_kcalloc(dev, num, sizeof(void *), 981 nfit_test->label = devm_kcalloc(dev, num, sizeof(void *),
937 GFP_KERNEL); 982 GFP_KERNEL);
938 nfit_test->label_dma = devm_kcalloc(dev, num, 983 nfit_test->label_dma = devm_kcalloc(dev, num,
@@ -943,7 +988,8 @@ static int nfit_test_probe(struct platform_device *pdev)
943 sizeof(dma_addr_t), GFP_KERNEL); 988 sizeof(dma_addr_t), GFP_KERNEL);
944 if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label 989 if (nfit_test->dimm && nfit_test->dimm_dma && nfit_test->label
945 && nfit_test->label_dma && nfit_test->dcr 990 && nfit_test->label_dma && nfit_test->dcr
946 && nfit_test->dcr_dma) 991 && nfit_test->dcr_dma && nfit_test->flush
992 && nfit_test->flush_dma)
947 /* pass */; 993 /* pass */;
948 else 994 else
949 return -ENOMEM; 995 return -ENOMEM;