From: Will Deacon <will@kernel.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
linux-arm-kernel@lists.infradead.org,
Robin Murphy <robin.murphy@arm.com>,
Eric Auger <eric.auger@redhat.com>,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Jerry Snitselaar <jsnitsel@redhat.com>,
Moritz Fischer <mdf@kernel.org>,
Michael Shavit <mshavit@google.com>,
Nicolin Chen <nicolinc@nvidia.com>,
patches@lists.linux.dev,
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
Subject: Re: [PATCH v9 02/14] iommu/arm-smmu-v3: Start building a generic PASID layer
Date: Tue, 2 Jul 2024 15:57:05 +0100 [thread overview]
Message-ID: <20240702145705.GA4135@willie-the-truck> (raw)
In-Reply-To: <2-v9-5cd718286059+79186-smmuv3_newapi_p2b_jgg@nvidia.com>
On Tue, Jun 25, 2024 at 09:37:33AM -0300, Jason Gunthorpe wrote:
> Add arm_smmu_set_pasid()/arm_smmu_remove_pasid() which are to be used by
> callers that already constructed the arm_smmu_cd they wish to program.
>
> These functions will encapsulate the shared logic to setup a CD entry that
> will be shared by SVA and S1 domain cases.
>
> Prior fixes had already moved most of this logic up into
> __arm_smmu_sva_bind(), move it to it's final home.
>
> Following patches will relieve some of the remaining SVA restrictions:
>
> - The RID domain is a S1 domain and has already setup the STE to point to
> the CD table
> - The programmed PASID is the mm_get_enqcmd_pasid()
> - Nothing changes while SVA is running (sva_enable)
>
> SVA invalidation will still iterate over the S1 domain's master list,
> later patches will resolve that.
>
> Tested-by: Nicolin Chen <nicolinc@nvidia.com>
> Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
> Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 57 ++++++++++---------
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 32 ++++++++++-
> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 9 ++-
> 3 files changed, 67 insertions(+), 31 deletions(-)
[...]
> @@ -611,10 +599,9 @@ void arm_smmu_sva_remove_dev_pasid(struct iommu_domain *domain,
> struct arm_smmu_bond *bond = NULL, *t;
> struct arm_smmu_master *master = dev_iommu_priv_get(dev);
>
> + arm_smmu_remove_pasid(master, to_smmu_domain(domain), id);
> +
> mutex_lock(&sva_lock);
> -
> - arm_smmu_clear_cd(master, id);
This looks a bit alarming, as you're effectively moving the CD
modification outside of the critical section. I assume we're relying on
the iommu group mutex to serialise this in the caller? I can't see any
consistent locking in the driver for arm_smmu_clear_cd().
As an additional patch, perhaps we should consider documenting what each
lock in the driver protects and the lock ordering requirements they
have? We've got a few global locks with generic names and after a few
rounds of refactoring it's really hard to know who's responsible for
what, especially now that we have stale comments referring to
arm_smmu_share_asid(). We've also grown a number of places where we
drop a lock in the callee and immediately re-take it in the caller,
which tends to be a source of bugs.
Thanks,
Will
next prev parent reply other threads:[~2024-07-02 14:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 12:37 [PATCH v9 00/14] Update SMMUv3 to the modern iommu API (part 2b/3) Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 01/14] iommu/arm-smmu-v3: Convert to domain_alloc_sva() Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 02/14] iommu/arm-smmu-v3: Start building a generic PASID layer Jason Gunthorpe
2024-07-02 14:57 ` Will Deacon [this message]
2024-07-02 17:03 ` Nicolin Chen
2024-07-09 19:39 ` Jason Gunthorpe
2024-09-06 14:08 ` Will Deacon
2024-10-07 17:43 ` Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 03/14] iommu/arm-smmu-v3: Make smmu_domain->devices into an allocated list Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 04/14] iommu/arm-smmu-v3: Make changing domains be hitless for ATS Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 05/14] iommu/arm-smmu-v3: Add ssid to struct arm_smmu_master_domain Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 06/14] iommu/arm-smmu-v3: Do not use master->sva_enable to restrict attaches Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 07/14] iommu/arm-smmu-v3: Thread SSID through the arm_smmu_attach_*() interface Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 08/14] iommu/arm-smmu-v3: Make SVA allocate a normal arm_smmu_domain Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 09/14] iommu/arm-smmu-v3: Keep track of arm_smmu_master_domain for SVA Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 10/14] iommu/arm-smmu-v3: Put the SVA mmu notifier in the smmu_domain Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 11/14] iommu/arm-smmu-v3: Allow IDENTITY/BLOCKED to be set while PASID is used Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 12/14] iommu/arm-smmu-v3: Test the STE S1DSS functionality Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 13/14] iommu/arm-smmu-v3: Allow a PASID to be set when RID is IDENTITY/BLOCKED Jason Gunthorpe
2024-06-25 12:37 ` [PATCH v9 14/14] iommu/arm-smmu-v3: Allow setting a S1 domain to a PASID Jason Gunthorpe
2024-07-02 18:43 ` [PATCH v9 00/14] Update SMMUv3 to the modern iommu API (part 2b/3) Will Deacon
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=20240702145705.GA4135@willie-the-truck \
--to=will@kernel.org \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mdf@kernel.org \
--cc=mshavit@google.com \
--cc=nicolinc@nvidia.com \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
/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