850-0014-PCI-aardvark-Fix-reading-PCI_EXP_RTSTA_PME-bit-on-em.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From 5f354992eeef9a51c67796dc9f7f578d3584baa2 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <[email protected]>
  3. Date: Wed, 8 Dec 2021 05:57:54 +0100
  4. Subject: [PATCH] PCI: aardvark: Fix reading PCI_EXP_RTSTA_PME bit on emulated
  5. bridge
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. The emulated bridge returns incorrect value for PCI_EXP_RTSTA register
  10. during readout in advk_pci_bridge_emul_pcie_conf_read() function: the
  11. correct bit is BIT(16), but we are setting BIT(23), because the code
  12. does
  13. *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16
  14. where
  15. PCIE_MSG_PM_PME_MASK
  16. is
  17. BIT(7).
  18. The code should probably have been something like
  19. *value = (!!(isr0 & PCIE_MSG_PM_PME_MASK)) << 16,
  20. but we are better of using an if() and using the proper macro for this
  21. bit.
  22. Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
  23. Signed-off-by: Pali Rohár <[email protected]>
  24. Signed-off-by: Marek Behún <[email protected]>
  25. ---
  26. drivers/pci/controller/pci-aardvark.c | 4 +++-
  27. 1 file changed, 3 insertions(+), 1 deletion(-)
  28. --- a/drivers/pci/controller/pci-aardvark.c
  29. +++ b/drivers/pci/controller/pci-aardvark.c
  30. @@ -874,7 +874,9 @@ advk_pci_bridge_emul_pcie_conf_read(stru
  31. case PCI_EXP_RTSTA: {
  32. u32 isr0 = advk_readl(pcie, PCIE_ISR0_REG);
  33. u32 msglog = advk_readl(pcie, PCIE_MSG_LOG_REG);
  34. - *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16 | (msglog >> 16);
  35. + *value = msglog >> 16;
  36. + if (isr0 & PCIE_MSG_PM_PME_MASK)
  37. + *value |= PCI_EXP_RTSTA_PME;
  38. return PCI_BRIDGE_EMUL_HANDLED;
  39. }