From: Jonathan Cameron via <qemu-arm@nongnu.org>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
<linuxarm@huawei.com>, <qemu-arm@nongnu.org>,
<qemu-devel@nongnu.org>, <eric.auger@redhat.com>,
<peter.maydell@linaro.org>, <jgg@nvidia.com>,
<ddutile@redhat.com>, <berrange@redhat.com>, <nathanc@nvidia.com>,
<mochs@nvidia.com>, <smostafa@google.com>,
<wangzhou1@hisilicon.com>, <jiangkunkun@huawei.com>,
<zhangfei.gao@linaro.org>, <zhenzhong.duan@intel.com>,
<shameerkolothum@gmail.com>
Subject: Re: [RFC PATCH v3 08/15] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback
Date: Wed, 16 Jul 2025 10:33:46 +0100 [thread overview]
Message-ID: <20250716103346.00005ca4@huawei.com> (raw)
In-Reply-To: <aHaJYfitACLvupZV@Asurada-Nvidia>
On Tue, 15 Jul 2025 10:01:21 -0700
Nicolin Chen <nicolinc@nvidia.com> wrote:
> On Tue, Jul 15, 2025 at 11:29:41AM +0100, Jonathan Cameron wrote:
> > > + if (!iommufd_backend_alloc_viommu(idev->iommufd, idev->devid,
> > > + IOMMU_VIOMMU_TYPE_ARM_SMMUV3,
> > > + s2_hwpt_id, &viommu_id, errp)) {
> > > + return false;
> > > + }
>
> [...]
>
> > > +free_abort_hwpt:
> > > + iommufd_backend_free_id(idev->iommufd, viommu->abort_hwpt_id);
> > > +free_viommu:
> > > + iommufd_backend_free_id(idev->iommufd, viommu->core.viommu_id);
> > > + g_free(viommu);
> >
> > No unwinding of iommufd_backened_alloc_viommu?
> > Looks like we just leak it until destruction of the fd.
> >
> > Maybe add a comment for those like me who aren't all that familiar with
> > this stuff and see an alloc with no matching free.
>
> Those iommufd_backend_free_id calls are the reverts. An iommufd
> object is free-ed using its object id, i.e. the "viommu_id" and
> "abort_hwpt_id" in the lines.
Ah. I confused IDs and thought this was unwinding the two
iommufd_backend_alloc_hwpt() calls but of course the second one doesn't
need unwinding in the error path as it is the last call so if it fails
nothing to unwind.
So feel free to ignore this comment.
>
> Adding comments to every single iommufd_backened_free_id() call
> isn't optimal, IMHO, as that function would be invoked across
> different vIOMMU files and even the vfio/iommufd core files.
>
> Perhaps QEMU should wrap it up with a helper, E.g.
>
> static inline void iommufd_backend_free(int iommufd, int obj_id)
> {
> iommufd_backend_free_id(iommufd, obj_id);
> }
>
> if it helps readability?
That would then leave us with iommufd_backend_alloc_hwpt() being
unwound by a direct iommufd_backend_free_id() which is equally
odd - so let's just keep them all being odd.
Jonathan
>
> Nicolin
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
<linuxarm@huawei.com>, <qemu-arm@nongnu.org>,
<qemu-devel@nongnu.org>, <eric.auger@redhat.com>,
<peter.maydell@linaro.org>, <jgg@nvidia.com>,
<ddutile@redhat.com>, <berrange@redhat.com>, <nathanc@nvidia.com>,
<mochs@nvidia.com>, <smostafa@google.com>,
<wangzhou1@hisilicon.com>, <jiangkunkun@huawei.com>,
<zhangfei.gao@linaro.org>, <zhenzhong.duan@intel.com>,
<shameerkolothum@gmail.com>
Subject: Re: [RFC PATCH v3 08/15] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback
Date: Wed, 16 Jul 2025 10:33:46 +0100 [thread overview]
Message-ID: <20250716103346.00005ca4@huawei.com> (raw)
In-Reply-To: <aHaJYfitACLvupZV@Asurada-Nvidia>
On Tue, 15 Jul 2025 10:01:21 -0700
Nicolin Chen <nicolinc@nvidia.com> wrote:
> On Tue, Jul 15, 2025 at 11:29:41AM +0100, Jonathan Cameron wrote:
> > > + if (!iommufd_backend_alloc_viommu(idev->iommufd, idev->devid,
> > > + IOMMU_VIOMMU_TYPE_ARM_SMMUV3,
> > > + s2_hwpt_id, &viommu_id, errp)) {
> > > + return false;
> > > + }
>
> [...]
>
> > > +free_abort_hwpt:
> > > + iommufd_backend_free_id(idev->iommufd, viommu->abort_hwpt_id);
> > > +free_viommu:
> > > + iommufd_backend_free_id(idev->iommufd, viommu->core.viommu_id);
> > > + g_free(viommu);
> >
> > No unwinding of iommufd_backened_alloc_viommu?
> > Looks like we just leak it until destruction of the fd.
> >
> > Maybe add a comment for those like me who aren't all that familiar with
> > this stuff and see an alloc with no matching free.
>
> Those iommufd_backend_free_id calls are the reverts. An iommufd
> object is free-ed using its object id, i.e. the "viommu_id" and
> "abort_hwpt_id" in the lines.
Ah. I confused IDs and thought this was unwinding the two
iommufd_backend_alloc_hwpt() calls but of course the second one doesn't
need unwinding in the error path as it is the last call so if it fails
nothing to unwind.
So feel free to ignore this comment.
>
> Adding comments to every single iommufd_backened_free_id() call
> isn't optimal, IMHO, as that function would be invoked across
> different vIOMMU files and even the vfio/iommufd core files.
>
> Perhaps QEMU should wrap it up with a helper, E.g.
>
> static inline void iommufd_backend_free(int iommufd, int obj_id)
> {
> iommufd_backend_free_id(iommufd, obj_id);
> }
>
> if it helps readability?
That would then leave us with iommufd_backend_alloc_hwpt() being
unwound by a direct iommufd_backend_free_id() which is equally
odd - so let's just keep them all being odd.
Jonathan
>
> Nicolin
next prev parent reply other threads:[~2025-07-16 9:34 UTC|newest]
Thread overview: 165+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 15:59 [RFC PATCH v3 00/15] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 15:59 ` [RFC PATCH v3 01/15] backends/iommufd: Introduce iommufd_backend_alloc_viommu Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 16:22 ` Nicolin Chen
2025-07-15 9:14 ` Jonathan Cameron via
2025-07-15 9:14 ` Jonathan Cameron via
2025-07-14 15:59 ` [RFC PATCH v3 02/15] backends/iommufd: Introduce iommufd_vdev_alloc Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 16:27 ` Nicolin Chen
2025-07-15 9:19 ` Jonathan Cameron via
2025-07-15 9:19 ` Jonathan Cameron via
2025-07-14 15:59 ` [RFC PATCH v3 03/15] hw/arm/smmu-common: Factor out common helper functions and export Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-15 9:27 ` Jonathan Cameron via
2025-07-15 9:27 ` Jonathan Cameron via
2025-07-14 15:59 ` [RFC PATCH v3 04/15] hw/arm/smmu-common: Introduce smmu_iommu_ops_by_type() helper Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 16:38 ` Nicolin Chen via
2025-07-14 16:38 ` Nicolin Chen via
2025-07-15 9:30 ` Jonathan Cameron via
2025-07-15 9:30 ` Jonathan Cameron via
2025-09-04 7:55 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 05/15] hw/arm/smmuv3-accel: Introduce smmuv3 accel device Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 17:23 ` Nicolin Chen
2025-09-04 14:33 ` Eric Auger
2025-09-05 8:22 ` Shameer Kolothum
2025-09-05 10:17 ` Eric Auger
2025-09-08 9:15 ` Shameer Kolothum
2025-09-09 13:38 ` Eric Auger
2025-07-15 9:45 ` Jonathan Cameron via
2025-07-15 9:45 ` Jonathan Cameron via
2025-07-15 10:48 ` Duan, Zhenzhong
2025-07-15 17:29 ` Nicolin Chen
2025-07-16 3:38 ` Duan, Zhenzhong
2025-07-16 9:27 ` Shameerali Kolothum Thodi via
2025-07-16 9:27 ` Shameerali Kolothum Thodi via
2025-09-04 14:31 ` Eric Auger
2025-09-10 16:10 ` Shameer Kolothum
2025-07-14 15:59 ` [RFC PATCH v3 06/15] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 18:18 ` Nicolin Chen
2025-07-15 9:51 ` Jonathan Cameron via
2025-07-15 9:51 ` Jonathan Cameron via
2025-07-15 10:53 ` Duan, Zhenzhong
2025-07-15 17:59 ` Nicolin Chen
2025-07-16 6:26 ` Duan, Zhenzhong
2025-07-16 9:34 ` Shameerali Kolothum Thodi via
2025-07-16 9:34 ` Shameerali Kolothum Thodi via
2025-07-16 10:32 ` Duan, Zhenzhong
2025-07-16 17:51 ` Nicolin Chen
2025-07-16 18:21 ` Nicolin Chen
2025-09-05 8:34 ` Eric Auger
2025-09-05 8:14 ` Eric Auger
2025-09-08 7:41 ` Shameer Kolothum
2025-09-09 13:34 ` Eric Auger
2025-07-16 8:06 ` Shameerali Kolothum Thodi via
2025-07-16 8:06 ` Shameerali Kolothum Thodi via
2025-09-05 8:29 ` Eric Auger
2025-09-08 7:55 ` Shameer Kolothum
2025-08-06 0:55 ` Nicolin Chen
2025-09-16 10:33 ` Shameer Kolothum
2025-09-17 18:45 ` Nicolin Chen
2025-09-17 18:52 ` Shameer Kolothum
2025-09-17 19:04 ` Jason Gunthorpe
2025-09-18 13:31 ` Shameer Kolothum
2025-09-18 22:00 ` Nicolin Chen
2025-09-19 7:38 ` Shameer Kolothum
2025-09-19 18:36 ` Nicolin Chen
2025-09-20 13:03 ` Peter Maydell
2025-09-22 8:28 ` Shameer Kolothum
2025-09-05 8:42 ` Eric Auger
2025-09-08 8:03 ` Shameer Kolothum
2025-07-14 15:59 ` [RFC PATCH v3 07/15] hw/arm/smmuv3: Implement get_viommu_cap() callback Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 18:31 ` Nicolin Chen
2025-09-05 8:49 ` Eric Auger
2025-09-08 8:22 ` Shameer Kolothum
2025-09-08 13:40 ` Jason Gunthorpe
2025-09-09 13:37 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 08/15] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 19:11 ` Nicolin Chen
2025-07-15 10:29 ` Jonathan Cameron via
2025-07-15 10:29 ` Jonathan Cameron via
2025-07-15 17:01 ` Nicolin Chen
2025-07-16 9:33 ` Jonathan Cameron via [this message]
2025-07-16 9:33 ` Jonathan Cameron via
2025-09-05 9:27 ` Eric Auger
2025-09-08 8:49 ` Shameer Kolothum
2025-07-14 15:59 ` [RFC PATCH v3 09/15] hw/arm/smmuv3-accel: Support nested STE install/uninstall support Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 19:37 ` Nicolin Chen
2025-07-15 23:12 ` Nicolin Chen
2025-07-16 8:36 ` Shameerali Kolothum Thodi via
2025-07-16 8:36 ` Shameerali Kolothum Thodi via
2025-07-16 18:17 ` Nicolin Chen
2025-09-05 9:51 ` Eric Auger
2025-09-05 9:40 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 10/15] hw/arm/smmuv3-accel: Allocate a vDEVICE object for device Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 19:43 ` Nicolin Chen
2025-09-05 9:57 ` Eric Auger
2025-09-05 18:36 ` Nicolin Chen
2025-07-14 15:59 ` [RFC PATCH v3 11/15] hw/pci/pci: Introduce optional get_msi_address_space() callback Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 19:50 ` Nicolin Chen
2025-09-05 10:11 ` Eric Auger
2025-09-05 10:11 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 12/15] hw/arm/smmuv3-accel: Introduce helpers to batch and issue cache invalidations Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 19:55 ` Nicolin Chen
2025-07-15 10:39 ` Jonathan Cameron via
2025-07-15 10:39 ` Jonathan Cameron via
2025-07-15 17:07 ` Nicolin Chen
2025-09-05 10:31 ` Eric Auger
2025-09-08 9:59 ` Shameer Kolothum
2025-09-08 19:29 ` Nicolin Chen
2025-07-14 15:59 ` [RFC PATCH v3 13/15] hw/arm/smmuv3: Forward invalidation commands to hw Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-15 10:46 ` Jonathan Cameron via
2025-07-15 10:46 ` Jonathan Cameron via
2025-07-15 17:22 ` Nicolin Chen
2025-07-16 7:32 ` Shameerali Kolothum Thodi via
2025-07-16 7:32 ` Shameerali Kolothum Thodi via
2025-09-05 12:45 ` Eric Auger
2025-09-08 12:22 ` Shameer Kolothum
2025-09-08 20:12 ` Nicolin Chen
2025-09-09 13:43 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 14/15] Read and validate host SMMUv3 feature bits Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 20:04 ` Nicolin Chen via
2025-07-14 20:04 ` Nicolin Chen via
2025-07-14 20:24 ` Nicolin Chen via
2025-07-14 20:24 ` Nicolin Chen via
2025-07-15 10:48 ` Jonathan Cameron via
2025-07-15 10:48 ` Jonathan Cameron via
2025-07-16 2:57 ` Nicolin Chen via
2025-07-16 2:57 ` Nicolin Chen via
2025-07-16 10:26 ` Shameerali Kolothum Thodi via
2025-07-16 10:26 ` Shameerali Kolothum Thodi via
2025-07-16 18:37 ` Nicolin Chen
2025-07-16 11:51 ` Jason Gunthorpe
2025-07-16 17:35 ` Nicolin Chen
2025-07-16 17:45 ` Jason Gunthorpe
2025-07-16 18:09 ` Nicolin Chen
2025-07-16 18:42 ` Jason Gunthorpe
2025-07-16 18:53 ` Nicolin Chen
2025-09-05 13:04 ` Eric Auger
2025-07-22 17:42 ` Nicolin Chen
2025-09-05 13:20 ` Eric Auger
2025-07-14 15:59 ` [RFC PATCH v3 15/15] hw/arm/smmu-common: Add accel property for SMMU dev Shameer Kolothum via
2025-07-14 15:59 ` Shameer Kolothum via
2025-07-14 20:00 ` Nicolin Chen
2025-07-15 10:49 ` Jonathan Cameron via
2025-07-15 10:49 ` Jonathan Cameron via
2025-09-05 10:36 ` Eric Auger
2025-07-14 16:14 ` [RFC PATCH v3 00/15] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Nicolin Chen via
2025-07-14 16:14 ` Nicolin Chen via
2025-07-14 20:22 ` Nicolin Chen via
2025-07-14 20:22 ` Nicolin Chen via
2025-07-15 10:46 ` Duan, Zhenzhong
2025-07-16 7:27 ` Shameerali Kolothum Thodi via
2025-07-16 7:27 ` Shameerali Kolothum Thodi via
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=20250716103346.00005ca4@huawei.com \
--to=qemu-arm@nongnu.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=berrange@redhat.com \
--cc=ddutile@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jgg@nvidia.com \
--cc=jiangkunkun@huawei.com \
--cc=linuxarm@huawei.com \
--cc=mochs@nvidia.com \
--cc=nathanc@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shameerkolothum@gmail.com \
--cc=smostafa@google.com \
--cc=wangzhou1@hisilicon.com \
--cc=zhangfei.gao@linaro.org \
--cc=zhenzhong.duan@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 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.