From: Jason Gunthorpe <jgg@ziepe.ca>
To: Vasant Hegde <vasant.hegde@amd.com>
Cc: iommu@lists.linux.dev, joro@8bytes.org,
suravee.suthikulpanit@amd.com, wei.huang2@amd.com,
jsnitsel@redhat.com
Subject: Re: [PATCH 09/11] iommu/amd: Introduce helper functions for AMD IOMMU v2 driver
Date: Tue, 8 Aug 2023 12:49:10 -0300 [thread overview]
Message-ID: <ZNJj9ljbIM842lEh@ziepe.ca> (raw)
In-Reply-To: <20230808100232.5977-10-vasant.hegde@amd.com>
On Tue, Aug 08, 2023 at 10:02:30AM +0000, Vasant Hegde wrote:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>
> Introducing new functions to init and uninit v2 domain. Also setup /
> clear GCR3 table. These functions will make necessary changes to
> existing domain to switch to SVA mode.
Huh? "necessary changes to existing domains" ? That shouldn't be
something a driver ever does.
> +/*******************************
> + * V2API-related helper functions
> + * Note: Separate these out for now. It will be removed when
> + * deprecate the AMD IOMMU v2 API support.
> + */
> +int amd_iommu_v2api_domain_init(struct protection_domain *pdom)
> +{
> + unsigned long flags;
> + int ret = 0;
> +
> + spin_lock_irqsave(&pdom->lock, flags);
> +
> + /* Only allow v2API support on pass-through domain. */
> + if (pdom->pd_mode != PD_MODE_PT) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + pdom->pd_mode = PD_MODE_V2;
Wah?? You change a PT domain to a V2 domain? That seems totally
nonsensical.
This is continuing the wrong direction of the old code.
When you first create the GCR3 table you have to inspect which domain
is attached to the RID and setup the DTE/GCR3 accordingly.
You don't *change* the domain that is attached to the RID (other
things might be using it!) You just note that it is IDENTITY and do
the right things.
This should all be part of generic code that is working with the GCR3
object, not here in the v2api section.
Keep in mind that the API flow is to get a 'ref' on the GCR3 (eg
because the caller wants to put a domain in it) and a pairing 'unref'.
eg if it was already a v2 PT when you want to attach a PASID then
great, the device already has a gcr3 and so it just keeps
going. Having a PASID will block the GCR3 from being freed and it will
block V1 domains from being attached to the RID.
When the GCR3 becomes fully unrefed then all the PASIDs must be
removed, the RID must be an IDENTIY and then the driver can free the
GCR3 and reconfigure the DTE back to IDENTITY. Otherwise the DTE
points to the kernel owned GCR3.
Jason
next prev parent reply other threads:[~2023-08-08 15:49 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 10:02 [PATCH 00/11] iommu/amd: SVA support (part 2) - refactor support for GCR3 table Vasant Hegde
2023-08-08 10:02 ` [PATCH 01/11] iommu/amd: Rename helper function rlookup_amd_iommu() Vasant Hegde
2023-08-08 15:28 ` Jason Gunthorpe
2023-08-10 23:06 ` Suthikulpanit, Suravee
2023-08-11 13:06 ` Jason Gunthorpe
2023-08-08 10:02 ` [PATCH 02/11] iommu/amd: Introduce struct protection_domain.pd_mode Vasant Hegde
2023-08-08 15:30 ` Jason Gunthorpe
2023-08-11 10:04 ` Vasant Hegde
2023-08-11 13:21 ` Jason Gunthorpe
2023-08-08 10:02 ` [PATCH 03/11] iommu/amd: Introduce per-device GCR3 table Vasant Hegde
2023-08-08 15:32 ` Jason Gunthorpe
2023-08-10 23:31 ` Suthikulpanit, Suravee
2023-08-08 10:02 ` [PATCH 04/11] iommu/amd: Use protection_domain.flags to check page table mode Vasant Hegde
2023-08-08 15:35 ` Jason Gunthorpe
2023-08-11 10:10 ` Vasant Hegde
2023-08-08 10:02 ` [PATCH 05/11] iommu/amd: Refactor helper function for setting / clearing GCR3 Vasant Hegde
2023-08-08 10:02 ` [PATCH 06/11] iommu/amd: Refactor helper function for attaching / detaching device Vasant Hegde
2023-08-08 15:39 ` Jason Gunthorpe
2023-08-11 10:07 ` Vasant Hegde
2023-08-11 13:20 ` Jason Gunthorpe
2023-08-11 16:50 ` Vasant Hegde
2023-08-11 23:50 ` Jason Gunthorpe
2023-08-15 4:19 ` Tian, Kevin
2023-08-15 5:33 ` Suthikulpanit, Suravee
2023-08-15 11:42 ` Jason Gunthorpe
2023-08-08 10:02 ` [PATCH 07/11] iommu/amd: Refactor protection_domain helper functions Vasant Hegde
2023-08-08 10:02 ` [PATCH 08/11] iommu/amd: Refactor GCR3 table " Vasant Hegde
2023-08-08 10:02 ` [PATCH 09/11] iommu/amd: Introduce helper functions for AMD IOMMU v2 driver Vasant Hegde
2023-08-08 15:49 ` Jason Gunthorpe [this message]
2023-08-11 1:34 ` Suthikulpanit, Suravee
2023-08-11 13:17 ` Jason Gunthorpe
2023-08-11 16:51 ` Suthikulpanit, Suravee
2023-08-08 10:02 ` [PATCH 10/11] iommu/amd/iommu_v2: Add support to switch default domain to SVA mode Vasant Hegde
2023-08-08 15:51 ` Jason Gunthorpe
2023-08-08 10:02 ` [PATCH 11/11] iommu/amd: Remove unused GCR3 table parameters from struct protection_domain Vasant Hegde
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=ZNJj9ljbIM842lEh@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=jsnitsel@redhat.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=wei.huang2@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.