Skip to content

Commit 3b87356

Browse files
committed
nfit, tools/testing/nvdimm: test multiple control regions per-dimm
ACPI 6.1 clarifies that "The system shall include an NVDIMM Control Region Structure for every Function Interface in the NVDIMM." Implement this clarification in nfit_test. Signed-off-by: Dan Williams <[email protected]>
1 parent be26f9a commit 3b87356

File tree

1 file changed

+94
-24
lines changed
  • tools/testing/nvdimm/test

1 file changed

+94
-24
lines changed

tools/testing/nvdimm/test/nfit.c

Lines changed: 94 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ static int nfit_test0_alloc(struct nfit_test *t)
429429
size_t nfit_size = sizeof(struct acpi_nfit_system_address) * NUM_SPA
430430
+ sizeof(struct acpi_nfit_memory_map) * NUM_MEM
431431
+ sizeof(struct acpi_nfit_control_region) * NUM_DCR
432+
+ offsetof(struct acpi_nfit_control_region,
433+
window_size) * NUM_DCR
432434
+ sizeof(struct acpi_nfit_data_region) * NUM_BDW
433435
+ sizeof(struct acpi_nfit_flush_address) * NUM_DCR;
434436
int i;
@@ -478,7 +480,7 @@ static int nfit_test1_alloc(struct nfit_test *t)
478480
{
479481
size_t nfit_size = sizeof(struct acpi_nfit_system_address)
480482
+ sizeof(struct acpi_nfit_memory_map)
481-
+ sizeof(struct acpi_nfit_control_region);
483+
+ offsetof(struct acpi_nfit_control_region, window_size);
482484

483485
t->nfit_buf = test_alloc(t, nfit_size, &t->nfit_dma);
484486
if (!t->nfit_buf)
@@ -611,7 +613,7 @@ static void nfit_test0_setup(struct nfit_test *t)
611613
memdev->physical_id = 0;
612614
memdev->region_id = 0;
613615
memdev->range_index = 0+1;
614-
memdev->region_index = 0+1;
616+
memdev->region_index = 4+1;
615617
memdev->region_size = SPA0_SIZE/2;
616618
memdev->region_offset = t->spa_set_dma[0];
617619
memdev->address = 0;
@@ -626,7 +628,7 @@ static void nfit_test0_setup(struct nfit_test *t)
626628
memdev->physical_id = 1;
627629
memdev->region_id = 0;
628630
memdev->range_index = 0+1;
629-
memdev->region_index = 1+1;
631+
memdev->region_index = 5+1;
630632
memdev->region_size = SPA0_SIZE/2;
631633
memdev->region_offset = t->spa_set_dma[0] + SPA0_SIZE/2;
632634
memdev->address = 0;
@@ -641,7 +643,7 @@ static void nfit_test0_setup(struct nfit_test *t)
641643
memdev->physical_id = 0;
642644
memdev->region_id = 1;
643645
memdev->range_index = 1+1;
644-
memdev->region_index = 0+1;
646+
memdev->region_index = 4+1;
645647
memdev->region_size = SPA1_SIZE/4;
646648
memdev->region_offset = t->spa_set_dma[1];
647649
memdev->address = SPA0_SIZE/2;
@@ -656,7 +658,7 @@ static void nfit_test0_setup(struct nfit_test *t)
656658
memdev->physical_id = 1;
657659
memdev->region_id = 1;
658660
memdev->range_index = 1+1;
659-
memdev->region_index = 1+1;
661+
memdev->region_index = 5+1;
660662
memdev->region_size = SPA1_SIZE/4;
661663
memdev->region_offset = t->spa_set_dma[1] + SPA1_SIZE/4;
662664
memdev->address = SPA0_SIZE/2;
@@ -671,7 +673,7 @@ static void nfit_test0_setup(struct nfit_test *t)
671673
memdev->physical_id = 2;
672674
memdev->region_id = 0;
673675
memdev->range_index = 1+1;
674-
memdev->region_index = 2+1;
676+
memdev->region_index = 6+1;
675677
memdev->region_size = SPA1_SIZE/4;
676678
memdev->region_offset = t->spa_set_dma[1] + 2*SPA1_SIZE/4;
677679
memdev->address = SPA0_SIZE/2;
@@ -686,7 +688,7 @@ static void nfit_test0_setup(struct nfit_test *t)
686688
memdev->physical_id = 3;
687689
memdev->region_id = 0;
688690
memdev->range_index = 1+1;
689-
memdev->region_index = 3+1;
691+
memdev->region_index = 7+1;
690692
memdev->region_size = SPA1_SIZE/4;
691693
memdev->region_offset = t->spa_set_dma[1] + 3*SPA1_SIZE/4;
692694
memdev->address = SPA0_SIZE/2;
@@ -814,7 +816,7 @@ static void nfit_test0_setup(struct nfit_test *t)
814816
memdev->interleave_ways = 1;
815817

816818
offset = offset + sizeof(struct acpi_nfit_memory_map) * 14;
817-
/* dcr-descriptor0 */
819+
/* dcr-descriptor0: blk */
818820
dcr = nfit_buf + offset;
819821
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
820822
dcr->header.length = sizeof(struct acpi_nfit_control_region);
@@ -831,7 +833,7 @@ static void nfit_test0_setup(struct nfit_test *t)
831833
dcr->status_offset = 8;
832834
dcr->status_size = 4;
833835

834-
/* dcr-descriptor1 */
836+
/* dcr-descriptor1: blk */
835837
dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region);
836838
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
837839
dcr->header.length = sizeof(struct acpi_nfit_control_region);
@@ -848,7 +850,7 @@ static void nfit_test0_setup(struct nfit_test *t)
848850
dcr->status_offset = 8;
849851
dcr->status_size = 4;
850852

