qemu/include/hw/pci
Igor Mammedov 6b0969f1ec acpi: pcihp: pcie: set power on cap on parent slot
on creation a PCIDevice has power turned on at the end of pci_qdev_realize()
however later on if PCIe slot isn't populated with any children
it's power is turned off. It's fine if native hotplug is used
as plug callback will power slot on among other things.
However when ACPI hotplug is enabled it replaces native PCIe plug
callbacks with ACPI specific ones (acpi_pcihp_device_*plug_cb) and
as result slot stays powered off. It works fine as ACPI hotplug
on guest side takes care of enumerating/initializing hotplugged
device. But when later guest is migrated, call chain introduced by]
commit d5daff7d31 (pcie: implement slot power control for pcie root ports)

   pcie_cap_slot_post_load()
       -> pcie_cap_update_power()
           -> pcie_set_power_device()
               -> pci_set_power()
                   -> pci_update_mappings()

will disable earlier initialized BARs for the hotplugged device
in powered off slot due to commit 23786d1344 (pci: implement power state)
which disables BARs if power is off.

Fix it by setting PCI_EXP_SLTCTL_PCC to PCI_EXP_SLTCTL_PWR_ON
on slot (root port/downstream port) at the time a device
hotplugged into it. As result PCI_EXP_SLTCTL_PWR_ON is migrated
to target and above call chain keeps device plugged into it
powered on.

Fixes: d5daff7d31 ("pcie: implement slot power control for pcie root ports")
Fixes: 23786d1344 ("pci: implement power state")
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2053584
Suggested-by: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <20220301151200.3507298-3-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2022-03-06 05:08:23 -05:00
..
msi.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
msix.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
pci_bridge.h qtest/libqos: add a function to initialize secondary PCI buses 2021-12-15 08:07:04 +01:00
pci_bus.h pci: Move PCIBusClass typedef to pci.h 2020-08-27 14:04:54 -04:00
pci_host.h hw/pci/pci_host: Allow PCI host to bypass iommu 2021-07-16 11:10:45 -04:00
pci_ids.h vfio/pci: Add pba_offset PCI quirk for BAIDU KUNLUN AI processor 2021-07-14 13:47:17 -06:00
pci_regs.h pcie: Add 1.2 version token for the Power Management Capability 2022-03-06 05:08:23 -05:00
pci.h pcie: Add support for Single Root I/O Virtualization (SR/IOV) 2022-03-06 05:08:23 -05:00
pcie_aer.h Include hw/hw.h exactly where needed 2019-08-16 13:31:52 +02:00
pcie_host.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
pcie_port.h hw/pci/pcie: Do not set HPC flag if acpihp is used 2021-07-16 04:33:35 -04:00
pcie_regs.h pcie: Add a simple PCIe ACS (Access Control Services) helper function 2019-03-12 22:31:21 -04:00
pcie_sriov.h pcie: Add a helper to the SR/IOV API 2022-03-06 05:08:23 -05:00
pcie.h acpi: pcihp: pcie: set power on cap on parent slot 2022-03-06 05:08:23 -05:00
shpc.h Include migration/vmstate.h less 2019-08-16 13:31:52 +02:00
slotid_cap.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00