aboutsummaryrefslogtreecommitdiff
path: root/hw/pci
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2021-11-11 14:08:58 +0100
committerMichael S. Tsirkin <mst@redhat.com>2021-11-15 11:10:11 -0500
commit0d33415a4eafe532f3beef8272811d927236a353 (patch)
treeae65f05cbfb33da512f753dbf7e1f5cd7fde8518 /hw/pci
parent44242d4d3d082a28200fdbecaed5398122682e6e (diff)
downloadqemu-0d33415a4eafe532f3beef8272811d927236a353.zip
qemu-0d33415a4eafe532f3beef8272811d927236a353.tar.gz
qemu-0d33415a4eafe532f3beef8272811d927236a353.tar.bz2
pcie: fast unplug when slot power is off
In case the slot is powered off (and the power indicator turned off too) we can unplug right away, without round-trip to the guest. Also clear pending attention button press, there is nothing to care about any more. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Message-Id: <20211111130859.1171890-6-kraxel@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/pci')
-rw-r--r--hw/pci/pcie.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 959bf07..a930ac7 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -560,6 +560,16 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
return;
}
+ if (((sltctl & PCI_EXP_SLTCTL_PIC) == PCI_EXP_SLTCTL_PWR_IND_OFF) &&
+ ((sltctl & PCI_EXP_SLTCTL_PCC) == PCI_EXP_SLTCTL_PWR_OFF)) {
+ /* slot is powered off -> unplug without round-trip to the guest */
+ pcie_cap_slot_do_unplug(hotplug_pdev);
+ hotplug_event_notify(hotplug_pdev);
+ pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_ABP);
+ return;
+ }
+
pcie_cap_slot_push_attention_button(hotplug_pdev);
}