Hi Jan, 2014-07-01 15:34 GMT+08:00 Jan Kiszka <jan.kis...@web.de>: > Hi Le, > > On 2014-07-01 04:34, Le Tan wrote: >> Hi Jan, >> I use pci_setup_iommu() to setup a PCIIOMMUFunc for the q35 pci bus. >> In the iommu_fn, I print out the devfn parameter and find out that it >> sometimes will be -1. So what does it mean? >> The detail code is here: >> >> In mch_init() function, I write like this: >> PCIBus *pci_bus = PCI_BUS(qdev_get_parent_bus(DEVICE(mch))); >> pci_setup_iommu(pci_bus, q35_host_dma_iommu, mch->iommu); >> >> And in q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn), I >> print out the devfn parameter, sometimes it will be -1. > > Hmm, I have no idea about the reason and would suggest to set a > conditional breakpoint on this function, then print the backtrace to see > where this comes from and analyze the device structure from where that > -1 was most probably taken.
I have set a breakpoint here and cases whose devfn is -1 are different from each run. ICH9 LPC, cirrus-vga and e1000, these three devices' initialization will route to this problem. Sometimes the initialization of ICH9 LPC will be normal. The backtrace are given below. I trace to the function do_pci_register_device() and see that the dev->devfn is initialized after the pci_device_iommu_address_space() is called. So I think this is so strange. Is the devfn parameter to the q35_host_dma_iommu() not reliable and usable? Thanks very much! #0 q35_host_dma_iommu (bus=0x55555629d280, opaque=0x5555566a4df0, devfn=-1) at /home/tamlok/qemu-git/hw/pci-host/q35.c:351 #1 0x00005555558524ef in pci_device_iommu_address_space (dev=0x5555566a7e20) at /home/tamlok/qemu-git/hw/pci/pci.c:2284 #2 0x000055555584e5b4 in do_pci_register_device (pci_dev=0x5555566a7e20, bus=0x55555629d280, name=0x55555624a250 "ICH9 LPC", devfn=248) at /home/tamlok/qemu-git/hw/pci/pci.c:830 #3 0x0000555555850bac in pci_qdev_init (qdev=0x5555566a7e20) at /home/tamlok/qemu-git/hw/pci/pci.c:1759 #4 0x00005555557c9359 in device_realize (dev=0x5555566a7e20, errp=0x7fffffffdd50) at /home/tamlok/qemu-git/hw/core/qdev.c:182 #5 0x00005555557cb15c in device_set_realized (obj=0x5555566a7e20, value=true, errp=0x7fffffffded0) at /home/tamlok/qemu-git/hw/core/qdev.c:809 #6 0x00005555558d3234 in property_set_bool (obj=0x5555566a7e20, v=0x55555668bec0, opaque=0x55555662b360, name=0x5555559c2a86 "realized", errp=0x7fffffffded0) at /home/tamlok/qemu-git/qom/object.c:1421 #7 0x00005555558d1a68 in object_property_set (obj=0x5555566a7e20, v=0x55555668bec0, name=0x5555559c2a86 "realized", errp=0x7fffffffded0) at /home/tamlok/qemu-git/qom/object.c:819 #8 0x00005555558d3a26 in object_property_set_qobject (obj=0x5555566a7e20, value=0x5555566acfd0, name=0x5555559c2a86 "realized", errp=0x7fffffffded0) at /home/tamlok/qemu-git/qom/qom-qobject.c:24 #9 0x00005555558d1d65 in object_property_set_bool (obj=0x5555566a7e20, value=true, name=0x5555559c2a86 "realized", errp=0x7fffffffded0) at /home/tamlok/qemu-git/qom/object.c:883 #10 0x00005555557c9295 in qdev_init (dev=0x5555566a7e20) at /home/tamlok/qemu-git/hw/core/qdev.c:167 #11 0x00005555557c98a3 in qdev_init_nofail (dev=0x5555566a7e20) at /home/tamlok/qemu-git/hw/core/qdev.c:290 #12 0x0000555555850d6f in pci_create_simple_multifunction (bus=0x55555629d280, devfn=248, multifunction=true, name=0x5555559a3783 "ICH9 LPC") at /home/tamlok/qemu-git/hw/pci/pci.c:1800 #13 0x00005555556943ce in pc_q35_init (machine=0x555556281c00) at /home/tamlok/qemu-git/hw/i386/pc_q35.c:176 #14 0x000055555573c72f in main (argc=19, argv=0x7fffffffe4d8, envp=0x7fffffffe578) at /home/tamlok/qemu-git/vl.c:4441 #0 q35_host_dma_iommu (bus=0x55555629d280, opaque=0x5555566a4df0, devfn=-1) at /home/tamlok/qemu-git/hw/pci-host/q35.c:351 #1 0x00005555558524ef in pci_device_iommu_address_space (dev=0x5555566ef530) at /home/tamlok/qemu-git/hw/pci/pci.c:2284 #2 0x000055555584e5b4 in do_pci_register_device (pci_dev=0x5555566ef530, bus=0x55555629d280, name=0x5555562551a0 "cirrus-vga", devfn=8) at /home/tamlok/qemu-git/hw/pci/pci.c:830 #3 0x0000555555850bac in pci_qdev_init (qdev=0x5555566ef530) at /home/tamlok/qemu-git/hw/pci/pci.c:1759 #4 0x00005555557c9359 in device_realize (dev=0x5555566ef530, errp=0x7fffffffdca0) at /home/tamlok/qemu-git/hw/core/qdev.c:182 #5 0x00005555557cb15c in device_set_realized (obj=0x5555566ef530, value=true, errp=0x7fffffffde20) at /home/tamlok/qemu-git/hw/core/qdev.c:809 #6 0x00005555558d3234 in property_set_bool (obj=0x5555566ef530, v=0x55555666e300, opaque=0x555556856f90, name=0x5555559c2a86 "realized", errp=0x7fffffffde20) at /home/tamlok/qemu-git/qom/object.c:1421 #7 0x00005555558d1a68 in object_property_set (obj=0x5555566ef530, v=0x55555666e300, name=0x5555559c2a86 "realized", errp=0x7fffffffde20) at /home/tamlok/qemu-git/qom/object.c:819 #8 0x00005555558d3a26 in object_property_set_qobject (obj=0x5555566ef530, value=0x555556877740, name=0x5555559c2a86 "realized", errp=0x7fffffffde20) at /home/tamlok/qemu-git/qom/qom-qobject.c:24 #9 0x00005555558d1d65 in object_property_set_bool (obj=0x5555566ef530, value=true, name=0x5555559c2a86 "realized", errp=0x7fffffffde20) at /home/tamlok/qemu-git/qom/object.c:883 #10 0x00005555557c9295 in qdev_init (dev=0x5555566ef530) at /home/tamlok/qemu-git/hw/core/qdev.c:167 #11 0x00005555557c98a3 in qdev_init_nofail (dev=0x5555566ef530) at /home/tamlok/qemu-git/hw/core/qdev.c:290 #12 0x0000555555850d6f in pci_create_simple_multifunction (bus=0x55555629d280, devfn=-1, multifunction=false, name=0x5555559d5264 "cirrus-vga") at /home/tamlok/qemu-git/hw/pci/pci.c:1800 #13 0x0000555555850e19 in pci_create_simple (bus=0x55555629d280, devfn=-1, name=0x5555559d5264 "cirrus-vga") at /home/tamlok/qemu-git/hw/pci/pci.c:1811 #14 0x0000555555850746 in pci_vga_init (bus=0x55555629d280) at /home/tamlok/qemu-git/hw/pci/pci.c:1649 #15 0x00005555556925b5 in pc_vga_init (isa_bus=0x5555566ad390, pci_bus=0x55555629d280) at /home/tamlok/qemu-git/hw/i386/pc.c:1262 #16 0x00005555556946ab in pc_q35_init (machine=0x555556281c00) at /home/tamlok/qemu-git/hw/i386/pc_q35.c:238 #17 0x000055555573c72f in main (argc=19, argv=0x7fffffffe4d8, envp=0x7fffffffe578) at /home/tamlok/qemu-git/vl.c:4441 #0 q35_host_dma_iommu (bus=0x55555629d280, opaque=0x5555566a4df0, devfn=-1) at /home/tamlok/qemu-git/hw/pci-host/q35.c:351 #1 0x00005555558524ef in pci_device_iommu_address_space (dev=0x555556a10bb0) at /home/tamlok/qemu-git/hw/pci/pci.c:2284 #2 0x000055555584e5b4 in do_pci_register_device (pci_dev=0x555556a10bb0, bus=0x55555629d280, name=0x55555625bf70 "e1000", devfn=16) at /home/tamlok/qemu-git/hw/pci/pci.c:830 #3 0x0000555555850bac in pci_qdev_init (qdev=0x555556a10bb0) at /home/tamlok/qemu-git/hw/pci/pci.c:1759 #4 0x00005555557c9359 in device_realize (dev=0x555556a10bb0, errp=0x7fffffffde30) at /home/tamlok/qemu-git/hw/core/qdev.c:182 #5 0x00005555557cb15c in device_set_realized (obj=0x555556a10bb0, value=true, errp=0x7fffffffdfb8) at /home/tamlok/qemu-git/hw/core/qdev.c:809 #6 0x00005555558d3234 in property_set_bool (obj=0x555556a10bb0, v=0x55555666e300, opaque=0x555556732270, name=0x5555559abd39 "realized", errp=0x7fffffffdfb8) at /home/tamlok/qemu-git/qom/object.c:1421 #7 0x00005555558d1a68 in object_property_set (obj=0x555556a10bb0, v=0x55555666e300, name=0x5555559abd39 "realized", errp=0x7fffffffdfb8) at /home/tamlok/qemu-git/qom/object.c:819 #8 0x00005555558d3a26 in object_property_set_qobject (obj=0x555556a10bb0, value=0x555556773150, name=0x5555559abd39 "realized", errp=0x7fffffffdfb8) at /home/tamlok/qemu-git/qom/qom-qobject.c:24 #9 0x00005555558d1d65 in object_property_set_bool (obj=0x555556a10bb0, value=true, name=0x5555559abd39 "realized", errp=0x7fffffffdfb8) at /home/tamlok/qemu-git/qom/object.c:883 #10 0x000055555571d334 in qdev_device_add (opts=0x555556280420) at /home/tamlok/qemu-git/qdev-monitor.c:560 #11 0x000055555573733e in device_init_func (opts=0x555556280420, opaque=0x0) at /home/tamlok/qemu-git/vl.c:2414 #12 0x000055555598d077 in qemu_opts_foreach (list=0x555555d83a80, func=0x555555737313 <device_init_func>, opaque=0x0, abort_on_failure=1) at /home/tamlok/qemu-git/util/qemu-option.c:1052 #13 0x000055555573c790 in main (argc=19, argv=0x7fffffffe4d8, envp=0x7fffffffe578) at /home/tamlok/qemu-git/vl.c:4456 Le > Jan > >