@@ -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
3337static void * branch_to_test ;
3438static uint32_t test_num ;
3539static uint32_t onchip_peripherals_check ;
40+ static uint32_t memory_map_attr ;
3641
3742static
3843void
@@ -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+
5062static
5163void
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
249259next_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
283293uint32_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+ }
0 commit comments