From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Date: Tue, 05 Jul 2022 11:57:51 +0000 Subject: Re: [PATCH kernel] powerpc/iommu: Add simple iommu_ops to report capabilities Message-Id: List-Id: References: <20220705062235.2276125-1-aik@ozlabs.ru> In-Reply-To: <20220705062235.2276125-1-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Alexey Kardashevskiy Cc: linuxppc-dev@lists.ozlabs.org, Robin Murphy , Michael Ellerman , Lu Baolu , Kevin Tian , Joerg Roedel , Fabiano Rosas , Daniel Henrique Barboza , Murilo Opsfelder Araujo , Alex Williamson , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, iommu@lists.linux-foundation.org On Tue, Jul 05, 2022 at 04:22:35PM +1000, Alexey Kardashevskiy wrote: > I have not looked into the domains for ages, what is missing here? With this > on top of 5.19-rc1 VFIO works again on my POWER9 box. Thanks, Does this solve all the problems or just coherency? It seems like it should solve everything now as there will be a IOMMU_DOMAIN_BLOCKED and the ref logic will succeed to assign it? > +static struct iommu_domain *spapr_tce_iommu_domain_alloc(unsigned int type) > +{ > + struct iommu_domain *domain = kzalloc(sizeof(*domain), GFP_KERNEL); > + > + if (!domain) > + return NULL; This should only succeed if type is IOMMU_DOMAIN_BLOCKED > +static struct iommu_group *spapr_tce_iommu_device_group(struct device *dev) > +{ > + struct iommu_group *grp = dev->iommu_group; > + > + if (!grp) > + grp = ERR_PTR(-ENODEV); It looks like this should just always fail since the code code already checks iommu_group before calling this? (Arguably ppc should be refactored to use the normal probe_device and device_group ops to create groups, but that doesn't seem critical for this. Thanks Jason