[PATCH v2 2/7] arm: a37xx: pci: Disable bus mastering when unloading driver

Stefan Roese sr at denx.de
Thu May 27 08:20:02 CEST 2021


On 26.05.21 17:59, Pali Rohár wrote:
> 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 at kernel.org>
> Reviewed-by: Marek Behún <marek.behun at nic.cz>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan

> ---
>   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);
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de


More information about the U-Boot mailing list