Skip to content

Commit c7d652c

Browse files
committed
enhancement(pcie): add test coverage for PCI_MM_02
- Add p106_entry and p107_entry in p045.c using existing payload flow - Keep BAR discovery/access in payload; keep ioremap in helper - Select mapping attribute per entry: - p045/p103 -> DEVICE_nGnRnE - p106/p107 -> NORMAL_NC - Tag p106/p107 test entries with rule PCI_MM_02 - Add prototypes for p106_entry/p107_entry in acs_pcie.h - Extend TEST_ENTRY_ID_e with PCI_MM_02_ENTRY, P106_ENTRY, P107_ENTRY - Add pci_mm_02_entry wrapper and declaration - Register P106/P107/PCI_MM_02 function pointers in rule_metadata.c tables Signed-off-by: Sujana M <sujana.murali@arm.com> Change-Id: Ia28b14bd12419ad2d60d678043385a321918f464
1 parent 6de8ca8 commit c7d652c

7 files changed

Lines changed: 124 additions & 28 deletions

File tree

test_pool/pcie/p045.c

Lines changed: 85 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ test_config_t test_entries[] = {
2525
/* p045 targets EP, RP, DP, and UP, and is executed for BSA */
2626
{ ACS_PCIE_TEST_NUM_BASE + 45, "PCIe Device Memory mapping support ", "PCI_MM_01"},
2727
/* p103 targets RCiEP, RCEC, iEP_EP, and iEP_RP, and is executed for SBSA */
28-
{ ACS_PCIE_TEST_NUM_BASE + 103, "PCIe Device Memory mapping support ", "PCI_MM_01"}
28+
{ ACS_PCIE_TEST_NUM_BASE + 103, "PCIe Device Memory mapping support ", "PCI_MM_01"},
29+
/* p106 targets EP, RP, DP, and UP, and maps BAR to NORMAL memory */
30+
{ ACS_PCIE_TEST_NUM_BASE + 106, "PCIe Device Memory mapping support ", "PCI_MM_02"},
31+
/* p107 targets RCiEP, RCEC, iEP_EP, and iEP_RP, and maps BAR to NORMAL memory */
32+
{ ACS_PCIE_TEST_NUM_BASE + 107, "PCIe Device Memory mapping support ", "PCI_MM_02"}
2933
};
3034

3135
#define DATA 0xC0DECAFE
3236

3337
static void *branch_to_test;
3438
static uint32_t test_num;
3539
static uint32_t onchip_peripherals_check;
40+
static uint32_t memory_map_attr;
3641

3742
static
3843
void
@@ -47,9 +52,16 @@ esr(uint64_t interrupt_type, void *context)
4752
val_set_status(index, RESULT_FAIL(02));
4853
}
4954

55+
static
56+
uint32_t
57+
map_device_memory(uint64_t base, char **baseptr)
58+
{
59+
return val_memory_ioremap((void *)base, 1024, memory_map_attr, (void **)baseptr);
60+
}
61+
5062
static
5163
void
52-
payload(void)
64+
payload_check_device_mem_map(void)
5365
{
5466
uint32_t data;
5567
uint32_t old_data;
@@ -102,10 +114,10 @@ payload(void)
102114
if (onchip_peripherals_check) {
103115
if ((dp_type != iEP_EP) && (dp_type != iEP_RP) && (dp_type != RCEC) && (dp_type != RCiEP))
104116
continue;
105-
} else {
117+
} else {
106118
if ((dp_type != EP) && (dp_type != RP) && (dp_type != DP) && (dp_type != UP))
107119
continue;
108-
}
120+
}
109121

110122
val_print(DEBUG, "\n BDF under check %08x", bdf);
111123
val_pcie_read_cfg(bdf, TYPE01_RIDR, &reg_value);
@@ -138,13 +150,13 @@ payload(void)
138150

139151
if (bar_value == 0)
140152
{
141-
/** This BAR is not implemented **/
153+
/* This BAR is not implemented */
142154
val_print(DEBUG, "\n BAR is not implemented for BDF 0x%x", bdf);
143155
goto next_bar;
144156
}
145157

