From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4m0I-0005hH-Fi for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4m0F-0004x7-63 for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:54 -0400 Received: from [59.151.112.132] (port=34457 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4m0C-0004us-0d for qemu-devel@nongnu.org; Tue, 16 Jun 2015 04:13:51 -0400 From: Chen Fan Date: Tue, 16 Jun 2015 16:10:59 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [RFC v10 15/19] vfio: improve vfio_pci_hot_reset to support more case List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: izumi.taku@jp.fujitsu.com, alex.williamson@redhat.com the vfio_pci_hot_reset differentiate the single and multi in-used devices for reset. but sometimes we own the group without any devices, that also should support hot reset. Signed-off-by: Chen Fan --- hw/vfio/pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index fad6a80..a86edab 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3407,6 +3407,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; @@ -3436,6 +3437,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) { @@ -3447,12 +3449,21 @@ 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 we own the group but does not own the device, we also + * should call hot reset with multi. + */ + if (!single && !found) { + multi = true; + } } if (!single && !multi) { -- 1.9.3