qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: aik@ozlabs.ru, alex.williamson@redhat.com, qemu-ppc@nongnu.org,
	qemu-devel@nongnu.org, agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH v15 1/2] sPAPR: Implement EEH RTAS calls
Date: Thu, 15 Jan 2015 12:33:59 +1100	[thread overview]
Message-ID: <20150115013359.GC5297@voom.fritz.box> (raw)
In-Reply-To: <20150115001436.GA18267@shangw>

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

On Thu, Jan 15, 2015 at 11:14:36AM +1100, Gavin Shan wrote:
> On Wed, Jan 14, 2015 at 12:39:35PM +1100, David Gibson wrote:
> >On Mon, Jan 05, 2015 at 11:26:27AM +1100, Gavin Shan wrote:
> >> The emulation for EEH RTAS requests from guest isn't covered
> >> by QEMU yet and the patch implements them.
> >> 
> >> The patch defines constants used by EEH RTAS calls and adds
> >> callback sPAPRPHBClass::eeh_handler, which is going to be used
> >> this way:
> >> 
> >>   * RTAS calls are received in spapr_pci.c, sanity check is done
> >>     there.
> >>   * RTAS handlers handle what they can. If there is something it
> >>     cannot handle and sPAPRPHBClass::eeh_handler callback is defined,
> >>     it is called.
> >>   * sPAPRPHBClass::eeh_handler is only implemented for VFIO now. It
> >>     does ioctl() to the IOMMU container fd to complete the call. Error
> >>     codes from that ioctl() are transferred back to the guest.
> >> 
> >> [aik: defined RTAS tokens for EEH RTAS calls]
> >> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> >> ---
> >>  hw/ppc/spapr_pci.c          | 275 ++++++++++++++++++++++++++++++++++++++++++++
> >>  include/hw/pci-host/spapr.h |   7 ++
> >>  include/hw/ppc/spapr.h      |  43 ++++++-
> >>  3 files changed, 323 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> >> index 21b95b3..a150074 100644
> >> --- a/hw/ppc/spapr_pci.c
> >> +++ b/hw/ppc/spapr_pci.c
> >> @@ -406,6 +406,262 @@ static void rtas_ibm_query_interrupt_source_number(PowerPCCPU *cpu,
> >>      rtas_st(rets, 2, 1);/* 0 == level; 1 == edge */
> >>  }
> >>  
> >> +static int rtas_handle_eeh_request(sPAPREnvironment *spapr,
> >> +                                   uint64_t buid, uint32_t req, uint32_t opt)
> >> +{
> >> +    sPAPRPHBState *sphb = find_phb(spapr, buid);
> >> +    sPAPRPHBClass *info;
> >> +
> >> +    if (!sphb) {
> >> +        return -ENODEV;
> >
> >I think it would make more sense to return RTAS error codes here,
> >rather than errnos.  At present all the callers seem to ignore the
> >exact value of this return value.
> >
> >But it's not really correct to return RTAS_OUT_HW_ERROR for a bad
> >BUID, which is what this will do now.
> >
> 
> It makes sense: RTAS_OUT_PARAM_ERROR, instead of RTAS_OUT_HW_ERROR
> should be returned for invalid sPAPRPHBState and sPAPRPHBClass (as below).
> 
> It's a bit hard to have RTAS_OUT_* as the function's return value because
> RTAS_OUT_PARAM_ERROR should be returned for some RTAS calls even info->eeh_handler()
> returns negative value.

Um.. I don't quite see why that makes returning RTAS erorr values
difficult.  But I think it's made irrelevant by your suggestion later.

> >Also several of the callers have already done a find_phb() by the time
> >they call this.  Perhaps it would make more sense for this function to
> >take a sPAPRPHBState * instead of the buid.
> >
> 
> It's not sure that find_phb() called by callers() before calling this
> function. We did call find_dev() before calling this function for some
> cases. How about changing the code like this way: Drop rtas_handle_eeh_request()
> and put the logic into its callers, which would give more flexibility for
> the callers to return proper values.

Yes, I think that might be the best idea, rtas_handle_eeh_request()
seems like a bit of an odd multiplexer at the moment.

[snip]
> >The ret < 0 case isn't handled here.  It will fall through to
> >param_error_exit, which is non-obvious, and it also seems unlikely
> >that a parameter error is the only possible thing that can go wrong.
> >
> 
> Yeah, PAPR spec states the return value RTAS_OUT_SUCCESS or
> RTAS_OUT_PARAMETER_ERROR. There is no RTAS_OUT_HW_ERROR for
> this RTAS call "ibm,read-slot-reset-state2".

Heh, ok.  I think you still want to make the fall-through more
obvious, it's easy to miss.

-- 
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: Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2015-01-15  3:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-05  0:26 [Qemu-devel] [PATCH v15 0/2] EEH Support for VFIO Devices Gavin Shan
2015-01-05  0:26 ` [Qemu-devel] [PATCH v15 1/2] sPAPR: Implement EEH RTAS calls Gavin Shan
2015-01-14  1:39   ` David Gibson
2015-01-15  0:14     ` Gavin Shan
2015-01-15  1:33       ` David Gibson [this message]
2015-01-15  3:21         ` Gavin Shan
2015-01-05  0:26 ` [Qemu-devel] [PATCH v15 2/2] sPAPR: Implement sPAPRPHBClass::eeh_handler Gavin Shan
2015-01-14  1:41   ` David Gibson
2015-01-15  0:25     ` Gavin Shan
2015-02-04 13:42     ` Alexander Graf
2015-02-04 13:44       ` David Gibson

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=20150115013359.GC5297@voom.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=gwshan@linux.vnet.ibm.com \
    --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).