146158
/* Skip for IO address space */
147-
if (bar_value & 0x1) {
159+
if (bar_value & BAR_VALUE_IO_MASK) {
148160
val_print(DEBUG, "\n BAR is used for IO address space request");
149161
val_print(DEBUG, " for BDF 0x%x", bdf);
150162
goto next_bar;
@@ -154,30 +166,29 @@ payload(void)
154166
{
155167
val_print(TRACE,
156168
"\n The BAR supports 64-bit address decoding capability");
157-
val_pcie_read_cfg(bdf, offset+4, &bar_value_1);
169+
val_pcie_read_cfg(bdf, offset + BAR_32B_OFFSET, &bar_value_1);
158170
base = bar_value_1;
159171

160172
/* BAR supports 64-bit address therefore, write all 1's
161173
* to BARn and BARn+1 and identify the size requested
162174
*/
163175
val_pcie_write_cfg(bdf, offset, 0xFFFFFFF0);
164-
val_pcie_write_cfg(bdf, offset + 4, 0xFFFFFFFF);
176+
val_pcie_write_cfg(bdf, offset + BAR_32B_OFFSET, 0xFFFFFFFF);
165177
val_pcie_read_cfg(bdf, offset, &bar_reg_lower_value);
166178
bar_size = bar_reg_lower_value & 0xFFFFFFF0;
167-
val_pcie_read_cfg(bdf, offset + 4, &bar_reg_value);
179+
val_pcie_read_cfg(bdf, offset + BAR_32B_OFFSET, &bar_reg_value);
168180
bar_upper_bits = bar_reg_value;
169-
bar_size = bar_size | (bar_upper_bits << 32 );
181+
bar_size = bar_size | (bar_upper_bits << 32);
170182
bar_size = ~bar_size + 1;
171183

172184
/* Restore the original BAR value */
173-
val_pcie_write_cfg(bdf, offset + 4, bar_value_1);
185+
val_pcie_write_cfg(bdf, offset + BAR_32B_OFFSET, bar_value_1);
174186
val_pcie_write_cfg(bdf, offset, bar_value);
175187
base = (base << 32) | (bar_value & BAR_MASK);
176188
}
177-
178189
else {
179190
val_print(TRACE,
180-
"\n The BAR supports 32-bit address decoding capability");
191+
"\n The BAR supports 32-bit address decoding capability");
181192

182193
/* BAR supports 32-bit address. Write all 1's
183194
* to BARn and identify the size requested
@@ -210,11 +221,10 @@ payload(void)
210221

211222
test_skip = 0;
212223

213-
/* Map the BARs to a DEVICE memory (non-cachable) attribute
224+
/* Map the BARs to a memory attribute mentioned
214225
* and check transaction.
215226
*/
216-
status = val_memory_ioremap((void *)base, 1024, DEVICE_nGnRnE, (void **)&baseptr);
217-
227+
status = map_device_memory(base, &baseptr);
218228
/* Handle unimplemented PAL -> Report WARN */
219229
if (status == ACS_STATUS_PAL_NOT_IMPLEMENTED) {
220230
goto test_status;
@@ -229,7 +239,7 @@ payload(void)
229239

230240
test_warn = 0;
231241

232-
/* Access check. Not performing data comparison check. */
242+
/* Access check inside payload after obtaining BAR base and mapping */
233243
old_data = *(uint32_t *)(baseptr);
234244
*(uint32_t *)(baseptr) = DATA;
235245
data = *(uint32_t *)(baseptr);
@@ -248,10 +258,9 @@ payload(void)
248258

249259
next_bar:
250260
if (BAR_REG(bar_value) == BAR_32_BIT)
251-
offset = offset + 4;
252-
253-
if (BAR_REG(bar_value) == BAR_64_BIT)
254-
offset = offset + 8;
261+
offset = offset + BAR_32B_OFFSET;
262+
else if (BAR_REG(bar_value) == BAR_64_BIT)
263+
offset = offset + BAR_64B_OFFSET;
255264

256265
if (msa_en)
257266
val_pcie_disable_msa(bdf);
@@ -273,11 +282,12 @@ payload(void)
273282
}
274283
} else if (test_warn) {
275284
val_set_status(index, RESULT_WARNING(1));
276-
} else if (test_fail)
285+
} else if (test_fail) {
277286
val_set_status(index, RESULT_FAIL(test_fail));
278-
else
287+
} else {
279288
val_set_status(index, RESULT_PASS);
280289
return;
290+
}
281291
}
282292

