From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YfiOm-0001B2-1A for qemu-devel@nongnu.org; Wed, 08 Apr 2015 01:19:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YfiOk-0000Kk-Lu for qemu-devel@nongnu.org; Wed, 08 Apr 2015 01:19:35 -0400 Date: Wed, 8 Apr 2015 15:08:31 +1000 From: David Gibson Message-ID: <20150408050831.GH28909@voom.redhat.com> References: <1427779727-13353-1-git-send-email-aik@ozlabs.ru> <1427779727-13353-11-git-send-email-aik@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="D6IIOQQv2Iwyp54J" Content-Disposition: inline In-Reply-To: <1427779727-13353-11-git-send-email-aik@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH qemu v5 10/12] spapr_pci: Rework finish_realize() 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 --D6IIOQQv2Iwyp54J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 31, 2015 at 04:28:45PM +1100, Alexey Kardashevskiy wrote: > This renames and reworks finish_realize() which used to finalize DMA > setup with an assumption that it will not change later. >=20 > The new callback supports multiple windows and supports various > parameters such as page and windows sizes. >=20 > This is a mechanical change so no change in behaviour is expected. >=20 > Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson In terms of the basic concept anyway. I'd prefer to see it moved earlier in the series though, so we don't have the now confusingly named "finish_realize" callbacks floating about. > --- > hw/ppc/spapr_pci.c | 14 +++++++++----- > hw/ppc/spapr_pci_vfio.c | 24 +++++++++++++----------- > include/hw/pci-host/spapr.h | 3 ++- > 3 files changed, 24 insertions(+), 17 deletions(-) >=20 > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > index 57bbc82..b8c2488 100644 > --- a/hw/ppc/spapr_pci.c > +++ b/hw/ppc/spapr_pci.c > @@ -729,10 +729,9 @@ int spapr_phb_dma_reset(sPAPRPHBState *sphb) > const uint32_t liobn =3D SPAPR_PCI_LIOBN(sphb->index, 0); > sPAPRTCETable *tcet =3D spapr_tce_find_by_liobn(liobn); > sPAPRPHBClass *spc =3D SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb); > - Error *err =3D NULL; > =20 > spapr_tce_table_disable(tcet); > - spc->finish_realize(sphb, &err); > + spc->dma_init_window(sphb, liobn, SPAPR_TCE_PAGE_SHIFT, 0); > =20 > return 0; > } > @@ -904,15 +903,20 @@ static void spapr_phb_realize(DeviceState *dev, Err= or **errp) > sphb->msi =3D g_hash_table_new_full(g_int_hash, g_int_equal, g_free,= g_free); > } > =20 > -static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp) > +static int spapr_phb_dma_init_window(sPAPRPHBState *sphb, uint32_t liobn, > + uint32_t page_shift, > + uint64_t window_size_hint) > { > sPAPRTCETable *tcet; > uint32_t nb_table; > + uint64_t bus_offset =3D 0; > =20 > tcet =3D spapr_tce_find_by_liobn(sphb->dma_liobn); > nb_table =3D SPAPR_PCI_DMA32_SIZE >> SPAPR_TCE_PAGE_SHIFT; > - spapr_tce_set_props(tcet, 0, SPAPR_TCE_PAGE_SHIFT, nb_table, false); > + spapr_tce_set_props(tcet, bus_offset, page_shift, nb_table, false); > spapr_tce_table_enable(tcet); > + > + return 0; > } > =20 > static int spapr_phb_children_reset(Object *child, void *opaque) > @@ -1065,7 +1069,7 @@ static void spapr_phb_class_init(ObjectClass *klass= , void *data) > dc->vmsd =3D &vmstate_spapr_pci; > set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); > dc->cannot_instantiate_with_device_add_yet =3D false; > - spc->finish_realize =3D spapr_phb_finish_realize; > + spc->dma_init_window =3D spapr_phb_dma_init_window; > } > =20 > static const TypeInfo spapr_phb_info =3D { > diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c > index 1657f6b..a7e32f6 100644 > --- a/hw/ppc/spapr_pci_vfio.c > +++ b/hw/ppc/spapr_pci_vfio.c > @@ -21,43 +21,45 @@ > #include "hw/pci-host/spapr.h" > #include "linux/vfio.h" > #include "hw/vfio/vfio.h" > +#include "qemu/error-report.h" > =20 > static Property spapr_phb_vfio_properties[] =3D { > DEFINE_PROP_INT32("iommu", sPAPRPHBVFIOState, iommugroupid, -1), > DEFINE_PROP_END_OF_LIST(), > }; > =20 > -static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **e= rrp) > +static int spapr_phb_vfio_dma_init_window(sPAPRPHBState *sphb, uint32_t = liobn, > + uint32_t page_shift, > + uint64_t window_size_hint) > { > sPAPRPHBVFIOState *svphb =3D SPAPR_PCI_VFIO_HOST_BRIDGE(sphb); > struct vfio_iommu_spapr_tce_info info =3D { .argsz =3D sizeof(info) = }; > int ret; > - sPAPRTCETable *tcet; > - uint32_t liobn =3D svphb->phb.dma_liobn; > uint32_t nb_table; > + sPAPRTCETable *tcet =3D spapr_tce_find_by_liobn(liobn); > =20 > ret =3D vfio_container_ioctl(&svphb->phb.iommu_as, > VFIO_CHECK_EXTENSION, > (void *) VFIO_SPAPR_TCE_IOMMU); > if (ret !=3D 1) { > - error_setg_errno(errp, -ret, > - "spapr-vfio: SPAPR extension is not supported"); > - return; > + error_report("spapr-vfio: SPAPR extension is not supported: %m"); > + return ret; > } > =20 > ret =3D vfio_container_ioctl(&sphb->iommu_as, > VFIO_IOMMU_SPAPR_TCE_GET_INFO, &info); > if (ret) { > - error_setg_errno(errp, -ret, > - "spapr-vfio: get info from container failed"); > - return; > + error_report("spapr-vfio: get info from container failed: %m"); > + return ret; > } > =20 > tcet =3D spapr_tce_find_by_liobn(liobn); > nb_table =3D info.dma32_window_size >> SPAPR_TCE_PAGE_SHIFT; > - spapr_tce_set_props(tcet, info.dma32_window_start, SPAPR_TCE_PAGE_SH= IFT, > + spapr_tce_set_props(tcet, info.dma32_window_start, page_shift, > nb_table, true); > spapr_tce_table_enable(tcet); > + > + return ret; > } > =20 > static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb, > @@ -177,7 +179,7 @@ static void spapr_phb_vfio_class_init(ObjectClass *kl= ass, void *data) > sPAPRPHBClass *spc =3D SPAPR_PCI_HOST_BRIDGE_CLASS(klass); > =20 > dc->props =3D spapr_phb_vfio_properties; > - spc->finish_realize =3D spapr_phb_vfio_finish_realize; > + spc->dma_init_window =3D spapr_phb_vfio_dma_init_window; > spc->eeh_set_option =3D spapr_phb_vfio_eeh_set_option; > spc->eeh_get_state =3D spapr_phb_vfio_eeh_get_state; > spc->eeh_reset =3D spapr_phb_vfio_eeh_reset; > diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h > index f592276..f556a41 100644 > --- a/include/hw/pci-host/spapr.h > +++ b/include/hw/pci-host/spapr.h > @@ -48,7 +48,8 @@ typedef struct sPAPRPHBVFIOState sPAPRPHBVFIOState; > struct sPAPRPHBClass { > PCIHostBridgeClass parent_class; > =20 > - void (*finish_realize)(sPAPRPHBState *sphb, Error **errp); > + int (*dma_init_window)(sPAPRPHBState *sphb, uint32_t liobn, > + uint32_t page_shift, uint64_t window_size_hin= t); > int (*eeh_set_option)(sPAPRPHBState *sphb, unsigned int addr, int op= tion); > int (*eeh_get_state)(sPAPRPHBState *sphb, int *state); > int (*eeh_reset)(sPAPRPHBState *sphb, int option); --=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 --D6IIOQQv2Iwyp54J Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVJLfPAAoJEGw4ysog2bOSG6cP/il5KO6+4KoltUCPnNU3Vv4/ 2Zg3le1A5RD7WASNu2USI0UySpHS47YTP3jvPjM0YGjA7RMTWe2uSFnE968gaszO 21AwE/CuoGSBEQPZYCkOUK0x4/QJ6qriiVnaAsq67W7Xr0Wkcfqo37nG/AdDrBsH 3kNSbaMsBQnnRiY5lUV2GxcJKwzuB/YesxXYNisdyaWan6Loox+0wKhF+uHiz0B2 fhPLu6Ki7khjFsRmrnwsCTOA3k3B4Xp6Ze/eaURWIWWbXQp08vqMtDP4t9jH9xjg zn/jwuxn4LwTjzoq6zz6tJyLiQgm/4zAo7Qtw4qsFJRUWxQGbOtOFaT0kKiwN+++ Twc7oZ7aRP2VHFcfQ6LCDy+I/OOmWvt2g9VP/C0PyagD8AC10hwZoDF6JiggPqnA oVFI+IRdGKdiA8GtZSjd79l9zKHzNqoNR2sQIp6TkNhz2xXfA+Ecpwgnu6m4NoMv 0zzxjgASomRX8OGb7dTncX5b0yCWTmUXcOzvvxqyCC+2C1M5fT+Ryt3Qz4r2ertp gbOH7Cvyp+iuy4EUR9lg2RcQL2jYtapkgFxqZD86caRP2go3NNakWVHSdg4KoqNR EsGkAnr92HP3ofOhAutVSfPl2+RlOwGNdcFy5y98qgnV2Ox5z9l9FG/0cuB1lsb8 bJtkSr2cxtZXiK6QEQRn =l0Fs -----END PGP SIGNATURE----- --D6IIOQQv2Iwyp54J--