[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v8 5/6] AMD/IOMMU: pull ATS disabling earlier


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 22 Sep 2021 16:38:10 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=L4OzGEj91QdJC5vdoESTAykpaiWdGj46EwoZ9sMMZn8=; b=lwUwJSZDUNVr5P2xHsnGjGYmzVxPWT4DBJ76dX6DxO6J0NwxlkOGwEzU4TEjVgvKyT9QSHXjPHJrK+nHJ1bz3Ow0NZQIxqfAXxsQAl2cOBjhk47dLaZlslmhZBctI1OKEvDQfp783HY5ZQQiC2FQ2A8ZrkRORyJ4LaynxQrW6mnNJoQHe4SLTne/0/IxDAUZtVYA1enYGYMH9BTlPJ3Sg6bJ2qNEbt8/hvbkGf7nNRYE58xmN5JOO7A8qi8MNBvuYSz46ZcTsuyJ5mBJFctRFn2KhGRfYqhO5pK4xrRmlaLWdWIG8zaR6I5p7MDVENQRN7qEOE6MzzOscF2bk/9p/g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fc/ksO43unMARgcWrNAODMghjoBwYq0onMQNlotNsMIfjU2jZUA+5pEfyyUepztttEAmCQa/U3kSXEg9EqxFJjTOnjofB+zQmibDftehe38kw0b3ogzLhgr5oLFo3BtX2XcezWzV32SYqXb5hgHklG63a1IrfI8aMfoJaUa22UBSeIpiGlB3lHUDh0tBOBbL5qw5Lwpao+oNS+J/HMsF4SEHaGKrxffLp1InGuD2b+TL5fLdW9IL0ZDCo006yGGaFw9vhnzTiccpN0zygFnQ/MlC6uGIMBDpxaHglV46RfR+/EOhXh3zC0xOChEjfeiY1ZIud+oEuFUz6BjqPMJ4Jg==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Wed, 22 Sep 2021 14:38:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Disabling should be done in the opposite order of enabling: ATS wants to
be turned off before adjusting the DTE, just like it gets enabled only
after the DTE was suitably prepared. Note that we want ATS to be
disabled as soon as any of the DTEs involved in the handling of a device
(including phantom devices) gets adjusted respectively. For this reason
the "devfn == pdev->devfn" of the original conditional gets dropped.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
TBD: This points out that for phantom devices the ordering in
     amd_iommu_setup_domain_device() may also not be fully suitable: ATS
     would better be enabled on the device only after all involved DTEs
     have got prepared. This would be a less straightforward change,
     though.
---
v8: New.

--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -313,6 +313,12 @@ static void amd_iommu_disable_domain_dev
     if ( QUARANTINE_SKIP(domain) )
         return;
 
+    ASSERT(pcidevs_locked());
+
+    if ( pci_ats_device(iommu->seg, bus, pdev->devfn) &&
+         pci_ats_enabled(iommu->seg, bus, pdev->devfn) )
+        disable_ats_device(pdev);
+
     BUG_ON ( iommu->dev_table.buffer == NULL );
     req_id = get_dma_requestor_id(iommu->seg, PCI_BDF2(bus, devfn));
     table = iommu->dev_table.buffer;
@@ -348,13 +354,6 @@ static void amd_iommu_disable_domain_dev
     }
     else
         spin_unlock_irqrestore(&iommu->lock, flags);
-
-    ASSERT(pcidevs_locked());
-
-    if ( devfn == pdev->devfn &&
-         pci_ats_device(iommu->seg, bus, devfn) &&
-         pci_ats_enabled(iommu->seg, bus, devfn) )
-        disable_ats_device(pdev);
 }
 
 static int reassign_device(struct domain *source, struct domain *target,




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.