qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/6] RfC: try improve native hotplug for pcie root ports


From: Gerd Hoffmann
Subject: Re: [PATCH 0/6] RfC: try improve native hotplug for pcie root ports
Date: Tue, 2 Nov 2021 13:09:21 +0100

  Hi,

> > So in theory the guest turning off slot power quickly should work just
> > fine and speed up the unplug process in the common case (guest is
> > up'n'running and responsitive).  Down to 1-2 secs instead of 5-7.
> > Didn't actually test that though.

Tried mean while, test patch (not polished yet) below.

> Even if this speeds up unplug, hotplug remains slow, right?

Notplug never was slow for me ...

take care,
  Gerd

>From 074627a24a54203f2b4baf787fd4110c78222e23 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Tue, 19 Oct 2021 09:12:22 +0200
Subject: [PATCH] pciehp: fast virtual unplug for VMs

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/pci/hotplug/pciehp.h      |  3 +++
 drivers/pci/hotplug/pciehp_core.c |  5 +++++
 drivers/pci/hotplug/pciehp_ctrl.c | 10 +++++++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 69fd401691be..131ffec2e947 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -79,6 +79,7 @@ extern int pciehp_poll_time;
  * @request_result: result of last user request submitted to the IRQ thread
  * @requester: wait queue to wake up on completion of user request,
  *     used for synchronous slot enable/disable request via sysfs
+ * @is_virtual: virtual machine pcie port.
  *
  * PCIe hotplug has a 1:1 relationship between controller and slot, hence
  * unlike other drivers, the two aren't represented by separate structures.
@@ -109,6 +110,8 @@ struct controller {
        unsigned int ist_running;
        int request_result;
        wait_queue_head_t requester;
+
+       bool is_virtual;
 };
 
 /**
diff --git a/drivers/pci/hotplug/pciehp_core.c 
b/drivers/pci/hotplug/pciehp_core.c
index ad3393930ecb..28867ec33f5b 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -227,6 +227,11 @@ static int pciehp_probe(struct pcie_device *dev)
                goto err_out_shutdown_notification;
        }
 
+       if (dev->port->vendor == PCI_VENDOR_ID_REDHAT &&
+           dev->port->device == 0x000c)
+               /* qemu pcie root port */
+               ctrl->is_virtual = true;
+
        pciehp_check_presence(ctrl);
 
        return 0;
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c 
b/drivers/pci/hotplug/pciehp_ctrl.c
index 529c34808440..c0a05bbdb948 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -21,6 +21,10 @@
 #include <linux/pci.h>
 #include "pciehp.h"
 
+static bool fast_virtual_unplug = true;
+module_param(fast_virtual_unplug, bool, 0644);
+MODULE_PARM_DESC(fast_virtual_unplug, "Fast unplug (don't wait 5 seconds) for 
virtual machines.");
+
 /* The following routines constitute the bulk of the
    hotplug controller logic
  */
@@ -176,7 +180,11 @@ void pciehp_handle_button_press(struct controller *ctrl)
                /* blink power indicator and turn off attention */
                pciehp_set_indicators(ctrl, PCI_EXP_SLTCTL_PWR_IND_BLINK,
                                      PCI_EXP_SLTCTL_ATTN_IND_OFF);
-               schedule_delayed_work(&ctrl->button_work, 5 * HZ);
+               if (ctrl->is_virtual && fast_virtual_unplug) {
+                       schedule_delayed_work(&ctrl->button_work, 1);
+               } else {
+                       schedule_delayed_work(&ctrl->button_work, 5 * HZ);
+               }
                break;
        case BLINKINGOFF_STATE:
        case BLINKINGON_STATE:
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]