diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-10-19 09:12:22 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2023-01-06 06:27:34 +0100 |
commit | 22227165e7c468d90f97b06a9ef2fe572add7fa5 (patch) | |
tree | 62b1535038efbe18195884c548373e88766c52e4 /drivers/pci/hotplug/pciehp_ctrl.c | |
parent | 76dcd734eca23168cb008912c0f69ff408905235 (diff) | |
download | linux-22227165e7c468d90f97b06a9ef2fe572add7fa5.tar.gz |
pciehp: fast unplug for virtual machinespcie-hotplug
The PCIe specification asks the OS to wait five seconds after the
attention button has been pressed before actually un-plugging the
device. This gives the operator the chance to cancel the operation
by pressing the attention button again within those five seconds.
For physical hardware this makes sense. Picking the wrong button
by accident can easily happen and it can be corrected that way.
For virtual hardware the benefits are questionable. Typically
users find the five second delay annoying.
This patch adds the fast_virtual_unplug module parameter to the
pciehp driver. When enabled (which is the default) the linux
kernel will simply skip the delay for virtual pcie ports, which
reduces the total time for the unplug operation from 6-7 seconds
to 1-2 seconds.
Virtual pcie ports are identified by PCI ID. For now the qemu
pcie root ports are detected, other hardware can be added easily.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'drivers/pci/hotplug/pciehp_ctrl.c')
-rw-r--r-- | drivers/pci/hotplug/pciehp_ctrl.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c index 529c34808440..119bb11f87d6 100644 --- a/drivers/pci/hotplug/pciehp_ctrl.c +++ b/drivers/pci/hotplug/pciehp_ctrl.c @@ -15,12 +15,17 @@ #define dev_fmt(fmt) "pciehp: " fmt +#include <linux/moduleparam.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/pm_runtime.h> #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 +181,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: |