9b8ae26dfebc82a3015ad2d584790447256da616
[openwrt/staging/robimarko.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 --- a/drivers/pci/controller/pci-aardvark.c
21 +++ b/drivers/pci/controller/pci-aardvark.c
22 @@ -1679,6 +1679,7 @@ static int advk_pcie_remove(struct platf
23 {
24 struct advk_pcie *pcie = platform_get_drvdata(pdev);
25 struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
26 + u32 val;
27 int i;
28
29 /* Remove PCI bus with all devices */
30 @@ -1687,6 +1688,11 @@ static int advk_pcie_remove(struct platf
31 pci_remove_root_bus(bridge->bus);
32 pci_unlock_rescan_remove();
33
34 + /* Disable Root Bridge I/O space, memory space and bus mastering */
35 + val = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
36 + val &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
37 + advk_writel(pcie, val, PCIE_CORE_CMD_STATUS_REG);
38 +
39 /* Remove IRQ domains */
40 advk_pcie_remove_msi_irq_domain(pcie);
41 advk_pcie_remove_irq_domain(pcie);