From: Jason Gunthorpe <jgg@nvidia.com>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>,
Alex Williamson <alex.williamson@redhat.com>,
Robin Murphy <robin.murphy@arm.com>,
Christoph Hellwig <hch@infradead.org>,
Kevin Tian <kevin.tian@intel.com>,
Ashok Raj <ashok.raj@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Will Deacon <will@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
rafael@kernel.org, Diana Craciun <diana.craciun@oss.nxp.com>,
Cornelia Huck <cohuck@redhat.com>,
Eric Auger <eric.auger@redhat.com>, Liu Yi L <yi.l.liu@intel.com>,
Jacob jun Pan <jacob.jun.pan@intel.com>,
Chaitanya Kulkarni <kch@nvidia.com>,
Stuart Yoder <stuyoder@gmail.com>,
Laurentiu Tudor <laurentiu.tudor@nxp.com>,
Thierry Reding <thierry.reding@gmail.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Jonathan Hunter <jonathanh@nvidia.com>,
Li Yang <leoyang.li@nxp.com>, Dmitry Osipenko <digetx@gmail.com>,
iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 6/8] gpu/host1x: Use iommu_attach/detach_device()
Date: Thu, 6 Jan 2022 20:48:25 -0400 [thread overview]
Message-ID: <20220107004825.GP2328285@nvidia.com> (raw)
In-Reply-To: <2befad17-05fe-3768-6fbb-67440a5befa3@linux.intel.com>
On Fri, Jan 07, 2022 at 08:35:34AM +0800, Lu Baolu wrote:
> On 1/6/22 11:35 PM, Jason Gunthorpe wrote:
> > On Thu, Jan 06, 2022 at 10:20:51AM +0800, Lu Baolu wrote:
> > > Ordinary drivers should use iommu_attach/detach_device() for domain
> > > attaching and detaching.
> > >
> > > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> > > drivers/gpu/host1x/dev.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/gpu/host1x/dev.c b/drivers/gpu/host1x/dev.c
> > > index fbb6447b8659..6e08cb6202cc 100644
> > > +++ b/drivers/gpu/host1x/dev.c
> > > @@ -265,7 +265,7 @@ static struct iommu_domain *host1x_iommu_attach(struct host1x *host)
> > > goto put_cache;
> > > }
> > > - err = iommu_attach_group(host->domain, host->group);
> > > + err = iommu_attach_device(host->domain, host->dev);
> > > if (err) {
> > > if (err == -ENODEV)
> > > err = 0;
> > > @@ -335,7 +335,7 @@ static void host1x_iommu_exit(struct host1x *host)
> > > {
> > > if (host->domain) {
> > > put_iova_domain(&host->iova);
> > > - iommu_detach_group(host->domain, host->group);
> > > + iommu_detach_device(host->domain, host->dev);
> > > iommu_domain_free(host->domain);
> > > host->domain = NULL;
> >
> > Shouldn't this add the flag to tegra_host1x_driver ?
>
> This is called for a single driver. The call trace looks like below:
>
> static struct platform_driver tegra_host1x_driver = {
> .driver = {
> .name = "tegra-host1x",
> .of_match_table = host1x_of_match,
> },
> .probe = host1x_probe,
> .remove = host1x_remove,
> };
>
> host1x_probe(dev)
> ->host1x_iommu_init(host) //host is a wrapper of dev
> iommu_domain_alloc(&platform_bus_type)
> iommu_attach_group(domain, group);
The main question is if the iommu group is being shared with other
drivers, not the call chain for this function.
For tegra you have to go look in each entry of the of_match_table:
{ .compatible = "nvidia,tegra114-host1x", .data = &host1x02_info, },
And find the DTS block:
host1x@50000000 {
compatible = "nvidia,tegra114-host1x";
reg = <0x50000000 0x00028000>;
interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, /* syncpt */
<GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; /* general */
interrupt-names = "syncpt", "host1x";
clocks = <&tegra_car TEGRA114_CLK_HOST1X>;
clock-names = "host1x";
resets = <&tegra_car 28>;
reset-names = "host1x";
iommus = <&mc TEGRA_SWGROUP_HC>;
Then check if any other devices in the DTS use the same 'iommus' which
is how the groups are setup.
I checked everything and it does look like this is a single device
group.
Jason
next prev parent reply other threads:[~2022-01-07 0:48 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-06 2:20 [PATCH v1 0/8] Scrap iommu_attach/detach_group() interfaces Lu Baolu
2022-01-06 2:20 ` [PATCH v1 1/8] iommu: Add iommu_group_replace_domain() Lu Baolu
2022-01-06 17:06 ` Jason Gunthorpe
2022-01-07 0:26 ` Lu Baolu
2022-02-14 12:09 ` Robin Murphy
2022-02-14 12:45 ` Jason Gunthorpe
2022-02-14 14:10 ` Robin Murphy
2022-02-14 14:56 ` Jason Gunthorpe
2022-02-14 16:38 ` Robin Murphy
2022-02-14 17:25 ` Jason Gunthorpe
2022-01-06 2:20 ` [PATCH v1 2/8] vfio/type1: Use iommu_group_replace_domain() Lu Baolu
2022-01-06 2:20 ` [PATCH v1 3/8] iommu: Extend iommu_at[de]tach_device() for multi-device groups Lu Baolu
2022-01-06 17:22 ` Jason Gunthorpe
2022-01-07 1:14 ` Lu Baolu
2022-01-07 1:19 ` Jason Gunthorpe
2022-02-14 11:39 ` Joerg Roedel
2022-02-14 13:03 ` Jason Gunthorpe
2022-02-14 14:39 ` Joerg Roedel
2022-02-14 15:18 ` Robin Murphy
2022-02-14 15:46 ` Jason Gunthorpe
2022-02-15 8:58 ` Joerg Roedel
2022-02-15 13:47 ` Jason Gunthorpe
2022-02-16 6:28 ` Lu Baolu
2022-02-16 13:54 ` Jason Gunthorpe
2022-01-06 2:20 ` [PATCH v1 4/8] drm/tegra: Use iommu_attach/detatch_device() Lu Baolu
2022-01-06 2:20 ` [PATCH v1 5/8] iommu/amd: Use iommu_attach/detach_device() Lu Baolu
2022-01-06 14:33 ` Jason Gunthorpe
2022-01-07 0:23 ` Lu Baolu
2022-02-14 11:27 ` Joerg Roedel
2022-02-14 13:15 ` Jason Gunthorpe
2022-02-14 13:40 ` Joerg Roedel
2022-02-14 14:02 ` Jason Gunthorpe
2022-02-14 14:23 ` Joerg Roedel
2022-02-14 15:00 ` Jason Gunthorpe
2022-02-15 9:11 ` Joerg Roedel
2022-02-15 13:02 ` Robin Murphy
2022-02-15 14:37 ` Jason Gunthorpe
2022-01-06 2:20 ` [PATCH v1 6/8] gpu/host1x: " Lu Baolu
2022-01-06 15:35 ` Jason Gunthorpe
2022-01-07 0:35 ` Lu Baolu
2022-01-07 0:48 ` Jason Gunthorpe [this message]
2022-01-07 1:19 ` Lu Baolu
2022-01-06 2:20 ` [PATCH v1 7/8] media: staging: media: tegra-vde: " Lu Baolu
2022-01-06 2:20 ` [PATCH v1 8/8] iommu: Remove iommu_attach/detach_group() Lu Baolu
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=20220107004825.GP2328285@nvidia.com \
--to=jgg@nvidia.com \
--cc=airlied@linux.ie \
--cc=alex.williamson@redhat.com \
--cc=ashok.raj@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=cohuck@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=diana.craciun@oss.nxp.com \
--cc=digetx@gmail.com \
--cc=eric.auger@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=kch@nvidia.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=laurentiu.tudor@nxp.com \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robin.murphy@arm.com \
--cc=stuyoder@gmail.com \
--cc=thierry.reding@gmail.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.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;
as well as URLs for NNTP newsgroup(s).