On Wed, Apr 24, 2024 at 04:54:01PM -0700, Tomasz Jeznach wrote: > On Wed, Apr 24, 2024 at 4:39 PM Jason Gunthorpe <jgg@xxxxxxxx> wrote: > > > > On Wed, Apr 24, 2024 at 04:30:45PM -0700, Tomasz Jeznach wrote: > > > > > @@ -46,6 +46,10 @@ MODULE_LICENSE("GPL"); > > > > > #define dev_to_iommu(dev) \ > > > > > container_of((dev)->iommu->iommu_dev, struct riscv_iommu_device, iommu) > > > > > > > > > > +/* IOMMU PSCID allocation namespace. */ > > > > > +static DEFINE_IDA(riscv_iommu_pscids); > > > > > +#define RISCV_IOMMU_MAX_PSCID BIT(20) > > > > > + > > > > > > > > You may consider putting this IDA in the riscv_iommu_device() and move > > > > the pscid from the domain to the bond? > > > > > > > > > > I've been considering containing IDA inside riscv_iommu_device at some > > > point, but it made PCSID management more complicated. In the follow > > > up patches it is desired for PSCID to be unique across all IOMMUs in > > > the system (within guest's GSCID), as the protection domains might > > > (and will) be shared between more than single IOMMU device. > > > > The PCSID isn't scoped under the GSCID? That doesn't sound very good, > > it means VM's can't direct issue invalidation with their local view of > > the PCSID space? > > > > To clarify: PSCID namespace is per GSCID. > However there might be more than one IOMMU in a single system sharing > the same GSCID I assume this is because GSCID ends up shared with kvm? > and with e.g. SVA domains attached to more than one > IOMMU. It was simpler to manage PCSID globally. If the PSCID is moved into the invalidation list like Intel structured it then it doesn't matter for SVA, or really anything. AFAIK the only reason to do otherwise is if you have a reason to share the ID with the CPU/MM and the IOMMU probably to coordinate invalidations. But if you do this then you really just always want to use the MM's global ID space in the first place... So I'm not sure :) Jason