From patchwork Tue Sep 20 20:45:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 672450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sdwHB70Nhz9sCp for ; Wed, 21 Sep 2016 07:04:22 +1000 (AEST) Received: from localhost ([::1]:38081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmSDE-0002oW-Ih for incoming@patchwork.ozlabs.org; Tue, 20 Sep 2016 17:04:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmRvi-00050b-FA for qemu-devel@nongnu.org; Tue, 20 Sep 2016 16:46:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bmRvh-0007Nq-9s for qemu-devel@nongnu.org; Tue, 20 Sep 2016 16:46:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42568) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bmRvh-0007NX-0J for qemu-devel@nongnu.org; Tue, 20 Sep 2016 16:46:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3049685540; Tue, 20 Sep 2016 20:46:12 +0000 (UTC) Received: from localhost.redhat.com (vpn1-4-38.ams2.redhat.com [10.36.4.38]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8KKjufn030187; Tue, 20 Sep 2016 16:46:10 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, qemu-devel@nongnu.org, alex.williamson@redhat.com, armbru@redhat.com Date: Tue, 20 Sep 2016 20:45:46 +0000 Message-Id: <1474404352-28958-7-git-send-email-eric.auger@redhat.com> In-Reply-To: <1474404352-28958-1-git-send-email-eric.auger@redhat.com> References: <1474404352-28958-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 20 Sep 2016 20:46:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/12] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Pass an error object to prepare for migration to VFIO-PCI realize. In vfio_probe_igd_bar4_quirk, simply report the error without propagating. Transform vfio_pci_igd_opregion_init into a void function. The -EINVAL returned value only is used in vfio_initfn and during migration to realize, this will not be used anymore. Signed-off-by: Eric Auger --- hw/vfio/pci-quirks.c | 19 +++++++++---------- hw/vfio/pci.c | 6 +++--- hw/vfio/pci.h | 5 +++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index bec694c..57921de 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1055,8 +1055,8 @@ typedef struct VFIOIGDQuirk { * the table and to write the base address of that memory to the ASLS register * of the IGD device. */ -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info) +void vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, Error **errp) { int ret; @@ -1064,10 +1064,10 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, ret = pread(vdev->vbasedev.fd, vdev->igd_opregion, info->size, info->offset); if (ret != info->size) { - error_report("vfio: Error reading IGD OpRegion"); + error_setg(errp, "failed to read IGD OpRegion"); g_free(vdev->igd_opregion); vdev->igd_opregion = NULL; - return -EINVAL; + return; } /* @@ -1091,8 +1091,6 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, pci_set_long(vdev->pdev.config + IGD_ASLS, 0); pci_set_long(vdev->pdev.wmask + IGD_ASLS, ~0); pci_set_long(vdev->emulated_config_bits + IGD_ASLS, ~0); - - return 0; } /* @@ -1363,6 +1361,7 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) uint64_t *bdsm_size; uint32_t gmch; uint16_t cmd_orig, cmd; + Error *err = NULL; /* * This must be an Intel VGA device at address 00:02.0 for us to even @@ -1487,10 +1486,10 @@ static void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) } /* Setup OpRegion access */ - ret = vfio_pci_igd_opregion_init(vdev, opregion); - if (ret) { - error_report("IGD device %s failed to setup OpRegion, " - "legacy mode disabled", vdev->vbasedev.name); + vfio_pci_igd_opregion_init(vdev, opregion, &err); + if (err) { + error_append_hint(&err, "IGD legacy mode disabled\n"); + error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name); goto out; } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 07a44f5..f9a4fe7 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2720,10 +2720,10 @@ static int vfio_initfn(PCIDevice *pdev) goto out_teardown; } - ret = vfio_pci_igd_opregion_init(vdev, opregion); + vfio_pci_igd_opregion_init(vdev, opregion, &err); g_free(opregion); - if (ret) { - error_setg_errno(&err, -ret, "IGD OpRegion initialization failed"); + if (err) { + ret = -EINVAL; goto out_teardown; } } diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 7d482d9..5336aa4 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -163,7 +163,8 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev); int vfio_populate_vga(VFIOPCIDevice *vdev); -int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, - struct vfio_region_info *info); +void vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, + struct vfio_region_info *info, + Error **errp); #endif /* HW_VFIO_VFIO_PCI_H */