diff options
| author | Dan Williams <dan.j.williams@intel.com> | 2016-10-19 00:48:19 -0400 |
|---|---|---|
| committer | Dan Williams <dan.j.williams@intel.com> | 2016-10-19 11:57:33 -0400 |
| commit | dafb1048740c36c008fc093bea3532637c143f91 (patch) | |
| tree | 23c4919bcf91adc3a65b628c8fff84308dd2c8c7 /tools/testing | |
| parent | 42237e393f64d619ed56e17fbf8fd27526485695 (diff) | |
tools/testing/nvdimm: dynamic label support
Update nfit_test infrastructure to enable labels for the dimm on the
nfit_test.1 bus. This bus has a pmem region without aliased blk space,
so it is a candidate for dynamically enabling label support by writing
a namespace index block.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/nvdimm/test/nfit.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c index c9a6458cb63e..c02f9a8bd382 100644 --- a/tools/testing/nvdimm/test/nfit.c +++ b/tools/testing/nvdimm/test/nfit.c | |||
| @@ -124,12 +124,13 @@ struct nfit_test_dcr { | |||
| 124 | (((node & 0xfff) << 16) | ((socket & 0xf) << 12) \ | 124 | (((node & 0xfff) << 16) | ((socket & 0xf) << 12) \ |
| 125 | | ((imc & 0xf) << 8) | ((chan & 0xf) << 4) | (dimm & 0xf)) | 125 | | ((imc & 0xf) << 8) | ((chan & 0xf) << 4) | (dimm & 0xf)) |
| 126 | 126 | ||
| 127 | static u32 handle[NUM_DCR] = { | 127 | static u32 handle[] = { |
| 128 | [0] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 0), | 128 | [0] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 0), |
| 129 | [1] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 1), | 129 | [1] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 1), |
| 130 | [2] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 0), | 130 | [2] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 0), |
| 131 | [3] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 1), | 131 | [3] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 1), |
| 132 | [4] = NFIT_DIMM_HANDLE(0, 1, 0, 0, 0), | 132 | [4] = NFIT_DIMM_HANDLE(0, 1, 0, 0, 0), |
| 133 | [5] = NFIT_DIMM_HANDLE(1, 0, 0, 0, 0), | ||
| 133 | }; | 134 | }; |
| 134 | 135 | ||
| 135 | static unsigned long dimm_fail_cmd_flags[NUM_DCR]; | 136 | static unsigned long dimm_fail_cmd_flags[NUM_DCR]; |
| @@ -141,6 +142,7 @@ struct nfit_test { | |||
| 141 | void *nfit_buf; | 142 | void *nfit_buf; |
| 142 | dma_addr_t nfit_dma; | 143 | dma_addr_t nfit_dma; |
| 143 | size_t nfit_size; | 144 | size_t nfit_size; |
| 145 | int dcr_idx; | ||
| 144 | int num_dcr; | 146 | int num_dcr; |
| 145 | int num_pm; | 147 | int num_pm; |
| 146 | void **dimm; | 148 | void **dimm; |
| @@ -425,11 +427,11 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc, | |||
| 425 | break; | 427 | break; |
| 426 | case ND_CMD_GET_CONFIG_DATA: | 428 | case ND_CMD_GET_CONFIG_DATA: |
| 427 | rc = nfit_test_cmd_get_config_data(buf, buf_len, | 429 | rc = nfit_test_cmd_get_config_data(buf, buf_len, |
| 428 | t->label[i]); | 430 | t->label[i - t->dcr_idx]); |
| 429 | break; | 431 | break; |
| 430 | case ND_CMD_SET_CONFIG_DATA: | 432 | case ND_CMD_SET_CONFIG_DATA: |
| 431 | rc = nfit_test_cmd_set_config_data(buf, buf_len, | 433 | rc = nfit_test_cmd_set_config_data(buf, buf_len, |
| 432 | t->label[i]); | 434 | t->label[i - t->dcr_idx]); |
| 433 | break; | 435 | break; |
| 434 | case ND_CMD_SMART: | 436 | case ND_CMD_SMART: |
| 435 | rc = nfit_test_cmd_smart(buf, buf_len); | 437 | rc = nfit_test_cmd_smart(buf, buf_len); |
| @@ -681,7 +683,7 @@ static int nfit_test0_alloc(struct nfit_test *t) | |||
| 681 | if (!t->spa_set[2]) | 683 | if (!t->spa_set[2]) |
| 682 | return -ENOMEM; | 684 | return -ENOMEM; |
| 683 | 685 | ||
| 684 | for (i = 0; i < NUM_DCR; i++) { | 686 | for (i = 0; i < t->num_dcr; i++) { |
| 685 | t->dimm[i] = test_alloc(t, DIMM_SIZE, &t->dimm_dma[i]); | 687 | t->dimm[i] = test_alloc(t, DIMM_SIZE, &t->dimm_dma[i]); |
| 686 | if (!t->dimm[i]) | 688 | if (!t->dimm[i]) |
| 687 | return -ENOMEM; | 689 | return -ENOMEM; |
| @@ -698,7 +700,7 @@ static int nfit_test0_alloc(struct nfit_test *t) | |||
| 698 | return -ENOMEM; | 700 | return -ENOMEM; |
| 699 | } | 701 | } |
| 700 | 702 | ||
| 701 | for (i = 0; i < NUM_DCR; i++) { | 703 | for (i = 0; i < t->num_dcr; i++) { |
| 702 | t->dcr[i] = test_alloc(t, LABEL_SIZE, &t->dcr_dma[i]); | 704 | t->dcr[i] = test_alloc(t, LABEL_SIZE, &t->dcr_dma[i]); |
| 703 | if (!t->dcr[i]) | 705 | if (!t->dcr[i]) |
| 704 | return -ENOMEM; | 706 | return -ENOMEM; |
| @@ -727,6 +729,7 @@ static int nfit_test1_alloc(struct nfit_test *t) | |||
| 727 | size_t nfit_size = sizeof(struct acpi_nfit_system_address) * 2 | 729 | size_t nfit_size = sizeof(struct acpi_nfit_system_address) * 2 |
| 728 | + sizeof(struct acpi_nfit_memory_map) | 730 | + sizeof(struct acpi_nfit_memory_map) |
| 729 | + offsetof(struct acpi_nfit_control_region, window_size); | 731 | + offsetof(struct acpi_nfit_control_region, window_size); |
| 732 | int i; | ||
| 730 | 733 | ||
| 731 | t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); | 734 | t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma); |
| 732 | if (!t->nfit_buf) | 735 | if (!t->nfit_buf) |
| @@ -737,6 +740,13 @@ static int nfit_test1_alloc(struct nfit_test *t) | |||
| 737 | if (!t->spa_set[0]) | 740 | if (!t->spa_set[0]) |
| 738 | return -ENOMEM; | 741 | return -ENOMEM; |
| 739 | 742 | ||
| 743 | for (i = 0; i < t->num_dcr; i++) { | ||
| 744 | t->label[i] = test_alloc(t, LABEL_SIZE, &t->label_dma[i]); | ||
| 745 | if (!t->label[i]) | ||
| 746 | return -ENOMEM; | ||
| 747 | sprintf(t->label[i], "label%d", i); | ||
| 748 | } | ||
| 749 | |||
| 740 | t->spa_set[1] = test_alloc(t, SPA_VCD_SIZE, &t->spa_set_dma[1]); | 750 | t->spa_set[1] = test_alloc(t, SPA_VCD_SIZE, &t->spa_set_dma[1]); |
| 741 | if (!t->spa_set[1]) | 751 | if (!t->spa_set[1]) |
| 742 | return -ENOMEM; | 752 | return -ENOMEM; |
| @@ -1449,7 +1459,7 @@ static void nfit_test1_setup(struct nfit_test *t) | |||
| 1449 | memdev = nfit_buf + offset; | 1459 | memdev = nfit_buf + offset; |
| 1450 | memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP; | 1460 | memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP; |
| 1451 | memdev->header.length = sizeof(*memdev); | 1461 | memdev->header.length = sizeof(*memdev); |
| 1452 | memdev->device_handle = 0; | 1462 | memdev->device_handle = handle[5]; |
| 1453 | memdev->physical_id = 0; | 1463 | memdev->physical_id = 0; |
| 1454 | memdev->region_id = 0; | 1464 | memdev->region_id = 0; |
| 1455 | memdev->range_index = 0+1; | 1465 | memdev->range_index = 0+1; |
| @@ -1471,7 +1481,7 @@ static void nfit_test1_setup(struct nfit_test *t) | |||
| 1471 | window_size); | 1481 | window_size); |
| 1472 | dcr->region_index = 0+1; | 1482 | dcr->region_index = 0+1; |
| 1473 | dcr_common_init(dcr); | 1483 | dcr_common_init(dcr); |
| 1474 | dcr->serial_number = ~0; | 1484 | dcr->serial_number = ~handle[5]; |
| 1475 | dcr->code = NFIT_FIC_BYTE; | 1485 | dcr->code = NFIT_FIC_BYTE; |
| 1476 | dcr->windows = 0; | 1486 | dcr->windows = 0; |
| 1477 | 1487 | ||
| @@ -1482,6 +1492,9 @@ static void nfit_test1_setup(struct nfit_test *t) | |||
| 1482 | set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); | 1492 | set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en); |
| 1483 | set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); | 1493 | set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en); |
| 1484 | set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); | 1494 | set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_cmd_force_en); |
| 1495 | set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_cmd_force_en); | ||
| 1496 | set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); | ||
| 1497 | set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_cmd_force_en); | ||
| 1485 | } | 1498 | } |
| 1486 | 1499 | ||
| 1487 | static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa, | 1500 | static int nfit_test_blk_do_io(struct nd_blk_region *ndbr, resource_size_t dpa, |
| @@ -1658,12 +1671,15 @@ static __init int nfit_test_init(void) | |||
| 1658 | switch (i) { | 1671 | switch (i) { |
| 1659 | case 0: | 1672 | case 0: |
| 1660 | nfit_test->num_pm = NUM_PM; | 1673 | nfit_test->num_pm = NUM_PM; |
| 1674 | nfit_test->dcr_idx = 0; | ||
| 1661 | nfit_test->num_dcr = NUM_DCR; | 1675 | nfit_test->num_dcr = NUM_DCR; |
| 1662 | nfit_test->alloc = nfit_test0_alloc; | 1676 | nfit_test->alloc = nfit_test0_alloc; |
| 1663 | nfit_test->setup = nfit_test0_setup; | 1677 | nfit_test->setup = nfit_test0_setup; |
| 1664 | break; | 1678 | break; |
| 1665 | case 1: | 1679 | case 1: |
| 1666 | nfit_test->num_pm = 1; | 1680 | nfit_test->num_pm = 1; |
| 1681 | nfit_test->dcr_idx = NUM_DCR; | ||
| 1682 | nfit_test->num_dcr = 1; | ||
| 1667 | nfit_test->alloc = nfit_test1_alloc; | 1683 | nfit_test->alloc = nfit_test1_alloc; |
| 1668 | nfit_test->setup = nfit_test1_setup; | 1684 | nfit_test->setup = nfit_test1_setup; |
| 1669 | break; | 1685 | break; |
