public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
	robin.murphy@arm.com, will@kernel.org, joro@8bytes.org
Cc: jean-philippe@linaro.org, darren@os.amperecomputing.com,
	scott@os.amperecomputing.com, gankulkarni@os.amperecomputing.com
Subject: [PATCH] iommu/arm-smmu-v3: Enable PCI ATS in passthrough mode as well
Date: Thu,  2 Feb 2023 04:40:53 -0800	[thread overview]
Message-ID: <20230202124053.848792-1-gankulkarni@os.amperecomputing.com> (raw)

The current smmu-v3 driver does not enable PCI ATS for physical functions
of ATS capable End Points when booted in smmu bypass mode
(iommu.passthrough=1). This will not allow virtual functions to enable
ATS(even though EP supports it) while they are attached to a VM using
VFIO driver.

This patch adds changes to enable ATS support for physical functions
in passthrough/bypass mode as well.

Also, adding check to avoid disabling of ATS if it is not enabled,
to avoid unnecessary call-traces.

Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index 6d5df91c5c46..5a605cb5ccef 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2313,11 +2313,16 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master)
 static void arm_smmu_disable_ats(struct arm_smmu_master *master)
 {
 	struct arm_smmu_domain *smmu_domain = master->domain;
+	struct pci_dev *pdev;
 
 	if (!master->ats_enabled)
 		return;
 
-	pci_disable_ats(to_pci_dev(master->dev));
+	pdev = to_pci_dev(master->dev);
+
+	if (pdev->ats_enabled)
+		pci_disable_ats(pdev);
+
 	/*
 	 * Ensure ATS is disabled at the endpoint before we issue the
 	 * ATC invalidation via the SMMU.
@@ -2453,8 +2458,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
 
 	master->domain = smmu_domain;
 
-	if (smmu_domain->stage != ARM_SMMU_DOMAIN_BYPASS)
-		master->ats_enabled = arm_smmu_ats_supported(master);
+	master->ats_enabled = arm_smmu_ats_supported(master);
 
 	arm_smmu_install_ste_for_dev(master);
 
-- 
2.37.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

             reply	other threads:[~2023-02-02 12:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 12:40 Ganapatrao Kulkarni [this message]
2023-02-02 13:22 ` [PATCH] iommu/arm-smmu-v3: Enable PCI ATS in passthrough mode as well Robin Murphy
2023-02-03 10:44   ` Ganapatrao Kulkarni
2023-02-03 12:12     ` Robin Murphy
2023-02-03 12:00 ` Jean-Philippe Brucker
2023-02-03 12:05   ` Will Deacon
2023-02-06 17:20   ` Ganapatrao Kulkarni
2023-02-06 19:45     ` Jean-Philippe Brucker
2023-02-07  9:50       ` Ganapatrao Kulkarni

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=20230202124053.848792-1-gankulkarni@os.amperecomputing.com \
    --to=gankulkarni@os.amperecomputing.com \
    --cc=darren@os.amperecomputing.com \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=scott@os.amperecomputing.com \
    --cc=will@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