[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <34442ab9-08e1-4e9a-b08e-3b81a581fec3@linux.intel.com>
Date: Tue, 10 Jun 2025 12:27:04 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Nicolin Chen <nicolinc@...dia.com>, jgg@...dia.com, joro@...tes.org,
will@...nel.org, robin.murphy@....com, bhelgaas@...gle.com
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org, patches@...ts.linux.dev, pjaroszynski@...dia.com,
vsethi@...dia.com
Subject: Re: [PATCH RFC v1 2/2] pci: Suspend ATS before doing FLR
On 6/10/25 02:45, Nicolin Chen wrote:
> Per PCIe r6.3, sec 10.3.1 IMPLEMENTATION NOTE, software should disable ATS
> before initiating a Function Level Reset.
>
> Call iommu_dev_reset_prepare() before FLR and iommu_dev_reset_done() after,
> in the two FLR Functions. This will dock the device at IOMMU_DOMAIN_BLOCKED
> during the FLR function, which should allow the IOMMU driver to pause DMA
> traffic and invode pci_disable_ats() and pci_enable_ats() respectively.
>
> Add a warning if ATS isn't disabled, in which case IOMMU driver should fix
> itself to disable ATS following the design in iommu_dev_reset_prepare().
>
> Signed-off-by: Nicolin Chen<nicolinc@...dia.com>
> ---
> drivers/pci/pci.c | 42 ++++++++++++++++++++++++++++++++++++++----
> 1 file changed, 38 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e9448d55113b..61535435bde1 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -13,6 +13,7 @@
> #include <linux/delay.h>
> #include <linux/dmi.h>
> #include <linux/init.h>
> +#include <linux/iommu.h>
> #include <linux/msi.h>
> #include <linux/of.h>
> #include <linux/pci.h>
> @@ -4518,13 +4519,26 @@ EXPORT_SYMBOL(pci_wait_for_pending_transaction);
> */
> int pcie_flr(struct pci_dev *dev)
> {
> + int ret = 0;
> +
> if (!pci_wait_for_pending_transaction(dev))
> pci_err(dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
>
> + /*
> + * Per PCIe r6.3, sec 10.3.1 IMPLEMENTATION NOTE, software disables ATS
> + * before initiating a Function Level Reset. So notify the iommu driver
> + * that actually enabled ATS. Have to call it after waiting for pending
> + * DMA transaction.
> + */
> + if (iommu_dev_reset_prepare(&dev->dev))
> + pci_err(dev, "failed to stop IOMMU\n");
Need to abort here?
Thanks,
baolu
Powered by blists - more mailing lists