From: Jason Gunthorpe <jgg@ziepe.ca>
To: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, Kevin Tian <kevin.tian@intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
Alexey Kardashevskiy <aik@amd.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Xu Yilun <yilun.xu@linux.intel.com>,
Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Steven Price <steven.price@arm.com>
Subject: Re: [PATCH v2 2/3] iommufd/tsm: add vdevice TSM bind/unbind ioctl
Date: Fri, 13 Mar 2026 15:42:59 -0300 [thread overview]
Message-ID: <20260313184259.GM1704121@ziepe.ca> (raw)
In-Reply-To: <20260311213555.00001064@huawei.com>
On Wed, Mar 11, 2026 at 09:35:55PM +0000, Jonathan Cameron wrote:
> > +int iommufd_vdevice_tsm_op_ioctl(struct iommufd_ucmd *ucmd)
> > +{
> > + int rc;
> > + struct kvm *kvm;
> > + struct iommufd_vdevice *vdev;
> > + struct iommu_vdevice_tsm_op *cmd = ucmd->cmd;
> > +
> > + if (cmd->flags)
> > + return -EOPNOTSUPP;
> > +
> > + vdev = container_of(iommufd_get_object(ucmd->ictx, cmd->vdevice_id,
> > + IOMMUFD_OBJ_VDEVICE),
> > + struct iommufd_vdevice, obj);
>
> I'd be tempted to do something with a helper function to simplify flow.
It is already
static inline struct iommufd_vdevice *
iommufd_get_vdevice(struct iommufd_ctx *ictx, u32 id)
{
return container_of(iommufd_get_object(ictx, id,
IOMMUFD_OBJ_VDEVICE),
struct iommufd_vdevice, obj);
}
> Then the helper function can do direct returns on errors given the
> iommfd_object is managed in outer function.
Use cleanup.h ? It is not the iommufd style the break things up into
little functions for error unwind reasons
> > + if (!vdev->viommu->kvm_filp) {
> > + rc = -ENODEV;
> > + goto out_put_vdev;
> > + }
> > +
> > + kvm = vdev->viommu->kvm_filp->private_data;
> > + if (!kvm) {
Ah this I don't think you should be doing. That needs a helper from
kvm
Jason
next prev parent reply other threads:[~2026-03-13 18:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 11:17 [PATCH v2 0/3] Add iommufd ioctls to support TSM operations Aneesh Kumar K.V (Arm)
2026-03-09 11:17 ` [PATCH v2 1/3] iommufd/viommu: Allow associating a KVM VM fd with a vIOMMU Aneesh Kumar K.V (Arm)
2026-03-11 21:18 ` Jonathan Cameron
2026-03-13 18:27 ` Jason Gunthorpe
2026-03-13 6:15 ` Nicolin Chen
2026-03-13 18:34 ` Jason Gunthorpe
2026-03-16 5:49 ` Aneesh Kumar K.V
2026-03-13 18:31 ` Jason Gunthorpe
2026-03-09 11:17 ` [PATCH v2 2/3] iommufd/tsm: add vdevice TSM bind/unbind ioctl Aneesh Kumar K.V (Arm)
2026-03-11 21:35 ` Jonathan Cameron
2026-03-13 18:42 ` Jason Gunthorpe [this message]
2026-03-13 18:48 ` Jason Gunthorpe
2026-03-16 7:12 ` Tian, Kevin
2026-03-16 8:45 ` Aneesh Kumar K.V
2026-03-09 11:17 ` [PATCH v2 3/3] iommufd/vdevice: add TSM guest request ioctl Aneesh Kumar K.V (Arm)
2026-03-11 21:43 ` Jonathan Cameron
2026-03-13 18:46 ` Jason Gunthorpe
2026-03-13 18:49 ` Jason Gunthorpe
2026-03-13 22:17 ` Dan Williams
2026-03-16 7:25 ` Tian, Kevin
2026-03-16 5:47 ` Aneesh Kumar K.V
2026-03-16 7:28 ` Tian, Kevin
2026-03-16 7:31 ` Tian, Kevin
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=20260313184259.GM1704121@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=Suzuki.Poulose@arm.com \
--cc=aik@amd.com \
--cc=aneesh.kumar@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jonathan.cameron@huawei.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@rivosinc.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