[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/20] pcie: factor out pcie_cap_slot_unplug()
From: |
Michael S. Tsirkin |
Subject: |
[PULL 18/20] pcie: factor out pcie_cap_slot_unplug() |
Date: |
Mon, 15 Nov 2021 11:39:00 -0500 |
From: Gerd Hoffmann <kraxel@redhat.com>
No functional change.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Message-Id: <20211111130859.1171890-5-kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pci/pcie.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index b92dbff118..959bf074b2 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -497,6 +497,25 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice
*dev, void *opaque)
object_unparent(OBJECT(dev));
}
+static void pcie_cap_slot_do_unplug(PCIDevice *dev)
+{
+ PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev));
+ uint8_t *exp_cap = dev->config + dev->exp.exp_cap;
+ uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP);
+
+ pci_for_each_device_under_bus(sec_bus, pcie_unplug_device, NULL);
+
+ pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_PDS);
+ if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA ||
+ (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) {
+ pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
+ PCI_EXP_LNKSTA_DLLLA);
+ }
+ pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_PDC);
+}
+
void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
@@ -676,7 +695,6 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
uint32_t pos = dev->exp.exp_cap;
uint8_t *exp_cap = dev->config + pos;
uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
- uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP);
if (ranges_overlap(addr, len, pos + PCI_EXP_SLTSTA, 2)) {
/*
@@ -726,17 +744,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
(val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF &&
(!(old_slt_ctl & PCI_EXP_SLTCTL_PCC) ||
(old_slt_ctl & PCI_EXP_SLTCTL_PIC_OFF) != PCI_EXP_SLTCTL_PIC_OFF)) {
- PCIBus *sec_bus = pci_bridge_get_sec_bus(PCI_BRIDGE(dev));
- pci_for_each_device_under_bus(sec_bus, pcie_unplug_device, NULL);
- pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
- PCI_EXP_SLTSTA_PDS);
- if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA ||
- (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) {
- pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
- PCI_EXP_LNKSTA_DLLLA);
- }
- pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
- PCI_EXP_SLTSTA_PDC);
+ pcie_cap_slot_do_unplug(dev);
}
pcie_cap_update_power(dev);
--
MST
- [PULL 08/20] bios-tables-test: Allow changes in DSDT ACPI tables, (continued)
- [PULL 08/20] bios-tables-test: Allow changes in DSDT ACPI tables, Michael S. Tsirkin, 2021/11/15
- [PULL 09/20] hw/i386/acpi-build: Deny control on PCIe Native Hot-plug in _OSC, Michael S. Tsirkin, 2021/11/15
- [PULL 10/20] tests: bios-tables-test update expected blobs, Michael S. Tsirkin, 2021/11/15
- [PULL 11/20] virtio: use virtio accessor to access packed descriptor flags, Michael S. Tsirkin, 2021/11/15
- [PULL 12/20] virtio: use virtio accessor to access packed event, Michael S. Tsirkin, 2021/11/15
- [PULL 13/20] vdpa: Replace qemu_open_old by qemu_open at, Michael S. Tsirkin, 2021/11/15
- [PULL 14/20] vdpa: Check for existence of opts.vhostdev, Michael S. Tsirkin, 2021/11/15
- [PULL 15/20] pci: implement power state, Michael S. Tsirkin, 2021/11/15
- [PULL 16/20] pcie: implement slot power control for pcie root ports, Michael S. Tsirkin, 2021/11/15
- [PULL 17/20] pcie: add power indicator blink check, Michael S. Tsirkin, 2021/11/15
- [PULL 18/20] pcie: factor out pcie_cap_slot_unplug(),
Michael S. Tsirkin <=
- [PULL 19/20] pcie: fast unplug when slot power is off, Michael S. Tsirkin, 2021/11/15
- [PULL 20/20] pcie: expire pending delete, Michael S. Tsirkin, 2021/11/15
- [PULL 03/20] vhost: Rename last_index to vq_index_end, Michael S. Tsirkin, 2021/11/15
- Re: [PULL 00/20] pci,pc,virtio: bugfixes, Philippe Mathieu-Daudé, 2021/11/15
- Re: [PULL 00/20] pci,pc,virtio: bugfixes, Richard Henderson, 2021/11/16