[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZZeyAC3c8LJz7nsQ@Asurada-Nvidia>
Date: Thu, 4 Jan 2024 23:38:40 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: Yi Liu <yi.l.liu@...el.com>, "Tian, Kevin" <kevin.tian@...el.com>,
"joro@...tes.org" <joro@...tes.org>, "alex.williamson@...hat.com"
<alex.williamson@...hat.com>, "robin.murphy@....com" <robin.murphy@....com>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>, "cohuck@...hat.com"
<cohuck@...hat.com>, "eric.auger@...hat.com" <eric.auger@...hat.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>, "mjrosato@...ux.ibm.com"
<mjrosato@...ux.ibm.com>, "chao.p.peng@...ux.intel.com"
<chao.p.peng@...ux.intel.com>, "yi.y.sun@...ux.intel.com"
<yi.y.sun@...ux.intel.com>, "peterx@...hat.com" <peterx@...hat.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"shameerali.kolothum.thodi@...wei.com"
<shameerali.kolothum.thodi@...wei.com>, "lulu@...hat.com" <lulu@...hat.com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>, "Duan,
Zhenzhong" <zhenzhong.duan@...el.com>, "joao.m.martins@...cle.com"
<joao.m.martins@...cle.com>, "Zeng, Xin" <xin.zeng@...el.com>, "Zhao, Yan Y"
<yan.y.zhao@...el.com>
Subject: Re: [PATCH v7 1/3] iommufd: Add data structure for Intel VT-d
stage-1 cache invalidation
On Wed, Jan 03, 2024 at 08:02:04PM -0400, Jason Gunthorpe wrote:
> On Wed, Jan 03, 2024 at 12:18:35PM -0800, Nicolin Chen wrote:
> > > The driver would have to create it and there would be some driver
> > > specific enclosing struct to go with it
> > >
> > > Perhaps device_ids goes in the driver specific struct, I don't know.
> >
> > +struct iommufd_viommu {
> > + struct iommufd_object obj;
> > + struct iommufd_ctx *ictx;
> > + struct iommu_device *iommu_dev;
> > + struct iommufd_hwpt_paging *hwpt; /* maybe unneeded */
> > +
> > + int vmid;
> > +
> > + union iommu_driver_user_data {
> > + struct iommu_driver_user_vtd;
> > + struct iommu_driver_user_arm_smmuv3;
> > + struct iommu_driver_user_amd_viommu;
> > + };
>
> Not like that, in the usual container_of way
How about this:
// iommu.h
@@ -490,6 +490,16 @@ struct iommu_ops {
+ /* User space instance allocation and freeing by the iommu driver */
+ struct iommu_device_user *(*iommu_alloc_user)(struct iommu_device *iommu);
+ void (*iommu_free_user)(struct iommu_device_user *iommu_user);
+ int (*iommu_user_set_dev_id)(struct iommu_device_user *iommu_user,
+ struct device *dev, u64 dev_id);
+ int (*iommu_user_unset_dev_id)(struct iommu_device_user *iommu_user,
+ struct device *dev);
+ int (*iommu_cache_invalidate_usewr)(struct iommu_device_user *iommu_user,
+ struct iommu_user_data_array *array);
...
+/**
+ * struct iommu_device_user - IOMMU core representation of one IOMMU virtual
+ * instance
+ * @iommu_dev: Underlying IOMMU hardware instance
+ * @id: Virtual instance ID, e.g. a vmid
+ */
+struct iommu_device_user {
+ struct iommu_device *iommu_dev;
+ struct xarray virtual_ids;
+ u32 id;
+};
// iommufd_private.h
+struct iommufd_viommu {
+ struct iommufd_object obj;
+ struct iommufd_ctx *ictx;
+ struct iommu_device *iommu_dev;
+ struct iommu_device_user *iommu_user;
+ struct iommufd_hwpt_paging *hwpt;
+};
+
+int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd);
+void iommufd_viommu_destroy(struct iommufd_object *obj);
So iommu_alloc_user op allocates a driver private structure that
contains an iommu_device_user and returns &priv->iommu_user.
The set/unset_dev_id ops probably need a type argument if there
can be a multi-xarray case, then the virtual_ids xarray should
be moved to the driver private structure too?
Also, a 64-bit virtual id in the uAPI was suggested previously.
But xarray is limited to a 32-bit index? Should we compromise
the uAPI to 32-bit or is there an alternative for a 64-bit id
lookup?
Thanks
Nicolin
Powered by blists - more mailing lists