From: Zong Li <zong.li@sifive.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Tomasz Jeznach <tjeznach@rivosinc.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Anup Patel <apatel@ventanamicro.com>,
Sunil V L <sunilvl@ventanamicro.com>,
Nick Kossifidis <mick@ics.forth.gr>,
Sebastien Boeuf <seb@rivosinc.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
devicetree@vger.kernel.org, iommu@lists.linux.dev,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux@rivosinc.com, Lu Baolu <baolu.lu@linux.intel.com>
Subject: Re: [PATCH v8 7/7] iommu/riscv: Paging domain support
Date: Wed, 24 Jul 2024 10:43:53 +0800 [thread overview]
Message-ID: <CANXhq0ptWEk7xQmepRVih8JQvKuZWvxBtwzyUtPhoy6HqP0vGA@mail.gmail.com> (raw)
In-Reply-To: <20240723130839.GL14050@ziepe.ca>
On Tue, Jul 23, 2024 at 9:08 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Fri, Jul 19, 2024 at 02:33:13PM +0800, Zong Li wrote:
>
> > > +static void riscv_iommu_free_paging_domain(struct iommu_domain *iommu_domain)
> > > +{
> > > + struct riscv_iommu_domain *domain = iommu_domain_to_riscv(iommu_domain);
> > > + const unsigned long pfn = virt_to_pfn(domain->pgd_root);
> > > +
> > > + WARN_ON(!list_empty(&domain->bonds));
> >
> > Hi Tomasz,
> > I recently hit the issue here when I removed a device. I think we need
> > to unlink the device's bond in domain before releasing domain.
> > Do you mind pick the following modification in this patch? Thanks.
> >
> > diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
> > index 859cdd455576..f0707147e706 100644
> > --- a/drivers/iommu/riscv/iommu.c
> > +++ b/drivers/iommu/riscv/iommu.c
> > @@ -1541,6 +1541,8 @@ static void riscv_iommu_release_device(struct device *dev)
> > {
> > struct riscv_iommu_info *info = dev_iommu_priv_get(dev);
> >
> > + riscv_iommu_bond_unlink(info->domain, dev);
> > +
> > synchronize_rcu();
> > kfree(info);
> > }
>
> That does not seem the right place to put that, or something else has
> gone wrong becuase:
>
> > > static const struct iommu_ops riscv_iommu_ops = {
> > > + .pgsize_bitmap = SZ_4K,
> > > .of_xlate = riscv_iommu_of_xlate,
> > > .identity_domain = &riscv_iommu_identity_domain,
> > > .blocked_domain = &riscv_iommu_blocking_domain,
> > > .release_domain = &riscv_iommu_blocking_domain,
>
> The above use of release_domain will attach to the blocking domain
> prior to calling release_device and when doing so everything about any
> previous domain should have been fully cleaned up.
>
> So info->domain should be the blocking domain during release_device
> (if not that is another bug)
>
> And attaching the blocking domain should have cleared the
> domain->bonds of any prior paging domain.
Yes, you are right, there is no issue. I mixed up my codebase, which
doesn't support release_domain yet. Please ignore this, and thanks for
pointing it out.
>
> Jason
next prev parent reply other threads:[~2024-07-24 2:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-15 5:27 [PATCH v8 0/7] Linux RISC-V IOMMU Support Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 1/7] dt-bindings: iommu: riscv: Add bindings for RISC-V IOMMU Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 2/7] iommu/riscv: Add RISC-V IOMMU platform device driver Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 3/7] iommu/riscv: Add RISC-V IOMMU PCIe " Tomasz Jeznach
2024-08-30 7:04 ` Jim Shu
2024-08-30 12:01 ` Daniel Henrique Barboza
2024-08-30 15:37 ` Tomasz Jeznach
2024-08-30 15:49 ` Robin Murphy
2024-08-30 15:53 ` Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 4/7] iommu/riscv: Enable IOMMU registration and device probe Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 5/7] iommu/riscv: Device directory management Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 6/7] iommu/riscv: Command and fault queue support Tomasz Jeznach
2024-06-15 5:27 ` [PATCH v8 7/7] iommu/riscv: Paging domain support Tomasz Jeznach
2024-07-19 6:33 ` Zong Li
2024-07-23 13:08 ` Jason Gunthorpe
2024-07-24 2:43 ` Zong Li [this message]
2024-08-06 19:24 ` Easwar Hariharan
2024-08-08 13:14 ` Jason Gunthorpe
2024-08-08 16:40 ` Easwar Hariharan
2024-08-12 13:12 ` Robin Murphy
2024-07-24 14:28 ` [PATCH v8 0/7] Linux RISC-V IOMMU Support Palmer Dabbelt
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=CANXhq0ptWEk7xQmepRVih8JQvKuZWvxBtwzyUtPhoy6HqP0vGA@mail.gmail.com \
--to=zong.li@sifive.com \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=baolu.lu@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@rivosinc.com \
--cc=mick@ics.forth.gr \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=seb@rivosinc.com \
--cc=sunilvl@ventanamicro.com \
--cc=tjeznach@rivosinc.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;
as well as URLs for NNTP newsgroup(s).