From: Jean-Philippe Brucker <jean-philippe@linaro.org>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux-foundation.org,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
joro@8bytes.org, catalin.marinas@arm.com, will@kernel.org,
robin.murphy@arm.com, baolu.lu@linux.intel.com,
Jonathan.Cameron@huawei.com, jacob.jun.pan@linux.intel.com,
zhangfei.gao@linaro.org, xuzaibo@huawei.com,
fenghua.yu@intel.com, eric.auger@redhat.com
Subject: Re: [PATCH v10 12/13] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()
Date: Wed, 25 Nov 2020 10:27:49 +0100 [thread overview]
Message-ID: <20201125092749.GA2445658@myrica> (raw)
In-Reply-To: <20201124235800.GA242277@nvidia.com>
On Tue, Nov 24, 2020 at 07:58:00PM -0400, Jason Gunthorpe wrote:
> On Fri, Sep 18, 2020 at 12:18:52PM +0200, Jean-Philippe Brucker wrote:
>
> > +/* Allocate or get existing MMU notifier for this {domain, mm} pair */
> > +static struct arm_smmu_mmu_notifier *
> > +arm_smmu_mmu_notifier_get(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) {
> > + if (smmu_mn->mn.mm == mm) {
> > + refcount_inc(&smmu_mn->refs);
> > + return smmu_mn;
> > + }
> > + }
> > +
> > + cd = arm_smmu_alloc_shared_cd(mm);
> > + if (IS_ERR(cd))
> > + return ERR_CAST(cd);
> > +
> > + smmu_mn = kzalloc(sizeof(*smmu_mn), GFP_KERNEL);
> > + if (!smmu_mn) {
> > + ret = -ENOMEM;
> > + goto err_free_cd;
> > + }
> > +
> > + refcount_set(&smmu_mn->refs, 1);
> > + smmu_mn->cd = cd;
> > + smmu_mn->domain = smmu_domain;
> > + smmu_mn->mn.ops = &arm_smmu_mmu_notifier_ops;
> > +
> > + ret = mmu_notifier_register(&smmu_mn->mn, mm);
> > + if (ret) {
> > + kfree(smmu_mn);
> > + goto err_free_cd;
> > + }
>
> I suppose this hasn't been applied yet, but someone asked me to look
> at this series..
It's queued for v5.11, but I could submit improvements for 5.12
> Why did you drop the change to mmu_notifier_get here?
Dropped at v6 when I got rid of the io_mm cruft:
https://lore.kernel.org/linux-iommu/20200430143424.2787566-1-jean-philippe@linaro.org/
> I'm strongly
> trying to discourage static lists matching mm's like smmu_mn is
> doing. This is handled by the core code, don't open code it..
We discussed this at v6, which wonkily stored the mn ops in the domain to
obtain a unique notifier per {mm, domain}. A clean solution requires
changing mm_notifier_get() to use an opaque token. Rather than testing
{mm, ops} uniqueness it would compare {mm, ops, token}. I figured it
wasn't worth the effort for a single driver, especially since the SMMU
driver would still have one list matching because it needs to deal with
both {mm, domain} and {mm, device} uniqueness.
https://lore.kernel.org/linux-iommu/20200501121552.GA6012@infradead.org/
Thanks,
Jean
next prev parent reply other threads:[~2020-11-25 9:28 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-18 10:18 [PATCH v10 00/13] iommu: Shared Virtual Addressing for SMMUv3 (PT sharing part) Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 01/13] mm: Define pasid in mm Jean-Philippe Brucker
2020-09-28 22:22 ` Will Deacon
2020-09-28 22:43 ` Fenghua Yu
2020-09-30 9:13 ` Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 02/13] iommu/ioasid: Add ioasid references Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 03/13] iommu/sva: Add PASID helpers Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 04/13] arm64: mm: Pin down ASIDs for sharing mm with devices Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 05/13] iommu/io-pgtable-arm: Move some definitions to a header Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 06/13] arm64: cpufeature: Export symbol read_sanitised_ftr_reg() Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 07/13] iommu/arm-smmu-v3: Move definitions to a header Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 08/13] iommu/arm-smmu-v3: Share process page tables Jean-Philippe Brucker
2020-09-18 10:18 ` [PATCH v10 09/13] iommu/arm-smmu-v3: Seize private ASID Jean-Philippe Brucker
2020-09-18 13:07 ` Jonathan Cameron
2020-09-18 10:18 ` [PATCH v10 10/13] iommu/arm-smmu-v3: Check for SVA features Jean-Philippe Brucker
2020-09-21 8:59 ` Shameerali Kolothum Thodi
2020-09-24 10:13 ` Jean-Philippe Brucker
2020-09-24 11:13 ` Shameerali Kolothum Thodi
2020-12-09 19:49 ` Krishna Reddy
2020-12-09 20:07 ` Will Deacon
2020-12-09 20:38 ` Krishna Reddy
2020-12-14 9:32 ` Jean-Philippe Brucker
2020-12-14 23:23 ` Krishna Reddy
2020-09-18 10:18 ` [PATCH v10 11/13] iommu/arm-smmu-v3: Add SVA device feature Jean-Philippe Brucker
2020-12-15 1:09 ` Krishna Reddy
2021-01-06 10:09 ` Jean-Philippe Brucker
2021-01-06 17:23 ` Krishna Reddy
2020-09-18 10:18 ` [PATCH v10 12/13] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind() Jean-Philippe Brucker
2020-11-24 23:58 ` Jason Gunthorpe
2020-11-25 9:27 ` Jean-Philippe Brucker [this message]
2020-11-26 0:37 ` Jason Gunthorpe
2020-09-18 10:18 ` [PATCH v10 13/13] iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops Jean-Philippe Brucker
2020-09-18 13:15 ` [PATCH v10 00/13] iommu: Shared Virtual Addressing for SMMUv3 (PT sharing part) Jonathan Cameron
2020-09-28 16:47 ` Jean-Philippe Brucker
2020-09-28 17:23 ` Will Deacon
2020-09-28 22:39 ` Will Deacon
2020-09-30 9:12 ` Jean-Philippe Brucker
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=20201125092749.GA2445658@myrica \
--to=jean-philippe@linaro.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=baolu.lu@linux.intel.com \
--cc=catalin.marinas@arm.com \
--cc=eric.auger@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=xuzaibo@huawei.com \
--cc=zhangfei.gao@linaro.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;
as well as URLs for NNTP newsgroup(s).