• Amos Kong's avatar
    PCI: Can continually add funcs after adding func0 · f382a086
    Amos Kong authored
    Boot up a KVM guest, and hotplug multifunction
    devices(func1,func2,func0,func3) to guest.
    
    for i in 1 2 0 3;do
    qemu-img create /tmp/resize$i.qcow2 1G -f qcow2
    (qemu) drive_add 0x11.$i id=drv11$i,if=none,file=/tmp/resize$i.qcow2
    (qemu) device_add virtio-blk-pci,id=dev11$i,drive=drv11$i,addr=0x11.$i,multifunction=on
    done
    
    In linux kernel, when func0 of the slot is hot-added, the whole
    slot will be marked as 'enabled', then driver will ignore other new
    hotadded funcs.
    But in Win7 & WinXP, we can continaully add other funcs after adding
    func0, all funcs will be added in guest.
    
    drivers/pci/hotplug/acpiphp_glue.c:
    static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
    {
    ....
            for (slot = bridge->slots; slot; slot = slot->next) {
                    if (slot->flags & SLOT_ENABLED) {
                            acpiphp_disable_slot()
                    else
                            acpiphp_enable_slot()
    ....                              |
    }                    ...
    f382a086
acpiphp_glue.c 37.8 KB