generic: 5.15: copy config and patch from 5.10
[openwrt/openwrt.git] / target / linux / generic / pending-5.15 / 850-0014-PCI-aardvark-Fix-reading-PCI_EXP_RTSTA_PME-bit-on-em.patch
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 --- a/drivers/pci/controller/pci-aardvark.c
33 +++ b/drivers/pci/controller/pci-aardvark.c
34 @@ -874,7 +874,9 @@ advk_pci_bridge_emul_pcie_conf_read(stru
35 case PCI_EXP_RTSTA: {
36 u32 isr0 = advk_readl(pcie, PCIE_ISR0_REG);
37 u32 msglog = advk_readl(pcie, PCIE_MSG_LOG_REG);
38 - *value = (isr0 & PCIE_MSG_PM_PME_MASK) << 16 | (msglog >> 16);
39 + *value = msglog >> 16;
40 + if (isr0 & PCIE_MSG_PM_PME_MASK)
41 + *value |= PCI_EXP_RTSTA_PME;
42 return PCI_BRIDGE_EMUL_HANDLED;
43 }
44