From: Michael Shavit <mshavit@google.com>
To: Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Joerg Roedel <joro@8bytes.org>
Cc: Michael Shavit <mshavit@google.com>,
jean-philippe@linaro.org, nicolinc@nvidia.com, jgg@nvidia.com,
baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v2 17/18] iommu/arm-smmu-v3-sva: Alloc notifier for {smmu,mn}
Date: Tue, 6 Jun 2023 20:07:53 +0800 [thread overview]
Message-ID: <20230606120854.4170244-18-mshavit@google.com> (raw)
In-Reply-To: <20230606120854.4170244-1-mshavit@google.com>
The arm_smmu_nofitier for an mn can be shared across all devices with
the same upstream smmu. This breaks the last remaining explicit
dependency on the device's primary domain in arm-smmu-v3-sva.
Signed-off-by: Michael Shavit <mshavit@google.com>
---
.../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 18 +++++++-----------
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 +-
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 4 ++--
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
index 9a2da579c3563..3e49838e4f55c 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c
@@ -258,17 +258,16 @@ static const struct mmu_notifier_ops arm_smmu_mmu_notifier_ops = {
.free_notifier = arm_smmu_mmu_notifier_free,
};
-/* Allocate or get existing MMU notifier for this {domain, mm} pair */
+/* Allocate or get existing MMU notifier for this {smmu, mm} pair */
static struct arm_smmu_mmu_notifier *
arm_smmu_mmu_notifier_get(struct arm_smmu_device *smmu,
- struct arm_smmu_domain *smmu_domain,
struct mm_struct *mm)
{
int ret;
struct arm_smmu_ctx_desc *cd;
struct arm_smmu_mmu_notifier *smmu_mn;
- list_for_each_entry(smmu_mn, &smmu_domain->mmu_notifiers, list) {
+ list_for_each_entry(smmu_mn, &smmu->mmu_notifiers, list) {
if (smmu_mn->mn.mm == mm) {
refcount_inc(&smmu_mn->refs);
return smmu_mn;
@@ -296,9 +295,8 @@ arm_smmu_mmu_notifier_get(struct arm_smmu_device *smmu,
}
arm_smmu_init_shared_cd_domain(smmu, &smmu_mn->domain, cd);
- list_add(&smmu_mn->list, &smmu_domain->mmu_notifiers);
+ list_add(&smmu_mn->list, &smmu->mmu_notifiers);
return smmu_mn;
-
err_free_cd:
arm_smmu_free_shared_cd(cd);
return ERR_PTR(ret);
@@ -314,7 +312,6 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn)
return;
list_del(&smmu_mn->list);
-
/*
* If we went through clear(), we've already invalidated, and no
* new TLB entry can have been formed.
@@ -331,18 +328,17 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn)
static int __arm_smmu_sva_bind(struct device *dev,
struct arm_smmu_sva_domain *sva_domain,
- struct mm_struct *mm)
+ struct mm_struct *mm,
+ ioasid_t id)
{
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
- struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
- struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain);
+ struct arm_smmu_domain *smmu_domain;
int ret;
if (!master || !master->sva_enabled)
return -ENODEV;
sva_domain->smmu_mn = arm_smmu_mmu_notifier_get(master->smmu,
- smmu_domain,
mm);
if (IS_ERR(sva_domain->smmu_mn)) {
sva_domain->smmu_mn = NULL;
@@ -533,7 +529,7 @@ static int arm_smmu_sva_set_dev_pasid(struct iommu_domain *domain,
struct mm_struct *mm = domain->mm;
mutex_lock(&sva_lock);
- ret = __arm_smmu_sva_bind(dev, to_sva_domain(domain), mm);
+ ret = __arm_smmu_sva_bind(dev, to_sva_domain(domain), mm, id);
mutex_unlock(&sva_lock);
return ret;
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 3c5ff4f58934a..e68c5264c6171 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -2058,7 +2058,6 @@ static void arm_smmu_init_smmu_domain(struct arm_smmu_domain *smmu_domain)
mutex_init(&smmu_domain->init_mutex);
INIT_LIST_HEAD(&smmu_domain->attached_domains);
spin_lock_init(&smmu_domain->attached_domains_lock);
- INIT_LIST_HEAD(&smmu_domain->mmu_notifiers);
}
static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
@@ -2859,6 +2858,7 @@ static struct iommu_device *arm_smmu_probe_device(struct device *dev)
goto err_free_master;
}
+ INIT_LIST_HEAD(&smmu->mmu_notifiers);
return &smmu->iommu;
err_free_master:
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
index 2c33c0461036d..041b0e532ac3d 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
@@ -674,6 +674,8 @@ struct arm_smmu_device {
struct rb_root streams;
struct mutex streams_mutex;
+
+ struct list_head mmu_notifiers;
};
struct arm_smmu_stream {
@@ -737,8 +739,6 @@ struct arm_smmu_domain {
struct list_head attached_domains;
spinlock_t attached_domains_lock;
-
- struct list_head mmu_notifiers;
};
static inline struct arm_smmu_domain *to_smmu_domain(struct iommu_domain *dom)
--
2.41.0.rc0.172.g3f132b7071-goog
next prev parent reply other threads:[~2023-06-06 12:11 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 12:07 [PATCH v2 00/18] Add PASID support to SMMUv3 unmanaged domains Michael Shavit
2023-06-06 12:07 ` [PATCH v2 01/18] iommu/arm-smmu-v3: Move ctx_desc out of s1_cfg Michael Shavit
2023-06-06 12:07 ` [PATCH v2 02/18] iommu/arm-smmu-v3: Add smmu_s1_cfg to smmu_master Michael Shavit
2023-06-06 12:07 ` [PATCH v2 03/18] iommu/arm-smmu-v3: Refactor write_strtab_ent Michael Shavit
2023-06-06 12:07 ` [PATCH v2 04/18] iommu/arm-smmu-v3: Refactor write_ctx_desc Michael Shavit
2023-06-06 12:07 ` [PATCH v2 05/18] iommu/arm-smmu-v3: Use the master-owned s1_cfg Michael Shavit
2023-06-06 12:07 ` [PATCH v2 06/18] iommu/arm-smmu-v3: Simplify arm_smmu_enable_ats Michael Shavit
2023-06-06 12:07 ` [PATCH v2 07/18] iommu/arm-smmu-v3: Keep track of attached ssids Michael Shavit
2023-06-06 12:07 ` [PATCH v2 08/18] iommu/arm-smmu-v3: Add helper for atc invalidation Michael Shavit
2023-06-06 12:07 ` [PATCH v2 09/18] iommu/arm-smmu-v3: Implement set_dev_pasid Michael Shavit
2023-06-06 12:07 ` [PATCH v2 10/18] iommu/arm-smmu-v3-sva: Remove bond refcount Michael Shavit
2023-06-06 12:07 ` [PATCH v2 11/18] iommu/arm-smmu-v3-sva: Clean unused iommu_sva Michael Shavit
2023-06-06 12:07 ` [PATCH v2 12/18] iommu/arm-smmu-v3-sva: Remove arm_smmu_bond Michael Shavit
2023-06-06 12:07 ` [PATCH v2 13/18] iommu/arm-smmu-v3-sva: Add check when enabling sva Michael Shavit
2023-06-06 12:07 ` [PATCH v2 14/18] iommu/arm-smmu-v3: Support domains with shared CDs Michael Shavit
2023-06-06 17:09 ` Jason Gunthorpe
2023-06-06 18:36 ` Michael Shavit
2023-06-07 11:59 ` Jason Gunthorpe
2023-06-08 2:39 ` Baolu Lu
2023-06-08 13:39 ` Jason Gunthorpe
2023-06-09 1:44 ` Baolu Lu
2023-06-14 9:17 ` Michael Shavit
2023-06-14 9:43 ` Michael Shavit
2023-06-14 9:57 ` Robin Murphy
2023-06-14 12:10 ` Jason Gunthorpe
2023-06-14 13:30 ` Michael Shavit
2023-06-14 13:35 ` Jason Gunthorpe
2023-07-05 9:56 ` Zhang, Tina
2023-07-10 16:55 ` Jason Gunthorpe
2023-07-11 0:26 ` Zhang, Tina
2023-07-11 13:53 ` Jason Gunthorpe
2023-06-06 12:07 ` [PATCH v2 15/18] iommu/arm-smmu-v3: Allow more re-use for SVA Michael Shavit
2023-06-06 12:07 ` [PATCH v2 16/18] iommu/arm-smmu-v3-sva: Attach S1_SHARED_CD domain Michael Shavit
2023-06-06 12:07 ` Michael Shavit [this message]
2023-06-06 12:07 ` [PATCH v2 18/18] iommu/arm-smmu-v3-sva: Remove atc_inv_domain_ssid Michael Shavit
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=20230606120854.4170244-18-mshavit@google.com \
--to=mshavit@google.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.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