pci: hotplug handler reworks
v2 cover pci: hotplug handler reworks
This series reworks some pci hotplug handlers (except for s390, that will require more work but is not required for now).
1. Route all unplug calls via the hotplug handler when called from the unplug_request handler. This will be required to get multi-stage hotplug handlers running, but also makes sense on its own (just like we already did for some CPU/memory hotplug handlers).
2. Introduce some pre_plug handlers where it makes sense already.
3. Call the plug/pre_plug handler also for coldplugged devices. Especially pcihp is special as it overwrites hotplug handlers.
This series will not yet factor out pre_plug/plug/unplug from pci device realize/unrealize functions, this will require more work but this series is also required first to get it running.
Quoted 1 line
From my POV what needs to be done in the future:
1. Introduce pre_plug/plug/unplug_request/unplug handlers for all PCI buses
2. Move pci realize/unrealize parts to pre_plug/pkug/unplug functions like pci_pre_plug() ...
3. Call the pci pre_plug/plug/unplug handlers from the PCI bus hotplug handler at the right spots
4. Factor more checks from existing plug() handlers out into pre_plug() (e.g. after the call to pci_pre_plug())
v1 -> v2:
- Added "pci/pcie: rename hotplug handler callbacks"
- Added "pci/shpc: rename hotplug handler callbacks"
- Added "s390x/pci: rename hotplug handler callbacks"
- Dropped "pci/shpc: move hotplug checks to preplug handler" -- We will have to factor out stuff into pre_plug() first as described above
- Renamed and added more details to the "perform unplug via the hotplug handler" patches
- "pci/pcihp: overwrite hotplug handler recursively from the start" -- Perform the overwrite only for cold plugged bridges, to keep the existing behavior
David Hildenbrand (10):
pci/pcie: rename hotplug handler callbacks
pci/shpc: rename hotplug handler callbacks
s390x/pci: rename hotplug handler callbacks
pci/pcie: stop plug/unplug if the slot is locked pci/pcihp: perform check for bus capability in pre_plug handler pci/pcihp: overwrite hotplug handler recursively from the start pci/pcihp: perform unplug via the hotplug handler pci/pcie: perform unplug via the hotplug handler pci/shpc: perform unplug via the hotplug handler
spapr_pci: perform unplug via the hotplug handler
hw/acpi/pcihp.c | 47 ++++++++++++++++++++++++++++----- hw/acpi/piix4.c | 39 ++++++++++++++------------- hw/pci-bridge/pci_bridge_dev.c | 31 +++++++++++++++------- hw/pci-bridge/pcie_pci_bridge.c | 29 ++++++++++++++------ hw/pci/pcie.c | 46 +++++++++++++++++++++----------- hw/pci/pcie_port.c | 6 +++-- hw/pci/shpc.c | 25 ++++++++++++------ hw/ppc/spapr_pci.c | 33 ++++++++++++++--------- hw/s390x/s390-pci-bus.c | 12 ++++----- include/hw/acpi/pcihp.h | 5 ++++ include/hw/pci/pcie.h | 12 ++++++--- include/hw/pci/shpc.h | 10 ++++--- 12 files changed, 201 insertions(+), 94 deletions(-)
Signature · 1 line
2.17.2
PATCH v2 1/10 pci/pcie: rename hotplug handler callbacks
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename pcie_cap_slot_hotplug_common() to pcie_cap_slot_check_common().
--- hw/pci/pcie.c | 17 ++++++++--------- hw/pci/pcie_port.c | 4 ++-- include/hw/pci/pcie.h | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-)
hw/pci/pcie.c +8 -9
@@ -315,9 +315,8 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event)hotplug_event_notify (dev); } -static void pcie_cap_slot_hotplug_common (PCIDevice *hotplug_dev, -DeviceState *dev, -uint8_t **exp_cap,Error **errp) +static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, +uint8_t **exp_cap,Error **errp) { *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA );
@@ -331,13 +330,13 @@ static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev, } } -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp) +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an
@@ -365,14 +364,14 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually,
hw/pci/pcie_port.c +2 -2
@@ -154,8 +154,8 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; - hc->plug = pcie_cap_slot_hotplug_cb; - hc->unplug_request = pcie_cap_slot_hot_unplug_request_cb; + hc->plug = pcie_cap_slot_plug_cb; + hc->unplug_request = pcie_cap_slot_unplug_request_cb; }static const TypeInfo pcie_slot_type_info = {
include/hw/pci/pcie.h +4 -4
@@ -131,8 +131,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 01/10] pci/pcie: rename hotplug handler callbacks
Quoted 5 lines · David Hildenbrand
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename
pcie_cap_slot_hotplug_common()topcie_cap_slot_check_common().
Uh.. this part of the message doesn't appear to be accurate any more.
Quoted 2 lines
Signed-off-by David Hildenbrand <[email protected]>
Apart from that,
Quoted 89 lines
--- hw/pci/pcie.c | 17 ++++++++--------- hw/pci/pcie_port.c | 4 ++-- include/hw/pci/pcie.h | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-)hw/pci/pcie.c +8
-9@@ -315,9 +315,8 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event)hotplug_event_notify (dev); } -static void pcie_cap_slot_hotplug_common (PCIDevice *hotplug_dev, -DeviceState *dev, -uint8_t **exp_cap,Error **errp) +static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, +uint8_t **exp_cap,Error **errp) { *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA );@@ -331,13 +330,13 @@ static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev, } } -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp) +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an @@ -365,14 +364,14 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually, hw/pci/pcie_port.c +2
-2@@ -154,8 +154,8 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; - hc->plug = pcie_cap_slot_hotplug_cb; - hc->unplug_request = pcie_cap_slot_hot_unplug_request_cb; + hc->plug = pcie_cap_slot_plug_cb; + hc->unplug_request = pcie_cap_slot_unplug_request_cb; }static const TypeInfo pcie_slot_type_info = {include/hw/pci/pcie.h +4
-4@@ -131,8 +131,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 01/10] pci/pcie: rename hotplug handler callbacks
Quoted 9 lines · David Gibson
Quoted 5 lines · David Hildenbrand
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename
pcie_cap_slot_hotplug_common()topcie_cap_slot_check_common().Uh.. this part of the message doesn't appear to be accurate any more.
Indeed, after renaming it 10 times I think I forgot to update the description :)
Thanks!
Quoted 7 lines
Quoted 2 lines
Signed-off-by David Hildenbrand <[email protected]>Apart from that,
Reviewed-by David Gibson <[email protected]>
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v2 01/10] pci/pcie: rename hotplug handler callbacks
In reply to David HildenbrandQuoted 7 lines · On Mon, 5 Nov 2018 11:20:35 +0100 David Hildenbrand <[email protected]> wrote:
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename
pcie_cap_slot_hotplug_common()topcie_cap_slot_check_common().Signed-off-by David Hildenbrand <[email protected]>
With commit message amended per David's suggestion
Quoted 89 lines
--- hw/pci/pcie.c | 17 ++++++++--------- hw/pci/pcie_port.c | 4 ++-- include/hw/pci/pcie.h | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-)hw/pci/pcie.c +8
-9@@ -315,9 +315,8 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event)hotplug_event_notify (dev); } -static void pcie_cap_slot_hotplug_common (PCIDevice *hotplug_dev, -DeviceState *dev, -uint8_t **exp_cap,Error **errp) +static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, +uint8_t **exp_cap,Error **errp) { *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA );@@ -331,13 +330,13 @@ static void pcie_cap_slot_hotplug_common(PCIDevice *hotplug_dev, } } -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp) +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an @@ -365,14 +364,14 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)object_unparent (OBJECT (dev)); } -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {uint8_t *exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_hotplug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp);/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually, hw/pci/pcie_port.c +2
-2@@ -154,8 +154,8 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; - hc->plug = pcie_cap_slot_hotplug_cb; - hc->unplug_request = pcie_cap_slot_hot_unplug_request_cb; + hc->plug = pcie_cap_slot_plug_cb; + hc->unplug_request = pcie_cap_slot_unplug_request_cb; }static const TypeInfo pcie_slot_type_info = {include/hw/pci/pcie.h +4
-4@@ -131,8 +131,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); -void pcie_cap_slot_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void pcie_cap_slot_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
PATCH v2 2/10 pci/shpc: rename hotplug handler callbacks
In reply to David HildenbrandThe callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename shpc_device_hotplug_common() to shpc_device_plug_common().
--- hw/pci-bridge/pci_bridge_dev.c | 17 ++++++++--------- hw/pci-bridge/pcie_pci_bridge.c | 17 ++++++++--------- hw/pci/shpc.c | 14 +++++++------- include/hw/pci/shpc.h | 8 ++++---- 4 files changed, 27 insertions(+), 29 deletions(-)
hw/pci-bridge/pci_bridge_dev.c +8 -9
@@ -206,8 +206,8 @@ static const VMStateDescription pci_bridge_dev_vmstate = { } }; -static void pci_bridge_dev_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pci_bridge_dev_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);
@@ -216,12 +216,11 @@ static void pci_bridge_dev_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pci_bridge_dev_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);
@@ -230,7 +229,7 @@ static void pci_bridge_dev_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pci_bridge_dev_class_init (ObjectClass *klass,void *data)
@@ -251,8 +250,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->props = pci_bridge_dev_properties; dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pci_bridge_dev_hotplug_cb; - hc->unplug_request = pci_bridge_dev_hot_unplug_request_cb; + hc->plug = pci_bridge_dev_plug_cb; + hc->unplug_request = pci_bridge_dev_unplug_request_cb; }static const TypeInfo pci_bridge_dev_info = {
hw/pci-bridge/pcie_pci_bridge.c +8 -9
@@ -137,8 +137,8 @@ static const VMStateDescription pcie_pci_bridge_dev_vmstate = { } }; -static void pcie_pci_bridge_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pcie_pci_bridge_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);
@@ -147,12 +147,11 @@ static void pcie_pci_bridge_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pcie_pci_bridge_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);
@@ -161,7 +160,7 @@ static void pcie_pci_bridge_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pcie_pci_bridge_class_init (ObjectClass *klass,void *data)
@@ -180,8 +179,8 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->props = pcie_pci_bridge_dev_properties; dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pcie_pci_bridge_hotplug_cb; - hc->unplug_request = pcie_pci_bridge_hot_unplug_request_cb; + hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }static const TypeInfo pcie_pci_bridge_info = {
hw/pci/shpc.c +7 -7
@@ -482,8 +482,8 @@ static const MemoryRegionOps shpc_mmio_ops = { .max_access_size = 4, }, }; -static void shpc_device_hotplug_common (PCIDevice *affected_dev,int *slot, -SHPCDevice *shpc,Error **errp) +static void shpc_device_plug_common (PCIDevice *affected_dev,int *slot, +SHPCDevice *shpc,Error **errp) {int pci_slot =PCI_SLOT (affected_dev->devfn); *slot =SHPC_PCI_TO_IDX (pci_slot);
@@ -497,7 +497,7 @@ static void shpc_device_hotplug_common(PCIDevice *affected_dev, int *slot, } } -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {Error *local_err =NULL ;
@@ -505,7 +505,7 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,SHPCDevice *shpc = pci_hotplug_dev->shpc;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
@@ -540,8 +540,8 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);
@@ -550,7 +550,7 @@ void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev,uint8_t led;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
include/hw/pci/shpc.h +4 -4
@@ -45,10 +45,10 @@ void shpc_free(PCIDevice *dev);void shpc_cap_write_config (PCIDevice *d,uint32_t addr,uint32_t val,int len); -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);extern VMStateInfo shpc_vmstate_info;#define SHPC_VMSTATE (_field, _type, _test) \
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 02/10] pci/shpc: rename hotplug handler callbacks
Quoted 7 lines · David Hildenbrand
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename
shpc_device_hotplug_common()toshpc_device_plug_common().Signed-off-by David Hildenbrand <[email protected]>
Quoted 181 lines
--- hw/pci-bridge/pci_bridge_dev.c | 17 ++++++++--------- hw/pci-bridge/pcie_pci_bridge.c | 17 ++++++++--------- hw/pci/shpc.c | 14 +++++++------- include/hw/pci/shpc.h | 8 ++++---- 4 files changed, 27 insertions(+), 29 deletions(-)hw/pci-bridge/pci_bridge_dev.c +8
-9@@ -206,8 +206,8 @@ static const VMStateDescription pci_bridge_dev_vmstate = { } }; -static void pci_bridge_dev_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pci_bridge_dev_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -216,12 +216,11 @@ static void pci_bridge_dev_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pci_bridge_dev_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -230,7 +229,7 @@ static void pci_bridge_dev_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pci_bridge_dev_class_init (ObjectClass *klass,void *data)@@ -251,8 +250,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->props = pci_bridge_dev_properties; dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pci_bridge_dev_hotplug_cb; - hc->unplug_request = pci_bridge_dev_hot_unplug_request_cb; + hc->plug = pci_bridge_dev_plug_cb; + hc->unplug_request = pci_bridge_dev_unplug_request_cb; }static const TypeInfo pci_bridge_dev_info = {hw/pci-bridge/pcie_pci_bridge.c +8
-9@@ -137,8 +137,8 @@ static const VMStateDescription pcie_pci_bridge_dev_vmstate = { } }; -static void pcie_pci_bridge_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pcie_pci_bridge_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -147,12 +147,11 @@ static void pcie_pci_bridge_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pcie_pci_bridge_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -161,7 +160,7 @@ static void pcie_pci_bridge_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pcie_pci_bridge_class_init (ObjectClass *klass,void *data)@@ -180,8 +179,8 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->props = pcie_pci_bridge_dev_properties; dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pcie_pci_bridge_hotplug_cb; - hc->unplug_request = pcie_pci_bridge_hot_unplug_request_cb; + hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }static const TypeInfo pcie_pci_bridge_info = {hw/pci/shpc.c +7
-7@@ -482,8 +482,8 @@ static const MemoryRegionOps shpc_mmio_ops = { .max_access_size = 4, }, }; -static void shpc_device_hotplug_common (PCIDevice *affected_dev,int *slot, -SHPCDevice *shpc,Error **errp) +static void shpc_device_plug_common (PCIDevice *affected_dev,int *slot, +SHPCDevice *shpc,Error **errp) {int pci_slot =PCI_SLOT (affected_dev->devfn); *slot =SHPC_PCI_TO_IDX (pci_slot);@@ -497,7 +497,7 @@ static void shpc_device_hotplug_common(PCIDevice *affected_dev, int *slot, } } -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {Error *local_err =NULL ;@@ -505,7 +505,7 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,SHPCDevice *shpc = pci_hotplug_dev->shpc;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;@@ -540,8 +540,8 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -550,7 +550,7 @@ void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev,uint8_t led;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;include/hw/pci/shpc.h +4
-4@@ -45,10 +45,10 @@ void shpc_free(PCIDevice *dev);void shpc_cap_write_config (PCIDevice *d,uint32_t addr,uint32_t val,int len); -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);extern VMStateInfo shpc_vmstate_info;#define SHPC_VMSTATE (_field, _type, _test) \
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 02/10] pci/shpc: rename hotplug handler callbacks
In reply to David HildenbrandQuoted 7 lines · On Mon, 5 Nov 2018 11:20:36 +0100 David Hildenbrand <[email protected]> wrote:
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
While at it, also rename
shpc_device_hotplug_common()toshpc_device_plug_common().Signed-off-by David Hildenbrand <[email protected]>
Quoted 181 lines
--- hw/pci-bridge/pci_bridge_dev.c | 17 ++++++++--------- hw/pci-bridge/pcie_pci_bridge.c | 17 ++++++++--------- hw/pci/shpc.c | 14 +++++++------- include/hw/pci/shpc.h | 8 ++++---- 4 files changed, 27 insertions(+), 29 deletions(-)hw/pci-bridge/pci_bridge_dev.c +8
-9@@ -206,8 +206,8 @@ static const VMStateDescription pci_bridge_dev_vmstate = { } }; -static void pci_bridge_dev_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pci_bridge_dev_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -216,12 +216,11 @@ static void pci_bridge_dev_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pci_bridge_dev_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -230,7 +229,7 @@ static void pci_bridge_dev_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pci_bridge_dev_class_init (ObjectClass *klass,void *data)@@ -251,8 +250,8 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->props = pci_bridge_dev_properties; dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pci_bridge_dev_hotplug_cb; - hc->unplug_request = pci_bridge_dev_hot_unplug_request_cb; + hc->plug = pci_bridge_dev_plug_cb; + hc->unplug_request = pci_bridge_dev_unplug_request_cb; }static const TypeInfo pci_bridge_dev_info = {hw/pci-bridge/pcie_pci_bridge.c +8
-9@@ -137,8 +137,8 @@ static const VMStateDescription pcie_pci_bridge_dev_vmstate = { } }; -static void pcie_pci_bridge_hotplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void pcie_pci_bridge_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -147,12 +147,11 @@ static void pcie_pci_bridge_hotplug_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hotplug_cb (hotplug_dev, dev, errp); +shpc_device_plug_cb (hotplug_dev, dev, errp); } -static void pcie_pci_bridge_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev, -Error **errp) +static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -161,7 +160,7 @@ static void pcie_pci_bridge_hot_unplug_request_cb(HotplugHandler *hotplug_dev, "this %s", TYPE_PCIE_PCI_BRIDGE_DEV);return ; } -shpc_device_hot_unplug_request_cb (hotplug_dev, dev, errp); +shpc_device_unplug_request_cb (hotplug_dev, dev, errp); }static void pcie_pci_bridge_class_init (ObjectClass *klass,void *data)@@ -180,8 +179,8 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->props = pcie_pci_bridge_dev_properties; dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); - hc->plug = pcie_pci_bridge_hotplug_cb; - hc->unplug_request = pcie_pci_bridge_hot_unplug_request_cb; + hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }static const TypeInfo pcie_pci_bridge_info = {hw/pci/shpc.c +7
-7@@ -482,8 +482,8 @@ static const MemoryRegionOps shpc_mmio_ops = { .max_access_size = 4, }, }; -static void shpc_device_hotplug_common (PCIDevice *affected_dev,int *slot, -SHPCDevice *shpc,Error **errp) +static void shpc_device_plug_common (PCIDevice *affected_dev,int *slot, +SHPCDevice *shpc,Error **errp) {int pci_slot =PCI_SLOT (affected_dev->devfn); *slot =SHPC_PCI_TO_IDX (pci_slot);@@ -497,7 +497,7 @@ static void shpc_device_hotplug_common(PCIDevice *affected_dev, int *slot, } } -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {Error *local_err =NULL ;@@ -505,7 +505,7 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,SHPCDevice *shpc = pci_hotplug_dev->shpc;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;@@ -540,8 +540,8 @@ void shpc_device_hotplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) {Error *local_err =NULL ;PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev);@@ -550,7 +550,7 @@ void shpc_device_hot_unplug_request_cb(HotplugHandler *hotplug_dev,uint8_t led;int slot; -shpc_device_hotplug_common (PCI_DEVICE (dev), &slot, shpc, &local_err); +shpc_device_plug_common (PCI_DEVICE (dev), &slot, shpc, &local_err);if (local_err) {error_propagate (errp, local_err);return ;include/hw/pci/shpc.h +4
-4@@ -45,10 +45,10 @@ void shpc_free(PCIDevice *dev);void shpc_cap_write_config (PCIDevice *d,uint32_t addr,uint32_t val,int len); -void shpc_device_hotplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, -Error **errp); -void shpc_device_hot_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp); +void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);extern VMStateInfo shpc_vmstate_info;#define SHPC_VMSTATE (_field, _type, _test) \
PATCH v2 3/10 s390x/pci: rename hotplug handler callbacks
In reply to David HildenbrandThe callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
--- hw/s390x/s390-pci-bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/s390x/s390-pci-bus.c +6 -6
@@ -813,8 +813,8 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390PCIBusDevice *pbdev)return true; } -static void s390_pcihost_hot_plug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_plug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pdev =NULL ;S390PCIBusDevice *pbdev =NULL ;
@@ -923,8 +923,8 @@ static void s390_pcihost_timer_cb(void *opaque)qdev_unplug (DEVICE (pbdev),NULL ); } -static void s390_pcihost_hot_unplug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_unplug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pci_dev =NULL ;PCIBus *bus;
@@ -1032,8 +1032,8 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data) dc->reset = s390_pcihost_reset; dc->realize = s390_pcihost_realize; - hc->plug = s390_pcihost_hot_plug; - hc->unplug = s390_pcihost_hot_unplug; + hc->plug = s390_pcihost_plug; + hc->unplug = s390_pcihost_unplug; msi_nonbroken = true; }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 03/10] s390x/pci: rename hotplug handler callbacks
Quoted 4 lines · David Hildenbrand
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
Signed-off-by David Hildenbrand <[email protected]>
Quoted 41 lines
--- hw/s390x/s390-pci-bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/s390x/s390-pci-bus.c +6
-6@@ -813,8 +813,8 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390PCIBusDevice *pbdev)return true; } -static void s390_pcihost_hot_plug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_plug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pdev =NULL ;S390PCIBusDevice *pbdev =NULL ;@@ -923,8 +923,8 @@ static void s390_pcihost_timer_cb(void *opaque)qdev_unplug (DEVICE (pbdev),NULL ); } -static void s390_pcihost_hot_unplug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_unplug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pci_dev =NULL ;PCIBus *bus;@@ -1032,8 +1032,8 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data) dc->reset = s390_pcihost_reset; dc->realize = s390_pcihost_realize; - hc->plug = s390_pcihost_hot_plug; - hc->unplug = s390_pcihost_hot_unplug; + hc->plug = s390_pcihost_plug; + hc->unplug = s390_pcihost_unplug; msi_nonbroken = true; }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 03/10] s390x/pci: rename hotplug handler callbacks
In reply to David HildenbrandQuoted 7 lines · On Mon, 5 Nov 2018 11:20:37 +0100 David Hildenbrand <[email protected]> wrote:
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
Signed-off-by David Hildenbrand <[email protected]>--- hw/s390x/s390-pci-bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
[I assume this series will go through the pci tree?]
Re: [Qemu-devel] [PATCH v2 03/10] s390x/pci: rename hotplug handler callbacks
In reply to David HildenbrandQuoted 4 lines · On Mon, 5 Nov 2018 11:20:37 +0100 David Hildenbrand <[email protected]> wrote:
The callbacks are also called for cold plugged devices. Drop the "hot" to better match the actual callback names.
Signed-off-by David Hildenbrand <[email protected]>
Quoted 41 lines
--- hw/s390x/s390-pci-bus.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/s390x/s390-pci-bus.c +6
-6@@ -813,8 +813,8 @@ static bool s390_pci_alloc_idx(S390pciState *s, S390PCIBusDevice *pbdev)return true; } -static void s390_pcihost_hot_plug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_plug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pdev =NULL ;S390PCIBusDevice *pbdev =NULL ;@@ -923,8 +923,8 @@ static void s390_pcihost_timer_cb(void *opaque)qdev_unplug (DEVICE (pbdev),NULL ); } -static void s390_pcihost_hot_unplug (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) +static void s390_pcihost_unplug (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {PCIDevice *pci_dev =NULL ;PCIBus *bus;@@ -1032,8 +1032,8 @@ static void s390_pcihost_class_init(ObjectClass *klass, void *data) dc->reset = s390_pcihost_reset; dc->realize = s390_pcihost_realize; - hc->plug = s390_pcihost_hot_plug; - hc->unplug = s390_pcihost_hot_unplug; + hc->plug = s390_pcihost_plug; + hc->unplug = s390_pcihost_unplug; msi_nonbroken = true; }
PATCH v2 4/10 pci/pcie: stop plug/unplug if the slot is locked
In reply to David HildenbrandWe better stop right away. While at it, properly move the check to the pre_plug handler.
--- hw/pci/pcie.c | 25 +++++++++++++++++-------- hw/pci/pcie_port.c | 1 + include/hw/pci/pcie.h | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-)
hw/pci/pcie.c +17 -8
@@ -316,10 +316,10 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event) }static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, -uint8_t **exp_cap,Error **errp) +Error **errp) { - *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; -uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA ); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint16_t sltsta =pci_get_word (exp_cap +PCI_EXP_SLTSTA );PCIE_DEV_PRINTF (PCI_DEVICE (dev),"hotplug state: 0x%x\n" , sltsta);if (sltsta &PCI_EXP_SLTSTA_EIS ) {
@@ -330,14 +330,19 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplug_dev, DeviceState *dev, } } +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, errp); +} +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev); +uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); -/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */
@@ -367,11 +372,15 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually,
hw/pci/pcie_port.c +1 -0
@@ -154,6 +154,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; + hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; }
include/hw/pci/pcie.h +2 -0
@@ -131,6 +131,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 04/10] pci/pcie: stop plug/unplug if the slot is locked
Quoted 5 lines · David Hildenbrand
We better stop right away. While at it, properly move the check to the
pre_plughandler.Reviewed-by Igor Mammedov <[email protected]>Signed-off-by David Hildenbrand <[email protected]>
Although I'm not sure the commit message gives a terribly clear picture of what's going on here.
Quoted 90 lines
--- hw/pci/pcie.c | 25 +++++++++++++++++-------- hw/pci/pcie_port.c | 1 + include/hw/pci/pcie.h | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-)hw/pci/pcie.c +17
-8@@ -316,10 +316,10 @@ static void pcie_cap_slot_event(PCIDevice *dev, PCIExpressHotPlugEvent event) }static void pcie_cap_slot_plug_common (PCIDevice *hotplug_dev,DeviceState *dev, -uint8_t **exp_cap,Error **errp) +Error **errp) { - *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; -uint16_t sltsta =pci_get_word (*exp_cap +PCI_EXP_SLTSTA ); +uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap; +uint16_t sltsta =pci_get_word (exp_cap +PCI_EXP_SLTSTA );PCIE_DEV_PRINTF (PCI_DEVICE (dev),"hotplug state: 0x%x\n" , sltsta);if (sltsta &PCI_EXP_SLTSTA_EIS ) {@@ -330,14 +330,19 @@ static void pcie_cap_slot_plug_common(PCIDevice *hotplug_dev, DeviceState *dev, } } +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, errp); +} +void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +PCIDevice *hotplug_pdev =PCI_DEVICE (hotplug_dev); +uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;PCIDevice *pci_dev =PCI_DEVICE (dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); -/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ @@ -367,11 +372,15 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -uint8_t *exp_cap; +Error *local_err =NULL ;PCIDevice *pci_dev =PCI_DEVICE (dev);PCIBus *bus =pci_get_bus (pci_dev); -pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &exp_cap, errp); +pcie_cap_slot_plug_common (PCI_DEVICE (hotplug_dev), dev, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + }/* In case user cancel the operation of multi-function hot-add, * remove the function that is unexposed to guest individually, hw/pci/pcie_port.c +1
-0@@ -154,6 +154,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc); dc->props = pcie_slot_props; + hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; }include/hw/pci/pcie.h +2
-0@@ -131,6 +131,8 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);void pcie_dev_ser_num_init (PCIDevice *dev,uint16_t offset,uint64_t ser_num);void pcie_ats_init (PCIDevice *dev,uint16_t offset); +void pcie_cap_slot_pre_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 04/10] pci/pcie: stop plug/unplug if the slot is locked
Quoted 11 lines · David Gibson
Quoted 5 lines · David Hildenbrand
We better stop right away. While at it, properly move the check to the
pre_plughandler.Reviewed-by Igor Mammedov <[email protected]>Signed-off-by David Hildenbrand <[email protected]>Reviewed-by David Gibson <[email protected]>Although I'm not sure the commit message gives a terribly clear picture of what's going on here.
Thanks, I'll change it to
"We better stop right away. For now, errors would be partially ignored (so the guest might get informed or the device might get unplugged), although actual plug/unplug will be reported as failed to the user.
While at it, properly move the check to the pre_plug handler for the plug case, as we can test the slot state before the device will be realized."
Signature · 3 lines
Thanks, David / dhildenb
PATCH v2 5/10 pci/pcihp: perform check for bus capability in pre_plug handler
In reply to David HildenbrandPerform the check in the pre_plug handler. In addition, we need the capability only if the device is actually hotplugged (and not created during machine initialization). This is a preparation for coldplugging pci devices via that hotplug handler.
--- hw/acpi/pcihp.c | 21 +++++++++++++++------ hw/acpi/piix4.c | 16 ++++++++++++++-- include/hw/acpi/pcihp.h | 2 ++ 3 files changed, 31 insertions(+), 8 deletions(-)
hw/acpi/pcihp.c +15 -6
@@ -217,17 +217,24 @@ void acpi_pcihp_reset(AcpiPciHpState *s)acpi_pcihp_update (s); } -void acpi_pcihp_device_plug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s, -DeviceState *dev,Error **errp) +void acpi_pcihp_device_pre_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) { -PCIDevice *pdev =PCI_DEVICE (dev); -int slot =PCI_SLOT (pdev->devfn); -int bsel =acpi_pcihp_get_bsel (pci_get_bus (pdev)); -if (bsel <0 ) { +/* Only hotplugged devices need the hotplug capability. */ +if (dev->hotplugged && +acpi_pcihp_get_bsel (pci_get_bus (PCI_DEVICE (dev))) <0 ) {error_setg (errp,"Unsupported bus. Bus doesn't have property '" ACPI_PCIHP_PROP_BSEL "' set" );return ; } +} + +void acpi_pcihp_device_plug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s, +DeviceState *dev,Error **errp) +{ +PCIDevice *pdev =PCI_DEVICE (dev); +int slot =PCI_SLOT (pdev->devfn); +int bsel;/* Don't send event when device is enabled during qemu machine creation: * it is present on boot, no hotplug event is necessary. We do send an
@@ -236,6 +243,8 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,return ; } + bsel =acpi_pcihp_get_bsel (pci_get_bus (pdev)); +g_assert (bsel >=0 ); s->acpi_pcihp_pci_status[bsel].up |= (1U << slot);acpi_send_event (DEVICE (hotplug_dev),ACPI_PCI_HOTPLUG_STATUS ); }
hw/acpi/piix4.c +14 -2
@@ -370,6 +370,18 @@ static void piix4_pm_powerdown_req(Notifier *n, void *opaque)acpi_pm1_evt_power_down (&s->ar); } +static void piix4_device_pre_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_pre_plug_cb (hotplug_dev, dev, errp); + }else if (!object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM ) && + !object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { +error_setg (errp,"acpi: device pre plug request for not supported" +" device type: %s" ,object_get_typename (OBJECT (dev))); + } +} +static void piix4_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
@@ -392,8 +404,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,acpi_cpu_plug_cb (hotplug_dev, &s->cpuhp_state, dev, errp); } }else { -error_setg (errp,"acpi: device plug request for not supported device" -" type: %s" ,object_get_typename (OBJECT (dev))); +g_assert_not_reached (); } }
@@ -702,6 +713,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)*/ dc->user_creatable = false; dc->hotpluggable = false; + hc->pre_plug = piix4_device_pre_plug_cb; hc->plug = piix4_device_plug_cb; hc->unplug_request = piix4_device_unplug_request_cb; hc->unplug = piix4_device_unplug_cb;
include/hw/acpi/pcihp.h +2 -0
@@ -56,6 +56,8 @@ typedef struct AcpiPciHpState {void acpi_pcihp_init (Object *owner,AcpiPciHpState *,PCIBus *root,MemoryRegion *address_space_io,bool bridges_enabled); +void acpi_pcihp_device_pre_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp);void acpi_pcihp_device_plug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp); void acpi_pcihp_device_unplug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,
Signature · 1 line
2.17.2
PATCH v2 6/10 pci/pcihp: overwrite hotplug handler recursively from the start
In reply to David HildenbrandFor now, the hotplug handler is not called for devices that are being cold plugged. The hotplug handler is setup when the machine initialization is fully done. Only bridges that were cold plugged are considered.
Set the hotplug handler for the root piix bus directly when realizing. Overwrite the hotplug handler of bridges when coldplugging them.
This will now make sure that the ACPI PCI hotplug handler is also called for cold plugged devices (also on bridges) but not for bridges that were hotplugged (keeping the current behavior).
--- hw/acpi/pcihp.c | 15 +++++++++++++++ hw/acpi/piix4.c | 16 +--------------- 2 files changed, 16 insertions(+), 15 deletions(-)
hw/acpi/pcihp.c +15 -0
@@ -30,6 +30,7 @@#include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bridge.h" #include "hw/acpi/acpi.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h"
@@ -240,6 +241,20 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,* it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ if (!dev->hotplugged) { +/* +* Overwrite the default hotplug handler with the ACPI PCI one +* for cold plugged bridges only. +*/ +if (!s->legacy_piix && +object_dynamic_cast (OBJECT (dev),TYPE_PCI_BRIDGE )) { +PCIBus *sec =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); + +qbus_set_hotplug_handler (BUS (sec),DEVICE (hotplug_dev), + &error_abort); +/* We don't have to overwrite any other hotplug handler yet */ +assert (QLIST_EMPTY (&sec->child)); + } +return ; }
hw/acpi/piix4.c +1 -15
@@ -446,15 +446,6 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, } } -static void piix4_update_bus_hotplug (PCIBus *pci_bus,void *opaque) -{ -PIIX4PMState *s = opaque; - -/* pci_bus cannot outlive PIIX4PMState, because /machine keeps it alive -* and it's not hot-unpluggable */ -qbus_set_hotplug_handler (BUS (pci_bus),DEVICE (s), &error_abort); -} -static void piix4_pm_machine_ready (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, machine_ready);
@@ -468,12 +459,6 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) pci_conf[0x63 ] =0x60 ; pci_conf[0x67 ] = (memory_region_present (io_as,0x3f8 ) ?0x08 :0 ) | (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); - -if (s->use_acpi_pci_hotplug) { -pci_for_each_bus (pci_get_bus (d), piix4_update_bus_hotplug, s); - }else { -piix4_update_bus_hotplug (pci_get_bus (d), s); - } }static void piix4_pm_add_propeties (PIIX4PMState *s)
@@ -547,6 +532,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)piix4_acpi_system_hot_add_init (pci_address_space_io (dev),pci_get_bus (dev), s); +qbus_set_hotplug_handler (BUS (pci_get_bus (dev)),DEVICE (s), &error_abort);piix4_pm_add_propeties (s); }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 06/10] pci/pcihp: overwrite hotplug handler recursively from the start
Quoted 5 lines · On Mon, 5 Nov 2018 11:20:40 +0100 David Hildenbrand <[email protected]> wrote:
For now, the hotplug handler is not called for devices that are being cold plugged. The hotplug handler is setup when the machine initialization is fully done. Only bridges that were cold plugged are considered.
Quoted 8 lines
Set the hotplug handler for the root piix bus directly when realizing. Overwrite the hotplug handler of bridges when coldplugging them.
This will now make sure that the ACPI PCI hotplug handler is also called for cold plugged devices (also on bridges) but not for bridges that were hotplugged (keeping the current behavior).
Signed-off-by David Hildenbrand <[email protected]>
Quoted 79 lines
--- hw/acpi/pcihp.c | 15 +++++++++++++++ hw/acpi/piix4.c | 16 +--------------- 2 files changed, 16 insertions(+), 15 deletions(-)hw/acpi/pcihp.c +15
-0@@ -30,6 +30,7 @@#include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_bridge.h" #include "hw/acpi/acpi.h" #include "sysemu/sysemu.h" #include "exec/address-spaces.h" @@ -240,6 +241,20 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,* it is present on boot, no hotplug event is necessary. We do send an * event when the device is disabled later. */ if (!dev->hotplugged) { +/* +* Overwrite the default hotplug handler with the ACPI PCI one +* for cold plugged bridges only. +*/ +if (!s->legacy_piix && +object_dynamic_cast (OBJECT (dev),TYPE_PCI_BRIDGE )) { +PCIBus *sec =pci_bridge_get_sec_bus (PCI_BRIDGE (pdev)); + +qbus_set_hotplug_handler (BUS (sec),DEVICE (hotplug_dev), + &error_abort); +/* We don't have to overwrite any other hotplug handler yet */ +assert (QLIST_EMPTY (&sec->child)); + } +return ; }hw/acpi/piix4.c +1
-15@@ -446,15 +446,6 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev, } } -static void piix4_update_bus_hotplug (PCIBus *pci_bus,void *opaque) -{ -PIIX4PMState *s = opaque; - -/* pci_bus cannot outlive PIIX4PMState, because /machine keeps it alive -* and it's not hot-unpluggable */ -qbus_set_hotplug_handler (BUS (pci_bus),DEVICE (s), &error_abort); -} -static void piix4_pm_machine_ready (Notifier *n,void *opaque) {PIIX4PMState *s =container_of (n, PIIX4PMState, machine_ready);@@ -468,12 +459,6 @@ static void piix4_pm_machine_ready(Notifier *n, void *opaque) pci_conf[0x63 ] =0x60 ; pci_conf[0x67 ] = (memory_region_present (io_as,0x3f8 ) ?0x08 :0 ) | (memory_region_present (io_as,0x2f8 ) ?0x90 :0 ); - -if (s->use_acpi_pci_hotplug) { -pci_for_each_bus (pci_get_bus (d), piix4_update_bus_hotplug, s); - }else { -piix4_update_bus_hotplug (pci_get_bus (d), s); - } }static void piix4_pm_add_propeties (PIIX4PMState *s)@@ -547,6 +532,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)piix4_acpi_system_hot_add_init (pci_address_space_io (dev),pci_get_bus (dev), s); +qbus_set_hotplug_handler (BUS (pci_get_bus (dev)),DEVICE (s), &error_abort);piix4_pm_add_propeties (s); }
PATCH v2 7/10 pci/pcihp: perform unplug via the hotplug handler
In reply to David HildenbrandIntroduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
--- hw/acpi/pcihp.c | 11 ++++++++++- hw/acpi/piix4.c | 7 +++++-- include/hw/acpi/pcihp.h | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-)
hw/acpi/pcihp.c +10 -1
@@ -154,6 +154,7 @@ static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev)static void acpi_pcihp_eject_slot (AcpiPciHpState *s,unsigned bsel,unsigned slots) { +HotplugHandler *hotplug_ctrl;BusChild *kid, *next;int slot =ctz32 (slots);PCIBus *bus =acpi_pcihp_find_hotplug_bus (s, bsel);
@@ -171,7 +172,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned sloPCIDevice *dev =PCI_DEVICE (qdev);if (PCI_SLOT (dev->devfn) == slot) {if (!acpi_pcihp_pc_no_hotplug (s, dev)) { -object_unparent (OBJECT (qdev)); + hotplug_ctrl =qdev_get_hotplug_handler (qdev); +hotplug_handler_unplug (hotplug_ctrl, qdev, &error_abort); } } }
@@ -266,6 +268,13 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp) +{ +object_unparent (OBJECT (dev)); +} + +void acpi_pcihp_device_unplug_request_cb (HotplugHandler *hotplug_dev, +AcpiPciHpState *s,DeviceState *dev, +Error **errp) {PCIDevice *pdev =PCI_DEVICE (dev);int slot =PCI_SLOT (pdev->devfn);
hw/acpi/piix4.c +5 -2
@@ -418,8 +418,8 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,acpi_memory_unplug_request_cb (hotplug_dev, &s->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { -acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, - errp); +acpi_pcihp_device_unplug_request_cb (hotplug_dev, &s->acpi_pci_hotplug, + dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && !s->cpu_hotplug_legacy) {acpi_cpu_unplug_request_cb (hotplug_dev, &s->cpuhp_state, dev, errp);
@@ -437,6 +437,9 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev,if (s->acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {acpi_memory_unplug_cb (&s->acpi_memory_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && !s->cpu_hotplug_legacy) {acpi_cpu_unplug_cb (&s->cpuhp_state, dev, errp);
include/hw/acpi/pcihp.h +3 -0
@@ -62,6 +62,9 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp);void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp); +void acpi_pcihp_device_unplug_request_cb (HotplugHandler *hotplug_dev, +AcpiPciHpState *s,DeviceState *dev, +Error **errp);/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 07/10] pci/pcihp: perform unplug via the hotplug handler
Quoted 10 lines · On Mon, 5 Nov 2018 11:20:41 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 81 lines
--- hw/acpi/pcihp.c | 11 ++++++++++- hw/acpi/piix4.c | 7 +++++-- include/hw/acpi/pcihp.h | 3 +++ 3 files changed, 18 insertions(+), 3 deletions(-)hw/acpi/pcihp.c +10
-1@@ -154,6 +154,7 @@ static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s, PCIDevice *dev)static void acpi_pcihp_eject_slot (AcpiPciHpState *s,unsigned bsel,unsigned slots) { +HotplugHandler *hotplug_ctrl;BusChild *kid, *next;int slot =ctz32 (slots);PCIBus *bus =acpi_pcihp_find_hotplug_bus (s, bsel);@@ -171,7 +172,8 @@ static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned sloPCIDevice *dev =PCI_DEVICE (qdev);if (PCI_SLOT (dev->devfn) == slot) {if (!acpi_pcihp_pc_no_hotplug (s, dev)) { -object_unparent (OBJECT (qdev)); + hotplug_ctrl =qdev_get_hotplug_handler (qdev); +hotplug_handler_unplug (hotplug_ctrl, qdev, &error_abort); } } }@@ -266,6 +268,13 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s,void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp) +{ +object_unparent (OBJECT (dev)); +} + +void acpi_pcihp_device_unplug_request_cb (HotplugHandler *hotplug_dev, +AcpiPciHpState *s,DeviceState *dev, +Error **errp) {PCIDevice *pdev =PCI_DEVICE (dev);int slot =PCI_SLOT (pdev->devfn);hw/acpi/piix4.c +5
-2@@ -418,8 +418,8 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,acpi_memory_unplug_request_cb (hotplug_dev, &s->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { -acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, - errp); +acpi_pcihp_device_unplug_request_cb (hotplug_dev, &s->acpi_pci_hotplug, + dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && !s->cpu_hotplug_legacy) {acpi_cpu_unplug_request_cb (hotplug_dev, &s->cpuhp_state, dev, errp);@@ -437,6 +437,9 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev,if (s->acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {acpi_memory_unplug_cb (&s->acpi_memory_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && !s->cpu_hotplug_legacy) {acpi_cpu_unplug_cb (&s->cpuhp_state, dev, errp);include/hw/acpi/pcihp.h +3
-0@@ -62,6 +62,9 @@ void acpi_pcihp_device_plug_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp);void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp); +void acpi_pcihp_device_unplug_request_cb (HotplugHandler *hotplug_dev, +AcpiPciHpState *s,DeviceState *dev, +Error **errp);/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
PATCH v2 8/10 pci/pcie: perform unplug via the hotplug handler
In reply to David HildenbrandIntroduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
--- hw/pci/pcie.c | 10 +++++++++- hw/pci/pcie_port.c | 1 + include/hw/pci/pcie.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-)
hw/pci/pcie.c +9 -1
@@ -364,11 +364,19 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, } } -static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {object_unparent (OBJECT (dev)); } +static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +{ +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (dev)); + +hotplug_handler_unplug (hotplug_ctrl,DEVICE (dev), &error_abort); +} +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
hw/pci/pcie_port.c +1 -0
@@ -156,6 +156,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data) dc->props = pcie_slot_props; hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; + hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; }
include/hw/pci/pcie.h +2 -0
@@ -135,6 +135,8 @@ void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 08/10] pci/pcie: perform unplug via the hotplug handler
Quoted 10 lines · David Hildenbrand
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 56 lines
--- hw/pci/pcie.c | 10 +++++++++- hw/pci/pcie_port.c | 1 + include/hw/pci/pcie.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-)hw/pci/pcie.c +9
-1@@ -364,11 +364,19 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, } } -static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {object_unparent (OBJECT (dev)); } +static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +{ +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (dev)); + +hotplug_handler_unplug (hotplug_ctrl,DEVICE (dev), &error_abort); +} +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {hw/pci/pcie_port.c +1
-0@@ -156,6 +156,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data) dc->props = pcie_slot_props; hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; + hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; }include/hw/pci/pcie.h +2
-0@@ -135,6 +135,8 @@ void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 08/10] pci/pcie: perform unplug via the hotplug handler
In reply to David HildenbrandQuoted 10 lines · On Mon, 5 Nov 2018 11:20:42 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 56 lines
--- hw/pci/pcie.c | 10 +++++++++- hw/pci/pcie_port.c | 1 + include/hw/pci/pcie.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-)hw/pci/pcie.c +9
-1@@ -364,11 +364,19 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, } } -static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) {object_unparent (OBJECT (dev)); } +static void pcie_unplug_device (PCIBus *bus,PCIDevice *dev,void *opaque) +{ +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (dev)); + +hotplug_handler_unplug (hotplug_ctrl,DEVICE (dev), &error_abort); +} +void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {hw/pci/pcie_port.c +1
-0@@ -156,6 +156,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data) dc->props = pcie_slot_props; hc->pre_plug = pcie_cap_slot_pre_plug_cb; hc->plug = pcie_cap_slot_plug_cb; + hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; }include/hw/pci/pcie.h +2
-0@@ -135,6 +135,8 @@ void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp);void pcie_cap_slot_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void pcie_cap_slot_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void pcie_cap_slot_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);#endif /* QEMU_PCIE_H */
PATCH v2 9/10 pci/shpc: perform unplug via the hotplug handler
In reply to David HildenbrandIntroduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
--- hw/pci-bridge/pci_bridge_dev.c | 14 ++++++++++++++ hw/pci-bridge/pcie_pci_bridge.c | 14 ++++++++++++++ hw/pci/shpc.c | 11 ++++++++++- include/hw/pci/shpc.h | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-)
hw/pci-bridge/pci_bridge_dev.c +14 -0
@@ -219,6 +219,19 @@ static void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); } +static void pci_bridge_dev_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +} +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
@@ -251,6 +264,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pci_bridge_dev_plug_cb; + hc->unplug = pci_bridge_dev_unplug_cb; hc->unplug_request = pci_bridge_dev_unplug_request_cb; }
hw/pci-bridge/pcie_pci_bridge.c +14 -0
@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); } +static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +} +static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
@@ -180,6 +193,7 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug = pcie_pci_bridge_unplug_cb; hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }
hw/pci/shpc.c +10 -1
@@ -238,6 +238,7 @@ static void shpc_invalid_command(SHPCDevice *shpc)static void shpc_free_devices_in_slot (SHPCDevice *shpc,int slot) { +HotplugHandler *hotplug_ctrl;int devfn;int pci_slot =SHPC_IDX_TO_PCI (slot); for (devfn = PCI_DEVFN(pci_slot, 0);
@@ -245,7 +246,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) ++devfn) {PCIDevice *affected_dev = shpc->sec_bus->devices[devfn];if (affected_dev) { -object_unparent (OBJECT (affected_dev)); + hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (affected_dev)); +hotplug_handler_unplug (hotplug_ctrl,DEVICE (affected_dev), + &error_abort); } } }
@@ -540,6 +543,12 @@ void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +object_unparent (OBJECT (dev)); +} +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
include/hw/pci/shpc.h +2 -0
@@ -47,6 +47,8 @@ void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);
Signature · 1 line
2.17.2
Re: [Qemu-devel] [PATCH v2 09/10] pci/shpc: perform unplug via the hotplug handler
Quoted 10 lines · David Hildenbrand
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 120 lines
--- hw/pci-bridge/pci_bridge_dev.c | 14 ++++++++++++++ hw/pci-bridge/pcie_pci_bridge.c | 14 ++++++++++++++ hw/pci/shpc.c | 11 ++++++++++- include/hw/pci/shpc.h | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +14
-0@@ -219,6 +219,19 @@ static void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); } +static void pci_bridge_dev_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +} +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -251,6 +264,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pci_bridge_dev_plug_cb; + hc->unplug = pci_bridge_dev_unplug_cb; hc->unplug_request = pci_bridge_dev_unplug_request_cb; }hw/pci-bridge/pcie_pci_bridge.c +14
-0@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); } +static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +} +static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -180,6 +193,7 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug = pcie_pci_bridge_unplug_cb; hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }hw/pci/shpc.c +10
-1@@ -238,6 +238,7 @@ static void shpc_invalid_command(SHPCDevice *shpc)static void shpc_free_devices_in_slot (SHPCDevice *shpc,int slot) { +HotplugHandler *hotplug_ctrl;int devfn;int pci_slot =SHPC_IDX_TO_PCI (slot); for (devfn = PCI_DEVFN(pci_slot, 0);@@ -245,7 +246,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) ++devfn) {PCIDevice *affected_dev = shpc->sec_bus->devices[devfn];if (affected_dev) { -object_unparent (OBJECT (affected_dev)); + hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (affected_dev)); +hotplug_handler_unplug (hotplug_ctrl,DEVICE (affected_dev), + &error_abort); } } }@@ -540,6 +543,12 @@ void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +object_unparent (OBJECT (dev)); +} +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {include/hw/pci/shpc.h +2
-0@@ -47,6 +47,8 @@ void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 09/10] pci/shpc: perform unplug via the hotplug handler
In reply to David HildenbrandQuoted 55 lines · On Mon, 5 Nov 2018 11:20:43 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>--- hw/pci-bridge/pci_bridge_dev.c | 14 ++++++++++++++ hw/pci-bridge/pcie_pci_bridge.c | 14 ++++++++++++++ hw/pci/shpc.c | 11 ++++++++++- include/hw/pci/shpc.h | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-)hw/pci-bridge/pci_bridge_dev.c +14
-0@@ -219,6 +219,19 @@ static void pci_bridge_dev_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); } +static void pci_bridge_dev_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCI_BRIDGE_DEV ); +return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +} +static void pci_bridge_dev_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -251,6 +264,7 @@ static void pci_bridge_dev_class_init(ObjectClass *klass, void *data) dc->vmsd = &pci_bridge_dev_vmstate;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pci_bridge_dev_plug_cb; + hc->unplug = pci_bridge_dev_unplug_cb; hc->unplug_request = pci_bridge_dev_unplug_request_cb; }hw/pci-bridge/pcie_pci_bridge.c +0
-0@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp);
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 160
Quoted 10 lines
hw/pci-bridge/pcie_pci_bridge.c +8
-0} +static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV );
Is it possible to reach here at all?
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 164
Quoted 4 lines
hw/pci-bridge/pcie_pci_bridge.c +4
-0+return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +}
you probably can share this function impl. with pci_bridge_dev_unplug_cb() if you use object_get_typename().
Quoted 62 lines
hw/pci-bridge/pcie_pci_bridge.c +2
-0+static void pcie_pci_bridge_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -180,6 +193,7 @@ static void pcie_pci_bridge_class_init(ObjectClass *klass, void *data) dc->reset = &pcie_pci_bridge_reset;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hc->plug = pcie_pci_bridge_plug_cb; + hc->unplug = pcie_pci_bridge_unplug_cb; hc->unplug_request = pcie_pci_bridge_unplug_request_cb; }hw/pci/shpc.c +4
-1@@ -238,6 +238,7 @@ static void shpc_invalid_command(SHPCDevice *shpc)static void shpc_free_devices_in_slot (SHPCDevice *shpc,int slot) { +HotplugHandler *hotplug_ctrl;int devfn;int pci_slot =SHPC_IDX_TO_PCI (slot); for (devfn = PCI_DEVFN(pci_slot, 0);@@ -245,7 +246,9 @@ static void shpc_free_devices_in_slot(SHPCDevice *shpc, int slot) ++devfn) {PCIDevice *affected_dev = shpc->sec_bus->devices[devfn];if (affected_dev) { -object_unparent (OBJECT (affected_dev)); + hotplug_ctrl =qdev_get_hotplug_handler (DEVICE (affected_dev)); +hotplug_handler_unplug (hotplug_ctrl,DEVICE (affected_dev), + &error_abort); } }}
hw/pci/shpc.c +6
-0@@ -540,6 +543,12 @@ void shpc_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,shpc_interrupt_update (pci_hotplug_dev); } +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) +{ +object_unparent (OBJECT (dev)); +} +void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {include/hw/pci/shpc.h +2
-0@@ -47,6 +47,8 @@ void shpc_cap_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len);void shpc_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp); +void shpc_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp);void shpc_device_unplug_request_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);
Re: [Qemu-devel] [PATCH v2 09/10] pci/shpc: perform unplug via the hotplug handler
Quoted 8 lines
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +0
-0@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); }
Quoted 9 lines
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 160
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +8
-0+static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV );Is it possible to reach here at all?
Right, this should right now not be possible. I'll turn this into an
g_assert(shpc_present(pci_hotplug_dev));
(if we every support surprise removal, we'll have to rethink either way)
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 164
Quoted 5 lines
hw/pci-bridge/pcie_pci_bridge.c +4
-0+return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +}you probably can share this function impl. with
pci_bridge_dev_unplug_cb()if you useobject_get_typename().
The same holds for all three functions (+ later pre_plug), however can we be sure there won't be differences in the near future?
If we don't expect these functions to differ, I can add a patch to factor the existing two functions (plug/unplug) out.
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v2 09/10] pci/shpc: perform unplug via the hotplug handler
Quoted 30 lines · On Tue, 20 Nov 2018 11:11:46 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +0
-0@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); }Quoted 9 lines
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 160
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +8
-0+static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV );Is it possible to reach here at all?
Right, this should right now not be possible. I'll turn this into an
g_assert(shpc_present(pci_hotplug_dev));
(if we every support surprise removal, we'll have to rethink either way)
Quoted 6 lines
Quoted 5 lines
hw/pci-bridge/pcie_pci_bridge.c +4
-0+return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +}
Quoted 8 lines
Quoted 2 lines
you probably can share this function impl. with
pci_bridge_dev_unplug_cb()if you useobject_get_typename().The same holds for all three functions (+ later
pre_plug), however can we be sure there won't be differences in the near future?If we don't expect these functions to differ, I can add a patch to factor the existing two functions (plug/unplug) out.
I'm not sure if they will differ or not in future,
but right now it looks as premature splitting.
It might be better to have a single function now and split it later when it is necessary.
Re: [Qemu-devel] [PATCH v2 09/10] pci/shpc: perform unplug via the hotplug handler
Quoted 39 lines · Igor Mammedov
Quoted 36 lines · On Tue, 20 Nov 2018 11:11:46 +0100 David Hildenbrand <[email protected]> wrote:
Quoted 8 lines
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +0
-0@@ -150,6 +150,19 @@ static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev,shpc_device_plug_cb (hotplug_dev, dev, errp); }Quoted 9 lines
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 160
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c +8
-0+static void pcie_pci_bridge_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCIDevice *pci_hotplug_dev =PCI_DEVICE (hotplug_dev); + +if (!shpc_present (pci_hotplug_dev)) { +error_setg (errp,"standard hotplug controller has been disabled for " +"this %s" ,TYPE_PCIE_PCI_BRIDGE_DEV );Is it possible to reach here at all?
Right, this should right now not be possible. I'll turn this into an
g_assert(shpc_present(pci_hotplug_dev));
(if we every support surprise removal, we'll have to rethink either way)
Quoted 8 lines
hw/pci-bridge/pcie_pci_bridge.c static void pcie_pci_bridge_plug_cb(HotplugHandler *hotplug_dev, · line 164
Quoted 5 lines
hw/pci-bridge/pcie_pci_bridge.c +4
-0+return ; + } +shpc_device_unplug_cb (hotplug_dev, dev, errp); +}you probably can share this function impl. with
pci_bridge_dev_unplug_cb()if you useobject_get_typename().The same holds for all three functions (+ later
pre_plug), however can we be sure there won't be differences in the near future?
Quoted 7 lines
Quoted 2 lines
If we don't expect these functions to differ, I can add a patch to factor the existing two functions (plug/unplug) out.
I'm not sure if they will differ or not in future,
but right now it looks as premature splitting.
It might be better to have a single function now and split it later when it is necessary.
Indeed, I already went ahead and sent a new version including the suggested re-factoring.
Thanks!
Signature · 3 lines
Thanks, David / dhildenb
PATCH v2 10/10 spapr_pci: perform unplug via the hotplug handler
In reply to David HildenbrandIntroduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
--- hw/ppc/spapr_pci.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
hw/ppc/spapr_pci.c +21 -12
@@ -1370,18 +1370,9 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,/* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb (DeviceState *dev) { -/* some version guests do not wait for completion of a device -* cleanup (generally done asynchronously by the kernel) before -* signaling to QEMU that the device is safe, but instead sleep -* for some 'safe' period of time. unfortunately on a busy host -* this sleep isn't guaranteed to be long enough, resulting in -* bad things like IRQ lines being left asserted during final -* device removal. to deal with this we call reset just prior -* to finalizing the device, which will put the device back into -* an 'idle' state, as the device cleanup code expects. -*/ -pci_device_reset (PCI_DEVICE (dev)); -object_unparent (OBJECT (dev)); +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (dev); + +hotplug_handler_unplug (hotplug_ctrl, dev, &error_abort); } static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb,
@@ -1490,6 +1481,23 @@ out: } } +static void spapr_pci_unplug (HotplugHandler *plug_handler, +DeviceState *plugged_dev,Error **errp) +{ +/* some version guests do not wait for completion of a device +* cleanup (generally done asynchronously by the kernel) before +* signaling to QEMU that the device is safe, but instead sleep +* for some 'safe' period of time. unfortunately on a busy host +* this sleep isn't guaranteed to be long enough, resulting in +* bad things like IRQ lines being left asserted during final +* device removal. to deal with this we call reset just prior +* to finalizing the device, which will put the device back into +* an 'idle' state, as the device cleanup code expects. +*/ +pci_device_reset (PCI_DEVICE (plugged_dev)); +object_unparent (OBJECT (plugged_dev)); +} +static void spapr_pci_unplug_request (HotplugHandler *plug_handler,DeviceState *plugged_dev,Error **errp) {
@@ -1965,6 +1973,7 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->user_creatable = true;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hp->plug = spapr_pci_plug; + hp->unplug = spapr_pci_unplug; hp->unplug_request = spapr_pci_unplug_request; }
Signature · 1 line
2.17.2
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 10/10] spapr_pci: perform unplug via the hotplug handler
Quoted 11 lines · On Mon, 5 Nov 2018 11:20:44 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>---
Quoted 61 lines
hw/ppc/spapr_pci.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)hw/ppc/spapr_pci.c +21
-12@@ -1370,18 +1370,9 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,/* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb (DeviceState *dev) { -/* some version guests do not wait for completion of a device -* cleanup (generally done asynchronously by the kernel) before -* signaling to QEMU that the device is safe, but instead sleep -* for some 'safe' period of time. unfortunately on a busy host -* this sleep isn't guaranteed to be long enough, resulting in -* bad things like IRQ lines being left asserted during final -* device removal. to deal with this we call reset just prior -* to finalizing the device, which will put the device back into -* an 'idle' state, as the device cleanup code expects. -*/ -pci_device_reset (PCI_DEVICE (dev)); -object_unparent (OBJECT (dev)); +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (dev); + +hotplug_handler_unplug (hotplug_ctrl, dev, &error_abort); } static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb,@@ -1490,6 +1481,23 @@ out: } } +static void spapr_pci_unplug (HotplugHandler *plug_handler, +DeviceState *plugged_dev,Error **errp) +{ +/* some version guests do not wait for completion of a device +* cleanup (generally done asynchronously by the kernel) before +* signaling to QEMU that the device is safe, but instead sleep +* for some 'safe' period of time. unfortunately on a busy host +* this sleep isn't guaranteed to be long enough, resulting in +* bad things like IRQ lines being left asserted during final +* device removal. to deal with this we call reset just prior +* to finalizing the device, which will put the device back into +* an 'idle' state, as the device cleanup code expects. +*/ +pci_device_reset (PCI_DEVICE (plugged_dev)); +object_unparent (OBJECT (plugged_dev)); +} +static void spapr_pci_unplug_request (HotplugHandler *plug_handler,DeviceState *plugged_dev,Error **errp) {@@ -1965,6 +1973,7 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->user_creatable = true;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hp->plug = spapr_pci_plug; + hp->unplug = spapr_pci_unplug; hp->unplug_request = spapr_pci_unplug_request; }
Re: [Qemu-devel] [Qemu-ppc] [PATCH v2 10/10] spapr_pci: perform unplug via the hotplug handler
Quoted 12 lines · Greg Kurz
Quoted 9 lines · On Mon, 5 Nov 2018 11:20:44 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Quoted 4 lines
Quoted 2 lines
Signed-off-by David Hildenbrand <[email protected]>---
Reviewed-by Greg Kurz <[email protected]>
BTW, sorry for dropping you RB! (realized it just now)
Signature · 3 lines
Thanks, David / dhildenb
Re: [Qemu-devel] [PATCH v2 10/10] spapr_pci: perform unplug via the hotplug handler
In reply to David HildenbrandQuoted 10 lines · David Hildenbrand
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 62 lines
--- hw/ppc/spapr_pci.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)hw/ppc/spapr_pci.c +21
-12@@ -1370,18 +1370,9 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,/* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb (DeviceState *dev) { -/* some version guests do not wait for completion of a device -* cleanup (generally done asynchronously by the kernel) before -* signaling to QEMU that the device is safe, but instead sleep -* for some 'safe' period of time. unfortunately on a busy host -* this sleep isn't guaranteed to be long enough, resulting in -* bad things like IRQ lines being left asserted during final -* device removal. to deal with this we call reset just prior -* to finalizing the device, which will put the device back into -* an 'idle' state, as the device cleanup code expects. -*/ -pci_device_reset (PCI_DEVICE (dev)); -object_unparent (OBJECT (dev)); +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (dev); + +hotplug_handler_unplug (hotplug_ctrl, dev, &error_abort); } static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb,@@ -1490,6 +1481,23 @@ out: } } +static void spapr_pci_unplug (HotplugHandler *plug_handler, +DeviceState *plugged_dev,Error **errp) +{ +/* some version guests do not wait for completion of a device +* cleanup (generally done asynchronously by the kernel) before +* signaling to QEMU that the device is safe, but instead sleep +* for some 'safe' period of time. unfortunately on a busy host +* this sleep isn't guaranteed to be long enough, resulting in +* bad things like IRQ lines being left asserted during final +* device removal. to deal with this we call reset just prior +* to finalizing the device, which will put the device back into +* an 'idle' state, as the device cleanup code expects. +*/ +pci_device_reset (PCI_DEVICE (plugged_dev)); +object_unparent (OBJECT (plugged_dev)); +} +static void spapr_pci_unplug_request (HotplugHandler *plug_handler,DeviceState *plugged_dev,Error **errp) {@@ -1965,6 +1973,7 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->user_creatable = true;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hp->plug = spapr_pci_plug; + hp->unplug = spapr_pci_unplug; hp->unplug_request = spapr_pci_unplug_request; }
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
[Qemu-devel] QEMU bootup hang in tcg model using mainline QEMU code
Hi All
using mainline QEMU code and below boot up commands, the QEMU will be hang when do bootup, if I add the "-enable-kvm" parameter, it can boot up successfully, do you know the reason about it?
I also try the "remotes/origin/stable-2.12" branch code using below same boot up commands, it does not have this hang issue. it seems the mainline code has some issue.
./qemu-system-aarch64 -m 1024 -cpu cortex-a57 -machine virt,gic-version=3 \
-smp 4 -nographic -kernel Image -append "root=/dev/sda1 console=ttyAMA0 sched_debug ignore_loglevel" \
-device virtio-scsi-device,id=scsi -drive file=./linaro.img,id=rootimg,cache=unsafe,if=none -device scsi-hd,drive=rootimg
Re: [Qemu-devel] [PATCH v2 10/10] spapr_pci: perform unplug via the hotplug handler
In reply to David HildenbrandQuoted 10 lines · On Mon, 5 Nov 2018 11:20:44 +0100 David Hildenbrand <[email protected]> wrote:
Introduce and use the "unplug" callback.
This is a preparation for multi-stage hotplug handlers, whereby the bus hotplug handler is overwritten by the machine hotplug handler. This handler will then pass control to the bus hotplug handler. So to get this running cleanly, we also have to make sure to go via the hotplug handler chain when actually unplugging a device after an unplug request. Lookup the hotplug handler and call "unplug".
Signed-off-by David Hildenbrand <[email protected]>
Quoted 62 lines
--- hw/ppc/spapr_pci.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)hw/ppc/spapr_pci.c +21
-12@@ -1370,18 +1370,9 @@ static int spapr_create_pci_child_dt(sPAPRPHBState *phb, PCIDevice *dev,/* Callback to be called during DRC release. */ void spapr_phb_remove_pci_device_cb (DeviceState *dev) { -/* some version guests do not wait for completion of a device -* cleanup (generally done asynchronously by the kernel) before -* signaling to QEMU that the device is safe, but instead sleep -* for some 'safe' period of time. unfortunately on a busy host -* this sleep isn't guaranteed to be long enough, resulting in -* bad things like IRQ lines being left asserted during final -* device removal. to deal with this we call reset just prior -* to finalizing the device, which will put the device back into -* an 'idle' state, as the device cleanup code expects. -*/ -pci_device_reset (PCI_DEVICE (dev)); -object_unparent (OBJECT (dev)); +HotplugHandler *hotplug_ctrl =qdev_get_hotplug_handler (dev); + +hotplug_handler_unplug (hotplug_ctrl, dev, &error_abort); } static sPAPRDRConnector *spapr_phb_get_pci_func_drc(sPAPRPHBState *phb,@@ -1490,6 +1481,23 @@ out: } } +static void spapr_pci_unplug (HotplugHandler *plug_handler, +DeviceState *plugged_dev,Error **errp) +{ +/* some version guests do not wait for completion of a device +* cleanup (generally done asynchronously by the kernel) before +* signaling to QEMU that the device is safe, but instead sleep +* for some 'safe' period of time. unfortunately on a busy host +* this sleep isn't guaranteed to be long enough, resulting in +* bad things like IRQ lines being left asserted during final +* device removal. to deal with this we call reset just prior +* to finalizing the device, which will put the device back into +* an 'idle' state, as the device cleanup code expects. +*/ +pci_device_reset (PCI_DEVICE (plugged_dev)); +object_unparent (OBJECT (plugged_dev)); +} +static void spapr_pci_unplug_request (HotplugHandler *plug_handler,DeviceState *plugged_dev,Error **errp) {@@ -1965,6 +1973,7 @@ static void spapr_phb_class_init(ObjectClass *klass, void *data) dc->user_creatable = true;set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); hp->plug = spapr_pci_plug; + hp->unplug = spapr_pci_unplug; hp->unplug_request = spapr_pci_unplug_request; }