Received: from eggs.gnu.org ([2001:4830:134:3::10]:33811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFaUp-0006h5-0q for qemu-devel@nongnu.org; Thu, 16 Jul 2015 00:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZFaUn-0005Pr-SS for qemu-devel@nongnu.org; Thu, 16 Jul 2015 00:10:06 -0400 Received: from [59.151.112.132] (port=4208 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZFaUm-00057f-Ah for qemu-devel@nongnu.org; Thu, 16 Jul 2015 00:10:05 -0400 From: Chen Hanxiao Date: Thu, 16 Jul 2015 12:00:49 +0800 Message-ID: <1437019253-17630-12-git-send-email-chenhanxiao@cn.fujitsu.com> In-Reply-To: <1437019253-17630-1-git-send-email-chenhanxiao@cn.fujitsu.com> References: <1437019253-17630-1-git-send-email-chenhanxiao@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v12 11/15] vfio: modify vfio_pci_hot_reset to support bus reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson , qemu-devel@nongnu.org Cc: Chen Fan From: Chen Fan the vfio_pci_hot_reset differentiate the single and multi in-used devices for reset. but in multi case, when some dependent devices are not assigned to VM, the devices can not be recovered by driver. Signed-off-by: Chen Fan Signed-off-by: Chen Hanxiao --- hw/vfio/pci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index bab72a4..c52456b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3287,6 +3287,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; + bool found; host.domain = devices[i].segment; host.bus = devices[i].bus; @@ -3316,6 +3317,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) goto out; } + found = false; /* Prep dependent devices for reset and clear our marker. */ QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { @@ -3327,12 +3329,23 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) ret = -EINVAL; goto out_single; } + found = true; vfio_pci_pre_reset(tmp); tmp->vbasedev.needs_reset = false; multi = true; break; } } + + /* + * If the dependent device is not assigned to VM, we should + * not call hot bus reset, otherwise, the dependent device + * can not be used in the future. + */ + if (!single && !found) { + ret = -EINVAL; + goto out_single; + } } if (!single && !multi) { -- 2.1.0