Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755790AbcCPQcR (ORCPT ); Wed, 16 Mar 2016 12:32:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40487 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755735AbcCPQcP (ORCPT ); Wed, 16 Mar 2016 12:32:15 -0400 Date: Wed, 16 Mar 2016 10:32:07 -0600 From: Alex Williamson To: Yongji Xie Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-doc@vger.kernel.org, bhelgaas@google.com, corbet@lwn.net, aik@ozlabs.ru, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, warrier@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com Subject: Re: [RFC PATCH v4 7/7] powerpc/powernv/pci-ioda: Add IOMMU_CAP_INTR_REMAP for IODA host bridge Message-ID: <20160316103207.6fffb9b5@t450s.home> In-Reply-To: <1457336918-3893-8-git-send-email-xyjxie@linux.vnet.ibm.com> References: <1457336918-3893-1-git-send-email-xyjxie@linux.vnet.ibm.com> <1457336918-3893-8-git-send-email-xyjxie@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1678 Lines: 52 On Mon, 7 Mar 2016 15:48:38 +0800 Yongji Xie wrote: > This patch adds IOMMU_CAP_INTR_REMAP for IODA host bridge so that > we can mmap MSI-X table in vfio driver. > > Signed-off-by: Yongji Xie > --- > arch/powerpc/platforms/powernv/pci-ioda.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c > index f90dc04..f01b9ab 100644 > --- a/arch/powerpc/platforms/powernv/pci-ioda.c > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c > @@ -1955,6 +1955,20 @@ static struct iommu_table_ops pnv_ioda2_iommu_ops = { > .free = pnv_ioda2_table_free, > }; > > +static bool pnv_ioda_iommu_capable(enum iommu_cap cap) > +{ > + switch (cap) { > + case IOMMU_CAP_INTR_REMAP: > + return true; > + default: > + return false; > + } > +} > + > +static struct iommu_ops pnv_ioda_iommu_ops = { > + .capable = pnv_ioda_iommu_capable, > +}; > + > static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb, > struct pnv_ioda_pe *pe, unsigned int base, > unsigned int segs) > @@ -3078,6 +3092,9 @@ static void pnv_pci_ioda_fixup(void) > > /* Link NPU IODA tables to their PCI devices. */ > pnv_npu_ioda_fixup(); > + > + /* Add IOMMU_CAP_INTR_REMAP */ > + bus_set_iommu(&pci_bus_type, &pnv_ioda_iommu_ops); > } > > /* Doesn't this set you up for a world of hurt? bus_set_iommu() calls iommu_bus_init() which sets up notifiers, which maybe you don't care about, but it also means that iommu_domain_alloc(&pci_bus_type) will segfault because you're not providing a domain_alloc callback here.