2267821f73e6944efd35e4c3f851e5556a2aa72f
[openwrt/staging/aparcar.git] /
1 From a46f2f6dd4093438d9615dfbf5c0fea2a9835dba Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
3 Date: Tue, 30 Nov 2021 18:29:08 +0100
4 Subject: [PATCH] PCI: aardvark: Disable bus mastering when unbinding driver
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Ensure that after driver unbind PCIe cards are not able to forward
10 memory and I/O requests in the upstream direction.
11
12 Link: https://lore.kernel.org/r/20211130172913.9727-7-kabel@kernel.org
13 Signed-off-by: Pali Rohár <pali@kernel.org>
14 Signed-off-by: Marek Behún <kabel@kernel.org>
15 Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
16 ---
17 drivers/pci/controller/pci-aardvark.c | 6 ++++++
18 1 file changed, 6 insertions(+)
19
20 diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
21 index 6348584c33be..12eae05f3d10 100644
22 --- a/drivers/pci/controller/pci-aardvark.c
23 +++ b/drivers/pci/controller/pci-aardvark.c
24 @@ -1695,6 +1695,7 @@ static int advk_pcie_remove(struct platform_device *pdev)
25 {
26 struct advk_pcie *pcie = platform_get_drvdata(pdev);
27 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
28 + u32 val;
29 int i;
30
31 /* Remove PCI bus with all devices */
32 @@ -1703,6 +1704,11 @@ static int advk_pcie_remove(struct platform_device *pdev)
33 pci_remove_root_bus(bridge->bus);
34 pci_unlock_rescan_remove();
35
36 + /* Disable Root Bridge I/O space, memory space and bus mastering */
37 + val = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
38 + val &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
39 + advk_writel(pcie, val, PCIE_CORE_CMD_STATUS_REG);
40 +
41 /* Remove IRQ domains */
42 advk_pcie_remove_msi_irq_domain(pcie);
43 advk_pcie_remove_irq_domain(pcie);
44 --
45 2.34.1
46