public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: <jgg@nvidia.com>, <kevin.tian@intel.com>, <joro@8bytes.org>,
	<will@kernel.org>, <iommu@lists.linux.dev>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/4] iommu: Add private_data_owner to iommu_domain
Date: Fri, 28 Feb 2025 09:40:06 -0800	[thread overview]
Message-ID: <Z8H09l8PzqfGjC8s@Asurada-Nvidia> (raw)
In-Reply-To: <2754908e-f345-43ca-9cb1-9300abe5d402@arm.com>

On Fri, Feb 28, 2025 at 04:29:17PM +0000, Robin Murphy wrote:
> On 28/02/2025 1:31 am, Nicolin Chen wrote:
> > @@ -435,6 +436,7 @@ int iommu_get_msi_cookie(struct iommu_domain *domain, dma_addr_t base)
> >   	cookie->msi_iova = base;
> >   	domain->iova_cookie = cookie;
> >   	iommu_domain_set_sw_msi(domain, iommu_dma_sw_msi);
> > +	domain->private_data_owner = IOMMU_DOMAIN_DATA_OWNER_DMA;
> 
> This doesn't help all that much when it can still be called on any old
> unmanaged domain and silently overwrite whatever the previous user thought
> they owned...

We could add another validation on top of this function to reject
private_data_owner != IOMMU_DOMAIN_DATA_OWNER_NONE?

> And really the "owner" of MSI cookies is VFIO, it just happens that all the
> code for them still lives in iommu-dma because it was written to piggyback
> off the same irqchip hooks. TBH I've long been keen on separating them
> further from "real" IOVA cookies, and generalising said hooks really removes
> any remaining reason to keep the implementations tied together at all,
> should they have cause to diverge further (e.g. with makign the MSI cookie
> window programmable). What I absolutely want to avoid is a notion of having
> two types of MSI-mapping cookies, one of which is two types of MSI-mapping
> cookies.
> 
> Hopefully that is all clear in the patch I proposed.

Yea, decoupling the MSI cookie from the iova_cookie makes sense
to me. I had the same feeling last week when I was preparing the
cleanup patch that added a iommu_put_msi_cookie(), but hesitated
after foreseeing a big rework that I was not sure you would like
or not. Glad that you did it..

With your patch now we even merged the two unions, which is nicer
from my point of view.

Thanks
Nicolin

  reply	other threads:[~2025-02-28 17:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28  1:31 [PATCH v2 0/4] iommu: Isolate iova_cookie to actual owners Nicolin Chen
2025-02-28  1:31 ` [PATCH v2 1/4] iommu: Add private_data_owner to iommu_domain Nicolin Chen
2025-02-28  3:13   ` Baolu Lu
2025-02-28  3:23     ` Nicolin Chen
2025-02-28  3:29       ` Baolu Lu
2025-02-28 16:29   ` Robin Murphy
2025-02-28 17:40     ` Nicolin Chen [this message]
2025-02-28  1:31 ` [PATCH v2 2/4] iommufd: Move iommufd_sw_msi and related functions to driver.c Nicolin Chen
2025-02-28 17:32   ` Jason Gunthorpe
2025-02-28 17:54     ` Nicolin Chen
2025-02-28 18:02       ` Jason Gunthorpe
2025-02-28 18:10         ` Nicolin Chen
2025-02-28  1:31 ` [PATCH v2 3/4] iommu: Drop sw_msi from iommu_domain Nicolin Chen
2025-02-28  1:31 ` [PATCH v2 4/4] iommu: Turn iova_cookie to dma-iommu private pointer Nicolin Chen

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=Z8H09l8PzqfGjC8s@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.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