From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z7EhV-0005YG-7s for qemu-devel@nongnu.org; Mon, 22 Jun 2015 23:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z7EhS-0005y9-LA for qemu-devel@nongnu.org; Mon, 22 Jun 2015 23:16:41 -0400 Date: Tue, 23 Jun 2015 11:33:58 +1000 From: David Gibson Message-ID: <20150623013358.GW13352@voom.redhat.com> References: <1434709077-17491-1-git-send-email-bharata@linux.vnet.ibm.com> <1434709077-17491-2-git-send-email-bharata@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ucW7QTJbHsz5ya91" Content-Disposition: inline In-Reply-To: <1434709077-17491-2-git-send-email-bharata@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [RFC PATCH v4 1/5] spapr: Initialize hotplug memory address space List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bharata B Rao Cc: mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com, imammedo@redhat.com --ucW7QTJbHsz5ya91 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 19, 2015 at 03:47:53PM +0530, Bharata B Rao wrote: > Initialize a hotplug memory region under which all the hotplugged > memory is accommodated. Also enable memory hotplug by setting > CONFIG_MEM_HOTPLUG. >=20 > Modelled on i386 memory hotplug. >=20 > Signed-off-by: Bharata B Rao > --- > default-configs/ppc64-softmmu.mak | 1 + > hw/ppc/spapr.c | 28 ++++++++++++++++++++++++++++ > include/hw/ppc/spapr.h | 12 ++++++++++++ > 3 files changed, 41 insertions(+) >=20 > diff --git a/default-configs/ppc64-softmmu.mak b/default-configs/ppc64-so= ftmmu.mak > index ab62cc7..e77cb1a 100644 > --- a/default-configs/ppc64-softmmu.mak > +++ b/default-configs/ppc64-softmmu.mak > @@ -52,3 +52,4 @@ CONFIG_XICS_KVM=3D$(and $(CONFIG_PSERIES),$(CONFIG_KVM)) > # For PReP > CONFIG_MC146818RTC=3Dy > CONFIG_ISA_TESTDEV=3Dy > +CONFIG_MEM_HOTPLUG=3Dy > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 5ca817c..87a29dc 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1549,6 +1549,34 @@ static void ppc_spapr_init(MachineState *machine) > memory_region_add_subregion(sysmem, 0, rma_region); > } > =20 > + /* initialize hotplug memory address space */ > + if (machine->ram_size < machine->maxram_size) { > + ram_addr_t hotplug_mem_size =3D machine->maxram_size - machine->= ram_size; > + > + if (machine->ram_slots > SPAPR_MAX_RAM_SLOTS) { > + error_report("unsupported amount of memory slots: %"PRIu64, > + machine->ram_slots); > + exit(EXIT_FAILURE); > + } > + > + spapr->hotplug_memory.base =3D ROUND_UP(machine->ram_size, > + SPAPR_HOTPLUG_MEM_ALIGN); > + > + hotplug_mem_size +=3D SPAPR_HOTPLUG_MEM_ALIGN * machine->ram_slo= ts; I'm not sure what this adjustment is about. Are you putting a gap of size SPAPR_HOTPLUG_MEM_ALIGN between each memory slot? That doesn't see to match the DRC initialization code in the next patch which assigns all the LMBs in the hotplug area contiguous addresses. > + if ((spapr->hotplug_memory.base + hotplug_mem_size) < > + hotplug_mem_size) { > + error_report("unsupported amount of maximum memory: " RAM_AD= DR_FMT, > + machine->maxram_size); > + exit(EXIT_FAILURE); > + } > + > + memory_region_init(&spapr->hotplug_memory.mr, OBJECT(spapr), > + "hotplug-memory", hotplug_mem_size); > + memory_region_add_subregion(sysmem, spapr->hotplug_memory.base, > + &spapr->hotplug_memory.mr); > + } > + > filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); > if (!filename) { > error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin"); > diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h > index 91a61ab..8a1929b 100644 > --- a/include/hw/ppc/spapr.h > +++ b/include/hw/ppc/spapr.h > @@ -5,6 +5,7 @@ > #include "hw/boards.h" > #include "hw/ppc/xics.h" > #include "hw/ppc/spapr_drc.h" > +#include "hw/mem/pc-dimm.h" > =20 > struct VIOsPAPRBus; > struct sPAPRPHBState; > @@ -76,6 +77,7 @@ struct sPAPRMachineState { > =20 > /*< public >*/ > char *kvm_type; > + MemoryHotplugState hotplug_memory; > }; > =20 > #define H_SUCCESS 0 > @@ -609,4 +611,14 @@ int spapr_rtc_import_offset(DeviceState *dev, int64_= t legacy_offset); > =20 > #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */ > =20 > +/* > + * This defines the maximum number of DIMM slots we can have for sPAPR > + * guest. This is not defined by sPAPR but we are defining it to 32 slots > + * based on default number of slots provided by PowerPC kernel. > + */ > +#define SPAPR_MAX_RAM_SLOTS 32 > + > +/* 1GB alignment for hotplug memory region */ > +#define SPAPR_HOTPLUG_MEM_ALIGN (1ULL << 30) > + > #endif /* !defined (__HW_SPAPR_H__) */ --=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 --ucW7QTJbHsz5ya91 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJViLeGAAoJEGw4ysog2bOSti0P/14Uu9tnk+7Zy0QsMWSBw+78 4ZSFwnKycm5mVmZAM49o722D6iC5Du2Xs2mNp4qT7CBNOtr052j+6jjteUgGUS7r H5OvxI857zaXAWcsCxfg6/nN/VcLbxgZ038hsH8+HEizjPeFkol+EWXEJWxz9Ysa 4vclXwFmr/Nv5JXB1PkYu6+WJfHyYEhz8uEQe1ztGpO9jVzVylVkQMVbnT99I/z7 ipTJdNBMu7fw6LsSBw82F/mIFzf84ZwjQUaG9jVK9bYNM28rYAHGEW8n7x8FI71P WZPQxiwmU6ylsgK8BWWjoh3odT8+w1ybn8VFt4QTVn1/tLpHArJ9whDGkOX+rC8d mtgbMIOVXrtWTUoBYfZMmri4vqkmtgMvemNbkILN0W+Ac11uIEmzJDBAIWLiNHu4 vWT8Cj+2ysLBAvlKwXeSMt3A0Z4u+eyKAv3OhnedTrgF+/6F2LeODZpNkYzxoEPX 8V7wM8sy8k7LGCZf+8yfELn/rvyrmeoOjw2y5Jx0lEJwPsClX8A4c9gZ9Q5HRUKK +uR+mywaVe4NaAwGpN9Z90fASNHQdYekzYLyHTbuxpHmF1xICSeCJOa72LltJjzR 0m/Wp4DgaYxGooc4kR2l75sDqs0EJV0oKJ3Ac9uGh+Mh/DKONub5AjrOLQzaasFC mK0KErqAAQzWS16keqYe =NNDC -----END PGP SIGNATURE----- --ucW7QTJbHsz5ya91--