From patchwork Mon Mar 7 03:23:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cao jin X-Patchwork-Id: 592745 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 7A11F140BB4 for ; Mon, 7 Mar 2016 14:24:45 +1100 (AEDT) Received: from localhost ([::1]:53271 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aclml-0004WV-Fw for incoming@patchwork.ozlabs.org; Sun, 06 Mar 2016 22:24:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aclkX-0000Lk-31 for qemu-devel@nongnu.org; Sun, 06 Mar 2016 22:22:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aclkS-0001PK-SW for qemu-devel@nongnu.org; Sun, 06 Mar 2016 22:22:24 -0500 Received: from [59.151.112.132] (port=53491 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aclkS-0001Bz-E4 for qemu-devel@nongnu.org; Sun, 06 Mar 2016 22:22:20 -0500 X-IronPort-AV: E=Sophos;i="5.22,518,1449504000"; d="scan'208";a="4286099" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Mar 2016 11:22:09 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 4A0F542AC84B; Mon, 7 Mar 2016 11:22:05 +0800 (CST) Received: from G08FNSTD140223.g08.fujitsu.local (10.167.226.69) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 7 Mar 2016 11:22:04 +0800 From: Cao jin To: Date: Mon, 7 Mar 2016 11:23:00 +0800 Message-ID: <1457320984-6540-8-git-send-email-caoj.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1457320984-6540-1-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1457320984-6540-1-git-send-email-caoj.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.69] X-yoursite-MailScanner-ID: 4A0F542AC84B.A97D2 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: chen.fan.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com, alex.williamson@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 07/11] vfio: add check aer functionality for hotplug device 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: Chen Fan Signed-off-by: Chen Fan --- hw/vfio/pci.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0898e34..24848c9 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3034,6 +3034,20 @@ post_reset: vfio_pci_post_reset(vdev); } +static void vfio_pci_is_valid(PCIDevice *dev, Error **errp) +{ + VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, dev); + Error *local_err = NULL; + + if (DEVICE(dev)->hotplugged && + (vdev->features & VFIO_FEATURE_ENABLE_AER)) { + vfio_check_host_bus_reset(vdev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } + } +} + static void vfio_instance_init(Object *obj) { PCIDevice *pci_dev = PCI_DEVICE(obj); @@ -3087,6 +3101,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->init = vfio_initfn; pdc->exit = vfio_exitfn; + pdc->is_valid_func = vfio_pci_is_valid; pdc->config_read = vfio_pci_read_config; pdc->config_write = vfio_pci_write_config; pdc->is_express = 1; /* We might be */