[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls |
Date: |
Mon, 16 Feb 2015 12:52:48 +1100 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Mon, Feb 16, 2015 at 10:16:01AM +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
> callbacks sPAPRPHBClass::{eeh_set_option, eeh_get_state, eeh_reset,
> eeh_configure}, which are going to be used as follows:
>
> * 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 the corresponding sPAPRPHBClass callback is
> defined, it is called.
> * Those callbacks are only implemented for VFIO now. They do ioctl()
> to the IOMMU container fd to complete the calls. Error codes from
> that ioctl() are transferred back to the guest.
>
> [aik: defined RTAS tokens for EEH RTAS calls]
> Signed-off-by: Gavin Shan <address@hidden>
> ---
> hw/ppc/spapr_pci.c | 281
> ++++++++++++++++++++++++++++++++++++++++++++
> include/hw/pci-host/spapr.h | 4 +
> include/hw/ppc/spapr.h | 43 ++++++-
> 3 files changed, 326 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> index cebdeb3..29b071d 100644
> --- a/hw/ppc/spapr_pci.c
> +++ b/hw/ppc/spapr_pci.c
> @@ -406,6 +406,268 @@ static void
> rtas_ibm_query_interrupt_source_number(PowerPCCPU *cpu,
> rtas_st(rets, 2, 1);/* 0 == level; 1 == edge */
> }
>
> +static void rtas_ibm_set_eeh_option(PowerPCCPU *cpu,
> + sPAPREnvironment *spapr,
> + uint32_t token, uint32_t nargs,
> + target_ulong args, uint32_t nret,
> + target_ulong rets)
> +{
> + sPAPRPHBState *sphb;
> + sPAPRPHBClass *spc;
> + uint32_t addr, option;
> + uint64_t buid;
> + int ret;
> +
> + if ((nargs != 4) || (nret != 1)) {
> + goto param_error_exit;
> + }
> +
> + buid = ((uint64_t)rtas_ld(args, 1) << 32) | rtas_ld(args, 2);
> + addr = rtas_ld(args, 0);
> + option = rtas_ld(args, 3);
> +
> + sphb = find_phb(spapr, buid);
> + if (!sphb) {
> + goto param_error_exit;
> + }
> +
> + spc = SPAPR_PCI_HOST_BRIDGE_GET_CLASS(sphb);
> + if (!spc->eeh_set_option) {
> + goto param_error_exit;
> + }
> +
> + /*
> + * The EEH functionality is enabled on basis of PCI device,
> + * instead of PE. We need check the validity of the PCI
> + * device address.
> + */
> + if (option == RTAS_EEH_ENABLE &&
> + !find_dev(spapr, buid, addr)) {
> + goto param_error_exit;
> + }
You're still breaking your layering by doing checks dependent on the
specific option both here and in the callback.
What I meant by my comments on the previous version was that this
find_dev() test should also move into the eeh_set_option callback.
Obviously that means adding addr into the parameters - but surely if
the addr has any meaning whatsoever, it must be at least potentially
needed by the callback anyway.
Apart from that,
Reviewed-by: David Gibson <address@hidden>
--
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
pgpBt9d_NJ9LK.pgp
Description: PGP signature
- [Qemu-ppc] [PATCH v18 0/2] EEH Support for VFIO Devices, Gavin Shan, 2015/02/15
- [Qemu-ppc] [PATCH v18 2/2] sPAPR: Implement sPAPRPHBClass EEH callbacks, Gavin Shan, 2015/02/15
- [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Gavin Shan, 2015/02/15
- Re: [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls,
David Gibson <=
- Re: [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Gavin Shan, 2015/02/16
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Michael Roth, 2015/02/18
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Gavin Shan, 2015/02/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, David Gibson, 2015/02/19
- Re: [Qemu-ppc] [Qemu-devel] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Gavin Shan, 2015/02/19
- Re: [Qemu-ppc] [PATCH v18 1/2] sPAPR: Implement EEH RTAS calls, Gavin Shan, 2015/02/19