From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayFbM-0005BC-Lb for qemu-devel@nongnu.org; Thu, 05 May 2016 05:29:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ayFbB-0000Xh-4b for qemu-devel@nongnu.org; Thu, 05 May 2016 05:29:39 -0400 Received: from mail-yw0-x241.google.com ([2607:f8b0:4002:c05::241]:33225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ayFb9-0000T0-UJ for qemu-devel@nongnu.org; Thu, 05 May 2016 05:29:33 -0400 Received: by mail-yw0-x241.google.com with SMTP id y6so11128928ywe.0 for ; Thu, 05 May 2016 02:29:17 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1462418761-12714-9-git-send-email-peterx@redhat.com> References: <1462418761-12714-1-git-send-email-peterx@redhat.com> <1462418761-12714-9-git-send-email-peterx@redhat.com> Date: Thu, 5 May 2016 12:29:13 +0300 Message-ID: From: David Kiarie Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH v6 08/26] intel_iommu: provide helper function vtd_get_iommu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: QEMU Developers , imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, Marcel Apfelbaum , "Michael S. Tsirkin" , pbonzini@redhat.com, Jan Kiszka , rkrcmar@redhat.com, alex.williamson@redhat.com, wexu@redhat.com On Thu, May 5, 2016 at 6:25 AM, Peter Xu wrote: > Moves acpi_get_iommu() under VT-d to make it a public function. > > Signed-off-by: Peter Xu > --- > hw/i386/acpi-build.c | 7 +------ > hw/i386/intel_iommu.c | 13 +++++++++++++ > include/hw/i386/intel_iommu.h | 2 ++ > 3 files changed, 16 insertions(+), 6 deletions(-) > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index 5d2d87b..b064bc2 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -2677,12 +2677,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) > > static bool acpi_has_iommu(void) > { > - bool ambiguous; > - Object *intel_iommu; > - > - intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, > - &ambiguous); > - return intel_iommu && !ambiguous; > + return !!vtd_iommu_get(); > } This is not consistent with what we have in the AMD IOMMU patches but I guess this could be easily fixed. > > static > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c > index 4d14124..a44289f 100644 > --- a/hw/i386/intel_iommu.c > +++ b/hw/i386/intel_iommu.c > @@ -2001,6 +2001,19 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn) > return vtd_dev_as; > } > > +IntelIOMMUState *vtd_iommu_get(void) > +{ > + bool ambiguous = false; > + Object *intel_iommu = NULL; > + > + intel_iommu = object_resolve_path_type("", TYPE_INTEL_IOMMU_DEVICE, > + &ambiguous); > + if (ambiguous) > + intel_iommu = NULL; > + > + return (IntelIOMMUState *)intel_iommu; > +} > + > /* Do the initialization. It will also be called when reset, so pay > * attention when adding new initialization stuff. > */ > diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h > index 4914fe6..9ee84f7 100644 > --- a/include/hw/i386/intel_iommu.h > +++ b/include/hw/i386/intel_iommu.h > @@ -196,5 +196,7 @@ struct IntelIOMMUState { > * create a new one if none exists > */ > VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn); > +/* Get default IOMMU object */ > +IntelIOMMUState *vtd_iommu_get(void); > > #endif > -- > 2.4.11 >