From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs3mI-0003gx-PL for qemu-devel@nongnu.org; Thu, 06 Oct 2016 04:11:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs3mD-0000ic-1X for qemu-devel@nongnu.org; Thu, 06 Oct 2016 04:11:41 -0400 Date: Thu, 6 Oct 2016 19:11:19 +1100 From: David Gibson Message-ID: <20161006081119.GM18733@umbus.fritz.box> References: <1475722987-18644-1-git-send-email-david@gibson.dropbear.id.au> <1475722987-18644-2-git-send-email-david@gibson.dropbear.id.au> <1c9498b5-469b-be4f-6a7f-f4b0e7dae4aa@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xtx0sNU5lZ46KfgK" Content-Disposition: inline In-Reply-To: <1c9498b5-469b-be4f-6a7f-f4b0e7dae4aa@redhat.com> Subject: Re: [Qemu-devel] [RFC 1/4] 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, benh@kernel.crashing.org, thuth@redhat.com, agraf@suse.de, mst@redhat.com, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, bharata@linux.vnet.ibm.com, abologna@redhat.com, mpolednik@redhat.com --xtx0sNU5lZ46KfgK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 06, 2016 at 09:10:41AM +0200, Laurent Vivier wrote: >=20 >=20 > On 06/10/2016 05:03, 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; >=20 > Why do you use new "const" instead of already defined "#define" from > spapr.h? Because the point of this change is that all the knowledge about where the PHBis placed is supposed to be restrictedto this function. Making these local consts enforces that. --=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 --xtx0sNU5lZ46KfgK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJX9gckAAoJEGw4ysog2bOSxjcQAMCqHheKPnQGVl6VWbAjRuDx fMPs7Fx0PwgLdPtxvD8q979BZQRPTgY4Anp1WabFgCnqV9JRWVg2jvFYcjEVYitc vKnUa/FOl+w/ETy0uDimr4rHQVuC+ILLnDyk/vCQQ0i+NXBwgIecs+MMyiaJR0Ws Gn8D8FLKYm+q+7Hm9kD0UcNRSNYEQizf6I43vLQuE5XENZMyDNzSuERaip10r19h 2FWSXjPOT4aB0VsbndNqChoTys5Q54Qz0u+kW+Xh/Q2SYKOrir8efsZXyhpNuJJz N6B7rE9tZ1BRhYVuxH+cBzxkvUmBTddU5Fu+1JfmMTcA2EWX2dZ1UtuGRfckhX/V 5gFRheXz9cUaF5ufOed6m0Ihn0MD2X3ypxGuJwbWYm7wnQCxanmjXVBRT8IYPMVj A0QYxmOpUcqM17REF1SvkurAHsBT4mIx5b7qzyEh0fquqtE/fckp6uASJr0O8Zvn bCK1M3WV3u1GDuytYsKSaYITsoZeavAGqBMmd7FXl5TQ1tSUJ0NmU161oxAeXpjJ K0gdQ3uUHBCbJKA3sDVcIRU+r571VV01/N1TxxzbznRLEboJ0GTjp4kSn0i5ddFX kti26lIGyrkRHzSG0OEuQcWWejegqKbnP54dixDkPzMJ9DFDgSMcnQ+EkHCPD2BA KUuc3Yaa7LcFsQNCQCXN =kS2l -----END PGP SIGNATURE----- --xtx0sNU5lZ46KfgK--