283293
uint32_t
@@ -287,13 +297,14 @@ p045_entry(uint32_t num_pe)
287297
uint32_t status = ACS_STATUS_FAIL;
288298
test_num = test_entries[0].test_num;
289299
onchip_peripherals_check = 0;
300+
memory_map_attr = DEVICE_nGnRnE;
290301

291302
num_pe = 1; //This test is run on single processor
292303

293304
val_log_context((char8_t *)__FILE__, (char8_t *)__func__, __LINE__);
294305
status = val_initialize_test(test_num, test_entries[0].desc, num_pe);
295306
if (status != ACS_STATUS_SKIP)
296-
val_run_test_payload(test_num, num_pe, payload, 0);
307+
val_run_test_payload(test_num, num_pe, payload_check_device_mem_map, 0);
297308

298309
/* get the result from all PE and check for failure */
299310
status = val_check_for_error(test_num, num_pe, test_entries[0].rule);
@@ -310,13 +321,14 @@ p103_entry(uint32_t num_pe)
310321
uint32_t status = ACS_STATUS_FAIL;
311322
test_num = test_entries[1].test_num;
312323
onchip_peripherals_check = 1;
324+
memory_map_attr = DEVICE_nGnRnE;
313325

314326
num_pe = 1; //This test is run on single processor
315327

316328
val_log_context((char8_t *)__FILE__, (char8_t *)__func__, __LINE__);
317329
status = val_initialize_test(test_num, test_entries[1].desc, num_pe);
318330
if (status != ACS_STATUS_SKIP)
319-
val_run_test_payload(test_num, num_pe, payload, 0);
331+
val_run_test_payload(test_num, num_pe, payload_check_device_mem_map, 0);
320332

321333
/* get the result from all PE and check for failure */
322334
status = val_check_for_error(test_num, num_pe, test_entries[1].rule);
@@ -325,3 +337,51 @@ p103_entry(uint32_t num_pe)
325337

326338
return status;
327339
}
340+
341+
uint32_t
342+
p106_entry(uint32_t num_pe)
343+
{
344+
345+
uint32_t status = ACS_STATUS_FAIL;
346+
test_num = test_entries[2].test_num;
347+
onchip_peripherals_check = 0;
348+
memory_map_attr = NORMAL_NC;
349+
350+
num_pe = 1; //This test is run on single processor
351+
352+
val_log_context((char8_t *)__FILE__, (char8_t *)__func__, __LINE__);
353+
status = val_initialize_test(test_num, test_entries[2].desc, num_pe);
354+
if (status != ACS_STATUS_SKIP)
355+
val_run_test_payload(test_num, num_pe, payload_check_device_mem_map, 0);
356+
357+
/* get the result from all PE and check for failure */
358+
status = val_check_for_error(test_num, num_pe, test_entries[2].rule);
359+
360+
val_report_status(0, ACS_END(test_num), test_entries[2].rule);
361+
362+
return status;
363+
}
364+
365+
uint32_t
366+
p107_entry(uint32_t num_pe)
367+
{
368+
369+
uint32_t status = ACS_STATUS_FAIL;
370+
test_num = test_entries[3].test_num;
371+
onchip_peripherals_check = 1;
372+
memory_map_attr = NORMAL_NC;
373+
374+
num_pe = 1; //This test is run on single processor
375+
376+
val_log_context((char8_t *)__FILE__, (char8_t *)__func__, __LINE__);
377+
status = val_initialize_test(test_num, test_entries[3].desc, num_pe);
378+
if (status != ACS_STATUS_SKIP)
379+
val_run_test_payload(test_num, num_pe, payload_check_device_mem_map, 0);
380+
381+
/* get the result from all PE and check for failure */
382+
status = val_check_for_error(test_num, num_pe, test_entries[3].rule);
383+
384+
val_report_status(0, ACS_END(test_num), test_entries[3].rule);
385+
386+
return status;
387+
}

val/include/acs_pcie.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,7 @@ uint32_t p100_entry(uint32_t num_pe);
292292
uint32_t p103_entry(uint32_t num_pe); /* Linux test */
293293
uint32_t p104_entry(uint32_t num_pe); /* Linux test */
294294
uint32_t p105_entry(uint32_t num_pe); /* Linux test */
295+
uint32_t p106_entry(uint32_t num_pe); /* Linux test */
296+
uint32_t p107_entry(uint32_t num_pe); /* Linux test */
295297

