From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFrIc-0002gf-B2 for qemu-devel@nongnu.org; Mon, 26 Jan 2015 16:34:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFrIN-0008AN-K1 for qemu-devel@nongnu.org; Mon, 26 Jan 2015 16:34:22 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:49927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFrIN-0008A9-4S for qemu-devel@nongnu.org; Mon, 26 Jan 2015 16:34:07 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 26 Jan 2015 16:34:06 -0500 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <20150116062155.GK5297@voom.fritz.box> References: <1419337831-16552-1-git-send-email-mdroth@linux.vnet.ibm.com> <1419337831-16552-4-git-send-email-mdroth@linux.vnet.ibm.com> <20150116062155.GK5297@voom.fritz.box> Message-ID: <20150126052126.23721.46247@loki> Date: Sun, 25 Jan 2015 23:21:26 -0600 Subject: Re: [Qemu-devel] [PATCH v4 03/17] spapr_rtas: add get/set-power-level RTAS interfaces List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson Cc: aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, ncmike@ncultra.org, qemu-ppc@nongnu.org, tyreld@linux.vnet.ibm.com, bharata.rao@gmail.com, nfont@linux.vnet.ibm.com Quoting David Gibson (2015-01-16 00:21:55) > On Tue, Dec 23, 2014 at 06:30:17AM -0600, Michael Roth wrote: > > From: Nathan Fontenot > > = > > Signed-off-by: Nathan Fontenot > > Signed-off-by: Michael Roth > > --- > > hw/ppc/spapr_rtas.c | 25 +++++++++++++++++++++++++ > > 1 file changed, 25 insertions(+) > > = > > diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c > > index 2ec2a8e..a2fb533 100644 > > --- a/hw/ppc/spapr_rtas.c > > +++ b/hw/ppc/spapr_rtas.c > > @@ -290,6 +290,27 @@ static void rtas_ibm_os_term(PowerPCCPU *cpu, > > rtas_st(rets, 0, ret); > > } > > = > > +static void rtas_set_power_level(PowerPCCPU *cpu, sPAPREnvironment *sp= apr, > > + uint32_t token, uint32_t nargs, > > + target_ulong args, uint32_t nret, > > + target_ulong rets) > > +{ > > + /* we currently only use a single, "live insert" powerdomain for > > + * hotplugged/dlpar'd resources, so the power is always live/full = (100) > > + */ > = > Even so, you should at least validate the number of args and rets, and > preferably check that the user isn't attempt to set something for some > other, non-existent power domain. > = > > + rtas_st(rets, 0, RTAS_OUT_SUCCESS); > > + rtas_st(rets, 1, 100); > > +} > > + > > +static void rtas_get_power_level(PowerPCCPU *cpu, sPAPREnvironment *sp= apr, > > + uint32_t token, uint32_t nargs, > > + target_ulong args, uint32_t nret, > > + target_ulong rets) > > +{ > > + rtas_st(rets, 0, RTAS_OUT_SUCCESS); > > + rtas_st(rets, 1, 100); > > +} > > + > > static struct rtas_call { > > const char *name; > > spapr_rtas_fn fn; > > @@ -419,6 +440,10 @@ static void core_rtas_register_types(void) > > rtas_ibm_set_system_parameter); > > spapr_rtas_register(RTAS_IBM_OS_TERM, "ibm,os-term", > > rtas_ibm_os_term); > > + spapr_rtas_register(RTAS_SET_POWER_LEVEL, "set-power-level", > > + rtas_set_power_level); > > + spapr_rtas_register(RTAS_GET_POWER_LEVEL, "get-power-level", > > + rtas_get_power_level); > > } > > = > > type_init(core_rtas_register_types) > = > This code should probably go in spapr_drc.c. The idea that spapr_rtas > was just the RTAS dispatch code, and RTAS functions that had no other > home. Generally RTAS functions should live with the devices they're > connected to. In this particular case the calls act on a "power domain" which isn't actually modeled in QEMU (we just assume a single "live-insertion" domain which just magically does everything we want), so I think it makes sense to leave these here. But for the others it does make sense to tie them with spapr_drc.c, or maybe spapr_drc_rtas.c to maintain the encapsulation of DRC state behind well-defined accessors. > = > -- = > David Gibson | I'll have my music baroque, and my code > david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _othe= r_ > | _way_ _around_! > http://www.ozlabs.org/~dgibson