Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: "Marek Behún" <kabel@kernel.org>
Cc: linux-pci@vger.kernel.org, pali@kernel.org
Subject: Re: [PATCH 5/7] PCI: aardvark: Disable bus mastering and mask all interrupts when unbinding driver
Date: Mon, 29 Nov 2021 16:43:26 +0000	[thread overview]
Message-ID: <20211129164326.GB26244@lpieralisi> (raw)
In-Reply-To: <20211031181233.9976-6-kabel@kernel.org>

On Sun, Oct 31, 2021 at 07:12:31PM +0100, Marek Behún wrote:
> From: Pali Rohár <pali@kernel.org>
> 
> Ensure that after driver unbinding PCIe cards are not be able to forward
> memory and I/O requests in the upstream direction and that no interrupt can
> be triggered.

Two actions - likely to require two patches.

> Fixes: 526a76991b7b ("PCI: aardvark: Implement driver 'remove' function and allow to build it as module")
> Signed-off-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Marek Behún <kabel@kernel.org>
> Cc: stable@vger.kernel.org

You keep adding stable tags, I suppose because you have fixes on top
that will need to go to stable, as said multiple times please let's
not jump the gun, let's fix (if this is fixing anything) mainline
first.

Lorenzo

>  drivers/pci/controller/pci-aardvark.c | 29 +++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c
> index 71ce9f02d596..08b34accfe2f 100644
> --- a/drivers/pci/controller/pci-aardvark.c
> +++ b/drivers/pci/controller/pci-aardvark.c
> @@ -1695,13 +1695,42 @@ static int advk_pcie_remove(struct platform_device *pdev)
>  {
>  	struct advk_pcie *pcie = platform_get_drvdata(pdev);
>  	struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
> +	u32 val;
>  	int i;
>  
> +	/* Remove PCI bus with all devices */
>  	pci_lock_rescan_remove();
>  	pci_stop_root_bus(bridge->bus);
>  	pci_remove_root_bus(bridge->bus);
>  	pci_unlock_rescan_remove();
>  
> +	/* Disable Root Bridge I/O space, memory space and bus mastering */
> +	val = advk_readl(pcie, PCIE_CORE_CMD_STATUS_REG);
> +	val &= ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
> +	advk_writel(pcie, val, PCIE_CORE_CMD_STATUS_REG);
> +
> +	/* Disable MSI */
> +	val = advk_readl(pcie, PCIE_CORE_CTRL2_REG);
> +	val &= ~PCIE_CORE_CTRL2_MSI_ENABLE;
> +	advk_writel(pcie, val, PCIE_CORE_CTRL2_REG);
> +
> +	/* Clear MSI address */
> +	advk_writel(pcie, 0, PCIE_MSI_ADDR_LOW_REG);
> +	advk_writel(pcie, 0, PCIE_MSI_ADDR_HIGH_REG);
> +
> +	/* Mask all interrupts */
> +	advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_MASK_REG);
> +	advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_MASK_REG);
> +	advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_MASK_REG);
> +	advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_MASK_REG);
> +
> +	/* Clear all interrupts */
> +	advk_writel(pcie, PCIE_MSI_ALL_MASK, PCIE_MSI_STATUS_REG);
> +	advk_writel(pcie, PCIE_ISR0_ALL_MASK, PCIE_ISR0_REG);
> +	advk_writel(pcie, PCIE_ISR1_ALL_MASK, PCIE_ISR1_REG);
> +	advk_writel(pcie, PCIE_IRQ_ALL_MASK, HOST_CTRL_INT_STATUS_REG);
> +
> +	/* Remove IRQ domains */
>  	advk_pcie_remove_msi_irq_domain(pcie);
>  	advk_pcie_remove_irq_domain(pcie);
>  
> -- 
> 2.32.0
> 

  reply	other threads:[~2021-11-29 16:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31 18:12 [PATCH 0/7] PCI: aardvark controller fixes BATCH 3 Marek Behún
2021-10-31 18:12 ` [PATCH 1/7] PCI: pci-bridge-emul: Add description for class_revision field Marek Behún
2021-10-31 18:12 ` [PATCH 2/7] PCI: pci-bridge-emul: Add definitions for missing capabilities registers Marek Behún
2021-11-29 16:44   ` Lorenzo Pieralisi
2021-10-31 18:12 ` [PATCH 3/7] PCI: aardvark: Add support for DEVCAP2, DEVCTL2, LNKCAP2 and LNKCTL2 registers on emulated bridge Marek Behún
2021-10-31 18:12 ` [PATCH 4/7] PCI: aardvark: Clear all MSIs at setup Marek Behún
2021-10-31 18:12 ` [PATCH 5/7] PCI: aardvark: Disable bus mastering and mask all interrupts when unbinding driver Marek Behún
2021-11-29 16:43   ` Lorenzo Pieralisi [this message]
2021-10-31 18:12 ` [PATCH 6/7] PCI: aardvark: Free config space for emulated root bridge when unbinding driver to fix memory leak Marek Behún
2021-10-31 18:12 ` [PATCH 7/7] PCI: aardvark: Reset PCIe card and disable PHY at driver unbind Marek Behún
2021-11-29 16:40   ` Lorenzo Pieralisi
2021-11-29 17:15     ` Marek Behún
2021-11-30 10:31       ` Lorenzo Pieralisi
2021-11-30 12:22         ` Marek Behún

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=20211129164326.GB26244@lpieralisi \
    --to=lorenzo.pieralisi@arm.com \
    --cc=kabel@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    /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