Received: from eggs.gnu.org ([2001:4830:134:3::10]:38765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XH1eA-0001Wd-Co for qemu-devel@nongnu.org; Mon, 11 Aug 2014 22:17:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XH1e5-0003sE-A6 for qemu-devel@nongnu.org; Mon, 11 Aug 2014 22:17:10 -0400 Date: Tue, 12 Aug 2014 12:14:11 +1000 From: David Gibson Message-ID: <20140812021411.GB23065@voom.redhat.com> References: <1406799254-25223-1-git-send-email-aik@ozlabs.ru> <1406799254-25223-10-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="IrhDeMKUP4DT/M7F" Content-Disposition: inline In-Reply-To: <1406799254-25223-10-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [RFC PATCH 09/10] spapr_pci_vfio: Enable DDW List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: Alex Williamson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Alexander Graf --IrhDeMKUP4DT/M7F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 31, 2014 at 07:34:13PM +1000, Alexey Kardashevskiy wrote: > This implements DDW for VFIO. Host kernel support is required for this. >=20 > Signed-off-by: Alexey Kardashevskiy > --- > hw/ppc/spapr_pci_vfio.c | 75 +++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 75 insertions(+) >=20 > diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c > index d3bddf2..dc443e2 100644 > --- a/hw/ppc/spapr_pci_vfio.c > +++ b/hw/ppc/spapr_pci_vfio.c > @@ -69,6 +69,77 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBStat= e *sphb, Error **errp) > /* Register default 32bit DMA window */ > memory_region_add_subregion(&sphb->iommu_root, tcet->bus_offset, > spapr_tce_get_iommu(tcet)); > + > + sphb->ddw_supported =3D !!(info.flags & VFIO_IOMMU_SPAPR_TCE_FLAG_DD= W); > +} > + > +static int spapr_pci_vfio_ddw_query(sPAPRPHBState *sphb, > + uint32_t *windows_available, > + uint32_t *page_size_mask) > +{ > + sPAPRPHBVFIOState *svphb =3D SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); > + struct vfio_iommu_spapr_tce_query query =3D { .argsz =3D sizeof(quer= y) }; > + int ret; > + > + ret =3D vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_QUERY, &query); > + if (ret) { > + return ret; > + } > + > + *windows_available =3D query.windows_available; > + *page_size_mask =3D query.page_size_mask; > + > + return ret; > +} > + > +static int spapr_pci_vfio_ddw_create(sPAPRPHBState *sphb, uint32_t page_= shift, > + uint32_t window_shift, uint32_t lio= bn, > + sPAPRTCETable **ptcet) > +{ > + sPAPRPHBVFIOState *svphb =3D SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); > + struct vfio_iommu_spapr_tce_create create =3D { > + .argsz =3D sizeof(create), > + .page_shift =3D page_shift, > + .window_shift =3D window_shift, > + .start_addr =3D 0 > + }; > + int ret; > + > + ret =3D vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_CREATE, &create); > + if (ret) { > + return ret; > + } > + > + *ptcet =3D spapr_tce_new_table(DEVICE(sphb), liobn, create.start_add= r, > + page_shift, 1 << (window_shift - page_s= hift), > + true); > + memory_region_add_subregion(&sphb->iommu_root, (*ptcet)->bus_offset, > + spapr_tce_get_iommu(*ptcet)); > + > + return ret; > +} > + > +static int spapr_pci_vfio_ddw_remove(sPAPRPHBState *sphb, sPAPRTCETable = *tcet) > +{ > + sPAPRPHBVFIOState *svphb =3D SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); > + struct vfio_iommu_spapr_tce_remove remove =3D { > + .argsz =3D sizeof(remove), > + .start_addr =3D tcet->bus_offset > + }; > + > + return vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove); > +} > + > +static int spapr_pci_vfio_ddw_reset(sPAPRPHBState *sphb) > +{ > + sPAPRPHBVFIOState *svphb =3D SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); > + struct vfio_iommu_spapr_tce_reset reset =3D { .argsz =3D sizeof(rese= t) }; > + > + return vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_RESET, &reset); > } > =20 > static void spapr_phb_vfio_reset(DeviceState *qdev) > @@ -84,6 +155,10 @@ static void spapr_phb_vfio_class_init(ObjectClass *kl= ass, void *data) > dc->props =3D spapr_phb_vfio_properties; > dc->reset =3D spapr_phb_vfio_reset; > spc->finish_realize =3D spapr_phb_vfio_finish_realize; > + spc->ddw_query =3D spapr_pci_vfio_ddw_query; > + spc->ddw_create =3D spapr_pci_vfio_ddw_create; > + spc->ddw_remove =3D spapr_pci_vfio_ddw_remove; > + spc->ddw_reset =3D spapr_pci_vfio_ddw_reset; > } > =20 > static const TypeInfo spapr_phb_vfio_info =3D { As with the emulated version, I don't see anything which will reset secondary TCE tables on a system reset. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --IrhDeMKUP4DT/M7F Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJT6XhzAAoJEGw4ysog2bOS0tMQAOA5ABmJvV8yQO3wSW0i+Db4 fIXWsCa9/qVQw2FMHnfM/Spemyi16nxVui7SwXwwONmHksCtv7Ufmuin9gLzeO4o 0xkcnBsWebEzm8LVZ40TUPT94pUceUtgEQYpp5ErkjdBsa+D5KCvBLwfAHbBX9K5 Qvq+fIYTsC5vhLa9GcKTu08shEyNGCRvdzcZJ81S9UFSlwrJvAnzNJMfHml/OXxc jvf1q+JB1wPbLJbly+MWop9sWHn0fw6o5s9IabeL02WqX9G8Pc6ZaudyL9K7FGIX BljAVLfUSWwAXlB8dzMk29AwdY7hl6kYwBou/Xu2hnhcUeyGCzl8weMCO7uRYsEI PHvYHI38D6LP8P4QnnilfBStRno816m67P9oHt7n7qbs4VVocCcQIIkTRaHtPlKO kOnv+Jx3WP4faP2MmC5IHiv2zCZAVo7fk59lqrbWKEmuGCxwqZ21jzNpUA4T5N0u FX7PxJx0Yk95vTYJKM+ZaROVeLnCnkdiJCTfpw0kp8QuErQ+QTMi2RmqVNstrZhR dYqsfzhekmfGGtd/TYMwIomuFVJKzGCncJlrC1XlcMeISy6t+PTB0cnfWny6AYJv Mx72MvKgN+CL2TF08XZlVyoy+jXmXwrP6cDQI58+HxARAwAhVHCAba3A8eoXkdfM ilPSQNGHg7PflyVNdXR+ =a8jz -----END PGP SIGNATURE----- --IrhDeMKUP4DT/M7F--