All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: izumi.taku@jp.fujitsu.com, alex.williamson@redhat.com
Subject: [Qemu-devel] [RFC v7 02/11] vfio: squeeze out vfio_pci_do_hot_reset for support bus reset
Date: Tue, 19 May 2015 12:42:44 +0800	[thread overview]
Message-ID: <123fba7bddfadd839b0441ce3ad0e527a32ddf0b.1432008287.git.chen.fan.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <cover.1432008287.git.chen.fan.fnst@cn.fujitsu.com>

squeeze out vfio_pci_do_hot_reset to do host bus reset when AER recovery.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
---
 hw/vfio/pci.c | 75 +++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 44 insertions(+), 31 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index fe4963f..037a2c6 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2683,6 +2683,48 @@ error:
     return ret;
 }
 
+static int vfio_pci_do_hot_reset(VFIOPCIDevice *vdev,
+                                 struct vfio_pci_hot_reset_info *info)
+{
+    VFIOGroup *group;
+    struct vfio_pci_hot_reset *reset;
+    int32_t *fds;
+    int ret, i, count;
+    struct vfio_pci_dependent_device *devices;
+
+    /* Determine how many group fds need to be passed */
+    count = 0;
+    devices = &info->devices[0];
+    QLIST_FOREACH(group, &vfio_group_list, next) {
+        for (i = 0; i < info->count; i++) {
+            if (group->groupid == devices[i].group_id) {
+                count++;
+                break;
+            }
+        }
+    }
+
+    reset = g_malloc0(sizeof(*reset) + (count * sizeof(*fds)));
+    reset->argsz = sizeof(*reset) + (count * sizeof(*fds));
+    fds = &reset->group_fds[0];
+
+    /* Fill in group fds */
+    QLIST_FOREACH(group, &vfio_group_list, next) {
+        for (i = 0; i < info->count; i++) {
+            if (group->groupid == devices[i].group_id) {
+                fds[reset->count++] = group->fd;
+                break;
+            }
+        }
+    }
+
+    /* Bus reset! */
+    ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, reset);
+    g_free(reset);
+
+    return ret;
+}
+
 static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos)
 {
     PCIDevice *pdev = &vdev->pdev;
@@ -2824,9 +2866,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
     VFIOGroup *group;
     struct vfio_pci_hot_reset_info *info;
     struct vfio_pci_dependent_device *devices;
-    struct vfio_pci_hot_reset *reset;
-    int32_t *fds;
-    int ret, i, count;
+    int ret, i;
     bool multi = false;
 
     trace_vfio_pci_hot_reset(vdev->vbasedev.name, single ? "one" : "multi");
@@ -2907,34 +2947,7 @@ static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single)
         goto out_single;
     }
 
-    /* Determine how many group fds need to be passed */
-    count = 0;
-    QLIST_FOREACH(group, &vfio_group_list, next) {
-        for (i = 0; i < info->count; i++) {
-            if (group->groupid == devices[i].group_id) {
-                count++;
-                break;
-            }
-        }
-    }
-
-    reset = g_malloc0(sizeof(*reset) + (count * sizeof(*fds)));
-    reset->argsz = sizeof(*reset) + (count * sizeof(*fds));
-    fds = &reset->group_fds[0];
-
-    /* Fill in group fds */
-    QLIST_FOREACH(group, &vfio_group_list, next) {
-        for (i = 0; i < info->count; i++) {
-            if (group->groupid == devices[i].group_id) {
-                fds[reset->count++] = group->fd;
-                break;
-            }
-        }
-    }
-
-    /* Bus reset! */
-    ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, reset);
-    g_free(reset);
+    ret = vfio_pci_do_hot_reset(vdev, info);
 
     trace_vfio_pci_hot_reset_result(vdev->vbasedev.name,
                                     ret ? "%m" : "Success");
-- 
1.9.3

  parent reply	other threads:[~2015-05-19  4:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19  4:42 [Qemu-devel] [RFC v7 00/11] vfio-pci: pass the aer error to guest Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 01/11] vfio: extract vfio_get_hot_reset_info as a single function Chen Fan
2015-05-19 19:34   ` Alex Williamson
2015-05-19  4:42 ` Chen Fan [this message]
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 03/11] qdev: add bus reset_notifiers callbacks for host bus reset Chen Fan
2015-05-19 19:34   ` Alex Williamson
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 04/11] vfio: add check host bus reset is support or not Chen Fan
2015-05-19 19:34   ` Alex Williamson
2015-05-20  7:24     ` Chen Fan
2015-05-20 18:47       ` Alex Williamson
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 05/11] vfio: do hot bus reset when do virtual secondary bus reset Chen Fan
2015-05-19 19:34   ` Alex Williamson
2015-05-20  9:59     ` Chen Fan
2015-05-20 18:47       ` Alex Williamson
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 06/11] vfio: add pcie extanded capability support Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 07/11] aer: impove pcie_aer_init to support vfio device Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 08/11] vfio: add aer support for " Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 09/11] pcie_aer: expose pcie_aer_msg() interface Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 10/11] vfio-pci: pass the aer error to guest Chen Fan
2015-05-19  4:42 ` [Qemu-devel] [RFC v7 11/11] vfio: add 'aer' property to expose aercap Chen Fan
2015-05-19 19:34   ` Alex Williamson
2015-05-20  3:43     ` Chen Fan
2015-05-20 18:47       ` Alex Williamson
2015-05-21  1:53         ` Chen Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=123fba7bddfadd839b0441ce3ad0e527a32ddf0b.1432008287.git.chen.fan.fnst@cn.fujitsu.com \
    --to=chen.fan.fnst@cn.fujitsu.com \
    --cc=alex.williamson@redhat.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.