diff mbox

[RFC,09/14] vfio: Expose a VFIO PCI device's group for EEH

Message ID 1442647117-2726-10-git-send-email-david@gibson.dropbear.id.au
State New
Headers show

Commit Message

David Gibson Sept. 19, 2015, 7:18 a.m. UTC
The Enhanced Error Handling (EEH) interface in PAPR operates on units of a
Partitionable Endpoint (PE).  For VFIO devices, the PE boundaries the guest
sees must match the PE (i.e. IOMMU group) boundaries on the host.  To
implement this VFIO needs to expose to EEH the IOMMU group each VFIO device
belongs to.

Add a vfio_pci_device_group() function to the VFIO/EEH interface for this
purpose.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/vfio/pci.c              | 13 +++++++++++++
 include/hw/vfio/vfio-eeh.h |  1 +
 2 files changed, 14 insertions(+)

Comments

Alex Williamson Sept. 23, 2015, 5:28 p.m. UTC | #1
On Sat, 2015-09-19 at 17:18 +1000, David Gibson wrote:
> The Enhanced Error Handling (EEH) interface in PAPR operates on units of a
> Partitionable Endpoint (PE).  For VFIO devices, the PE boundaries the guest
> sees must match the PE (i.e. IOMMU group) boundaries on the host.  To
> implement this VFIO needs to expose to EEH the IOMMU group each VFIO device
> belongs to.
> 
> Add a vfio_pci_device_group() function to the VFIO/EEH interface for this
> purpose.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  hw/vfio/pci.c              | 13 +++++++++++++
>  include/hw/vfio/vfio-eeh.h |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 73d34b9..29f9467 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -41,6 +41,7 @@
>  #include "trace.h"
>  #include "hw/vfio/vfio.h"
>  #include "hw/vfio/vfio-common.h"
> +#include "hw/vfio/vfio-eeh.h"


Why?  EEH may be the consumer, but it's not EEH specific, it should not
have the prototype in an EEH specific header.

>  
>  struct VFIOPCIDevice;
>  
> @@ -3351,6 +3352,18 @@ static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
>      vdev->req_enabled = false;
>  }
>  
> +VFIOGroup *vfio_pci_device_group(PCIDevice *pdev)
> +{
> +    VFIOPCIDevice *vdev;
> +
> +    if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
> +        return NULL;
> +    }
> +
> +    vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
> +    return vdev->vbasedev.group;
> +}
> +
>  /*
>   * AMD Radeon PCI config reset, based on Linux:
>   *   drivers/gpu/drm/radeon/ci_smc.c:ci_is_smc_running()
> diff --git a/include/hw/vfio/vfio-eeh.h b/include/hw/vfio/vfio-eeh.h
> index d7356f2..0ea87e1 100644
> --- a/include/hw/vfio/vfio-eeh.h
> +++ b/include/hw/vfio/vfio-eeh.h
> @@ -38,5 +38,6 @@
>  typedef struct VFIOGroup VFIOGroup;
>  
>  int vfio_eeh_op(VFIOGroup *group, uint32_t op);
> +VFIOGroup *vfio_pci_device_group(PCIDevice *pdev);
>  
>  #endif /* VFIO_EEH_H */
David Gibson Sept. 24, 2015, 1:16 a.m. UTC | #2
On Wed, Sep 23, 2015 at 11:28:43AM -0600, Alex Williamson wrote:
> On Sat, 2015-09-19 at 17:18 +1000, David Gibson wrote:
> > The Enhanced Error Handling (EEH) interface in PAPR operates on units of a
> > Partitionable Endpoint (PE).  For VFIO devices, the PE boundaries the guest
> > sees must match the PE (i.e. IOMMU group) boundaries on the host.  To
> > implement this VFIO needs to expose to EEH the IOMMU group each VFIO device
> > belongs to.
> > 
> > Add a vfio_pci_device_group() function to the VFIO/EEH interface for this
> > purpose.
> > 
> > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> > ---
> >  hw/vfio/pci.c              | 13 +++++++++++++
> >  include/hw/vfio/vfio-eeh.h |  1 +
> >  2 files changed, 14 insertions(+)
> > 
> > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> > index 73d34b9..29f9467 100644
> > --- a/hw/vfio/pci.c
> > +++ b/hw/vfio/pci.c
> > @@ -41,6 +41,7 @@
> >  #include "trace.h"
> >  #include "hw/vfio/vfio.h"
> >  #include "hw/vfio/vfio-common.h"
> > +#include "hw/vfio/vfio-eeh.h"
> 
> 
> Why?  EEH may be the consumer, but it's not EEH specific, it should not
> have the prototype in an EEH specific header.

Ok, planning to create a vfio-pci.h in the respin.
diff mbox

Patch

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 73d34b9..29f9467 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -41,6 +41,7 @@ 
 #include "trace.h"
 #include "hw/vfio/vfio.h"
 #include "hw/vfio/vfio-common.h"
+#include "hw/vfio/vfio-eeh.h"
 
 struct VFIOPCIDevice;
 
@@ -3351,6 +3352,18 @@  static void vfio_unregister_req_notifier(VFIOPCIDevice *vdev)
     vdev->req_enabled = false;
 }
 
+VFIOGroup *vfio_pci_device_group(PCIDevice *pdev)
+{
+    VFIOPCIDevice *vdev;
+
+    if (!object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
+        return NULL;
+    }
+
+    vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
+    return vdev->vbasedev.group;
+}
+
 /*
  * AMD Radeon PCI config reset, based on Linux:
  *   drivers/gpu/drm/radeon/ci_smc.c:ci_is_smc_running()
diff --git a/include/hw/vfio/vfio-eeh.h b/include/hw/vfio/vfio-eeh.h
index d7356f2..0ea87e1 100644
--- a/include/hw/vfio/vfio-eeh.h
+++ b/include/hw/vfio/vfio-eeh.h
@@ -38,5 +38,6 @@ 
 typedef struct VFIOGroup VFIOGroup;
 
 int vfio_eeh_op(VFIOGroup *group, uint32_t op);
+VFIOGroup *vfio_pci_device_group(PCIDevice *pdev);
 
 #endif /* VFIO_EEH_H */