[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZxRecZKbXd7cLOqy@Asurada-Nvidia>
Date: Sat, 19 Oct 2024 18:35:45 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: <kevin.tian@...el.com>, <will@...nel.org>, <joro@...tes.org>,
<suravee.suthikulpanit@....com>, <robin.murphy@....com>,
<dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>, <shuah@...nel.org>,
<linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>,
<eric.auger@...hat.com>, <jean-philippe@...aro.org>, <mdf@...nel.org>,
<mshavit@...gle.com>, <shameerali.kolothum.thodi@...wei.com>,
<smostafa@...gle.com>, <yi.l.liu@...el.com>, <aik@....com>,
<patches@...ts.linux.dev>
Subject: Re: [PATCH v3 01/16] iommufd/viommu: Introduce IOMMUFD_OBJ_VDEVICE
and its related struct
On Thu, Oct 17, 2024 at 03:45:56PM -0300, Jason Gunthorpe wrote:
> > +struct iommufd_vdevice *
> > +__iommufd_vdevice_alloc(struct iommufd_ctx *ictx, size_t size)
> > +{
> > + struct iommufd_object *obj;
> > +
> > + if (WARN_ON(size < sizeof(struct iommufd_vdevice)))
> > + return ERR_PTR(-EINVAL);
> > + obj = iommufd_object_alloc_elm(ictx, size, IOMMUFD_OBJ_VDEVICE);
> > + if (IS_ERR(obj))
> > + return ERR_CAST(obj);
> > + return container_of(obj, struct iommufd_vdevice, obj);
> > +}
>
> Like for the viommu this can all just be folded into the #define
It seems that we have to keep two small functions as followings,
unless we want to expose the enum iommufd_object_type.
---------------------------------------------------------------
diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 4495f1aaccca..fdd203487bac 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -38,10 +38,19 @@ _iommufd_object_alloc_member(struct iommufd_ctx *ictx, size_t size,
EXPORT_SYMBOL_NS_GPL(_iommufd_object_alloc_member, IOMMUFD);
struct iommufd_viommu *_iommufd_viommu_alloc(struct iommufd_ctx *ictx,
size_t size)
{
return container_of(_iommufd_object_alloc_member(ictx, size,
IOMMUFD_OBJ_VIOMMU),
struct iommufd_viommu, obj);
}
EXPORT_SYMBOL_NS_GPL(_iommufd_viommu_alloc, IOMMUFD);
+
+struct iommufd_vdevice *_iommufd_vdevice_alloc(struct iommufd_ctx *ictx,
+ size_t size)
+{
+ return container_of(_iommufd_object_alloc_member(ictx, size,
+ IOMMUFD_OBJ_VDEVICE),
+ struct iommufd_vdevice, obj);
+}
+EXPORT_SYMBOL_NS_GPL(_iommufd_vdevice_alloc, IOMMUFD);
---------------------------------------------------------------
Thanks
Nicolin
Powered by blists - more mailing lists