Skip to content

Commit 1ebd73c

Browse files
Sujana-Mprashymh
authored andcommitted
feat(pcie): add helper APIs to enable/disable DPC
- Introduce `val_pcie_enable_dpc()` and `val_pcie_disable_dpc()` helper functions to manage DPC trigger enable bits in the DPC capability structure. - Use these APIs to disable DPC for all Root Ports and Downstream Ports during PCIe device table creation to avoid unintended error signaling. - Update Exerciser test e024 to call the new API for disabling DPC instead of manually clearing control register bits. - Update relevant headers and extend copyright year to 2026. - Fixes #192 Change-Id: I8450efdc15d582bdbbddc90a8c885991613039e5
1 parent 0a19b7b commit 1ebd73c

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed

test_pool/exerciser/e024.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @file
2-
* Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved.
2+
* Copyright (c) 2023-2026, Arm Limited or its affiliates. All rights reserved.
33
* SPDX-License-Identifier : Apache-2.0
44
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -258,10 +258,12 @@ payload(void)
258258
val_print(ACS_PRINT_INFO, " EP BDF : 0x%x\n", e_bdf);
259259

260260
irq_pending = 1;
261+
/* Enable DPC */
262+
val_pcie_enable_dpc(erp_bdf, msg_type[i]);
263+
264+
/* Enable DPC Interrupt bit */
261265
val_pcie_read_cfg(erp_bdf, rp_dpc_cap_base + DPC_CTRL_OFFSET, &reg_value);
262-
reg_value &= DPC_DISABLE_MASK;
263266
reg_value |= DPC_INTR_ENABLE;
264-
reg_value = reg_value | (msg_type[i] << DPC_CTRL_TRG_EN_SHIFT);
265267
val_pcie_write_cfg(erp_bdf, rp_dpc_cap_base + DPC_CTRL_OFFSET, reg_value);
266268

267269
val_pcie_read_cfg(erp_bdf, rp_dpc_cap_base + DPC_CTRL_OFFSET, &reg_value);
@@ -381,13 +383,13 @@ payload(void)
381383
}
382384

383385
disable_dpc:
384-
/*Disable the DPC*/
386+
/*Disable the DPC status register*/
385387

386388
val_pcie_read_cfg(erp_bdf, rp_dpc_cap_base + DPC_STATUS_OFFSET, &reg_value);
387389
val_pcie_write_cfg(erp_bdf, rp_dpc_cap_base + DPC_STATUS_OFFSET, reg_value | 0x1);
388390

389-
val_pcie_read_cfg(erp_bdf, rp_dpc_cap_base + DPC_CTRL_OFFSET, &reg_value);
390-
val_pcie_write_cfg(erp_bdf, rp_dpc_cap_base + DPC_CTRL_OFFSET, reg_value & 0xFFFCFFFF);
391+
/*Disable the DPC control register*/
392+
val_pcie_disable_dpc(erp_bdf);
391393

392394
/* Restore the EP config space after Secondary Bus Reset */
393395
restore_config_space(erp_bdf);

val/include/val_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ void val_pcie_enable_msa(uint32_t bdf);
270270
void val_pcie_clear_urd(uint32_t bdf);
271271
void val_pcie_enable_eru(uint32_t bdf);
272272
void val_pcie_disable_eru(uint32_t bdf);
273+
void val_pcie_enable_dpc(uint32_t bdf, uint32_t err_type);
274+
void val_pcie_disable_dpc(uint32_t bdf);
273275
void val_pcie_get_mmio_bar(uint32_t bdf, void *base);
274276
void val_pcie_read_acsctrl(uint32_t arr[][1]);
275277
void val_pcie_write_acsctrl(uint32_t arr[][1]);

val/src/acs_pcie.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ val_pcie_create_device_bdf_table()
630630

631631
dp_type = val_pcie_device_port_type(bdf);
632632

633+
/* Disable DPC for RP and DP */
634+
if ((dp_type == RP) || (dp_type == DP))
635+
val_pcie_disable_dpc(bdf);
636+
633637
/* RCiEP rules are for SBSA L6 */
634638
if ((dp_type == RCiEP) || (dp_type == RCEC))
635639
g_pcie_integrated_devices++;
@@ -1100,6 +1104,60 @@ val_pcie_is_msa_enabled(uint32_t bdf)
11001104
return 1;
11011105
}
11021106

1107+
/**
1108+
@brief Enable DPC trigger enable bits
1109+
@param bdf - Segment/Bus/Dev/Func in the format of PCIE_CREATE_BDF
1110+
@param err_type - 1 for fatal error and 2 for fatal and non-fatal error
1111+
@return None
1112+
**/
1113+
void
1114+
val_pcie_enable_dpc(uint32_t bdf, uint32_t err_type)
1115+
{
1116+
uint32_t dpc_cap_base;
1117+
uint32_t reg_value;
1118+
uint32_t status;
1119+
1120+
/* Check DPC capability */
1121+
status = val_pcie_find_capability(bdf, PCIE_ECAP, ECID_DPC, &dpc_cap_base);
1122+
if (status == PCIE_CAP_NOT_FOUND)
1123+
{
1124+
val_print(ACS_PRINT_DEBUG, "DPC Capability not supported \n", 0);
1125+
return;
1126+
}
1127+
1128+
/* Enable DPC trigger enable bits */
1129+
val_pcie_read_cfg(bdf, dpc_cap_base + DPC_CTRL_OFFSET, &reg_value);
1130+
reg_value |= err_type << DPC_CTRL_TRG_EN_SHIFT;
1131+
val_pcie_write_cfg(bdf, dpc_cap_base + DPC_CTRL_OFFSET, reg_value);
1132+
}
1133+
1134+
/**
1135+
@brief Disable DPC trigger enable bits
1136+
@param bdf - Segment/Bus/Dev/Func in the format of PCIE_CREATE_BDF
1137+
@return DPC trigger enable bits value
1138+
**/
1139+
void
1140+
val_pcie_disable_dpc(uint32_t bdf)
1141+
{
1142+
1143+
uint32_t reg_value;
1144+
uint32_t dpc_cap_base;
1145+
uint32_t status;
1146+
1147+
/* Check DPC capability */
1148+
status = val_pcie_find_capability(bdf, PCIE_ECAP, ECID_DPC, &dpc_cap_base);
1149+
if (status == PCIE_CAP_NOT_FOUND)
1150+
{
1151+
val_print(ACS_PRINT_DEBUG, "DPC Capability not supported \n", 0);
1152+
return;
1153+
}
1154+
1155+
/* Disable "DPC Trigger Enable" bits */
1156+
val_pcie_read_cfg(bdf, dpc_cap_base + DPC_CTRL_OFFSET, &reg_value);
1157+
reg_value &= ~(DPC_CTRL_TRG_EN_MASK << DPC_CTRL_TRG_EN_SHIFT);
1158+
val_pcie_write_cfg(bdf, dpc_cap_base + DPC_CTRL_OFFSET, reg_value);
1159+
}
1160+
11031161
/**
11041162
@brief Clears unsupported request detected bit in Device Status Register
11051163

0 commit comments

Comments
 (0)