diff options
| author | Dan Williams <dan.j.williams@intel.com> | 2016-08-19 01:15:04 -0400 |
|---|---|---|
| committer | Dan Williams <dan.j.williams@intel.com> | 2016-08-23 10:49:42 -0400 |
| commit | c14a868a5a14f385059f012e54291de95a538a02 (patch) | |
| tree | 8a084782e9a79def7bc9d4a95ea4f6e7fb369cbd /tools/testing/nvdimm | |
| parent | c09f12186d6b03b798832d95289af76495990192 (diff) | |
tools/testing/nvdimm: unit test for acpi_nfit_notify()
We have had a couple bugs in this implementation in the past and before
we add another ->notify() implementation for nvdimm devices, lets allow
this routine to be exercised via nfit_test.
Rewrite acpi_nfit_notify() in terms of a generic struct device and
acpi_handle parameter, and then implement a mock acpi_evaluate_object()
that returns a _FIT payload.
Cc: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'tools/testing/nvdimm')
| -rw-r--r-- | tools/testing/nvdimm/Kbuild | 1 | ||||
| -rw-r--r-- | tools/testing/nvdimm/test/iomap.c | 17 | ||||
| -rw-r--r-- | tools/testing/nvdimm/test/nfit.c | 21 |
3 files changed, 33 insertions, 6 deletions
diff --git a/tools/testing/nvdimm/Kbuild b/tools/testing/nvdimm/Kbuild index ad6dd0543019..582db95127ed 100644 --- a/tools/testing/nvdimm/Kbuild +++ b/tools/testing/nvdimm/Kbuild | |||
| @@ -13,6 +13,7 @@ ldflags-y += --wrap=__release_region | |||
| 13 | ldflags-y += --wrap=devm_memremap_pages | 13 | ldflags-y += --wrap=devm_memremap_pages |
| 14 | ldflags-y += --wrap=insert_resource | 14 | ldflags-y += --wrap=insert_resource |
| 15 | ldflags-y += --wrap=remove_resource | 15 | ldflags-y += --wrap=remove_resource |
| 16 | ldflags-y += --wrap=acpi_evaluate_object | ||
| 16 | 17 | ||
| 17 | DRIVERS := ../../../drivers | 18 | DRIVERS := ../../../drivers |
| 18 | NVDIMM_SRC := $(DRIVERS)/nvdimm | 19 | NVDIMM_SRC := $(DRIVERS)/nvdimm |
diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c index c29f8dca9e67..dae5b9b6d186 100644 --- a/tools/testing/nvdimm/test/iomap.c +++ b/tools/testing/nvdimm/test/iomap.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 18 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 19 | #include <linux/pfn_t.h> | 19 | #include <linux/pfn_t.h> |
| 20 | #include <linux/acpi.h> | ||
| 20 | #include <linux/io.h> | 21 | #include <linux/io.h> |
| 21 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
| 22 | #include "nfit_test.h" | 23 | #include "nfit_test.h" |
| @@ -276,4 +277,20 @@ void __wrap___devm_release_region(struct device *dev, struct resource *parent, | |||
| 276 | } | 277 | } |
| 277 | EXPORT_SYMBOL(__wrap___devm_release_region); | 278 | EXPORT_SYMBOL(__wrap___devm_release_region); |
| 278 | 279 | ||
| 280 | acpi_status __wrap_acpi_evaluate_object(acpi_handle handle, acpi_string path, | ||
| 281 | struct acpi_object_list *p, struct acpi_buffer *buf) | ||
| 282 | { | ||
| 283 | struct nfit_test_resource *nfit_res = get_nfit_res((long) handle); | ||
| 284 | union acpi_object **obj; | ||
| 285 | |||
| 286 | if (!nfit_res || strcmp(path, "_FIT") || !buf) | ||
| 287 | return acpi_evaluate_object(handle, path, p, buf); | ||
| 288 | |||
| 289 | obj = nfit_res->buf; | ||
| 290 | buf->length = sizeof(union acpi_object); | ||
| 291 | buf->pointer = *obj; | ||
| 292 | return AE_OK; | ||
| 293 | } | ||
| 294 | EXPORT_SYMBOL(__wrap_acpi_evaluate_object); | ||
| 295 | |||
| 279 | MODULE_LICENSE("GPL v2"); | 296 | MODULE_LICENSE("GPL v2"); |
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index dd48f421844c..8d79c75d3cae 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c | |||
| @@ -154,6 +154,8 @@ struct nfit_test { | |||
| 154 | int (*alloc)(struct nfit_test *t); | 154 | int (*alloc)(struct nfit_test *t); |
| 155 | void (*setup)(struct nfit_test *t); | 155 | void (*setup)(struct nfit_test *t); |
| 156 | int setup_hotplug; | 156 | int setup_hotplug; |
| 157 | union acpi_object **_fit; | ||
| 158 | dma_addr_t _fit_dma; | ||
| 157 | struct ars_state { | 159 | struct ars_state { |
| 158 | struct nd_cmd_ars_status *ars_status; | 160 | struct nd_cmd_ars_status *ars_status; |
| 159 | unsigned long deadline; | 161 | unsigned long deadline; |
| @@ -615,6 +617,10 @@ static int nfit_test0_alloc(struct nfit_test *t) | |||
| 615 | return -ENOMEM; | 617 | return -ENOMEM; |
| 616 | } | 618 | } |
| 617 | 619 | ||
| 620 | t->_fit = test_alloc(t, sizeof(union acpi_object **), &t->_fit_dma); | ||
| 621 | if (!t->_fit) | ||
| 622 | return -ENOMEM; | ||
| 623 | |||
| 618 | return ars_state_init(&t->pdev.dev, &t->ars_state); | 624 | return ars_state_init(&t->pdev.dev, &t->ars_state); |
| 619 | } | 625 | } |
| 620 | 626 | ||
| @@ -1408,6 +1414,7 @@ static int nfit_test_probe(struct platform_device *pdev) | |||
| 1408 | struct acpi_nfit_desc *acpi_desc; | 1414 | struct acpi_nfit_desc *acpi_desc; |
| 1409 | struct device *dev = &pdev->dev; | 1415 | struct device *dev = &pdev->dev; |
| 1410 | struct nfit_test *nfit_test; | 1416 | struct nfit_test *nfit_test; |
| 1417 | union acpi_object *obj; | ||
| 1411 | int rc; | 1418 | int rc; |
| 1412 | 1419 | ||
| 1413 | nfit_test = to_nfit_test(&pdev->dev); | 1420 | nfit_test = to_nfit_test(&pdev->dev); |
| @@ -1475,15 +1482,17 @@ static int nfit_test_probe(struct platform_device *pdev) | |||
| 1475 | if (nfit_test->setup != nfit_test0_setup) | 1482 | if (nfit_test->setup != nfit_test0_setup) |
| 1476 | return 0; | 1483 | return 0; |
| 1477 | 1484 | ||
| 1478 | flush_work(&acpi_desc->work); | ||
| 1479 | nfit_test->setup_hotplug = 1; | 1485 | nfit_test->setup_hotplug = 1; |
| 1480 | nfit_test->setup(nfit_test); | 1486 | nfit_test->setup(nfit_test); |
| 1481 | 1487 | ||
| 1482 | rc = acpi_nfit_init(acpi_desc, nfit_test->nfit_buf, | 1488 | obj = kzalloc(sizeof(*obj), GFP_KERNEL); |
| 1483 | nfit_test->nfit_size); | 1489 | if (!obj) |
| 1484 | if (rc) | 1490 | return -ENOMEM; |
| 1485 | return rc; | 1491 | obj->type = ACPI_TYPE_BUFFER; |
| 1486 | 1492 | obj->buffer.length = nfit_test->nfit_size; | |
| 1493 | obj->buffer.pointer = nfit_test->nfit_buf; | ||
| 1494 | *(nfit_test->_fit) = obj; | ||
| 1495 | __acpi_nfit_notify(&pdev->dev, nfit_test, 0x80); | ||
| 1487 | return 0; | 1496 | return 0; |
| 1488 | } | 1497 | } |
| 1489 | 1498 | ||
