[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support
From: |
Marcel Apfelbaum |
Subject: |
[Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support |
Date: |
Thu, 19 Jun 2014 16:52:21 +0300 |
Hotplug triggers both 'present detect change' and
'attention button pressed'.
Hotunplug starts by triggering 'attention button pressed',
then waits for the OS to power off the device and only
then detaches it.
Signed-off-by: Marcel Apfelbaum <address@hidden>
---
hw/pci/pcie.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index f8bf515..9cfd93d 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -258,7 +258,8 @@ void pcie_cap_slot_hotplug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev,
pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
- pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC);
+ pcie_cap_slot_event(PCI_DEVICE(hotplug_dev),
+ PCI_EXP_HP_EV_PDC | PCI_EXP_HP_EV_ABP);
}
void pcie_cap_slot_hot_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
@@ -268,10 +269,7 @@ void pcie_cap_slot_hot_unplug_cb(HotplugHandler
*hotplug_dev, DeviceState *dev,
pcie_cap_slot_hotplug_common(PCI_DEVICE(hotplug_dev), dev, &exp_cap, errp);
- object_unparent(OBJECT(dev));
- pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
- PCI_EXP_SLTSTA_PDS);
- pcie_cap_slot_event(PCI_DEVICE(hotplug_dev), PCI_EXP_HP_EV_PDC);
+ pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev));
}
/* pci express slot for pci express root/downstream port
@@ -389,6 +387,18 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
sltsta);
}
+ if ((sltsta & PCI_EXP_SLTSTA_PDS) && (val & PCI_EXP_SLTCTL_PCC) &&
+ ((val & PCI_EXP_SLTCTL_PIC_OFF) == PCI_EXP_SLTCTL_PIC_OFF)) {
+ PCIDevice *slot_dev =
pci_bridge_get_sec_bus(PCI_BRIDGE(dev))->devices[0];
+ if (slot_dev) {
+ object_unparent(OBJECT(slot_dev));
+ pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_PDS);
+ pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
+ PCI_EXP_SLTSTA_PDC);
+ }
+ }
+
hotplug_event_notify(dev);
/*
--
1.8.3.1
- [Qemu-devel] [PATCH 0/3] hw/pcie: better hotplug/hotunplug support, Marcel Apfelbaum, 2014/06/19
- [Qemu-devel] [PATCH 1/3] hw/pcie: corrected a debug message, Marcel Apfelbaum, 2014/06/19
- [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Marcel Apfelbaum, 2014/06/19
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Michael S. Tsirkin, 2014/06/19
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Paolo Bonzini, 2014/06/19
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Marcel Apfelbaum, 2014/06/22
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Michael S. Tsirkin, 2014/06/22
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Michael S. Tsirkin, 2014/06/22
- Re: [Qemu-devel] [PATCH 2/3] hw/pcie: implement power controller functionality, Marcel Apfelbaum, 2014/06/22
[Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support,
Marcel Apfelbaum <=
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Michael S. Tsirkin, 2014/06/19
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Marcel Apfelbaum, 2014/06/22
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Michael S. Tsirkin, 2014/06/22
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Marcel Apfelbaum, 2014/06/22
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Michael S. Tsirkin, 2014/06/22
- Re: [Qemu-devel] [PATCH 3/3] hw/pcie: better hotplug/hotunplug support, Marcel Apfelbaum, 2014/06/22