On 05/05/26 7:59 pm, Harsh Prateek Bora wrote:
On 05/03/26 11:39 am, Saif Abrar wrote:
Sticky bits retain their values on reset and are not overwritten with
the reset value.
Added sticky reset logic for all required registers,
i.e. CFG core, PBL core, PHB error registers, PCIE stack registers and
REGB error registers.
Tested by writing all 1's to the reg PHB_PBL_ERR_INJECT.
This will set the bits in the reg PHB_PBL_ERR_STATUS.
Reset the PBL core by setting PHB_PCIE_CRESET_PBL in reg PHB_PCIE_CRESET.
Verify that the sticky bits in the PHB_PBL_ERR_STATUS reg are still set.
Signed-off-by: Saif Abrar <[email protected]>
---
v3: Updates for coding guidelines.
hw/pci-host/pnv_phb4.c | 123 +++++++++++++++++++++++++++-
include/hw/pci-host/pnv_phb4_regs.h | 20 ++++-
tests/qtest/pnv-phb4-test.c | 41 ++++++++++
3 files changed, 179 insertions(+), 5 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 763e9c9776..b3f46f7fe1 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -511,6 +511,18 @@ static uint32_t get_exp_offset(PCIDevice *pdev)
return rpc->exp_offset;
}
+/*
+ * Apply sticky-mask 's' to the reset-value 'v' and write to the
address 'a'.
+ * RC-config space values and masks are LE.
+ * Method pnv_phb4_rc_config_read() returns BE, hence convert to LE.
+ * Compute new value in LE domain.
+ * New value computation using sticky-mask is in LE.
+ * Convert the computed value from LE to BE before writing back.
+ */
+#define RC_CONFIG_STICKY_RESET(a, v, s) \
+ (pci_set_word(conf + (a), bswap32( \
+ (bswap32(pci_get_word(conf + (a))) & (s)) | ((v)
& ~(s)))))
Shouldn't we be using bswap16 here ?
If 32-bit helper is needed, we need to use pci_[get|set]_long instead.