public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH 2/6] arm: a37xx: pci: Disable bus mastering when unloading driver
Date: Mon, 17 May 2021 08:39:52 +0200	[thread overview]
Message-ID: <20210517063956.30905-2-pali@kernel.org> (raw)
In-Reply-To: <20210517063956.30905-1-pali@kernel.org>

Disable Root Bridge I/O space, memory space and bus mastering in Aardvark's
remove method, which is called before booting Linux kernel.

This ensures that PCIe device which was initialized and used by U-Boot
cannot do new DMA transfers until Linux initializes PCI subsystem and loads
appropriate drivers for the device.

During initialization of PCI subsystem Linux in fact disables this bus
mastering on Root Bridge (and later enables it when driver is loaded and
configured), but there is a possibility of a small window after U-Boot
boots Linux when bus mastering is enabled, which is not correct.

Signed-off-by: Pali Roh?r <pali@kernel.org>
Reviewed-by: Marek Beh?n <marek.behun@nic.cz>
---
 drivers/pci/pci-aardvark.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/pci/pci-aardvark.c b/drivers/pci/pci-aardvark.c
index 06c567e236f9..ee81b2ea46d3 100644
--- a/drivers/pci/pci-aardvark.c
+++ b/drivers/pci/pci-aardvark.c
@@ -675,6 +675,12 @@ static int pcie_advk_remove(struct udevice *dev)
 	struct pcie_advk *pcie = dev_get_priv(dev);
 	u32 reg;
 
+	reg = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
+	reg &= ~(PCIE_CORE_CMD_MEM_ACCESS_EN |
+		 PCIE_CORE_CMD_IO_ACCESS_EN |
+		 PCIE_CORE_CMD_MEM_IO_REQ_EN);
+	advk_writel(pcie, reg, PCIE_CORE_CMD_STATUS_REG);
+
 	reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG);
 	reg &= ~LINK_TRAINING_EN;
 	advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG);
-- 
2.20.1

  reply	other threads:[~2021-05-17  6:39 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  6:39 [PATCH 1/6] arm: a37xx: pci: Don't put link into LTSSM Recovery state during probe Pali Rohár
2021-05-17  6:39 ` Pali Rohár [this message]
2021-05-17  6:39 ` [PATCH 3/6] arm: a37xx: pci: Fix DT compatible string to Linux' DT compatible Pali Rohár
2021-05-17  6:39 ` [PATCH 4/6] arm: a37xx: pci: Find PCIe controller node by compatible instead of path Pali Rohár
2021-05-17  6:39 ` [PATCH 5/6] arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function Pali Rohár
2021-05-17  6:39 ` [PATCH 6/6] arm: a37xx: pci: Increase PCIe MEM size from 16 MiB to 128 MiB - 64 KiB Pali Rohár
2021-05-24  7:20   ` Pali Rohár
2021-05-26 15:59 ` [PATCH v2 1/7] arm: a37xx: pci: Don't put link into LTSSM Recovery state during probe Pali Rohár
2021-05-26 15:59   ` [PATCH v2 2/7] arm: a37xx: pci: Disable bus mastering when unloading driver Pali Rohár
2021-05-27  6:20     ` Stefan Roese
2021-05-26 15:59   ` [PATCH v2 3/7] arm: a37xx: pci: Fix DT compatible string to Linux' DT compatible Pali Rohár
2021-05-27  6:20     ` Stefan Roese
2021-05-26 15:59   ` [PATCH v2 4/7] arm: a37xx: pci: Find PCIe controller node by compatible instead of path Pali Rohár
2021-05-27  6:21     ` Stefan Roese
2021-05-26 15:59   ` [PATCH v2 5/7] arm: a37xx: pci: Fix a3700_fdt_fix_pcie_regions() function Pali Rohár
2021-05-27  6:22     ` Stefan Roese
2021-05-26 15:59   ` [PATCH v2 6/7] arm: a37xx: pci: Increase PCIe MEM size from 16 MiB to 127 MiB Pali Rohár
2021-05-27  6:23     ` Stefan Roese
2021-05-26 15:59   ` [PATCH v2 7/7] arm: a37xx: pci: Fix configuring PCIe resources Pali Rohár
2021-05-27  6:24     ` Stefan Roese
2021-05-27  6:19   ` [PATCH v2 1/7] arm: a37xx: pci: Don't put link into LTSSM Recovery state during probe Stefan Roese
2021-06-01 12:57     ` Pali Rohár
2021-06-02  5:12       ` Stefan Roese
2021-06-02 12:42         ` Marek Behún
2021-06-04  9:28           ` Stefan Roese
2021-06-04 13:12   ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210517063956.30905-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox