From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMB2v-0002PR-TS for qemu-devel@nongnu.org; Tue, 26 Aug 2014 03:20:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMB2q-0006Ov-1r for qemu-devel@nongnu.org; Tue, 26 Aug 2014 03:20:01 -0400 Date: Tue, 26 Aug 2014 17:19:19 +1000 From: David Gibson Message-ID: <20140826071919.GX9923@voom.redhat.com> References: <1408097555-28126-1-git-send-email-aik@ozlabs.ru> <1408097555-28126-12-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="dZJOqldIUwtPuZvk" Content-Disposition: inline In-Reply-To: <1408097555-28126-12-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [RFC PATCH v2 11/13] 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, Gavin Shan , Alexander Graf --dZJOqldIUwtPuZvk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 15, 2014 at 08:12:33PM +1000, Alexey Kardashevskiy wrote: > This implements DDW for VFIO. Host kernel support is required for this. >=20 > Signed-off-by: Alexey Kardashevskiy > --- > Changes: > v2: > * remove()/reset() callbacks use spapr_pci's ones > --- > hw/ppc/spapr_pci_vfio.c | 86 +++++++++++++++++++++++++++++++++++++++++++= ++++++ > 1 file changed, 86 insertions(+) >=20 > diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c > index 11b4272..79df716 100644 > --- a/hw/ppc/spapr_pci_vfio.c > +++ b/hw/ppc/spapr_pci_vfio.c > @@ -71,6 +71,88 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBStat= e *sphb, Error **errp) > spapr_tce_get_iommu(tcet)); > =20 > object_unref(OBJECT(tcet)); > + > + if (sphb->ddw_enabled) { > + sphb->ddw_enabled =3D !!(info.flags & VFIO_IOMMU_SPAPR_TCE_FLAG_= DDW); This overrides an explicit ddw=3D set by the user, which is a bit counter-intuitive. > + } > +} > + > +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_addr, page_shift, > + 1ULL << (window_shift - page_shift), > + 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 > + }; > + int ret; > + > + spapr_pci_ddw_remove(sphb, tcet); > + ret =3D vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_REMOVE, &remove); > + > + return ret; > +} > + > +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) }; > + int ret; > + > + spapr_pci_ddw_reset(sphb); > + ret =3D vfio_container_ioctl(&sphb->iommu_as, svphb->iommugroupid, > + VFIO_IOMMU_SPAPR_TCE_RESET, &reset); Unlike the non-VFIO version, this doesn't appear to reset ddw_num. Also, there isn't call to explicitly call DDW reset on system reset. Is that handled in kernel by the overall VFIO reset? > + return ret; > } > =20 > static void spapr_phb_vfio_class_init(ObjectClass *klass, void *data) > @@ -80,6 +162,10 @@ static void spapr_phb_vfio_class_init(ObjectClass *kl= ass, void *data) > =20 > dc->props =3D spapr_phb_vfio_properties; > 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 { --=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 --dZJOqldIUwtPuZvk Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJT/DT3AAoJEGw4ysog2bOSzU8P/2V6rtDnQCkQnH6s54zP5J40 LnZERLaOrBqSR7ETVMceYmfofWCy9Nswcdp3SkIZI1eG8LvZxV3+2Xmn68cqFBE6 3oo5y8ZbojYPohpuIoLhKysRz1r7FDkCbFKyaJz37XR+A8G27rGC0RvToOXHW/Qt 6NvvR4EnRfd93f9ruBq4n6SN3Q8X9YnbCmJ7pClgp2/oyaCaOW5GwEyzHGtuj1pz xf5X78duyTGBm6u5H2GDKS1jB4pMrBo3VR496PDdTfycgO9ghfoFDndN58wJ017O 45q1NIFrWJvuIBom7ie0LNNISEcDs1jtlUsIDH1iOg40pN8eE+OTVbYpBDcGu1Wd XfXyedtErxrlyDGRHtTHzS7Dye8eEUtcUyLnblJUbnp+8dTAJEcri32Yz/y4Lnzq 6frUHn5qdph8QT0E1elhvlX/PelXOZe81ZysUIbhO/EbYmiBg+MtstQhg91xfI1C pejT+b0mIafKJXCF9OMeIiOhbaVSOctq0DrMW/7DmR6AQagpxHLNO10Bmmb/CM+o 6Y/bUt6fsV/kGz/tF5nB5Qj3Ip0Nc5AbNkP0yxvDM1LbdqGbJPsHfH4zGXSU1amN 2ElqzC0QVqGaIBBv/Z1Dw+hgADO+GdquHbFEISE6JlztoQBUWEDiW6ur+oDU0+ZQ DYrRHvKTXdpDm0MuEcCC =Xw6H -----END PGP SIGNATURE----- --dZJOqldIUwtPuZvk--