From patchwork Sat Sep 19 07:18:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 519636 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 19298140338 for ; Sat, 19 Sep 2015 17:21:36 +1000 (AEST) Received: from localhost ([::1]:44130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCSk-0004km-0B for incoming@patchwork.ozlabs.org; Sat, 19 Sep 2015 03:21:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCPf-0008FM-5D for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZdCPd-0003sg-Oy for qemu-devel@nongnu.org; Sat, 19 Sep 2015 03:18:23 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:46432) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZdCPd-0003qr-3a; Sat, 19 Sep 2015 03:18:21 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 33751140909; Sat, 19 Sep 2015 17:18:17 +1000 (AEST) From: David Gibson To: gwshan@linux.vnet.ibm.com, alex.williamson@redhat.com, aik@ozlabs.ru Date: Sat, 19 Sep 2015 17:18:32 +1000 Message-Id: <1442647117-2726-10-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1442647117-2726-1-git-send-email-david@gibson.dropbear.id.au> References: <1442647117-2726-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2401:3900:2:1::2 Cc: lvivier@redhat.com, thuth@redhat.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, David Gibson Subject: [Qemu-devel] [RFC PATCH 09/14] 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 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 --- 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" 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 */