Revision 4cff0a59 hw/pcie.c

b/hw/pcie.c
192 192
}
193 193

  
194 194
static int pcie_cap_slot_hotplug(DeviceState *qdev,
195
                                 PCIDevice *pci_dev, int state)
195
                                 PCIDevice *pci_dev, PCIHotplugState state)
196 196
{
197 197
    PCIDevice *d = DO_UPCAST(PCIDevice, qdev, qdev);
198 198
    uint8_t *exp_cap = d->config + d->exp.exp_cap;
199 199
    uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
200 200

  
201
    if (!pci_dev->qdev.hotplugged) {
202
        assert(state); /* this case only happens at machine creation. */
201
    /* Don't send event when device is enabled during qemu machine creation:
202
     * it is present on boot, no hotplug event is necessary. We do send an
203
     * event when the device is disabled later. */
204
    if (state == PCI_COLDPLUG_ENABLED) {
203 205
        pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
204 206
                                   PCI_EXP_SLTSTA_PDS);
205 207
        return 0;
......
219 221
     */
220 222
    assert(PCI_FUNC(pci_dev->devfn) == 0);
221 223

  
222
    if (state) {
224
    if (state == PCI_HOTPLUG_ENABLED) {
223 225
        pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
224 226
                                   PCI_EXP_SLTSTA_PDS);
225 227
        pcie_cap_slot_event(d, PCI_EXP_HP_EV_PDC);

Also available in: Unified diff