5b0d7b341a6bd638a6bae99a07324f913ccebc75
[openwrt/staging/lynxis.git] /
1 From 5f354992eeef9a51c67796dc9f7f578d3584baa2 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
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
10 The emulated bridge returns incorrect value for PCI_EXP_RTSTA register
11 during readout in advk_pci_bridge_emul_pcie_conf_read() function: the
12 correct bit is BIT(16), but we are setting BIT(23), because the code
13 does
14 *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16
15 where
16 PCIE_MSG_PM_PME_MASK
17 is
18 BIT(7).
19
20 The code should probably have been something like
21 *value = (!!(isr0 & PCIE_MSG_PM_PME_MASK)) << 16,
22 but we are better of using an if() and using the proper macro for this
23 bit.
24
25 Fixes: 8a3ebd8de328 ("PCI: aardvark: Implement emulated root PCI bridge config space")
26 Signed-off-by: Pali Rohár <pali@kernel.org>
27 Signed-off-by: Marek Behún <kabel@kernel.org>
28 ---
29 drivers/pci/controller/pci-aardvark.c | 4 +++-
30 1 file changed, 3 insertions(+), 1 deletion(-)
31
32 diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
33 index 7956b103d3c7..44d9c8c4d258 100644
34 --- a/drivers/pci/controller/pci-aardvark.c
35 +++ b/drivers/pci/controller/pci-aardvark.c
36 @@ -874,7 +874,9 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
37 case PCI_EXP_RTSTA: {
38 u32 isr0 = advk_readl(pcie, PCIE_ISR0_REG);
39 u32 msglog = advk_readl(pcie, PCIE_MSG_LOG_REG);
40 - *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16 | (msglog >> 16);
41 + *value = msglog >> 16;
42 + if (isr0 & PCIE_MSG_PM_PME_MASK)
43 + *value |= PCI_EXP_RTSTA_PME;
44 return PCI_BRIDGE_EMUL_HANDLED;
45 }
46
47 --
48 2.34.1
49