All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>, Paul Durrant <paul@xen.org>
Subject: [PATCH v8 5/6] AMD/IOMMU: pull ATS disabling earlier
Date: Wed, 22 Sep 2021 16:38:10 +0200	[thread overview]
Message-ID: <34c081bd-ac6d-055c-e6c1-eeac62851389@suse.com> (raw)
In-Reply-To: <d249a759-188a-d689-316a-4743922827e5@suse.com>

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@suse.com>
---
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,



  parent reply	other threads:[~2021-09-22 14:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 14:35 [PATCH v8 0/6] AMD/IOMMU: further work split from XSA-378 Jan Beulich
2021-09-22 14:36 ` [PATCH v8 1/6] AMD/IOMMU: obtain IVHD type to use earlier Jan Beulich
2021-09-28  7:12   ` Durrant, Paul
2021-10-19 23:34   ` Andrew Cooper
2021-10-20  6:58     ` Jan Beulich
2021-10-20  8:17     ` Jan Beulich
2021-09-22 14:37 ` [PATCH v8 2/6] AMD/IOMMU: improve (extended) feature detection Jan Beulich
2021-09-22 14:37 ` [PATCH v8 3/6] AMD/IOMMU: check IVMD ranges against host implementation limits Jan Beulich
2021-09-22 14:37 ` [PATCH v8 4/6] AMD/IOMMU: respect AtsDisabled device flag Jan Beulich
2021-09-28  7:34   ` Durrant, Paul
2021-09-28  7:47     ` Jan Beulich
2021-09-28  7:57       ` Durrant, Paul
2021-09-22 14:38 ` Jan Beulich [this message]
2021-09-28  7:36   ` [PATCH v8 5/6] AMD/IOMMU: pull ATS disabling earlier Durrant, Paul
2021-09-22 14:38 ` [PATCH v8 6/6] AMD/IOMMU: expose errors and warnings unconditionally Jan Beulich
2021-09-28  7:42   ` Durrant, Paul
2021-09-28  7:50     ` Jan Beulich

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=34c081bd-ac6d-055c-e6c1-eeac62851389@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=paul@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.