From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de,
Gavin Shan <gwshan@linux.vnet.ibm.com>,
alex.williamson@redhat.com, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v15 1/2] sPAPR: Implement EEH RTAS calls
Date: Thu, 15 Jan 2015 14:21:22 +1100 [thread overview]
Message-ID: <20150115032122.GA17053@shangw> (raw)
In-Reply-To: <20150115013359.GC5297@voom.fritz.box>
On Thu, Jan 15, 2015 at 12:33:59PM +1100, David Gibson wrote:
>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.
>
Yeah, it's irrelevant after rtas_handle_eeh_request() is dropped.
>> >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.
>
Thanks for confirm. I'll change code accordingly in next revision.
>[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.
>
Yes, I still need make it more obvious like this:
int ret;
ret = info->eeh_handler();
#if RTAS_CALL_SUPPORTS_HW_ERROR_AS_RETURN_VALUE
if (ret < 0) {
rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
return;
}
#else
if (ret < 0) {
goto param_error_exit;
}
#endif
/* Handle the result from info->eeh_handler() */
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
return;
param_error_exit:
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
Thanks,
Gavin
>--
>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
next prev parent reply other threads:[~2015-01-15 3:31 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
2015-01-15 3:21 ` Gavin Shan [this message]
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=20150115032122.GA17053@shangw \
--to=gwshan@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=david@gibson.dropbear.id.au \
--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 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.