From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev,
joro@8bytes.org, bhelgaas@google.com, robin.murphy@arm.com,
will@kernel.org
Cc: jean-philippe@linaro.org,
sathyanarayanan.kuppuswamy@linux.intel.com,
darren@os.amperecomputing.com, scott@os.amperecomputing.com
Subject: Re: [PATCH v2 2/2] iommu/arm-smmu-v3: Configure STU of a PF if ATS is not enabled.
Date: Mon, 13 Mar 2023 19:49:20 +0530 [thread overview]
Message-ID: <2dc4db94-1d03-2080-aa6d-56a7327bde5f@os.amperecomputing.com> (raw)
In-Reply-To: <20230228042137.1941024-3-gankulkarni@os.amperecomputing.com>
Hi Will, Robin,
On 28-02-2023 09:51 am, Ganapatrao Kulkarni wrote:
> When the host kernel is booted with iommu passthrough mode, PF and VFs
> are enumerated with iommu/smmu domain set to bypass mode.
> In bypass mode, ATS is not enabled on all VFs and associated PF.
> When VFs are attached to a VM, the corresponding iommu domain is set to
> SMMU translation mode and smmu-v3 driver try to enable the ATS and fails
> due to invalid STU of a PF.
>
> Adding a fix to configure STU of a PF while enumerating in passthrough
> mode.
>
Any comments on this patch/series?
> Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
> ---
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 25 ++++++++++++++++++++-
> 1 file changed, 24 insertions(+), 1 deletion(-)
>
> 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 f2425b0f0cd6..b218ef0bf001 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2292,6 +2292,23 @@ static bool arm_smmu_ats_supported(struct arm_smmu_master *master)
> return dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev));
> }
>
> +static void arm_smmu_ats_stu_init(struct arm_smmu_master *master)
> +{
> + size_t stu;
> + struct pci_dev *pdev;
> + struct arm_smmu_device *smmu = master->smmu;
> +
> + if (master->ats_enabled)
> + return;
> +
> + /* Smallest Translation Unit: log2 of the smallest supported granule */
> + stu = __ffs(smmu->pgsize_bitmap);
> + pdev = to_pci_dev(master->dev);
> +
> + if (pci_ats_stu_configure(pdev, stu))
> + dev_err(master->dev, "Failed to configure ATS STU (%zu)\n", stu);
> +}
> +
> static void arm_smmu_enable_ats(struct arm_smmu_master *master)
> {
> size_t stu;
> @@ -2404,6 +2421,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> struct arm_smmu_device *smmu;
> struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
> struct arm_smmu_master *master;
> + bool ats_supported;
>
> if (!fwspec)
> return -ENOENT;
> @@ -2446,9 +2464,10 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> }
>
> master->domain = smmu_domain;
> + ats_supported = arm_smmu_ats_supported(master);
>
> if (smmu_domain->stage != ARM_SMMU_DOMAIN_BYPASS)
> - master->ats_enabled = arm_smmu_ats_supported(master);
> + master->ats_enabled = ats_supported;
>
> arm_smmu_install_ste_for_dev(master);
>
> @@ -2458,6 +2477,10 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
>
> arm_smmu_enable_ats(master);
>
> + /* Configure ATS STU of a PF in passthrough */
> + if (!master->ats_enabled && ats_supported)
> + arm_smmu_ats_stu_init(master);
> +
> out_unlock:
> mutex_unlock(&smmu_domain->init_mutex);
> return ret;
Thanks,
Ganapat
next prev parent reply other threads:[~2023-03-13 14:20 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 4:21 [PATCH v2 0/2] Add support to enable ATS on VFs independently Ganapatrao Kulkarni
2023-02-28 4:21 ` [PATCH v2 1/2] PCI/ATS: Add a helper function to configure ATS STU of a PF Ganapatrao Kulkarni
2023-02-28 16:30 ` Sathyanarayanan Kuppuswamy
2023-03-08 8:54 ` Ganapatrao Kulkarni
2023-03-13 21:12 ` Bjorn Helgaas
2023-03-13 22:30 ` Sathyanarayanan Kuppuswamy
2023-03-13 22:42 ` Bjorn Helgaas
2023-03-14 10:08 ` Ganapatrao Kulkarni
2023-03-14 12:52 ` Sathyanarayanan Kuppuswamy
2023-03-14 14:36 ` Ganapatrao Kulkarni
2023-03-14 16:02 ` Bjorn Helgaas
2023-03-14 16:50 ` Sathyanarayanan Kuppuswamy
2023-03-14 17:10 ` Bjorn Helgaas
2023-03-14 18:01 ` Ganapatrao Kulkarni
2023-03-14 18:12 ` Sathyanarayanan Kuppuswamy
2023-03-14 21:17 ` Bjorn Helgaas
2023-03-15 4:22 ` Sathyanarayanan Kuppuswamy
2023-03-15 14:30 ` Ganapatrao Kulkarni
2023-02-28 4:21 ` [PATCH v2 2/2] iommu/arm-smmu-v3: Configure STU of a PF if ATS is not enabled Ganapatrao Kulkarni
2023-03-13 14:19 ` Ganapatrao Kulkarni [this message]
2023-03-02 4:24 ` [PATCH v2 0/2] Add support to enable ATS on VFs independently Sathyanarayanan Kuppuswamy
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=2dc4db94-1d03-2080-aa6d-56a7327bde5f@os.amperecomputing.com \
--to=gankulkarni@os.amperecomputing.com \
--cc=bhelgaas@google.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=linux-pci@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.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
all inboxes | Powered by JetHome®