296298
#endif

val/include/acs_pcie_spec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@
130130
#define BAR_BASE_MASK 0xfffffff
131131

132132
/*BAR offset */
133+
#define BAR_32B_OFFSET 4
134+
#define BAR_64B_OFFSET 8
133135
#define BAR0_OFFSET 0x10
134136
#define BAR_TYPE_0_MAX_OFFSET 0x24
135137
#define BAR_TYPE_1_MAX_OFFSET 0x14

val/include/rule_based_execution_enum.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ typedef enum {
856856
PCI_LI_02_ENTRY,
857857
PCI_LI_03_ENTRY,
858858
PCI_MM_01_ENTRY,
859+
PCI_MM_02_ENTRY,
859860
PCI_MM_03_ENTRY,
860861
P049_ENTRY,
861862
P095_ENTRY,
@@ -937,6 +938,8 @@ typedef enum {
937938
P068_ENTRY,
938939
P071_ENTRY,
939940
P103_ENTRY,
941+
P106_ENTRY,
942+
P107_ENTRY,
940943
E006_ENTRY,
941944
E019_ENTRY,
942945
E020_ENTRY,

val/include/test_wrappers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ uint32_t ie_reg_3_entry(uint32_t num_pe);
4141
uint32_t pci_in_19_entry(uint32_t num_pe);
4242
uint32_t pci_li_01_entry(uint32_t num_pe);
4343
uint32_t pci_mm_01_entry(uint32_t num_pe);
44+
uint32_t pci_mm_02_entry(uint32_t num_pe);
4445
uint32_t pci_mm_03_entry(uint32_t num_pe);
4546
uint32_t ri_smu_1_entry(uint32_t num_pe);
4647
uint32_t cxl_02_entry(uint32_t num_pe);

val/src/rule_metadata.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,13 @@ rule_test_map_t rule_test_map[RULE_ID_SENTINEL] = {
19511951
.platform_bitmask = PLATFORM_BAREMETAL | PLATFORM_UEFI | PLATFORM_LINUX,
19521952
.flag = BASE_RULE,
19531953
},
1954+
[PCI_MM_02] = {
1955+
.test_entry_id = PCI_MM_02_ENTRY,
1956+
.module_id = PCIE,
1957+
.rule_desc = "PCIe Non-Cacheable Memory mapping support",
1958+
.platform_bitmask = PLATFORM_BAREMETAL | PLATFORM_UEFI | PLATFORM_LINUX,
1959+
.flag = BASE_RULE,
1960+
},
19541961
[PCI_MM_03] = {
19551962
.test_entry_id = PCI_MM_03_ENTRY,
19561963
.module_id = PCIE,
@@ -3282,9 +3289,6 @@ rule_test_map_t rule_test_map[RULE_ID_SENTINEL] = {
32823289
[PCI_LI_04] = {
32833290
.module_id = PCIE,
32843291
},
3285-
[PCI_MM_02] = {
3286-
.module_id = PCIE,
3287-
},
32883292
[PCI_MM_04] = {
32893293
.module_id = PCIE,
32903294
},
@@ -3438,10 +3442,13 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
34383442
[P001_ENTRY] = p001_entry,
34393443
[P045_ENTRY] = p045_entry, // used in wrapper.
34403444
[P103_ENTRY] = p103_entry, // used in wrapper.
3445+
[P106_ENTRY] = p106_entry, // used in wrapper.
34413446
[P094_ENTRY] = p094_entry, // used in wrapper.
34423447
[P104_ENTRY] = p104_entry, // used in wrapper.
3448+
[P107_ENTRY] = p107_entry, // used in wrapper.
34433449
[PCI_LI_02_ENTRY] = pci_li_02_entry,
34443450
[PCI_MM_01_ENTRY] = pci_mm_01_entry,
3451+
[PCI_MM_02_ENTRY] = pci_mm_02_entry,
34453452
[PCI_MM_03_ENTRY] = pci_mm_03_entry,
34463453
[PCI_MSI_2_ENTRY] = pci_msi_2_entry,
34473454
[D004_ENTRY] = d004_entry,
@@ -3549,6 +3556,7 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
35493556
[PCI_LI_02_ENTRY] = pci_li_02_entry,
35503557
[PCI_LI_03_ENTRY] = pci_li_03_entry,
35513558
[PCI_MM_01_ENTRY] = pci_mm_01_entry,
3559+
[PCI_MM_02_ENTRY] = pci_mm_02_entry,
35523560
[PCI_MM_03_ENTRY] = pci_mm_03_entry,
35533561
[PCI_MSI_2_ENTRY] = pci_msi_2_entry,
35543562
[PCI_PP_04_ENTRY] = pci_pp_04_entry,
@@ -3977,6 +3985,8 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
39773985
[P094_ENTRY] = p094_entry, // used in wrapper.
39783986
[P103_ENTRY] = p103_entry, // used in wrapper.
39793987
[P104_ENTRY] = p104_entry, // used in wrapper.
3988+
[P106_ENTRY] = p106_entry, // used in wrapper.
3989+
[P107_ENTRY] = p107_entry, // used in wrapper.
39803990
[P105_ENTRY] = p105_entry,
39813991
[PCI_IC_11_ENTRY] = pci_ic_11_entry,
39823992
[PCI_IN_04_ENTRY] = pci_in_04_entry,
@@ -3988,6 +3998,7 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
39883998
[PCI_LI_02_ENTRY] = pci_li_02_entry,
39893999
[PCI_LI_03_ENTRY] = pci_li_03_entry,
39904000
[PCI_MM_01_ENTRY] = pci_mm_01_entry,
4001+
[PCI_MM_02_ENTRY] = pci_mm_02_entry,
39914002
[PCI_MM_03_ENTRY] = pci_mm_03_entry,
39924003
[PCI_MSI_2_ENTRY] = pci_msi_2_entry,
39934004
[PCI_PP_04_ENTRY] = pci_pp_04_entry,
@@ -4238,6 +4249,7 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
42384249
[PCI_LI_02_ENTRY] = pci_li_02_entry,
42394250
[PCI_LI_03_ENTRY] = pci_li_03_entry,
42404251
[PCI_MM_01_ENTRY] = pci_mm_01_entry,
4252+
[PCI_MM_02_ENTRY] = pci_mm_02_entry,
42414253
[PCI_MM_03_ENTRY] = pci_mm_03_entry,
42424254
[PCI_MSI_2_ENTRY] = pci_msi_2_entry,
42434255
[PCI_PP_04_ENTRY] = pci_pp_04_entry,
@@ -4361,6 +4373,8 @@ test_entry_fn_t test_entry_func_table[TEST_ENTRY_SENTINEL] = {
43614373
[P018_ENTRY] = p018_entry, // used in wrapper.
43624374
[P094_ENTRY] = p094_entry, // used in wrapper.
43634375
[P104_ENTRY] = p104_entry, // used in wrapper.
4376+
[P106_ENTRY] = p106_entry, // used in wrapper.
4377+
[P107_ENTRY] = p107_entry, // used in wrapper.
43644378
[P009_ENTRY] = p009_entry,
43654379
[P095_ENTRY] = p095_entry,
43664380
[P020_ENTRY] = p020_entry, // used in wrapper.

val/src/test_wrappers.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,20 @@ pci_mm_01_entry(uint32_t num_pe)
319319
return run_pcie_static_and_exerciser(p_list, e_list, num_pe);
320320
}
321321

322+
/* PCI_MM_02 */
323+
uint32_t
324+
pci_mm_02_entry(uint32_t num_pe)
325+
{
326+
#ifdef BSA_LINUX_BUILD
327+
TEST_ENTRY_ID_e tst_entry_list[] = {PCI_MM_01_ENTRY, P106_ENTRY, TEST_ENTRY_SENTINEL};
328+
#else
329+
TEST_ENTRY_ID_e tst_entry_list[] = {PCI_MM_01_ENTRY, P106_ENTRY, P107_ENTRY,
330+
TEST_ENTRY_SENTINEL};
331+
#endif
332+
333+
return run_test_entries(tst_entry_list, num_pe);
334+
}
335+
322336
/* PCI_MM_03 */
323337
uint32_t
324338
pci_mm_03_entry(uint32_t num_pe)

0 commit comments

Comments
 (0)