Skip to content

Commit dafb104

Browse files
committed
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>
1 parent 42237e3 commit dafb104

File tree

1 file changed

+23
-7
lines changed
  • tools/testing/nvdimm/test

1 file changed

+23
-7
lines changed

tools/testing/nvdimm/test/nfit.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ struct nfit_test_dcr {
124124
(((node & 0xfff) << 16) | ((socket & 0xf) << 12) \
125125
| ((imc & 0xf) << 8) | ((chan & 0xf) << 4) | (dimm & 0xf))
126126

127-
static u32 handle[NUM_DCR] = {
127+
static u32 handle[] = {
128128
[0] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 0),
129129
[1] = NFIT_DIMM_HANDLE(0, 0, 0, 0, 1),
130130
[2] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 0),
131131
[3] = NFIT_DIMM_HANDLE(0, 0, 1, 0, 1),
132132
[4] = NFIT_DIMM_HANDLE(0, 1, 0, 0, 0),
133+
[5] = NFIT_DIMM_HANDLE(1, 0, 0, 0, 0),
133134
};
134135

135136
static unsigned long dimm_fail_cmd_flags[NUM_DCR];
@@ -141,6 +142,7 @@ struct nfit_test {
141142
void *nfit_buf;
142143
dma_addr_t nfit_dma;
143144
size_t nfit_size;
145+
int dcr_idx;
144146
int num_dcr;
145147
int num_pm;
146148
void **dimm;
@@ -425,11 +427,11 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
425427
break;
426428
case ND_CMD_GET_CONFIG_DATA:
427429
rc = nfit_test_cmd_get_config_data(buf, buf_len,
428-
t->label[i]);
430+
t->label[i - t->dcr_idx]);
429431
break;
430432
case ND_CMD_SET_CONFIG_DATA:
431433
rc = nfit_test_cmd_set_config_data(buf, buf_len,
432-
t->label[i]);
434+
t->label[i - t->dcr_idx]);
433435
break;
434436
case ND_CMD_SMART:
435437
rc = nfit_test_cmd_smart(buf, buf_len);
@@ -681,7 +683,7 @@ static int nfit_test0_alloc(struct nfit_test *t)
681683
if (!t->spa_set[2])
682684
return -ENOMEM;
683685

684-
for (i = 0; i < NUM_DCR; i++) {
686+
for (i = 0; i < t->num_dcr; i++) {
685687
t->dimm[i] = test_alloc(t, DIMM_SIZE, &t->dimm_dma[i]);
686688
if (!t->dimm[i])
687689
return -ENOMEM;
@@ -698,7 +700,7 @@ static int nfit_test0_alloc(struct nfit_test *t)
698700
return -ENOMEM;
699701
}
700702

701-
for (i = 0; i < NUM_DCR; i++) {
703+
for (i = 0; i < t->num_dcr; i++) {
702704
t->dcr[i] = test_alloc(t, LABEL_SIZE, &t->dcr_dma[i]);
703705
if (!t->dcr[i])
704706
return -ENOMEM;
@@ -727,6 +729,7 @@ static int nfit_test1_alloc(struct nfit_test *t)
727729
size_t nfit_size = sizeof(struct acpi_nfit_system_address) * 2
728730
+ sizeof(struct acpi_nfit_memory_map)
729731
+ offsetof(struct acpi_nfit_control_region, window_size);
732+
int i;
730733

731734
t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma);
732735
if (!t->nfit_buf)
@@ -737,6 +740,13 @@ static int nfit_test1_alloc(struct nfit_test *t)
737740
if (!t->spa_set[0])
738741
return -ENOMEM;
739742

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+
740750
t->spa_set[1] = test_alloc(t, SPA_VCD_SIZE, &t->spa_set_dma[1]);
741751
if (!t->spa_set[1])
742752
return -ENOMEM;
@@ -1449,7 +1459,7 @@ static void nfit_test1_setup(struct nfit_test *t)
14491459
memdev = nfit_buf + offset;
14501460
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
14511461
memdev->header.length = sizeof(*memdev);
1452-
memdev->device_handle = 0;
1462+
memdev->device_handle = handle[5];
14531463
memdev->physical_id = 0;
14541464
memdev->region_id = 0;
14551465
memdev->range_index = 0+1;
@@ -1471,7 +1481,7 @@ static void nfit_test1_setup(struct nfit_test *t)
14711481
window_size);
14721482
dcr->region_index = 0+1;
14731483
dcr_common_init(dcr);
1474-
dcr->serial_number = ~0;
1484+
dcr->serial_number = ~handle[5];
14751485
dcr->code = NFIT_FIC_BYTE;
14761486
dcr->windows = 0;
14771487

@@ -1482,6 +1492,9 @@ static void nfit_test1_setup(struct nfit_test *t)
14821492
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_cmd_force_en);
14831493
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_cmd_force_en);
14841494
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);
14851498
}
14861499

14871500
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)
16581671
switch (i) {
16591672
case 0:
16601673
nfit_test->num_pm = NUM_PM;
1674+
nfit_test->dcr_idx = 0;
16611675
nfit_test->num_dcr = NUM_DCR;
16621676
nfit_test->alloc = nfit_test0_alloc;
16631677
nfit_test->setup = nfit_test0_setup;
16641678
break;
16651679
case 1:
16661680
nfit_test->num_pm = 1;
1681+
nfit_test->dcr_idx = NUM_DCR;
1682+
nfit_test->num_dcr = 1;
16671683
nfit_test->alloc = nfit_test1_alloc;
16681684
nfit_test->setup = nfit_test1_setup;
16691685
break;

0 commit comments

Comments
 (0)