From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Gunthorpe Date: Mon, 18 Jul 2022 16:49:20 +0000 Subject: Re: [PATCH kernel 1/3] powerpc/iommu: Add "borrowing" iommu_table_group_ops Message-Id: <20220718164920.GC4609@nvidia.com> List-Id: References: <20220714081822.3717693-1-aik@ozlabs.ru> <20220714081822.3717693-2-aik@ozlabs.ru> In-Reply-To: <20220714081822.3717693-2-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, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, Deming Wang , Robin Murphy , Alex Williamson , Daniel Henrique Barboza , Fabiano Rosas , Murilo Opsfelder Araujo , Nicholas Piggin , Michael Ellerman On Thu, Jul 14, 2022 at 06:18:20PM +1000, Alexey Kardashevskiy wrote: > PPC64 IOMMU API defines iommu_table_group_ops which handles DMA windows > for PEs: control the ownership, create/set/unset a table the hardware > for dynamic DMA windows (DDW). VFIO uses the API to implement support > on POWER. > > So far only PowerNV IODA2 (POWER8 and newer machines) implemented this and other cases (POWER7 or nested KVM) did not and instead reused > existing iommu_table structs. This means 1) no DDW 2) ownership transfer > is done directly in the VFIO SPAPR TCE driver. > > Soon POWER is going to get its own iommu_ops and ownership control is > going to move there. This implements spapr_tce_table_group_ops which > borrows iommu_table tables. The upside is that VFIO needs to know less > about POWER. > > The new ops returns the existing table from create_table() and > only checks if the same window is already set. This is only going to work > if the default DMA window starts table_group.tce32_start and as big as > pe->table_group.tce32_size (not the case for IODA2+ PowerNV). > > This changes iommu_table_group_ops::take_ownership() to return an error > if borrowing a table failed. > > This should not cause any visible change in behavior for PowerNV. > pSeries was not that well tested/supported anyway. > > Signed-off-by: Alexey Kardashevskiy > --- > arch/powerpc/include/asm/iommu.h | 6 +- > arch/powerpc/kernel/iommu.c | 98 ++++++++++++++++++++++- > arch/powerpc/platforms/powernv/pci-ioda.c | 6 +- > arch/powerpc/platforms/pseries/iommu.c | 3 + > drivers/vfio/vfio_iommu_spapr_tce.c | 94 ++++------------------ > 5 files changed, 121 insertions(+), 86 deletions(-) Reviewed-by: Jason Gunthorpe Jason