From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buTMc-0004tO-7f for qemu-devel@nongnu.org; Wed, 12 Oct 2016 19:55:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buTMa-0005c5-T8 for qemu-devel@nongnu.org; Wed, 12 Oct 2016 19:55:10 -0400 Date: Thu, 13 Oct 2016 10:25:04 +1100 From: David Gibson Message-ID: <20161012232504.GB18039@umbus.fritz.box> References: <1476247497-6976-1-git-send-email-david@gibson.dropbear.id.au> <1476247497-6976-5-git-send-email-david@gibson.dropbear.id.au> <376499b1-5464-a89a-d4d4-b031c8fbc9bd@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5I6of5zJg18YgZEa" Content-Disposition: inline In-Reply-To: <376499b1-5464-a89a-d4d4-b031c8fbc9bd@redhat.com> Subject: Re: [Qemu-devel] [PATCHv2 4/7] spapr_pci: Delegate placement of PCI host bridges to machine type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: agraf@suse.de, mst@redhat.com, Andrea Bolognani , aik@ozlabs.ru, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, benh@kernel.crashing.org --5I6of5zJg18YgZEa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 12, 2016 at 11:26:05AM +0200, Laurent Vivier wrote: >=20 >=20 > On 12/10/2016 06:44, David Gibson wrote: > > The 'spapr-pci-host-bridge' represents the virtual PCI host bridge (PHB) > > for a PAPR guest. Unlike on x86, it's routine on Power (both bare metal > > and PAPR guests) to have numerous independent PHBs, each controlling a > > separate PCI domain. > >=20 > > There are two ways of configuring the spapr-pci-host-bridge device: fir= st > > it can be done fully manually, specifying the locations and sizes of all > > the IO windows. This gives the most control, but is very awkward with 6 > > mandatory parameters. Alternatively just an "index" can be specified > > which essentially selects from an array of predefined PHB locations. > > The PHB at index 0 is automatically created as the default PHB. > >=20 > > The current set of default locations causes some problems for guests wi= th > > large RAM (> 1 TiB) or PCI devices with very large BARs (e.g. big nVidia > > GPGPU cards via VFIO). Obviously, for migration we can only change the > > locations on a new machine type, however. > >=20 > > This is awkward, because the placement is currently decided within the > > spapr-pci-host-bridge code, so it breaks abstraction to look inside the > > machine type version. > >=20 > > So, this patch delegates the "default mode" PHB placement from the > > spapr-pci-host-bridge device back to the machine type via a public meth= od > > in sPAPRMachineClass. It's still a bit ugly, but it's about the best we > > can do. > >=20 > > For now, this just changes where the calculation is done. It doesn't > > change the actual location of the host bridges, or any other behaviour. > >=20 > > Signed-off-by: David Gibson > > --- > > hw/ppc/spapr.c | 34 ++++++++++++++++++++++++++++++++++ > > hw/ppc/spapr_pci.c | 22 ++++++++-------------- > > include/hw/pci-host/spapr.h | 11 +---------- > > include/hw/ppc/spapr.h | 4 ++++ > > 4 files changed, 47 insertions(+), 24 deletions(-) > >=20 > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > > index 03e3803..f6e9c2a 100644 > > --- a/hw/ppc/spapr.c > > +++ b/hw/ppc/spapr.c > > @@ -2370,6 +2370,39 @@ static HotpluggableCPUList *spapr_query_hotplugg= able_cpus(MachineState *machine) > > return head; > > } > > =20 > > +static void spapr_phb_placement(sPAPRMachineState *spapr, uint32_t ind= ex, > > + uint64_t *buid, hwaddr *pio, hwaddr *p= io_size, > > + hwaddr *mmio, hwaddr *mmio_size, > > + unsigned n_dma, uint32_t *liobns, Erro= r **errp) > > +{ > > + const uint64_t base_buid =3D 0x800000020000000ULL; > > + const hwaddr phb0_base =3D 0x10000000000ULL; /* 1 TiB */ > > + const hwaddr phb_spacing =3D 0x1000000000ULL; /* 64 GiB */ > > + const hwaddr mmio_offset =3D 0xa0000000; /* 2 GiB + 512 MiB */ > > + const hwaddr pio_offset =3D 0x80000000; /* 2 GiB */ > > + const uint32_t max_index =3D 255; > > + > > + hwaddr phb_base; > > + int i; > > + > > + if (index > max_index) { > > + error_setg(errp, "\"index\" for PAPR PHB is too large (max %u)= ", > > + max_index); > > + return; > > + } > > + > > + *buid =3D base_buid + index; > > + for (i =3D 0; i < n_dma; ++i) { > > + liobns[i] =3D SPAPR_PCI_LIOBN(index, i); > > + } > > + > > + phb_base =3D phb0_base + index * phb_spacing; > > + *pio =3D phb_base + pio_offset; > > + *pio_size =3D SPAPR_PCI_IO_WIN_SIZE; > > + *mmio =3D phb_base + mmio_offset; > > + *mmio_size =3D SPAPR_PCI_MMIO_WIN_SIZE; >=20 > sphb->io_win_size (*pio_size) and sphb->mem_win_size (*mmio_size) were > previously initialized from spapr_phb_properties[], you overwrite these > values now. Is this what you want? Uuuhhhh... I guess not. I put the sizes in here because I wanted to have all the configuration for the common case in one place, rather than split between phb_placement() and the default properties. But you're right, it does introduce a real, if small, behaviour change, which this patch isn't supposed to do. I'll change it. --=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 --5I6of5zJg18YgZEa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX/sZMAAoJEGw4ysog2bOS1AAP/Ra/qsa11HCI1yP8hI74i4HI l2tXr9fK9tM1Elx8vGSsDcyQdz6JriTokn4+IbAMfvIueJsb8IdplYo+SCEsawKz TSxE9e38lOT0e3JDxme3+bJNFmJnLx/lGCHI7QnIMsVfm8/4TcmAs3lNpsx+114z dU1a8j16pIhtjeIUbXyFtIz2filwz624+Jvl3MHAVXQyBsvY+xGdKvBDM0cZIlwA QGBN8yrdbBCUVluwfr7xfjUCLuIkdG7hPnftW1b+ZKzYjoji4ONX4g41qZIhFrG2 h5h1tIcQBSIDcieSuEVhkyyAURoO6kn7urjWNk/Dpx//5hdNg9qewpL8DYOkEjSF 5EW7vzb2ITXhuYSAQshv+SDFH0+KU2VFpVzhOc0RS1cLLDknv26IZicKE8SyZ7nJ kC58KUVclcL/Kk3fEo6OEzFnuQqO7sGL5qf5AzDuUFN/jXxqRXhTMobe8q+xng+f A+yx1iUO5Z7PZrX7eMQS8bxecP5q2r4YC6LLVskaNrRoMNUCq0mhXTBQFzR4dgZz ky81eTSmXddYxKGYT6TQAvq2gfVTBYAwW2GgYSUQ3SCTTmv/iFCHYsyRuLYnkEch TD2ekEdsY5q+KwGTbWG6F/YPCgjbN37/yjeIS9ounWItFN5nbP1QAARBFiuttGig 8JF7bAa3UNK97IKegThr =WMFd -----END PGP SIGNATURE----- --5I6of5zJg18YgZEa--