From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50327) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLnPm-0000NU-U0 for qemu-devel@nongnu.org; Sat, 09 Jul 2016 04:15:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLnPi-0007EL-MF for qemu-devel@nongnu.org; Sat, 09 Jul 2016 04:15:05 -0400 Received: from mout.web.de ([212.227.17.11]:49169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLnPi-0007EH-C2 for qemu-devel@nongnu.org; Sat, 09 Jul 2016 04:15:02 -0400 References: <1467706769-12505-1-git-send-email-peterx@redhat.com> <1467706769-12505-5-git-send-email-peterx@redhat.com> From: Jan Kiszka Message-ID: <5780B278.7020001@web.de> Date: Sat, 9 Jul 2016 10:14:48 +0200 MIME-Version: 1.0 In-Reply-To: <1467706769-12505-5-git-send-email-peterx@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="d0MOsihlt4DfrLC0SSUSp5FnDhvqnwFo6" Subject: Re: [Qemu-devel] [PATCH v11 04/28] x86-iommu: q35: generalize find_add_as() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu , qemu-devel@nongnu.org Cc: imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, marcel@redhat.com, mst@redhat.com, pbonzini@redhat.com, rkrcmar@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, davidkiarie4@gmail.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --d0MOsihlt4DfrLC0SSUSp5FnDhvqnwFo6 From: Jan Kiszka To: Peter Xu , qemu-devel@nongnu.org Cc: imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com, jasowang@redhat.com, marcel@redhat.com, mst@redhat.com, pbonzini@redhat.com, rkrcmar@redhat.com, alex.williamson@redhat.com, wexu@redhat.com, davidkiarie4@gmail.com Message-ID: <5780B278.7020001@web.de> Subject: Re: [PATCH v11 04/28] x86-iommu: q35: generalize find_add_as() References: <1467706769-12505-1-git-send-email-peterx@redhat.com> <1467706769-12505-5-git-send-email-peterx@redhat.com> In-Reply-To: <1467706769-12505-5-git-send-email-peterx@redhat.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 2016-07-05 10:19, Peter Xu wrote: > Remove VT-d calls in common q35 codes. Instead, we provide a general > find_add_as() for x86-iommu type. >=20 > Signed-off-by: Peter Xu > --- > hw/i386/intel_iommu.c | 15 ++++++++------- > include/hw/i386/intel_iommu.h | 5 ----- > include/hw/i386/x86-iommu.h | 3 +++ > 3 files changed, 11 insertions(+), 12 deletions(-) You claim to remove something from "common q35 code", but I don't see changes to it. Instead, the patch introduces a method that seems to remain unused outside the implementing class (I just grep'ed your tree). Anything missing? Jan >=20 > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c > index 3ee5782..2ac79ab 100644 > --- a/hw/i386/intel_iommu.c > +++ b/hw/i386/intel_iommu.c > @@ -1910,8 +1910,10 @@ static Property vtd_properties[] =3D { > }; > =20 > =20 > -VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int = devfn) > +static AddressSpace *vtd_find_add_as(X86IOMMUState *x86_iommu, PCIBus = *bus, > + int devfn) > { > + IntelIOMMUState *s =3D (IntelIOMMUState *)x86_iommu; > uintptr_t key =3D (uintptr_t)bus; > VTDBus *vtd_bus =3D g_hash_table_lookup(s->vtd_as_by_busptr, &key)= ; > VTDAddressSpace *vtd_dev_as; > @@ -1939,7 +1941,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState = *s, PCIBus *bus, int devfn) > address_space_init(&vtd_dev_as->as, > &vtd_dev_as->iommu, "intel_iommu"); > } > - return vtd_dev_as; > + return &vtd_dev_as->as; > } > =20 > /* Do the initialization. It will also be called when reset, so pay > @@ -2032,13 +2034,11 @@ static void vtd_reset(DeviceState *dev) > =20 > static AddressSpace *vtd_host_dma_iommu(PCIBus *bus, void *opaque, int= devfn) > { > - IntelIOMMUState *s =3D opaque; > - VTDAddressSpace *vtd_as; > + X86IOMMUState *x86_iommu =3D opaque; > + X86IOMMUClass *x86_class =3D X86_IOMMU_GET_CLASS(x86_iommu); > =20 > assert(0 <=3D devfn && devfn <=3D X86_IOMMU_PCI_DEVFN_MAX); > - > - vtd_as =3D vtd_find_add_as(s, bus, devfn); > - return &vtd_as->as; > + return x86_class->find_add_as(x86_iommu, bus, devfn); > } > =20 > static void vtd_realize(DeviceState *dev, Error **errp) > @@ -2071,6 +2071,7 @@ static void vtd_class_init(ObjectClass *klass, vo= id *data) > dc->props =3D vtd_properties; > dc->hotpluggable =3D false; > x86_class->realize =3D vtd_realize; > + x86_class->find_add_as =3D vtd_find_add_as; > } > =20 > static const TypeInfo vtd_info =3D { > diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iomm= u.h > index 0794309..e36b896 100644 > --- a/include/hw/i386/intel_iommu.h > +++ b/include/hw/i386/intel_iommu.h > @@ -125,9 +125,4 @@ struct IntelIOMMUState { > VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects inde= xed by bus number */ > }; > =20 > -/* Find the VTD Address space associated with the given bus pointer, > - * create a new one if none exists > - */ > -VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int = devfn); > - > #endif > diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h > index b2401a6..581da16 100644 > --- a/include/hw/i386/x86-iommu.h > +++ b/include/hw/i386/x86-iommu.h > @@ -21,6 +21,7 @@ > #define IOMMU_COMMON_H > =20 > #include "hw/sysbus.h" > +#include "exec/memory.h" > =20 > #define TYPE_X86_IOMMU_DEVICE ("x86-iommu") > #define X86_IOMMU_DEVICE(obj) \ > @@ -39,6 +40,8 @@ struct X86IOMMUClass { > SysBusDeviceClass parent; > /* Intel/AMD specific realize() hook */ > DeviceRealize realize; > + /* Find/Add IOMMU address space for specific PCI device */ > + AddressSpace *(*find_add_as)(X86IOMMUState *s, PCIBus *bus, int de= vfn); > }; > =20 > struct X86IOMMUState { >=20 --d0MOsihlt4DfrLC0SSUSp5FnDhvqnwFo6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAleAsngACgkQitSsb3rl5xSaygCcDL99vG9L/v86VPu8vNgj8Dtv TQcAni0hzm5TpHEJL77C5ixdCExouiJ5 =VBXW -----END PGP SIGNATURE----- --d0MOsihlt4DfrLC0SSUSp5FnDhvqnwFo6--