From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCWK-0005zj-1O for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:38:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZjCWG-00023D-Or for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:38:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCWG-00022m-In for qemu-devel@nongnu.org; Mon, 05 Oct 2015 16:38:00 -0400 From: Alex Williamson Date: Mon, 05 Oct 2015 14:37:59 -0600 Message-ID: <20151005203755.310.85609.stgit@gimli.home> In-Reply-To: <20151005203357.310.44414.stgit@gimli.home> References: <20151005203357.310.44414.stgit@gimli.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL 10/10] vfio: Expose a VFIO PCI device's group for EEH List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent Vivier , David Gibson From: David Gibson 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 Reviewed-by: Laurent Vivier Signed-off-by: Alex Williamson --- 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 */