9b4c6ef233a4078a62c7a92107115308a8a5c8b0
[openwrt/staging/dedeckeh.git] /
1 From 3fe0073d116d9902df08761c1cf0d733dd4c38fc 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 06:03:50 +0100
4 Subject: [PATCH] PCI: aardvark: Optimize writing PCI_EXP_RTCTL_PMEIE and
5 PCI_EXP_RTSTA_PME on emulated bridge
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 To optimize advk_pci_bridge_emul_pcie_conf_write() code, touch
11 PCIE_ISR0_REG and PCIE_ISR0_MASK_REG registers only when it is really
12 needed, when processing PCI_EXP_RTCTL_PMEIE and PCI_EXP_RTSTA_PME bits.
13
14 Signed-off-by: Pali Rohár <pali@kernel.org>
15 Signed-off-by: Marek Behún <kabel@kernel.org>
16 ---
17 drivers/pci/controller/pci-aardvark.c | 20 +++++++++++---------
18 1 file changed, 11 insertions(+), 9 deletions(-)
19
20 --- a/drivers/pci/controller/pci-aardvark.c
21 +++ b/drivers/pci/controller/pci-aardvark.c
22 @@ -933,19 +933,21 @@ advk_pci_bridge_emul_pcie_conf_write(str
23 advk_pcie_wait_for_retrain(pcie);
24 break;
25
26 - case PCI_EXP_RTCTL: {
27 + case PCI_EXP_RTCTL:
28 /* Only mask/unmask PME interrupt */
29 - u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG) &
30 - ~PCIE_MSG_PM_PME_MASK;
31 - if ((new & PCI_EXP_RTCTL_PMEIE) == 0)
32 - val |= PCIE_MSG_PM_PME_MASK;
33 - advk_writel(pcie, val, PCIE_ISR0_MASK_REG);
34 + if (mask & PCI_EXP_RTCTL_PMEIE) {
35 + u32 val = advk_readl(pcie, PCIE_ISR0_MASK_REG);
36 + if (new & PCI_EXP_RTCTL_PMEIE)
37 + val &= ~PCIE_MSG_PM_PME_MASK;
38 + else
39 + val |= PCIE_MSG_PM_PME_MASK;
40 + advk_writel(pcie, val, PCIE_ISR0_MASK_REG);
41 + }
42 break;
43 - }
44
45 case PCI_EXP_RTSTA:
46 - new = (new & PCI_EXP_RTSTA_PME) >> 9;
47 - advk_writel(pcie, new, PCIE_ISR0_REG);
48 + if (new & PCI_EXP_RTSTA_PME)
49 + advk_writel(pcie, PCIE_MSG_PM_PME_MASK, PCIE_ISR0_REG);
50 break;
51
52 case PCI_EXP_DEVCTL: