From patchwork Mon Oct 5 20:37:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 526551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7259014012C for ; Tue, 6 Oct 2015 07:42:01 +1100 (AEDT) Received: from localhost ([::1]:47658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZjCa7-000450-Ai for incoming@patchwork.ozlabs.org; Mon, 05 Oct 2015 16:41:59 -0400 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 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4ACEE461D4; Mon, 5 Oct 2015 20:38:00 +0000 (UTC) Received: from gimli.home (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t95KbxK0026659; Mon, 5 Oct 2015 16:37:59 -0400 From: Alex Williamson To: qemu-devel@nongnu.org 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> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Laurent Vivier , David Gibson Subject: [Qemu-devel] [PULL 10/10] vfio: Expose a VFIO PCI device's group for EEH X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 */