[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/31] acpi: pcihp: allow repeating hot-unplug requests
From: |
Michael S. Tsirkin |
Subject: |
[PULL 26/31] acpi: pcihp: allow repeating hot-unplug requests |
Date: |
Tue, 25 Apr 2023 03:46:24 -0400 |
From: Igor Mammedov <imammedo@redhat.com>
with Q35 using ACPI PCI hotplug by default, user's request to unplug
device is ignored when it's issued before guest OS has been booted.
And any additional attempt to request device hot-unplug afterwards
results in following error:
"Device XYZ is already in the process of unplug"
arguably it can be considered as a regression introduced by [2],
before which it was possible to issue unplug request multiple
times.
Accept new uplug requests after timeout (1ms). This brings ACPI PCI
hotplug on par with native PCIe unplug behavior [1] and allows user
to repeat unplug requests at propper times.
Set expire timeout to arbitrary 1msec so user won't be able to
flood guest with SCI interrupts by calling device_del in tight loop.
PS:
ACPI spec doesn't mandate what OSPM can do with GPEx.status
bits set before it's booted => it's impl. depended.
Status bits may be retained (I tested with one Windows version)
or cleared (Linux since 2.6 kernel times) during guest's ACPI
subsystem initialization.
Clearing status bits (though not wrong per se) hides the unplug
event from guest, and it's upto user to repeat device_del later
when guest is able to handle unplug requests.
1) 18416c62e3 ("pcie: expire pending delete")
2)
Fixes: cce8944cc9ef ("qdev-monitor: Forbid repeated device_del")
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
CC: mst@redhat.com
CC: anisinha@redhat.com
CC: jusual@redhat.com
CC: kraxel@redhat.com
Message-Id: <20230418090449.2155757-1-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Ani Sinha <anisinha@redhat.com>
---
hw/acpi/pcihp.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index dcfb779a7a..cdd6f775a1 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -357,6 +357,16 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler
*hotplug_dev,
* acpi_pcihp_eject_slot() when the operation is completed.
*/
pdev->qdev.pending_deleted_event = true;
+ /* if unplug was requested before OSPM is initialized,
+ * linux kernel will clear GPE0.sts[] bits during boot, which effectively
+ * hides unplug event. And than followup qmp_device_del() calls remain
+ * blocked by above flag permanently.
+ * Unblock qmp_device_del() by setting expire limit, so user can
+ * repeat unplug request later when OSPM has been booted.
+ */
+ pdev->qdev.pending_deleted_expires_ms =
+ qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* 1 msec */
+
s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
}
--
MST
- Re: [PULL 18/31] Add my old and new work email mapping and use work email to support acpi, (continued)
- [PULL 20/31] tests: bios-tables-test: replace memset with initializer, Michael S. Tsirkin, 2023/04/25
- [PULL 19/31] hw/acpi: limit warning on acpi table size to pc machines older than version 2.3, Michael S. Tsirkin, 2023/04/25
- [PULL 23/31] intel_iommu: refine iotlb hash calculation, Michael S. Tsirkin, 2023/04/25
- [PULL 25/31] virtio: i2c: Check notifier helpers for VIRTIO_CONFIG_IRQ_IDX, Michael S. Tsirkin, 2023/04/25
- [PULL 21/31] MAINTAINERS: Add Eugenio PĂ©rez as vhost-shadow-virtqueue reviewer, Michael S. Tsirkin, 2023/04/25
- [PULL 29/31] docs/specs: Convert pci-testdev.txt to rst, Michael S. Tsirkin, 2023/04/25
- [PULL 28/31] docs/specs: Convert pci-serial.txt to rst, Michael S. Tsirkin, 2023/04/25
- [PULL 31/31] hw/pci-bridge: Make PCIe and CXL PXB Devices inherit from TYPE_PXB_DEV, Michael S. Tsirkin, 2023/04/25
- [PULL 27/31] docs/specs/pci-ids: Convert from txt to rST, Michael S. Tsirkin, 2023/04/25
- [PULL 26/31] acpi: pcihp: allow repeating hot-unplug requests,
Michael S. Tsirkin <=
- [PULL 22/31] docs/cxl: Fix sentence, Michael S. Tsirkin, 2023/04/25
- [PULL 30/31] hw/pci-bridge: pci_expander_bridge fix type in pxb_cxl_dev_reset(), Michael S. Tsirkin, 2023/04/25
- [PULL 24/31] docs: Remove obsolete descriptions of SR-IOV support, Michael S. Tsirkin, 2023/04/25
- Re: [PULL 00/31] virtio,pc,pci: fixes, features, cleanups, Richard Henderson, 2023/04/25