Skip to content

Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API

Igor Mammedov qemu-devel 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest9 patches 5 repliesIn review
  2. v59 patches 10 repliesSuperseded
  3. v49 patches 5 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v311 patches21 repliesSuperseded
v211 patches4 repliesSuperseded
v17 patches26 repliesSuperseded

Changes in v6 from the cover letter

- fixed typos Eric pointed to
- fix conflict of [5/9] with new patch "acpi-build: append description for non-hotplug"
- rebased on top of todays PCI tree

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9define hotplug interfacehw/core/Makefile.objs hw/core/hotplug.c include/hw/hotplug.h+127 -00 replies
2/9qdev: add to BusState "hotplug-handler" linkhw/core/qdev.c include/hw/qdev-core.h+16 -03 replies
3/9qdev: add "hotpluggable" property to Devicehw/core/qdev.c include/hw/qdev-core.h+32 -00 replies
4/9hw/acpi: move typeinfo to the file endhw/acpi/piix4.c+46 -460 replies
5/9qdev:pci: refactor PCIDevice to use generic "hotpluggable" propertyhw/acpi/pcihp.c hw/acpi/piix4.c hw/display/cirrus_vga.c +13 more+21 -300 replies
6/9acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler APIhw/acpi/pcihp.c hw/acpi/piix4.c include/hw/acpi/acpi.h +1 more+60 -300 replies
7/9pci/shpc: convert SHPC hotplug to use hotplug-handler APIhw/pci-bridge/pci_bridge_dev.c hw/pci/shpc.c include/hw/pci/shpc.h+94 -470 replies
8/9pci/pcie: convert PCIE hotplug to use hotplug-handler APIhw/pci/pcie.c hw/pci/pcie_port.c include/hw/pci/pcie.h+53 -250 replies
9/9hw/pci: switch to a generic hotplug handling for PCIDevicehw/core/qdev.c hw/pci/pci.c include/hw/pci/pci.h +2 more+15 -450 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v6 yet.

Read the v6 thread

Cover letter [Qemu-devel] [PATCH v6 0/9] Refactor PCI/SHPC/PCIE hotplug to use a more generic hotplug API

changes since v5:
- fixed typos Eric pointed to
- fix conflict of [5/9] with new patch "acpi-build: append description for non-hotplug"
- rebased on top of todays PCI tree

changes since v4:
- rebased on top of PCI tree
- added wrapper to set hotplug-device property

changes since v3:
- fixup/add comments as reqused by Peter Crosthwaite
- use error_abort to reduce error handling verbosity
- fix tests/test-qdev-global-props build failure on make check
- rebase on top of current master:133fe7743 (with interface fixes)

changes since v2:
* s/hotplugable/hotpluggable/
* move hotplug check to an earlier patch:
"qdev: add "hotpluggable" property to Device"
--
Refactor PCI specific hotplug API to a more generic/reusable one. Model it after SCSI-BUS like hotplug API replacing single hotplug callback with hotplug/hot_unplug pair of callbacks as suggested by Paolo.
Difference between SCSI-BUS and this approach is that the former is BUS centric while the latter is device centred. Which is evolved from the fact that hotplug callbacks used by ACPI/SHPC/PCIE are implemented by devices rather than by bus and bus serves only as a proxy to forward event to hotplug device.
Memory hotplug also exposes tha same usage pattern hence an attempt to generalize hotplug API.

Refactoring also simplifies wiring of a hotplug device with a bus, all it needs is to set "hotplug-device" link on bus, which would potentially allow to do it from configuration file, there is not need to setup hotplug device callbacks on bus synce it can get them via HOTPLUG_DEVICE API of "hotplug-device" target.

In addition device centred hotplug API may be used by bus-less hotplug implementations as well if it's decided to use link<foo...> instead of bus.

Patches 8-11 are should be merged as one and are split only for simplifying review (they compile fine but PCI hotplug is broken until the last patch is applyed).

git tree for testing:
https://github.com/imammedo/qemu/commits/hotplug_dev_inf_v6

tested only ACPI and PCIE hotplug, since SHPC is not functional, tested
it under debugger that hotplhug event reaches handler and corresponding interrupt is emited.

Igor Mammedov (9):
define hotplug interface
qdev: add to BusState "hotplug-handler" link
qdev: add "hotpluggable" property to Device
hw/acpi: move typeinfo to the file end
qdev:pci: refactor PCIDevice to use generic "hotpluggable" property acpi/piix4pm: convert ACPI PCI hotplug to use hotplug-handler API pci/shpc: convert SHPC hotplug to use hotplug-handler API pci/pcie: convert PCIE hotplug to use hotplug-handler API hw/pci: switch to a generic hotplug handling for PCIDevice

 hw/acpi/pcihp.c                |   46 ++++++++++----
 hw/acpi/piix4.c                |  128 +++++++++++++++++++++-------------------
 hw/core/Makefile.objs          |    1 +
 hw/core/hotplug.c              |   48 +++++++++++++++
 hw/core/qdev.c                 |   50 ++++++++++++++-
 hw/display/cirrus_vga.c        |    2 +-
 hw/display/qxl.c               |    2 +-
 hw/display/vga-pci.c           |    2 +-
 hw/display/vmware_vga.c        |    2 +-
 hw/i386/acpi-build.c           |    4 +-
 hw/ide/piix.c                  |    4 +-
 hw/isa/piix4.c                 |    2 +-
 hw/pci-bridge/pci_bridge_dev.c |    9 +++
 hw/pci-host/piix.c             |    6 +-
 hw/pci/pci.c                   |   40 +------------
 hw/pci/pcie.c                  |   65 ++++++++++++--------
 hw/pci/pcie_port.c             |    8 +++
 hw/pci/shpc.c                  |  124 ++++++++++++++++++++++++---------------
 hw/usb/hcd-ehci-pci.c          |    2 +-
 hw/usb/hcd-ohci.c              |    2 +-
 hw/usb/hcd-uhci.c              |    2 +-
 hw/usb/hcd-xhci.c              |    2 +-
 include/hw/acpi/acpi.h         |    1 +
 include/hw/acpi/pcihp.h        |   10 ++-
 include/hw/hotplug.h           |   78 ++++++++++++++++++++++++
 include/hw/pci/pci.h           |   13 ----
 include/hw/pci/pci_bus.h       |    2 -
 include/hw/pci/pcie.h          |    5 ++
 include/hw/pci/shpc.h          |    8 +++
 include/hw/qdev-core.h         |   15 +++++
 tests/Makefile                 |    2 +-
 31 files changed, 463 insertions(+), 222 deletions(-)
 create mode 100644 hw/core/hotplug.c
 create mode 100644 include/hw/hotplug.h