[PATCH v2 0/3] Fix broken PCIe device after migration

Igor Mammedov posted 3 patches 2 years, 2 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220301151200.3507298-1-imammedo@redhat.com
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <ani@anisinha.ca>, Eduardo Habkost <eduardo@habkost.net>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Yanan Wang <wangyanan55@huawei.com>
include/hw/acpi/pcihp.h                    |  1 +
include/hw/pci-bridge/xio3130_downstream.h | 15 +++++++++++++++
include/hw/pci/pcie.h                      |  1 +
hw/acpi/ich9.c                             | 20 ++++++++++++++++++++
hw/acpi/pcihp.c                            | 15 ++++++++++++++-
hw/core/machine.c                          |  4 +++-
hw/pci-bridge/xio3130_downstream.c         |  3 ++-
hw/pci/pcie.c                              | 11 +++++++++++
8 files changed, 67 insertions(+), 3 deletions(-)
create mode 100644 include/hw/pci-bridge/xio3130_downstream.h
[PATCH v2 0/3] Fix broken PCIe device after migration
Posted by Igor Mammedov 2 years, 2 months ago
Changelog:
   v2:
     * instead of disabling power control on slot and letting ACPI
       PCI hotplug  module in guest to deal with it, set
       PCI_EXP_SLTCTL_PWR_ON on PCIe slot from acpi_pcihp_device_plug_cb()
       when a device plugged into it.

Currently ACPI PCI hotplug is enabled by default for Q35 machine
type and overrides native PCIe hotplug. It works as expected when
a PCIe device is hotplugged into slot, however the device becomes
in-operational after migration. Which is caused by BARs being
disabled on target due to powered off status of the slot.

Proposed fix turns on power on PCIe slot when a device is
hotplugged into it, then that state is migrated and device
stays powred on after migration. 

Tested with (seabios: FC34, Win2012; ovmf: RHEL8)

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2053584
CC: mst@redhat.com
CC: kraxel@redhat.com

Ref to v1:
 https://lore.kernel.org/all/20220225100127.78974d71@redhat.com/T/
Gitlab link:
 https://gitlab.com/imammedo/qemu/-/tree/pcie_poweroff_acpi_regression_rhbz2053584_V2

Igor Mammedov (3):
  pci: expose TYPE_XIO3130_DOWNSTREAM name
  acpi: pcihp: pcie: set power on cap on parent slot
  q35: compat: keep hotplugged PCIe device broken after migration for
    6.2 and older machine types

 include/hw/acpi/pcihp.h                    |  1 +
 include/hw/pci-bridge/xio3130_downstream.h | 15 +++++++++++++++
 include/hw/pci/pcie.h                      |  1 +
 hw/acpi/ich9.c                             | 20 ++++++++++++++++++++
 hw/acpi/pcihp.c                            | 15 ++++++++++++++-
 hw/core/machine.c                          |  4 +++-
 hw/pci-bridge/xio3130_downstream.c         |  3 ++-
 hw/pci/pcie.c                              | 11 +++++++++++
 8 files changed, 67 insertions(+), 3 deletions(-)
 create mode 100644 include/hw/pci-bridge/xio3130_downstream.h

-- 
2.31.1
Re: [PATCH v2 0/3] Fix broken PCIe device after migration
Posted by Michael S. Tsirkin 2 years, 2 months ago
On Tue, Mar 01, 2022 at 10:11:57AM -0500, Igor Mammedov wrote:
> Changelog:
>    v2:
>      * instead of disabling power control on slot and letting ACPI
>        PCI hotplug  module in guest to deal with it, set
>        PCI_EXP_SLTCTL_PWR_ON on PCIe slot from acpi_pcihp_device_plug_cb()
>        when a device plugged into it.
> 
> Currently ACPI PCI hotplug is enabled by default for Q35 machine
> type and overrides native PCIe hotplug. It works as expected when
> a PCIe device is hotplugged into slot, however the device becomes
> in-operational after migration. Which is caused by BARs being
> disabled on target due to powered off status of the slot.
> 
> Proposed fix turns on power on PCIe slot when a device is
> hotplugged into it, then that state is migrated and device
> stays powred on after migration. 


Looks good for 1-2. Some questions on 3.
Thanks!

> Tested with (seabios: FC34, Win2012; ovmf: RHEL8)
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=2053584
> CC: mst@redhat.com
> CC: kraxel@redhat.com
> 
> Ref to v1:
>  https://lore.kernel.org/all/20220225100127.78974d71@redhat.com/T/
> Gitlab link:
>  https://gitlab.com/imammedo/qemu/-/tree/pcie_poweroff_acpi_regression_rhbz2053584_V2
> 
> Igor Mammedov (3):
>   pci: expose TYPE_XIO3130_DOWNSTREAM name
>   acpi: pcihp: pcie: set power on cap on parent slot
>   q35: compat: keep hotplugged PCIe device broken after migration for
>     6.2 and older machine types
> 
>  include/hw/acpi/pcihp.h                    |  1 +
>  include/hw/pci-bridge/xio3130_downstream.h | 15 +++++++++++++++
>  include/hw/pci/pcie.h                      |  1 +
>  hw/acpi/ich9.c                             | 20 ++++++++++++++++++++
>  hw/acpi/pcihp.c                            | 15 ++++++++++++++-
>  hw/core/machine.c                          |  4 +++-
>  hw/pci-bridge/xio3130_downstream.c         |  3 ++-
>  hw/pci/pcie.c                              | 11 +++++++++++
>  8 files changed, 67 insertions(+), 3 deletions(-)
>  create mode 100644 include/hw/pci-bridge/xio3130_downstream.h
> 
> -- 
> 2.31.1