All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com,
	aik@ozlabs.ru, qemu-devel@nongnu.org, gwshan@linux.vnet.ibm.com,
	qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [RFC PATCH 02/14] spapr_pci: Switch EEH to vfio_eeh_op() interface
Date: Wed, 23 Sep 2015 11:28:22 -0600	[thread overview]
Message-ID: <1443029302.23936.482.camel@redhat.com> (raw)
In-Reply-To: <1442647117-2726-3-git-send-email-david@gibson.dropbear.id.au>

On Sat, 2015-09-19 at 17:18 +1000, David Gibson wrote:
> This switches all EEH on VFIO operations in spapr_pci_vfio() from the old
> broken vfio_container_ioctl() interface to the new vfio_eeh_op() interface.
> 
> In order to obtain the VFIOGroup * handle that vfio_eeh_op() requires, we
> add a helper function spapr_phb_check_vfio_group().  It gets the group from
> the VFIO PHB's groupid by calling into vfio_get_group().  Using that
> outside the VFIO is an abstraction violation, but so was
> vfio_container_ioctl() itself, and this is a useful intermediate step to
> cleaning it up properly.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/ppc/spapr_pci_vfio.c | 90 ++++++++++++++++++++++++++++++++-----------------
>  1 file changed, 59 insertions(+), 31 deletions(-)
> 
> diff --git a/hw/ppc/spapr_pci_vfio.c b/hw/ppc/spapr_pci_vfio.c
> index a61b418..a2b1093 100644
> --- a/hw/ppc/spapr_pci_vfio.c
> +++ b/hw/ppc/spapr_pci_vfio.c
> @@ -22,12 +22,27 @@
>  #include "hw/pci/msix.h"
>  #include "linux/vfio.h"
>  #include "hw/vfio/vfio.h"
> +#include "hw/vfio/vfio-eeh.h"
> +
> +#include "hw/vfio/vfio-common.h"
>  
>  static Property spapr_phb_vfio_properties[] = {
>      DEFINE_PROP_INT32("iommu", sPAPRPHBVFIOState, iommugroupid, -1),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> +static int spapr_phb_check_vfio_group(sPAPRPHBState *phb, VFIOGroup **gpp)
> +{
> +    VFIOGroup *group;
> +
> +    /* FIXME: this is an abstraction violation */
> +    group = vfio_get_group(SPAPR_PCI_VFIO_HOST_BRIDGE(phb)->iommugroupid,
> +                           &phb->iommu_as);
> +    if (gpp)
> +        *gpp = group;
> +    return RTAS_OUT_SUCCESS;
> +}

"check" for what?  Why does this have a return value if it can't fail?
This is a rather obscure wrapper of vfio_get_group().  It also seems
like yet another abstraction violation to make such a simply function
return RTAS error codes.

> +
>  static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)
>  {
>      sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
> @@ -74,13 +89,14 @@ static void spapr_phb_vfio_finish_realize(sPAPRPHBState *sphb, Error **errp)
>  
>  static void spapr_phb_vfio_eeh_reenable(sPAPRPHBVFIOState *svphb)
>  {
> -    struct vfio_eeh_pe_op op = {
> -        .argsz = sizeof(op),
> -        .op    = VFIO_EEH_PE_ENABLE
> -    };
> +    VFIOGroup *group;
> +    int ret;
>  
> -    vfio_container_ioctl(&svphb->phb.iommu_as,
> -                         svphb->iommugroupid, VFIO_EEH_PE_OP, &op);
> +    ret = spapr_phb_check_vfio_group(SPAPR_PCI_HOST_BRIDGE(svphb), &group);
> +    if (ret != RTAS_OUT_SUCCESS) {
> +        return;
> +    }
> +    vfio_eeh_op(group, VFIO_EEH_PE_ENABLE);

What did we just accomplish?  Is group valid?

>  }
>  
>  static void spapr_phb_vfio_reset(DeviceState *qdev)
> @@ -97,13 +113,18 @@ static void spapr_phb_vfio_reset(DeviceState *qdev)
>  static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
>                                           unsigned int addr, int option)
>  {
> -    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
> -    struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
> +    VFIOGroup *group;
> +    uint32_t op;
>      int ret;
>  
> +    ret = spapr_phb_check_vfio_group(sphb, &group);
> +    if (ret != RTAS_OUT_SUCCESS) {
> +        return ret;
> +    }
> +
>      switch (option) {
>      case RTAS_EEH_DISABLE:
> -        op.op = VFIO_EEH_PE_DISABLE;
> +        op = VFIO_EEH_PE_DISABLE;
>          break;
>      case RTAS_EEH_ENABLE: {
>          PCIHostState *phb;
> @@ -121,21 +142,20 @@ static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
>              return RTAS_OUT_PARAM_ERROR;
>          }
>  
> -        op.op = VFIO_EEH_PE_ENABLE;
> +        op = VFIO_EEH_PE_ENABLE;
>          break;
>      }
>      case RTAS_EEH_THAW_IO:
> -        op.op = VFIO_EEH_PE_UNFREEZE_IO;
> +        op = VFIO_EEH_PE_UNFREEZE_IO;
>          break;
>      case RTAS_EEH_THAW_DMA:
> -        op.op = VFIO_EEH_PE_UNFREEZE_DMA;
> +        op = VFIO_EEH_PE_UNFREEZE_DMA;
>          break;
>      default:
>          return RTAS_OUT_PARAM_ERROR;
>      }
>  
> -    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
> -                               VFIO_EEH_PE_OP, &op);
> +    ret = vfio_eeh_op(group, op);
>      if (ret < 0) {
>          return RTAS_OUT_HW_ERROR;
>      }
> @@ -145,13 +165,15 @@ static int spapr_phb_vfio_eeh_set_option(sPAPRPHBState *sphb,
>  
>  static int spapr_phb_vfio_eeh_get_state(sPAPRPHBState *sphb, int *state)
>  {
> -    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
> -    struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
> +    VFIOGroup *group;
>      int ret;
>  
> -    op.op = VFIO_EEH_PE_GET_STATE;
> -    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
> -                               VFIO_EEH_PE_OP, &op);
> +    ret = spapr_phb_check_vfio_group(sphb, &group);
> +    if (ret != RTAS_OUT_SUCCESS) {
> +        return ret;
> +    }
> +
> +    ret = vfio_eeh_op(group, VFIO_EEH_PE_GET_STATE);
>      if (ret < 0) {
>          return RTAS_OUT_PARAM_ERROR;
>      }
> @@ -205,28 +227,32 @@ static void spapr_phb_vfio_eeh_pre_reset(sPAPRPHBState *sphb)
>  
>  static int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb, int option)
>  {
> -    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
> -    struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
> +    VFIOGroup *group;
> +    uint32_t op;
>      int ret;
>  
> +    ret = spapr_phb_check_vfio_group(sphb, &group);
> +    if (ret != RTAS_OUT_SUCCESS) {
> +        return ret;
> +    }
> +
>      switch (option) {
>      case RTAS_SLOT_RESET_DEACTIVATE:
> -        op.op = VFIO_EEH_PE_RESET_DEACTIVATE;
> +        op = VFIO_EEH_PE_RESET_DEACTIVATE;
>          break;
>      case RTAS_SLOT_RESET_HOT:
>          spapr_phb_vfio_eeh_pre_reset(sphb);
> -        op.op = VFIO_EEH_PE_RESET_HOT;
> +        op = VFIO_EEH_PE_RESET_HOT;
>          break;
>      case RTAS_SLOT_RESET_FUNDAMENTAL:
>          spapr_phb_vfio_eeh_pre_reset(sphb);
> -        op.op = VFIO_EEH_PE_RESET_FUNDAMENTAL;
> +        op = VFIO_EEH_PE_RESET_FUNDAMENTAL;
>          break;
>      default:
>          return RTAS_OUT_PARAM_ERROR;
>      }
>  
> -    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
> -                               VFIO_EEH_PE_OP, &op);
> +    ret = vfio_eeh_op(group, op);
>      if (ret < 0) {
>          return RTAS_OUT_HW_ERROR;
>      }
> @@ -236,13 +262,15 @@ static int spapr_phb_vfio_eeh_reset(sPAPRPHBState *sphb, int option)
>  
>  static int spapr_phb_vfio_eeh_configure(sPAPRPHBState *sphb)
>  {
> -    sPAPRPHBVFIOState *svphb = SPAPR_PCI_VFIO_HOST_BRIDGE(sphb);
> -    struct vfio_eeh_pe_op op = { .argsz = sizeof(op) };
> +    VFIOGroup *group;
>      int ret;
>  
> -    op.op = VFIO_EEH_PE_CONFIGURE;
> -    ret = vfio_container_ioctl(&svphb->phb.iommu_as, svphb->iommugroupid,
> -                               VFIO_EEH_PE_OP, &op);
> +    ret = spapr_phb_check_vfio_group(sphb, &group);
> +    if (ret != RTAS_OUT_SUCCESS) {
> +        return ret;
> +    }
> +
> +    ret = vfio_eeh_op(group, VFIO_EEH_PE_CONFIGURE);
>      if (ret < 0) {
>          return RTAS_OUT_PARAM_ERROR;
>      }

  reply	other threads:[~2015-09-23 17:28 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-19  7:18 [Qemu-devel] [RFC PATCH 00/14] Allow EEH on "normal" sPAPR PCI host bridge David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 01/14] vfio: Start adding VFIO/EEH interface David Gibson
2015-09-23 17:28   ` Alex Williamson
2015-09-24  1:11     ` David Gibson
2015-09-24  2:12       ` Alex Williamson
2015-09-24  4:09         ` David Gibson
2015-09-24  5:45           ` Thomas Huth
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 02/14] spapr_pci: Switch EEH to vfio_eeh_op() interface David Gibson
2015-09-23 17:28   ` Alex Williamson [this message]
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 03/14] spapr_pci: Expose and generalize spapr_phb_check_vfio_group() David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 04/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() into spapr_pci code David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 05/14] spapr_pci: Fold spapr_phb_vfio_eeh_reset() " David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 06/14] spapr_pci: Fold spapr_phb_vfio_eeh_get_state() " David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 07/14] spapr_pci: Fold spapr_phb_vfio_eeh_set_option() " David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 08/14] spapr_pci: Fold spapr_phb_vfio_eeh_configure() " David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 09/14] vfio: Expose a VFIO PCI device's group for EEH David Gibson
2015-09-23 17:28   ` Alex Williamson
2015-09-24  1:16     ` David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 10/14] spapr_pci: Track guest Partitionable Endpoints David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 11/14] spapr_pci: Allow EEH on spapr-pci-host-bridge David Gibson
2015-09-23 17:28   ` Alex Williamson
2015-09-24  1:49     ` David Gibson
2015-09-24  2:19       ` Alex Williamson
2015-09-24  4:11         ` David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 12/14] spapr_pci: (Mostly) remove spapr-pci-vfio-host-bridge David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 13/14] spapr_pci: Remove finish_realize hook David Gibson
2015-09-19  7:18 ` [Qemu-devel] [RFC PATCH 14/14] vfio: Eliminate vfio_container_ioctl() 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=1443029302.23936.482.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=gwshan@linux.vnet.ibm.com \
    --cc=lvivier@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=thuth@redhat.com \
    /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.