All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
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 <sukadev@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v2 1/1] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO)
Date: Mon, 9 Nov 2015 16:01:49 +1100	[thread overview]
Message-ID: <20151109050149.GF18558@voom.redhat.com> (raw)
In-Reply-To: <563FFD9C.7070407@ozlabs.ru>

[-- Attachment #1: Type: text/plain, Size: 6000 bytes --]

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_sysparm()
> >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 application
> >that makes the rtas_get_sysparm() call.
> >
> >We currently hard code the number of module_types to 1, but we should determine
> >that dynamically somehow later.
> >
> >Thanks to input from Nishanth Aravamudan and Alexey Kardashevsk.
> 
> "iy" is missing :)
> 
> 
> >
> >Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
> >---
> >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 available
> >                 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 += ppc.o ppc_booke.o
> >  obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
> >  obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
> >  obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
> >+obj-$(CONFIG_PSERIES) += spapr_rtas_modinfo.o
> >  ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
> >  obj-y += 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 <libfdt.h>
> >@@ -240,6 +242,39 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *cpu,
> >      target_ulong ret = RTAS_OUT_SUCCESS;
> >
> >      switch (parameter) {
> >+    case RTAS_SYSPARM_PROCESSOR_MODULE_INFO: {
> >+        int i;
> >+        int offset = 0;
> >+        int size;
> 
> Nit - could be one line.
> 
> 
> >+        struct rtas_module_info modinfo;
> >+
> >+        if (rtas_get_module_info(&modinfo)) {
> >+            break;
> 
> 
> @ret will be still 0 in this case, set @ret to RTAS_OUT_HW_ERROR here.
> 
> Also, rtas_ibm_set_system_parameter() must return RTAS_OUT_NOT_AUTHORIZED on
> RTAS_SYSPARM_PROCESSOR_MODULE_INFO, as PAPR says.
> 
> 
> >+        }
> >+
> >+        size = sizeof(modinfo);
> >+        size += (modinfo.module_types - 1) * sizeof(struct rtas_socket_info);
> >+
> >+        stw_be_phys(&address_space_memory, buffer+offset, size);
> >+        offset += 2;
> >+
> >+        stw_be_phys(&address_space_memory, buffer+offset, modinfo.module_types);
> >+        offset += 2;
> >+
> >+        for (i = 0; i < modinfo.module_types; i++) {
> >+            stw_be_phys(&address_space_memory, buffer+offset,
> >+                                    modinfo.si[i].sockets);
> 
> 
> checkpatch.pl does not warn on this but new lines start under opening brace
> in the previous line.
> 
> In terms on vim, it would be:
> set expandtab
> set tabstop=4
> set shiftwidth=4
> set cino=:0,(0
> 
> 
> 
> >+            offset += 2;
> >+            stw_be_phys(&address_space_memory, buffer+offset,
> >+                                    modinfo.si[i].chips);
> >+            offset += 2;
> >+            stw_be_phys(&address_space_memory, buffer+offset,
> >+                                    modinfo.si[i].cores_per_chip);
> >+            offset += 2;
> >+        }
> >+        break;
> >+    }
> >+
> >      case RTAS_SYSPARM_SPLPAR_CHARACTERISTICS: {
> >          char *param_val = g_strdup_printf("MaxEntCap=%d,"
> >                                            "DesMem=%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 Emulator
> >+ *
> >+ * Hypercall based emulated RTAS
> 
> 
> This is a description of hw/ppc/spapr_rtas.c, not of the new file.
> 
> 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.
> 
> 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.

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-11-09  5:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 23:06 [Qemu-devel] [PATCH v2 1/1] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO) Sukadev Bhattiprolu
2015-11-09  1:57 ` Alexey Kardashevskiy
2015-11-09  5:01   ` David Gibson [this message]
2015-11-10  3:57   ` Sukadev Bhattiprolu
2015-11-10  4:25     ` Alexey Kardashevskiy
2015-11-10  4:46       ` Sukadev Bhattiprolu
2015-11-10  6:58         ` Alexey Kardashevskiy
2015-11-10 18:27           ` Sukadev Bhattiprolu
2015-11-09  4:58 ` David Gibson
2015-11-10  4:22   ` Sukadev Bhattiprolu
2015-11-10  9:53     ` Thomas Huth
2015-11-13 20:29       ` Sukadev Bhattiprolu
2015-11-11  0:17     ` David Gibson
2015-11-11  0:56       ` Nishanth Aravamudan
2015-11-11  1:41         ` David Gibson
2015-11-11 22:10           ` Nishanth Aravamudan
2015-11-12  4:47             ` David Gibson
2015-11-12 16:46               ` Nishanth Aravamudan
2015-12-01  3:41                 ` David Gibson
2015-12-05  1:04                   ` Nishanth Aravamudan
2015-12-10  3:55                     ` David Gibson
2015-11-13 20:21       ` Sukadev Bhattiprolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151109050149.GF18558@voom.redhat.com \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=benh@au1.ibm.com \
    --cc=nacc@linux.vnet.ibm.com \
    --cc=paulus@au1.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stewart@linux.vnet.ibm.com \
    --cc=sukadev@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.