From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Alexander Graf <agraf@suse.de>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>,
qemu-devel qemu-devel <qemu-devel@nongnu.org>,
"qemu-ppc@nongnu.org list:PowerPC" <qemu-ppc@nongnu.org>,
Paul Mackerras <paulus@samba.org>,
Andreas Faerber <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 09/12] spapr-vio: move special case handling for reg=0 to vio
Date: Thu, 20 Jun 2013 09:07:55 +1000 [thread overview]
Message-ID: <1371683275.28262.1.camel@pasglop> (raw)
In-Reply-To: <D7D464DF-4407-48CE-AD0B-AA2757A90777@suse.de>
On Wed, 2013-06-19 at 23:28 +0200, Alexander Graf wrote:
> On 19.06.2013, at 22:40, Anthony Liguori wrote:
>
> > The creatively named reg field is a hypervisor assigned global
> > identifier for a virtual device. Despite the fact that no device
> > is assigned a reg of 0, guests still use it to refer to early
> > console.
> >
> > Instead of handling this in the VTY device, handle this in the VIO
> > bus since this is ultimately about how devices are decoded.
> >
> > This does not produce a change in behavior since reg=0 hcalls to
> > non-VTY devices will still fail as gloriously as they did before
> > just for a different reason (invalid device instead of invalid reg).
>
> Ben, is it true that reg=0 is guaranteed to be free, regardless of the target call?
There is no guarantee other than what qemu does... I didn't write that
code so I don't know :-) But I don't see why it can't be kept free.
> Also, are there no other PAPR calls that could possibly refer to reg=0 but
> mean something different from the VTY device?
Not that come to mind.
Ben.
>
> Alex
>
> >
> > Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> > ---
> > hw/char/spapr_vty.c | 58 ++--------------------------------------------
> > hw/ppc/spapr_vio.c | 46 ++++++++++++++++++++++++++++++++++++
> > include/hw/ppc/spapr_vio.h | 2 --
> > 3 files changed, 48 insertions(+), 58 deletions(-)
> >
> > diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c
> > index 4bac79e..45fc3ce 100644
> > --- a/hw/char/spapr_vty.c
> > +++ b/hw/char/spapr_vty.c
> > @@ -86,23 +86,6 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev)
> > return 0;
> > }
> >
> > -static VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg)
> > -{
> > - VIOsPAPRDevice *sdev;
> > -
> > - sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
> > - if (!sdev && reg == 0) {
> > - /* Hack for kernel early debug, which always specifies reg==0.
> > - * We search all VIO devices, and grab the vty with the lowest
> > - * reg. This attempts to mimic existing PowerVM behaviour
> > - * (early debug does work there, despite having no vty with
> > - * reg==0. */
> > - return spapr_vty_get_default(spapr->vio_bus);
> > - }
> > -
> > - return sdev;
> > -}
> > -
> > /* Forward declaration */
> > static target_ulong h_put_term_char(PowerPCCPU *cpu, sPAPREnvironment *spapr,
> > target_ulong opcode, target_ulong *args)
> > @@ -114,7 +97,7 @@ static target_ulong h_put_term_char(PowerPCCPU *cpu, sPAPREnvironment *spapr,
> > VIOsPAPRDevice *sdev;
> > uint8_t buf[16];
> >
> > - sdev = vty_lookup(spapr, reg);
> > + sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
> > if (!sdev) {
> > return H_PARAMETER;
> > }
> > @@ -141,7 +124,7 @@ static target_ulong h_get_term_char(PowerPCCPU *cpu, sPAPREnvironment *spapr,
> > VIOsPAPRDevice *sdev;
> > uint8_t buf[16];
> >
> > - sdev = vty_lookup(spapr, reg);
> > + sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
> > if (!sdev) {
> > return H_PARAMETER;
> > }
> > @@ -191,43 +174,6 @@ static const TypeInfo spapr_vty_info = {
> > .class_init = spapr_vty_class_init,
> > };
> >
> > -VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
> > -{
> > - VIOsPAPRDevice *sdev, *selected;
> > - BusChild *kid;
> > -
> > - /*
> > - * To avoid the console bouncing around we want one VTY to be
> > - * the "default". We haven't really got anything to go on, so
> > - * arbitrarily choose the one with the lowest reg value.
> > - */
> > -
> > - selected = NULL;
> > - QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
> > - DeviceState *iter = kid->child;
> > -
> > - /* Only look at VTY devices */
> > - if (!object_dynamic_cast(OBJECT(iter), "spapr-vty")) {
> > - continue;
> > - }
> > -
> > - sdev = VIO_SPAPR_DEVICE(iter);
> > -
> > - /* First VTY we've found, so it is selected for now */
> > - if (!selected) {
> > - selected = sdev;
> > - continue;
> > - }
> > -
> > - /* Choose VTY with lowest reg value */
> > - if (sdev->reg < selected->reg) {
> > - selected = sdev;
> > - }
> > - }
> > -
> > - return selected;
> > -}
> > -
> > static void spapr_vty_register_types(void)
> > {
> > spapr_register_hypercall(H_PUT_TERM_CHAR, h_put_term_char);
> > diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
> > index 2c5b159..ee99eec 100644
> > --- a/hw/ppc/spapr_vio.c
> > +++ b/hw/ppc/spapr_vio.c
> > @@ -77,11 +77,57 @@ static const TypeInfo spapr_vio_bus_info = {
> > .instance_size = sizeof(VIOsPAPRBus),
> > };
> >
> > +static VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus)
> > +{
> > + VIOsPAPRDevice *sdev, *selected;
> > + BusChild *kid;
> > +
> > + /*
> > + * To avoid the console bouncing around we want one VTY to be
> > + * the "default". We haven't really got anything to go on, so
> > + * arbitrarily choose the one with the lowest reg value.
> > + */
> > +
> > + selected = NULL;
> > + QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
> > + DeviceState *iter = kid->child;
> > +
> > + /* Only look at VTY devices */
> > + if (!object_dynamic_cast(OBJECT(iter), "spapr-vty")) {
> > + continue;
> > + }
> > +
> > + sdev = VIO_SPAPR_DEVICE(iter);
> > +
> > + /* First VTY we've found, so it is selected for now */
> > + if (!selected) {
> > + selected = sdev;
> > + continue;
> > + }
> > +
> > + /* Choose VTY with lowest reg value */
> > + if (sdev->reg < selected->reg) {
> > + selected = sdev;
> > + }
> > + }
> > +
> > + return selected;
> > +}
> > +
> > VIOsPAPRDevice *spapr_vio_find_by_reg(VIOsPAPRBus *bus, uint32_t reg)
> > {
> > BusChild *kid;
> > VIOsPAPRDevice *dev = NULL;
> >
> > + /* Hack for kernel early debug, which always specifies reg==0.
> > + * We search all VIO devices, and grab the vty with the lowest
> > + * reg. This attempts to mimic existing PowerVM behaviour
> > + * (early debug does work there, despite having no vty with
> > + * reg==0. */
> > + if (reg == 0) {
> > + return spapr_vty_get_default(bus);
> > + }
> > +
> > QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
> > dev = (VIOsPAPRDevice *)kid->child;
> > if (dev->reg == reg) {
> > diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h
> > index 817f5ff..f55eb90 100644
> > --- a/include/hw/ppc/spapr_vio.h
> > +++ b/include/hw/ppc/spapr_vio.h
> > @@ -127,8 +127,6 @@ void spapr_vty_create(VIOsPAPRBus *bus, CharDriverState *chardev);
> > void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd);
> > void spapr_vscsi_create(VIOsPAPRBus *bus);
> >
> > -VIOsPAPRDevice *spapr_vty_get_default(VIOsPAPRBus *bus);
> > -
> > void spapr_vio_quiesce(void);
> >
> > #endif /* _HW_SPAPR_VIO_H */
> > --
> > 1.8.0
> >
next prev parent reply other threads:[~2013-06-19 23:08 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 20:40 [Qemu-devel] [PATCH 00/12] spapr: add qtest support and refactor vty Anthony Liguori
2013-06-19 20:40 ` [Qemu-devel] [PATCH 01/12] chardev: ringbuf: add optional save parameter to save state Anthony Liguori
2013-06-20 19:49 ` Eric Blake
2013-06-19 20:40 ` [Qemu-devel] [PATCH 02/12] qtest: add spapr hypercall support Anthony Liguori
2013-06-20 15:20 ` Andreas Färber
2013-06-20 15:42 ` Anthony Liguori
2013-06-20 18:43 ` Alexander Graf
2013-06-20 18:58 ` Anthony Liguori
2013-06-20 19:28 ` [Qemu-devel] [Qemu-ppc] " Scott Wood
2013-06-20 21:57 ` [Qemu-devel] " Alexander Graf
2013-06-19 20:40 ` [Qemu-devel] [PATCH 03/12] qtest: return string from QMP commands Anthony Liguori
2013-06-20 15:24 ` Andreas Färber
2013-06-20 15:43 ` Anthony Liguori
2013-06-19 20:40 ` [Qemu-devel] [PATCH 04/12] qtest: add interface to save/restore Anthony Liguori
2013-06-20 15:38 ` Andreas Färber
2013-06-19 20:40 ` [Qemu-devel] [PATCH 05/12] spapr-vty: add qtest test case Anthony Liguori
2013-06-19 21:13 ` Alexander Graf
2013-06-19 21:43 ` Anthony Liguori
2013-06-19 21:47 ` Alexander Graf
2013-06-19 20:40 ` [Qemu-devel] [PATCH 06/12] spapr-vty: add copyright and license Anthony Liguori
2013-06-20 1:45 ` Michael Ellerman
2013-06-20 4:08 ` Alexey Kardashevskiy
2013-06-20 4:43 ` David Gibson
2013-06-20 8:52 ` Paolo Bonzini
2013-06-20 15:47 ` Andreas Färber
2013-06-19 20:40 ` [Qemu-devel] [PATCH 07/12] spapr-rtas: add CPU argument to RTAS calls Anthony Liguori
2013-06-19 21:15 ` Alexander Graf
2013-06-20 15:51 ` Andreas Färber
2013-06-20 16:10 ` Anthony Liguori
2013-06-19 20:40 ` [Qemu-devel] [PATCH 08/12] spapr-rtas: use hypercall interface and remove special vty interfaces Anthony Liguori
2013-06-19 21:24 ` Alexander Graf
2013-06-19 21:45 ` Anthony Liguori
2013-06-19 21:48 ` Alexander Graf
2013-06-19 20:40 ` [Qemu-devel] [PATCH 09/12] spapr-vio: move special case handling for reg=0 to vio Anthony Liguori
2013-06-19 21:28 ` Alexander Graf
2013-06-19 21:49 ` Anthony Liguori
2013-06-19 21:53 ` Alexander Graf
2013-06-19 23:20 ` Anthony Liguori
2013-06-19 23:07 ` Benjamin Herrenschmidt [this message]
2013-06-19 20:40 ` [Qemu-devel] [PATCH 10/12] spapr-vty: refactor the code to improve consistency Anthony Liguori
2013-06-19 21:37 ` Alexander Graf
2013-06-19 20:40 ` [Qemu-devel] [PATCH 11/12] spapr-vio: pass type to spapr_vio_find_by_reg() Anthony Liguori
2013-06-19 21:38 ` Alexander Graf
2013-06-19 21:56 ` Anthony Liguori
2013-06-19 20:40 ` [Qemu-devel] [PATCH 12/12] spapr-vty: remove unfixable FIXME Anthony Liguori
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=1371683275.28262.1.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=aliguori@us.ibm.com \
--cc=paulus@samba.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).