|
|
77c23f |
From 035f8aaabf2c31cd6206bff6da23a12fee69d1b7 Mon Sep 17 00:00:00 2001
|
|
|
77c23f |
From: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Date: Tue, 16 Jun 2020 12:25:36 -0400
|
|
|
77c23f |
Subject: [PATCH 1/3] hw/pci/pcie: Move hot plug capability check to pre_plug
|
|
|
77c23f |
callback
|
|
|
77c23f |
|
|
|
77c23f |
RH-Author: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Message-id: <20200616122536.1027685-1-jusual@redhat.com>
|
|
|
77c23f |
Patchwork-id: 97548
|
|
|
77c23f |
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/1] hw/pci/pcie: Move hot plug capability check to pre_plug callback
|
|
|
77c23f |
Bugzilla: 1820531
|
|
|
77c23f |
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
77c23f |
|
|
|
77c23f |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1820531
|
|
|
77c23f |
BRANCH: rhel-av-8.2.1
|
|
|
77c23f |
UPSTREAM: merged
|
|
|
77c23f |
BREW: 29422092
|
|
|
77c23f |
|
|
|
77c23f |
Check for hot plug capability earlier to avoid removing devices attached
|
|
|
77c23f |
during the initialization process.
|
|
|
77c23f |
|
|
|
77c23f |
Run qemu with an unattached drive:
|
|
|
77c23f |
-drive file=$FILE,if=none,id=drive0 \
|
|
|
77c23f |
-device pcie-root-port,id=rp0,slot=3,bus=pcie.0,hotplug=off
|
|
|
77c23f |
Hotplug a block device:
|
|
|
77c23f |
device_add virtio-blk-pci,id=blk0,drive=drive0,bus=rp0
|
|
|
77c23f |
If hotplug fails on plug_cb, drive0 will be deleted.
|
|
|
77c23f |
|
|
|
77c23f |
Fixes: 0501e1aa1d32a6 ("hw/pci/pcie: Forbid hot-plug if it's disabled on the slot")
|
|
|
77c23f |
|
|
|
77c23f |
Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
77c23f |
Signed-off-by: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Message-Id: <20200604125947.881210-1-jusual@redhat.com>
|
|
|
77c23f |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
77c23f |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
77c23f |
(cherry picked from commit 0dabc0f6544f2c0310546f6d6cf3b68979580a9c)
|
|
|
77c23f |
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
|
|
|
77c23f |
---
|
|
|
77c23f |
hw/pci/pcie.c | 19 +++++++++++--------
|
|
|
77c23f |
1 file changed, 11 insertions(+), 8 deletions(-)
|
|
|
77c23f |
|
|
|
77c23f |
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
|
|
|
77c23f |
index abc99b6eff..1386dd228c 100644
|
|
|
77c23f |
--- a/hw/pci/pcie.c
|
|
|
77c23f |
+++ b/hw/pci/pcie.c
|
|
|
77c23f |
@@ -407,6 +407,17 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplug_dev, DeviceState *dev,
|
|
|
77c23f |
void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
77c23f |
Error **errp)
|
|
|
77c23f |
{
|
|
|
77c23f |
+ PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
|
|
|
77c23f |
+ uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
|
|
|
77c23f |
+ uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
|
|
|
77c23f |
+
|
|
|
77c23f |
+ /* Check if hot-plug is disabled on the slot */
|
|
|
77c23f |
+ if (dev->hotplugged && (sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
|
|
|
77c23f |
+ error_setg(errp, "Hot-plug failed: unsupported by the port device '%s'",
|
|
|
77c23f |
+ DEVICE(hotplug_pdev)->id);
|
|
|
77c23f |
+ return;
|
|
|
77c23f |
+ }
|
|
|
77c23f |
+
|
|
|
77c23f |
pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, errp);
|
|
|
77c23f |
}
|
|
|
77c23f |
|
|
|
77c23f |
@@ -415,7 +426,6 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
77c23f |
{
|
|
|
77c23f |
PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
|
|
|
77c23f |
uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
|
|
|
77c23f |
- uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
|
|
|
77c23f |
PCIDevice *pci_dev = PCI_DEVICE(dev);
|
|
|
77c23f |
|
|
|
77c23f |
/* Don't send event when device is enabled during qemu machine creation:
|
|
|
77c23f |
@@ -431,13 +441,6 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
77c23f |
return;
|
|
|
77c23f |
}
|
|
|
77c23f |
|
|
|
77c23f |
- /* Check if hot-plug is disabled on the slot */
|
|
|
77c23f |
- if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
|
|
|
77c23f |
- error_setg(errp, "Hot-plug failed: unsupported by the port device '%s'",
|
|
|
77c23f |
- DEVICE(hotplug_pdev)->id);
|
|
|
77c23f |
- return;
|
|
|
77c23f |
- }
|
|
|
77c23f |
-
|
|
|
77c23f |
/* To enable multifunction hot-plug, we just ensure the function
|
|
|
77c23f |
* 0 added last. When function 0 is added, we set the sltsta and
|
|
|
77c23f |
* inform OS via event notification.
|
|
|
77c23f |
--
|
|
|
77c23f |
2.27.0
|
|
|
77c23f |
|