From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47833) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zvea7-0003wC-Qo for qemu-devel@nongnu.org; Mon, 09 Nov 2015 00:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zvea4-0008Hc-Ty for qemu-devel@nongnu.org; Mon, 09 Nov 2015 00:01:27 -0500 Date: Mon, 9 Nov 2015 16:01:49 +1100 From: David Gibson Message-ID: <20151109050149.GF18558@voom.redhat.com> References: <1446678366-15082-1-git-send-email-sukadev@linux.vnet.ibm.com> <563FFD9C.7070407@ozlabs.ru> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FeAIMMcddNRN4P4/" Content-Disposition: inline In-Reply-To: <563FFD9C.7070407@ozlabs.ru> Subject: Re: [Qemu-devel] [PATCH v2 1/1] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexey Kardashevskiy Cc: stewart@linux.vnet.ibm.com, benh@au1.ibm.com, nacc@linux.vnet.ibm.com, agraf@suse.de, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, paulus@au1.ibm.com, Sukadev Bhattiprolu --FeAIMMcddNRN4P4/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Nov 09, 2015 at 12:57:48PM +1100, Alexey Kardashevskiy wrote: > On 11/05/2015 10:06 AM, Sukadev Bhattiprolu wrote: > >Implement RTAS_SYSPARM_PROCESSOR_MODULE_INFO parameter to rtas_get_syspa= rm() > >call in qemu. This call returns the processor module (socket), chip and = core > >information as specified in section 7.3.16.18 of PAPR v2.7. > > > >We walk the /proc/device-tree to determine the number of chips, cores and > >modules in the _host_ system and return this info to the guest applicati= on > >that makes the rtas_get_sysparm() call. > > > >We currently hard code the number of module_types to 1, but we should de= termine > >that dynamically somehow later. > > > >Thanks to input from Nishanth Aravamudan and Alexey Kardashevsk. >=20 > "iy" is missing :) >=20 >=20 > > > >Signed-off-by: Sukadev Bhattiprolu > >--- > >Changelog[v2]: > > [Alexey Kardashevsk] Use existing interfaces like ldl_be_p(), > > stw_be_phys(), g_hash_table_new_full(), error_report() = rather > > than re-inventing; fix indentation, function prottypes = etc; > > Drop the fts() interface (which doesn't seem to be avai= lable > > on mingw32/mingw64) and use opendir() to walk specific > > directories in the directory tree. > >--- > > hw/ppc/Makefile.objs | 1 + > > hw/ppc/spapr_rtas.c | 35 +++++++ > > hw/ppc/spapr_rtas_modinfo.c | 230 ++++++++++++++++++++++++++++++++++++= ++++++++ > > hw/ppc/spapr_rtas_modinfo.h | 12 +++ > > include/hw/ppc/spapr.h | 1 + > > 5 files changed, 279 insertions(+) > > create mode 100644 hw/ppc/spapr_rtas_modinfo.c > > create mode 100644 hw/ppc/spapr_rtas_modinfo.h > > > >diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs > >index c1ffc77..57c6b02 100644 > >--- a/hw/ppc/Makefile.objs > >+++ b/hw/ppc/Makefile.objs > >@@ -4,6 +4,7 @@ obj-y +=3D ppc.o ppc_booke.o > > obj-$(CONFIG_PSERIES) +=3D spapr.o spapr_vio.o spapr_events.o > > obj-$(CONFIG_PSERIES) +=3D spapr_hcall.o spapr_iommu.o spapr_rtas.o > > obj-$(CONFIG_PSERIES) +=3D spapr_pci.o spapr_rtc.o spapr_drc.o spapr_r= ng.o > >+obj-$(CONFIG_PSERIES) +=3D spapr_rtas_modinfo.o > > ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy) > > obj-y +=3D spapr_pci_vfio.o > > endif > >diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > >index 34b12a3..41fd8a6 100644 > >--- a/hw/ppc/spapr_rtas.c > >+++ b/hw/ppc/spapr_rtas.c > >@@ -34,6 +34,8 @@ > > #include "hw/ppc/spapr.h" > > #include "hw/ppc/spapr_vio.h" > > #include "qapi-event.h" > >+ > >+#include "spapr_rtas_modinfo.h" > > #include "hw/boards.h" > > > > #include > >@@ -240,6 +242,39 @@ static void rtas_ibm_get_system_parameter(PowerPCCP= U *cpu, > > target_ulong ret =3D RTAS_OUT_SUCCESS; > > > > switch (parameter) { > >+ case RTAS_SYSPARM_PROCESSOR_MODULE_INFO: { > >+ int i; > >+ int offset =3D 0; > >+ int size; >=20 > Nit - could be one line. >=20 >=20 > >+ struct rtas_module_info modinfo; > >+ > >+ if (rtas_get_module_info(&modinfo)) { > >+ break; >=20 >=20 > @ret will be still 0 in this case, set @ret to RTAS_OUT_HW_ERROR here. >=20 > Also, rtas_ibm_set_system_parameter() must return RTAS_OUT_NOT_AUTHORIZED= on > RTAS_SYSPARM_PROCESSOR_MODULE_INFO, as PAPR says. >=20 >=20 > >+ } > >+ > >+ size =3D sizeof(modinfo); > >+ size +=3D (modinfo.module_types - 1) * sizeof(struct rtas_socke= t_info); > >+ > >+ stw_be_phys(&address_space_memory, buffer+offset, size); > >+ offset +=3D 2; > >+ > >+ stw_be_phys(&address_space_memory, buffer+offset, modinfo.modul= e_types); > >+ offset +=3D 2; > >+ > >+ for (i =3D 0; i < modinfo.module_types; i++) { > >+ stw_be_phys(&address_space_memory, buffer+offset, > >+ modinfo.si[i].sockets); >=20 >=20 > checkpatch.pl does not warn on this but new lines start under opening bra= ce > in the previous line. >=20 > In terms on vim, it would be: > set expandtab > set tabstop=3D4 > set shiftwidth=3D4 > set cino=3D:0,(0 >=20 >=20 >=20 > >+ offset +=3D 2; > >+ stw_be_phys(&address_space_memory, buffer+offset, > >+ modinfo.si[i].chips); > >+ offset +=3D 2; > >+ stw_be_phys(&address_space_memory, buffer+offset, > >+ modinfo.si[i].cores_per_chip); > >+ offset +=3D 2; > >+ } > >+ break; > >+ } > >+ > > case RTAS_SYSPARM_SPLPAR_CHARACTERISTICS: { > > char *param_val =3D g_strdup_printf("MaxEntCap=3D%d," > > "DesMem=3D%llu," > >diff --git a/hw/ppc/spapr_rtas_modinfo.c b/hw/ppc/spapr_rtas_modinfo.c > >new file mode 100644 > >index 0000000..068fc2c > >--- /dev/null > >+++ b/hw/ppc/spapr_rtas_modinfo.c > >@@ -0,0 +1,230 @@ > >+/* > >+ * QEMU PowerPC pSeries Logical Partition (aka sPAPR) hardware System E= mulator > >+ * > >+ * Hypercall based emulated RTAS >=20 >=20 > This is a description of hw/ppc/spapr_rtas.c, not of the new file. >=20 > Not sure the new code deserves a separate file, I'd either: > - add it into hw/ppc/spapr_rtas.c OR > - move rtas_ibm_get_system_parameter() + rtas_ibm_set_system_parameter() = to > a separate file (let's call it hw/ppc/spapr_rtas_syspar.c) and add this = new > parameter there as there will be new parameters in the future anyway. >=20 > But I'll leave to the maintainer (David, hi :) ). Actually it probably should go in target-ppc/kvm.c. Looking up things on the host in this way only makes sense for KVM, and we have other code in there that looks in the host /proc/device-tree. --=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 --FeAIMMcddNRN4P4/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWQCi9AAoJEGw4ysog2bOSIvsP/1idi9CjWIigGMsL8NQa7sY7 tFkRRXfzk5X8Oif6nUJTk1RpLt1k5uUPWCeHIbNzsE5iYkrQKaYVSUyFLfhDBv3I RmEJ415wMTxNT72AaMU36ovLqDOvjkcWp9m2+KWhvZSJJwCQxs+iBr517HSQ923N mlWo7z06SEuO7JT2oU6gAM8Vpyvi8HczcgvqSD4hk50HKXIS2ugUbTiVd/VWUmv6 l06+3xCfobIEM31jIh+lw01QEq30kk0FQ1Twnq7P+QHxxbuaQwKqPbXTWmnzkey+ yEW5L6e9P7ZVMc5+44ENfhYyIbCvQ8zMdnqkV6AdyxyhQyYnNpGowxo2lEiDI+LG EWxS/G/3/GP/c8o5E3JOe6GNocp4zbCw/xEfnlOC6QLD+yZpI9RHRlTq8UeYxFkY yxEOnOi3AC0rFq1jMbOPXI3MLJslY0QDOPPczwsWKidmYOC2/WKEqsmHFZOReztd 8o36xlwp2DghYxu1jSnif6Vl/uABJ7L8DvZ9szzt4BwkmFBBHiYrH66zE5jg4Cmm hLYEMdt6dAJScXu4L7wahOKk2pRfi2ezy+1BXQxZhuool1NHQ0P1nVVrZncXdJXf 6Mp9jtodHfGanDzZEGZI16uX5m+NiF1KIZ/+VoL0PFyPXALoP/ApRQi/hlpsU040 kNlaApNjzZ1nTwQOKDvO =r4A6 -----END PGP SIGNATURE----- --FeAIMMcddNRN4P4/--