linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: "Takashi Iwai" <tiwai@suse.de>,
	"Lu Baolu" <baolu.lu@linux.intel.com>,
	"Joerg Roedel" <jroedel@suse.de>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	regressions@lists.linux.dev, linux-kernel@vger.kernel.org,
	"Suravee Suthikulpanit" <suravee.suthikulpanit@amd.com>,
	"Felix Kuehling" <Felix.Kuehling@amd.com>,
	amd-gfx@lists.freedesktop.org,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	Pan@nvidia.com, Xinhui <Xinhui.Pan@amd.com>
Subject: Re: [REGRESSION 5.19.x] AMD HD-audio devices missing on 5.19
Date: Tue, 23 Aug 2022 21:02:59 -0300	[thread overview]
Message-ID: <20220824000259.GA4090@nvidia.com> (raw)
In-Reply-To: <478c4aba-897f-7e08-1df7-4e296538db9c@arm.com>

On Tue, Aug 23, 2022 at 10:01:57PM +0100, Robin Murphy wrote:

> > diff --git a/drivers/iommu/amd/iommu_v2.c b/drivers/iommu/amd/iommu_v2.c
> > index 696d5555be5794..6a1f02c62dffcc 100644
> > --- a/drivers/iommu/amd/iommu_v2.c
> > +++ b/drivers/iommu/amd/iommu_v2.c
> > @@ -777,6 +777,8 @@ int amd_iommu_init_device(struct pci_dev *pdev, int pasids)
> >   	if (dev_state->domain == NULL)
> >   		goto out_free_states;
> > +	/* See iommu_is_default_domain() */
> > +	dev_state->domain->type = IOMMU_DOMAIN_IDENTITY;
> >   	amd_iommu_domain_direct_map(dev_state->domain);
> 
> Same question as 6 months ago, apparently: allocating an unmanaged domain
> with a pagetable then sucking out the pagetable is silly enough, but if
> we're going to then also call it a proper identity domain, we should really
> just allocate an identity domain directly; but then why not just enable_v2
> on the identity domain that we know is already there courtesy of
> def_domain_type?

Yeah, nobody who knows this code answered that question either..

Looking at it a bit, I think this comment will start to be a problem:

	/*
	 * Save us all sanity checks whether devices already in the
	 * domain support IOMMUv2. Just force that the domain has no
	 * devices attached when it is switched into IOMMUv2 mode.
	 */
	ret = -EBUSY;
	if (domain->dev_cnt > 0 || domain->flags & PD_IOMMUV2_MASK)
		goto out;

Beacuse we should have dev_cnt != 0 on the existing identity domain at
this point - worse if the probe order is backwards the sound driver
may even already be running when we reach this.

Plus the challenge of undoing it when the PASID user goes away.

Overall I can see how it is easier and more logical to transition
between two domains. We already have good infrastructure for doing
that.

From a core perspective I don't have a real problem with iommu drivers
using multiple iommu_domains to manage their internal operations, eg
for different operating modes. But you are right that it should be
cleaner and directly allocate the special domains it needs. This would
be much more self-descriptive if it called a function 'allocate v2
identity domain', for instance.

I think it would also make sense for the core to provide some API to
change the default domain (ie dma API domain) of a group, and that
would be a more logical, and self explanatory, API for iommu drivers
to use than attach/detach. ie:

   iommu_change_default_domain(group, amd_identity_domain_v2):
   iommu_change_default_domain(group, amd_identity_domain_v1):

At least for this effort I wanted something simple enough to backport
that maybe doesn't need to be an expert in the amd iommu to write..
[I checked some more and the hack to change the type looks like it is
OK on the free path, so maybe this even works]

My general hope is that we can convince AMD to work on this once the
generic PASID & PRI series lands, as this entire private path to the
GPU driver and non-standard PASID handling all needs to be aligned
with the upcoming core code. When doing that work it would make sense
to tidy and modernize this better. I added a bunch of AMD people to
this thread to that end. It sure would be good if AMD participated in
that series since they are going to have to use it too.

https://lore.kernel.org/linux-iommu/20220817012024.3251276-1-baolu.lu@linux.intel.com/

Regards,
Jason

  reply	other threads:[~2022-08-24  0:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22 14:12 [REGRESSION 5.19.x] AMD HD-audio devices missing on 5.19 Takashi Iwai
2022-08-23  1:00 ` Jason Gunthorpe
2022-08-23  6:06   ` Takashi Iwai
2022-08-23 11:46     ` Takashi Iwai
2022-08-23 20:28       ` Jason Gunthorpe
2022-08-23 21:01         ` Robin Murphy
2022-08-24  0:02           ` Jason Gunthorpe [this message]
2022-09-06 15:41         ` Jason Gunthorpe
2022-09-06 15:52           ` Takashi Iwai
2022-09-06 15:53             ` Jason Gunthorpe
2022-09-06 16:04               ` Takashi Iwai
2022-09-06 16:08                 ` Jason Gunthorpe
2022-09-06 16:16                   ` Takashi Iwai
2022-09-07 10:08                     ` Takashi Iwai
2022-09-07 13:28         ` Takashi Iwai
2022-09-07 13:48           ` Jason Gunthorpe
2022-09-08  6:23             ` Takashi Iwai
2022-08-24  7:13 ` Thorsten Leemhuis
2022-09-19 15:23   ` [REGRESSION 5.19.x] AMD HD-audio devices missing on 5.19 #forregzbot Thorsten Leemhuis

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=20220824000259.GA4090@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=Pan@nvidia.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=christian.koenig@amd.com \
    --cc=eric.auger@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tiwai@suse.de \
    /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).