From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhDRM-00037i-4v for qemu-devel@nongnu.org; Wed, 30 Sep 2015 05:12:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhDRH-00010M-U9 for qemu-devel@nongnu.org; Wed, 30 Sep 2015 05:12:44 -0400 References: <1443579237-9636-1-git-send-email-david@gibson.dropbear.id.au> <1443579237-9636-8-git-send-email-david@gibson.dropbear.id.au> From: Laurent Vivier Message-ID: <560BA783.4070402@redhat.com> Date: Wed, 30 Sep 2015 11:12:35 +0200 MIME-Version: 1.0 In-Reply-To: <1443579237-9636-8-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv3 7/7] vfio: Expose a VFIO PCI device's group for EEH List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , alex.williamson@redhat.com, pbonzini@redhat.com Cc: thuth@redhat.com, qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, aik@ozlabs.ru, abologna@redhat.com, gwshan@linux.vnet.ibm.com, qemu-ppc@nongnu.org On 30/09/2015 04:13, 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 it will need to discover from VFIO which group a given > device belongs to. > > This exposes a new vfio_pci_device_group() function for this purpose. > > Signed-off-by: David Gibson > --- > hw/vfio/pci.c | 14 ++++++++++++++ > include/hw/vfio/vfio-pci.h | 11 +++++++++++ > 2 files changed, 25 insertions(+) > create mode 100644 include/hw/vfio/vfio-pci.h > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index dcabb6d..49ae834 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -35,6 +35,8 @@ > #include "pci.h" > #include "trace.h" > > +#include "hw/vfio/vfio-pci.h" > + > #define MSIX_CAP_LENGTH 12 > > static void vfio_disable_interrupts(VFIOPCIDevice *vdev); > @@ -2312,6 +2314,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; > +} > + > static int vfio_initfn(PCIDevice *pdev) > { > VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev); > diff --git a/include/hw/vfio/vfio-pci.h b/include/hw/vfio/vfio-pci.h > new file mode 100644 > index 0000000..32105f7 > --- /dev/null > +++ b/include/hw/vfio/vfio-pci.h > @@ -0,0 +1,11 @@ > +#ifndef VFIO_PCI_H > +#define VFIO_PCI_H > + > +#include "qemu/typedefs.h" > + > +/* We expose the concept of a VFIOGroup, though not its internals */ > +typedef struct VFIOGroup VFIOGroup; > + > +extern VFIOGroup *vfio_pci_device_group(PCIDevice *pdev); > + > +#endif /* VFIO_PCI_H */ > Reviewed-by: Laurent Vivier