On Thu, Oct 17, 2024 at 03:40:15PM -0300, Jason Gunthorpe wrote: > On Wed, Oct 09, 2024 at 09:38:11AM -0700, Nicolin Chen wrote: > > Add a new driver-type for ARM SMMUv3 to enum iommu_viommu_type. Implement > > +static inline struct iommufd_viommu * > > +arm_vsmmu_alloc(struct iommu_device *iommu_dev, struct iommu_domain *parent, > > + struct iommufd_ctx *ictx, unsigned int viommu_type) > > +{ > > + return ERR_PTR(-EOPNOTSUPP); > > +} > > Let's do #define NULL here instead so we don't get an op at all. Ack. > > +struct iommufd_viommu * > > +arm_vsmmu_alloc(struct iommu_device *iommu_dev, struct iommu_domain *parent, > > + struct iommufd_ctx *ictx, unsigned int viommu_type) > > +{ > > + struct arm_smmu_device *smmu = > > + container_of(iommu_dev, struct arm_smmu_device, iommu); > > + struct arm_smmu_domain *s2_parent = to_smmu_domain(parent); > > + struct arm_vsmmu *vsmmu; > > + > > + if (viommu_type != IOMMU_VIOMMU_TYPE_ARM_SMMUV3) > > + return ERR_PTR(-EOPNOTSUPP); > > So what happens if the user tries to create a default domain? > > It skips this and just creates an normal viommu object > > But then what? The driver needs to make sure it never casts that to a > arm_vsmmu ? How? So long as a driver doesn't provide iommu_ops->default_viommu_ops, it should be fine. We may also block DEFAULT viommu allocations in the core if the driver doesn't provide that default_viommu_ops. Nicolin