851-
/* dcr-descriptor2 */
853+
/* dcr-descriptor2: blk */
852854
dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region) * 2;
853855
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
854856
dcr->header.length = sizeof(struct acpi_nfit_control_region);
@@ -865,7 +867,7 @@ static void nfit_test0_setup(struct nfit_test *t)
865867
dcr->status_offset = 8;
866868
dcr->status_size = 4;
867869

868-
/* dcr-descriptor3 */
870+
/* dcr-descriptor3: blk */
869871
dcr = nfit_buf + offset + sizeof(struct acpi_nfit_control_region) * 3;
870872
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
871873
dcr->header.length = sizeof(struct acpi_nfit_control_region);
@@ -883,6 +885,63 @@ static void nfit_test0_setup(struct nfit_test *t)
883885
dcr->status_size = 4;
884886

885887
offset = offset + sizeof(struct acpi_nfit_control_region) * 4;
888+
/* dcr-descriptor0: pmem */
889+
dcr = nfit_buf + offset;
890+
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
891+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
892+
window_size);
893+
dcr->region_index = 4+1;
894+
dcr->vendor_id = 0xabcd;
895+
dcr->device_id = 0;
896+
dcr->revision_id = 1;
897+
dcr->serial_number = ~handle[0];
898+
dcr->code = NFIT_FIC_BYTEN;
899+
dcr->windows = 0;
900+
901+
/* dcr-descriptor1: pmem */
902+
dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
903+
window_size);
904+
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
905+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
906+
window_size);
907+
dcr->region_index = 5+1;
908+
dcr->vendor_id = 0xabcd;
909+
dcr->device_id = 0;
910+
dcr->revision_id = 1;
911+
dcr->serial_number = ~handle[1];
912+
dcr->code = NFIT_FIC_BYTEN;
913+
dcr->windows = 0;
914+
915+
/* dcr-descriptor2: pmem */
916+
dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
917+
window_size) * 2;
918+
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
919+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
920+
window_size);
921+
dcr->region_index = 6+1;
922+
dcr->vendor_id = 0xabcd;
923+
dcr->device_id = 0;
924+
dcr->revision_id = 1;
925+
dcr->serial_number = ~handle[2];
926+
dcr->code = NFIT_FIC_BYTEN;
927+
dcr->windows = 0;
928+
929+
/* dcr-descriptor3: pmem */
930+
dcr = nfit_buf + offset + offsetof(struct acpi_nfit_control_region,
931+
window_size) * 3;
932+
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
933+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
934+
window_size);
935+
dcr->region_index = 7+1;
936+
dcr->vendor_id = 0xabcd;
937+
dcr->device_id = 0;
938+
dcr->revision_id = 1;
939+
dcr->serial_number = ~handle[3];
940+
dcr->code = NFIT_FIC_BYTEN;
941+
dcr->windows = 0;
942+
943+
offset = offset + offsetof(struct acpi_nfit_control_region,
944+
window_size) * 4;
886945
/* bdw0 (spa/dcr0, dimm0) */
887946
bdw = nfit_buf + offset;
888947
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
@@ -962,11 +1021,11 @@ static void nfit_test0_setup(struct nfit_test *t)
9621021

