From: Jason Gunthorpe <jgg@nvidia.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Alexey Kardashevskiy <aik@amd.com>,
Bjorn Helgaas <helgaas@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Jonathan Cameron <jic23@kernel.org>,
Nicolin Chen <nicolinc@nvidia.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Steven Price <steven.price@arm.com>,
Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Will Deacon <will@kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH v6 08/11] iommufd: Add vIOMMU provider support
Date: Tue, 29 Sep 2026 16:10:38 -0300 [thread overview]
Message-ID: <20260929191038.GO1616761@nvidia.com> (raw)
In-Reply-To: <yq5ald8koxqa.fsf@kernel.org>
On Tue, Sep 29, 2026 at 09:28:53PM +0530, Aneesh Kumar K.V wrote:
> Switching pdev->tsm to an RCU-protected pointer requires broader changes
> to the existing TSM code. To move this series forward, I will continue
> protecting it with pci_tsm_rwsem in the next revision, as that requires
> fewer changes. We can revisit an RCU conversion later if needed?
Sure, as long as we get the general big picture properties of no hot
unplug and a very simple lifecycle model
> With this approach, viommu_alloc() will do:
> struct tsm_dev *tsm_dev = NULL;
>
>
> tsm_dev = tsm_get_device(idev->dev);
> ops = tsm_dev ? tsm_viommu_get_ops(tsm_dev, idev->dev, cmd->type) : NULL;
> if (!ops) {
> tsm_dev = NULL;
> ops = iommu_dev->ops->get_viommu_ops(idev->dev, cmd->type);
> }
>
> viommu = (struct iommufd_viommu *)_iommufd_object_alloc_ucmd(
> viommu->tsm_dev = tsm_dev;
> tsm_dev = NULL;
>
> rc = ops->viommu_init(viommu, idev->dev,....)
>
> ....
> if (tsm_dev)
> tsm_put_device(tsm_dev);
This probably shouldn't be here? The way iommufd usually works is
these undos are alway here:
> void iommufd_viommu_destroy(struct iommufd_object *obj)
> {
> ..
> if (viommu->tsm_dev)
> tsm_put_device(viommu->tsm_dev);
> ...
> }
> struct tsm_dev *pci_tsm_get_device(struct pci_dev *pdev)
> {
> const struct pci_tsm_ops *ops;
> struct tsm_dev *tsm_dev;
>
> guard(rwsem_read)(&pci_tsm_rwsem);
> if (!pdev->tsm)
> return NULL;
>
> tsm_dev = pdev->tsm->tsm_dev;
>
> ops = tsm_dev->pci_ops;
> if (!try_module_get(ops->owner)) // arm-cca-host
> return ERR_PTR(-ENODEV);
> if (!tsm_try_get(tsm_dev)) {
What/why is this tsm_try_get()? I wouldn't expect to see both
try_module_get() and tsm_try_get()?
> Are you suggesting setting suppress_bind_attrs = true for the
> arm-cca-host driver?
That or it blocks waiting on unbind.
No hot unplug of TSMs under active use. This is very hard to implement
correctly, and there is no use case.
> The driver model otherwise allows the driver to be unbound.
Isn't this is a side effect of introducing smcc bus? We didn't used to
have actual drivers for this stuff that isn't physically hot
pluggable.
> We need to support tsm_unregister() in that
> case. I am also not sure whether there are other paths that can call
> tsm_unregister(). Currently, we register the cleanup callback via
>
> tsm_dev = tsm_register(&sdev->dev, &cca_link_pci_ops);
>
> ret = devm_add_action_or_reset(&sdev->dev, cca_link_tsm_remove, tsm_dev);
> if (ret)
Yeah, since you have a driver it has to be structured like that, but
that doesn't mean we have to be forced into implementing full general
hot unplug across all of tsm.
Either block sysfs and use the module refcount, or hang in removal
until all the users naturally close (like vfio). Everything else is
too complicated to be justified..
Jason
next prev parent reply other threads:[~2026-09-29 19:10 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 14:01 [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 01/11] vfio: cache KVM VM file references instead of raw struct kvm pointers Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-30 7:19 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 02/11] vfio: cdev: Reject duplicate bind before updating KVM file Aneesh Kumar K.V (Arm)
2026-09-24 7:53 ` Tian, Kevin
2026-09-25 5:49 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 03/11] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 04/11] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-09-30 13:28 ` Vasant Hegde
2026-09-17 14:01 ` [RFC PATCH v6 05/11] iommu: Add a helper to validate a vIOMMU parent Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:48 ` Aneesh Kumar K.V
2026-09-25 12:23 ` Jason Gunthorpe
2026-09-28 10:36 ` Aneesh Kumar K.V
2026-09-28 12:11 ` Jason Gunthorpe
2026-09-28 15:39 ` Aneesh Kumar K.V
2026-09-28 16:17 ` Jason Gunthorpe
2026-09-28 18:08 ` Jacob Pan
2026-09-28 18:20 ` Jason Gunthorpe
2026-09-28 22:24 ` Jacob Pan
2026-09-28 23:03 ` Jason Gunthorpe
2026-09-29 5:55 ` Jacob Pan
2026-09-29 12:30 ` Jason Gunthorpe
2026-09-29 23:15 ` Jacob Pan
2026-09-29 23:30 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 06/11] iommu: Add a helper to query vIOMMU hardware parameters Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:59 ` Aneesh Kumar K.V
2026-09-25 12:29 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 07/11] coco: tsm: Expose active-user lifetime references Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 08/11] iommufd: Add vIOMMU provider support Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 6:08 ` Aneesh Kumar K.V
2026-09-25 12:39 ` Jason Gunthorpe
2026-09-28 3:41 ` Tian, Kevin
2026-09-29 6:14 ` Aneesh Kumar K.V
2026-09-29 12:17 ` Jason Gunthorpe
2026-09-29 12:45 ` Aneesh Kumar K.V
2026-09-29 13:06 ` Jason Gunthorpe
2026-09-29 15:58 ` Aneesh Kumar K.V
2026-09-29 19:10 ` Jason Gunthorpe [this message]
2026-09-28 10:51 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 09/11] iommufd: Add the vdevice TSM request ioctl Aneesh Kumar K.V (Arm)
2026-09-18 13:09 ` Alexey Kardashevskiy
2026-09-18 13:13 ` Jason Gunthorpe
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-30 8:03 ` Aneesh Kumar K.V
2026-09-30 13:26 ` Vasant Hegde
2026-09-30 14:03 ` Jason Gunthorpe
2026-09-30 14:08 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 10/11] PCI/TSM: Remove the legacy guest request interface Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 11/11] PCI/TSM: Add reference-counted contexts for vdevice providers Aneesh Kumar K.V (Arm)
2026-09-24 8:17 ` Tian, Kevin
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 8:15 ` Aneesh Kumar K.V
2026-09-28 18:47 ` Sonang Patel
2026-09-28 23:08 ` Jason Gunthorpe
2026-09-17 14:17 ` [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V
2026-09-24 7:48 ` Tian, Kevin
2026-09-24 19:20 ` Jason Gunthorpe
2026-09-28 3:35 ` Tian, Kevin
2026-09-28 13:08 ` Jason Gunthorpe
2026-09-25 8:29 ` Aneesh Kumar K.V
2026-09-28 3:41 ` Tian, Kevin
2026-09-28 3:55 ` Tian, Kevin
2026-09-24 19:09 ` Jason Gunthorpe
2026-09-25 6:46 ` Aneesh Kumar K.V
2026-09-25 12:45 ` Jason Gunthorpe
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=20260929191038.GO1616761@nvidia.com \
--to=jgg@nvidia.com \
--cc=Suzuki.Poulose@arm.com \
--cc=aik@amd.com \
--cc=aneesh.kumar@kernel.org \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jic23@kernel.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=pbonzini@redhat.com \
--cc=sameo@rivosinc.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=will@kernel.org \
--cc=yilun.xu@linux.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
all inboxes | Powered by JetHome®