|
|
77c23f |
From 8587278a20283851081d4d282d11ef6bafd17dc2 Mon Sep 17 00:00:00 2001
|
|
|
77c23f |
From: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Date: Tue, 17 Mar 2020 13:56:39 -0400
|
|
|
77c23f |
Subject: [PATCH 1/2] pcie_root_port: Add hotplug disabling option
|
|
|
77c23f |
MIME-Version: 1.0
|
|
|
77c23f |
Content-Type: text/plain; charset=UTF-8
|
|
|
77c23f |
Content-Transfer-Encoding: 8bit
|
|
|
77c23f |
|
|
|
77c23f |
RH-Author: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Message-id: <20200317135639.65085-1-jusual@redhat.com>
|
|
|
77c23f |
Patchwork-id: 94367
|
|
|
77c23f |
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 1/1] pcie_root_port: Add hotplug disabling option
|
|
|
77c23f |
Bugzilla: 1790899
|
|
|
77c23f |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
|
|
77c23f |
|
|
|
77c23f |
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1790899
|
|
|
77c23f |
BRANCH: rhel-av-8.2.1
|
|
|
77c23f |
UPSTREAM: merged
|
|
|
77c23f |
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=27302449
|
|
|
77c23f |
|
|
|
77c23f |
Make hot-plug/hot-unplug on PCIe Root Ports optional to allow libvirt
|
|
|
77c23f |
manage it and restrict unplug for the whole machine. This is going to
|
|
|
77c23f |
prevent user-initiated unplug in guests (Windows mostly).
|
|
|
77c23f |
Hotplug is enabled by default.
|
|
|
77c23f |
Usage:
|
|
|
77c23f |
-device pcie-root-port,hotplug=off,...
|
|
|
77c23f |
|
|
|
77c23f |
If you want to disable hot-unplug on some downstream ports of one
|
|
|
77c23f |
switch, disable hot-unplug on PCIe Root Port connected to the upstream
|
|
|
77c23f |
port as well as on the selected downstream ports.
|
|
|
77c23f |
|
|
|
77c23f |
Discussion related:
|
|
|
77c23f |
https://lists.gnu.org/archive/html/qemu-devel/2020-02/msg00530.html
|
|
|
77c23f |
|
|
|
77c23f |
Signed-off-by: Julia Suvorova <jusual@redhat.com>
|
|
|
77c23f |
Message-Id: <20200226174607.205941-1-jusual@redhat.com>
|
|
|
77c23f |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
77c23f |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
77c23f |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
77c23f |
(cherry picked from commit 530a0963184e57e71a5b538e9161f115df533e96)
|
|
|
77c23f |
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
|
|
|
77c23f |
---
|
|
|
77c23f |
hw/pci-bridge/pcie_root_port.c | 2 +-
|
|
|
77c23f |
hw/pci-bridge/xio3130_downstream.c | 2 +-
|
|
|
77c23f |
hw/pci/pcie.c | 11 +++++++----
|
|
|
77c23f |
hw/pci/pcie_port.c | 1 +
|
|
|
77c23f |
include/hw/pci/pcie.h | 2 +-
|
|
|
77c23f |
include/hw/pci/pcie_port.h | 3 +++
|
|
|
77c23f |
6 files changed, 14 insertions(+), 7 deletions(-)
|
|
|
77c23f |
|
|
|
77c23f |
diff --git a/hw/pci-bridge/pcie_root_port.c b/hw/pci-bridge/pcie_root_port.c
|
|
|
77c23f |
index 012c2cb12c..db80e2ec23 100644
|
|
|
77c23f |
--- a/hw/pci-bridge/pcie_root_port.c
|
|
|
77c23f |
+++ b/hw/pci-bridge/pcie_root_port.c
|
|
|
77c23f |
@@ -94,7 +94,7 @@ static void rp_realize(PCIDevice *d, Error **errp)
|
|
|
77c23f |
|
|
|
77c23f |
pcie_cap_arifwd_init(d);
|
|
|
77c23f |
pcie_cap_deverr_init(d);
|
|
|
77c23f |
- pcie_cap_slot_init(d, s->slot);
|
|
|
77c23f |
+ pcie_cap_slot_init(d, s);
|
|
|
77c23f |
pcie_cap_root_init(d);
|
|
|
77c23f |
|
|
|
77c23f |
pcie_chassis_create(s->chassis);
|
|
|
77c23f |
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
|
|
|
77c23f |
index a9f084b863..4489ce4a40 100644
|
|
|
77c23f |
--- a/hw/pci-bridge/xio3130_downstream.c
|
|
|
77c23f |
+++ b/hw/pci-bridge/xio3130_downstream.c
|
|
|
77c23f |
@@ -94,7 +94,7 @@ static void xio3130_downstream_realize(PCIDevice *d, Error **errp)
|
|
|
77c23f |
}
|
|
|
77c23f |
pcie_cap_flr_init(d);
|
|
|
77c23f |
pcie_cap_deverr_init(d);
|
|
|
77c23f |
- pcie_cap_slot_init(d, s->slot);
|
|
|
77c23f |
+ pcie_cap_slot_init(d, s);
|
|
|
77c23f |
pcie_cap_arifwd_init(d);
|
|
|
77c23f |
|
|
|
77c23f |
pcie_chassis_create(s->chassis);
|
|
|
77c23f |
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
|
|
|
77c23f |
index 08718188bb..0eb3a2a5d2 100644
|
|
|
77c23f |
--- a/hw/pci/pcie.c
|
|
|
77c23f |
+++ b/hw/pci/pcie.c
|
|
|
77c23f |
@@ -495,7 +495,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
|
|
|
77c23f |
|
|
|
77c23f |
/* pci express slot for pci express root/downstream port
|
|
|
77c23f |
PCI express capability slot registers */
|
|
|
77c23f |
-void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
|
|
|
77c23f |
+void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s)
|
|
|
77c23f |
{
|
|
|
77c23f |
uint32_t pos = dev->exp.exp_cap;
|
|
|
77c23f |
|
|
|
77c23f |
@@ -505,13 +505,16 @@ void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot)
|
|
|
77c23f |
pci_long_test_and_clear_mask(dev->config + pos + PCI_EXP_SLTCAP,
|
|
|
77c23f |
~PCI_EXP_SLTCAP_PSN);
|
|
|
77c23f |
pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP,
|
|
|
77c23f |
- (slot << PCI_EXP_SLTCAP_PSN_SHIFT) |
|
|
|
77c23f |
+ (s->slot << PCI_EXP_SLTCAP_PSN_SHIFT) |
|
|
|
77c23f |
PCI_EXP_SLTCAP_EIP |
|
|
|
77c23f |
- PCI_EXP_SLTCAP_HPS |
|
|
|
77c23f |
- PCI_EXP_SLTCAP_HPC |
|
|
|
77c23f |
PCI_EXP_SLTCAP_PIP |
|
|
|
77c23f |
PCI_EXP_SLTCAP_AIP |
|
|
|
77c23f |
PCI_EXP_SLTCAP_ABP);
|
|
|
77c23f |
+ if (s->hotplug) {
|
|
|
77c23f |
+ pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP,
|
|
|
77c23f |
+ PCI_EXP_SLTCAP_HPS |
|
|
|
77c23f |
+ PCI_EXP_SLTCAP_HPC);
|
|
|
77c23f |
+ }
|
|
|
77c23f |
|
|
|
77c23f |
if (dev->cap_present & QEMU_PCIE_SLTCAP_PCP) {
|
|
|
77c23f |
pci_long_test_and_set_mask(dev->config + pos + PCI_EXP_SLTCAP,
|
|
|
77c23f |
diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c
|
|
|
77c23f |
index c19a9be592..36dac33d98 100644
|
|
|
77c23f |
--- a/hw/pci/pcie_port.c
|
|
|
77c23f |
+++ b/hw/pci/pcie_port.c
|
|
|
77c23f |
@@ -147,6 +147,7 @@ static const TypeInfo pcie_port_type_info = {
|
|
|
77c23f |
static Property pcie_slot_props[] = {
|
|
|
77c23f |
DEFINE_PROP_UINT8("chassis", PCIESlot, chassis, 0),
|
|
|
77c23f |
DEFINE_PROP_UINT16("slot", PCIESlot, slot, 0),
|
|
|
77c23f |
+ DEFINE_PROP_BOOL("hotplug", PCIESlot, hotplug, true),
|
|
|
77c23f |
DEFINE_PROP_END_OF_LIST()
|
|
|
77c23f |
};
|
|
|
77c23f |
|
|
|
77c23f |
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
|
|
|
77c23f |
index 7064875835..14c58ebdb6 100644
|
|
|
77c23f |
--- a/include/hw/pci/pcie.h
|
|
|
77c23f |
+++ b/include/hw/pci/pcie.h
|
|
|
77c23f |
@@ -104,7 +104,7 @@ void pcie_cap_deverr_reset(PCIDevice *dev);
|
|
|
77c23f |
void pcie_cap_lnkctl_init(PCIDevice *dev);
|
|
|
77c23f |
void pcie_cap_lnkctl_reset(PCIDevice *dev);
|
|
|
77c23f |
|
|
|
77c23f |
-void pcie_cap_slot_init(PCIDevice *dev, uint16_t slot);
|
|
|
77c23f |
+void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s);
|
|
|
77c23f |
void pcie_cap_slot_reset(PCIDevice *dev);
|
|
|
77c23f |
void pcie_cap_slot_get(PCIDevice *dev, uint16_t *slt_ctl, uint16_t *slt_sta);
|
|
|
77c23f |
void pcie_cap_slot_write_config(PCIDevice *dev,
|
|
|
77c23f |
diff --git a/include/hw/pci/pcie_port.h b/include/hw/pci/pcie_port.h
|
|
|
77c23f |
index 7515430087..7072cc8731 100644
|
|
|
77c23f |
--- a/include/hw/pci/pcie_port.h
|
|
|
77c23f |
+++ b/include/hw/pci/pcie_port.h
|
|
|
77c23f |
@@ -55,6 +55,9 @@ struct PCIESlot {
|
|
|
77c23f |
|
|
|
77c23f |
/* Disable ACS (really for a pcie_root_port) */
|
|
|
77c23f |
bool disable_acs;
|
|
|
77c23f |
+
|
|
|
77c23f |
+ /* Indicates whether hot-plug is enabled on the slot */
|
|
|
77c23f |
+ bool hotplug;
|
|
|
77c23f |
QLIST_ENTRY(PCIESlot) next;
|
|
|
77c23f |
};
|
|
|
77c23f |
|
|
|
77c23f |
--
|
|
|
77c23f |
2.18.2
|
|
|
77c23f |
|