9631022
if (t->setup_hotplug) {
9641023
offset = offset + sizeof(struct acpi_nfit_flush_address) * 4;
965-
/* dcr-descriptor4 */
1024+
/* dcr-descriptor4: blk */
9661025
dcr = nfit_buf + offset;
9671026
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
9681027
dcr->header.length = sizeof(struct acpi_nfit_control_region);
969-
dcr->region_index = 4+1;
1028+
dcr->region_index = 8+1;
9701029
dcr->vendor_id = 0xabcd;
9711030
dcr->device_id = 0;
9721031
dcr->revision_id = 1;
@@ -980,11 +1039,26 @@ static void nfit_test0_setup(struct nfit_test *t)
9801039
dcr->status_size = 4;
9811040

9821041
offset = offset + sizeof(struct acpi_nfit_control_region);
1042+
/* dcr-descriptor4: pmem */
1043+
dcr = nfit_buf + offset;
1044+
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
1045+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
1046+
window_size);
1047+
dcr->region_index = 9+1;
1048+
dcr->vendor_id = 0xabcd;
1049+
dcr->device_id = 0;
1050+
dcr->revision_id = 1;
1051+
dcr->serial_number = ~handle[4];
1052+
dcr->code = NFIT_FIC_BYTEN;
1053+
dcr->windows = 0;
1054+
1055+
offset = offset + offsetof(struct acpi_nfit_control_region,
1056+
window_size);
9831057
/* bdw4 (spa/dcr4, dimm4) */
9841058
bdw = nfit_buf + offset;
9851059
bdw->header.type = ACPI_NFIT_TYPE_DATA_REGION;
9861060
bdw->header.length = sizeof(struct acpi_nfit_data_region);
987-
bdw->region_index = 4+1;
1061+
bdw->region_index = 8+1;
9881062
bdw->windows = 1;
9891063
bdw->offset = 0;
9901064
bdw->size = BDW_SIZE;
@@ -1032,7 +1106,7 @@ static void nfit_test0_setup(struct nfit_test *t)
10321106
memdev->physical_id = 4;
10331107
memdev->region_id = 0;
10341108
memdev->range_index = 10+1;
1035-
memdev->region_index = 4+1;
1109+
memdev->region_index = 8+1;
10361110
memdev->region_size = 0;
10371111
memdev->region_offset = 0;
10381112
memdev->address = 0;
@@ -1048,14 +1122,14 @@ static void nfit_test0_setup(struct nfit_test *t)
10481122
memdev->physical_id = 4;
10491123
memdev->region_id = 0;
10501124
memdev->range_index = 11+1;
1051-
memdev->region_index = 4+1;
1125+
memdev->region_index = 9+1;
10521126
memdev->region_size = SPA0_SIZE;
10531127
memdev->region_offset = t->spa_set_dma[2];
10541128
memdev->address = 0;
10551129
memdev->interleave_index = 0;
10561130
memdev->interleave_ways = 1;
10571131

1058-
/* mem-region16 (spa/dcr4, dimm4) */
1132+
/* mem-region16 (spa/bdw4, dimm4) */
10591133
memdev = nfit_buf + offset +
10601134
sizeof(struct acpi_nfit_memory_map) * 2;
10611135
memdev->header.type = ACPI_NFIT_TYPE_MEMORY_MAP;
@@ -1064,7 +1138,7 @@ static void nfit_test0_setup(struct nfit_test *t)
10641138
memdev->physical_id = 4;
10651139
memdev->region_id = 0;
10661140
memdev->range_index = 12+1;
1067-
memdev->region_index = 4+1;
1141+
memdev->region_index = 8+1;
10681142
memdev->region_size = 0;
10691143
memdev->region_offset = 0;
10701144
memdev->address = 0;
@@ -1135,19 +1209,15 @@ static void nfit_test1_setup(struct nfit_test *t)
11351209
/* dcr-descriptor0 */
11361210
dcr = nfit_buf + offset;
11371211
dcr->header.type = ACPI_NFIT_TYPE_CONTROL_REGION;
1138-
dcr->header.length = sizeof(struct acpi_nfit_control_region);
1212+
dcr->header.length = offsetof(struct acpi_nfit_control_region,
1213+
window_size);
11391214
dcr->region_index = 0+1;
11401215
dcr->vendor_id = 0xabcd;
11411216
dcr->device_id = 0;
11421217
dcr->revision_id = 1;
11431218
dcr->serial_number = ~0;
11441219
dcr->code = NFIT_FIC_BYTE;
11451220
dcr->windows = 0;
1146-
dcr->window_size = 0;
1147-
dcr->command_offset = 0;
1148-
dcr->command_size = 0;
1149-
dcr->status_offset = 0;
1150-
dcr->status_size = 0;
11511221

11521222
acpi_desc = &t->acpi_desc;
11531223
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);

0 commit comments

Comments
 (0)