From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1xnJ-0007W6-AP for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:08:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1xnA-0006Ra-On for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:08:21 -0400 Received: from mout.web.de ([212.227.17.11]:49696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1xnA-0006RL-F5 for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:08:12 -0400 Message-ID: <53B2B2B8.1090600@web.de> Date: Tue, 01 Jul 2014 15:08:08 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <53B26475.9030809@web.de> <53B2B011.2020604@web.de> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="060Kqg5sSmiPUSjLrWhgSPmppeNiAeDe6" Subject: Re: [Qemu-devel] Why devfn will be -1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Le Tan Cc: qemu-devel This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --060Kqg5sSmiPUSjLrWhgSPmppeNiAeDe6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 2014-07-01 15:02, Le Tan wrote: > 2014-07-01 20:56 GMT+08:00 Jan Kiszka : >> On 2014-07-01 14:55, Le Tan wrote: >>> 2014-07-01 20:52 GMT+08:00 Le Tan : >>>> Hi Jan, >>>> >>>> 2014-07-01 15:34 GMT+08:00 Jan Kiszka : >>>>> 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 bu= s. >>>>>> 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 =3D 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 t= o see >>>>> where this comes from and analyze the device structure from where t= hat >>>>> -1 was most probably taken. >>> >>> I think maybe this is a bug? In the function do_pci_register_device()= , >>> maybe these two sentence should be reorder? >>> dma_as =3D pci_device_iommu_address_space(pci_dev); >>> pci_dev->devfn =3D devfn; >> >> Looks like. Give it a try, then possibly send a patch :) > I reorder these two sentences and get the print log like this: > vtd bus 0 slot 31 func 0 devfn 248 > vtd bus 0 slot 31 func 2 devfn 250 > vtd bus 0 slot 31 func 3 devfn 251 > vtd bus 0 slot 1 func 0 devfn 8 > vtd bus 0 slot 2 func 0 devfn 16 >=20 > The "info pci" output is here: > (qemu) info pci > Bus 0, device 0, function 0: > Host bridge: PCI device 8086:29c0 > id "" > Bus 0, device 1, function 0: > VGA controller: PCI device 1013:00b8 > BAR0: 32 bit prefetchable memory at 0xfc000000 [0xfdffffff]. > BAR1: 32 bit memory at 0xfebf0000 [0xfebf0fff]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe]. > id "" > Bus 0, device 2, function 0: > Ethernet controller: PCI device 8086:100e > IRQ 11. > BAR0: 32 bit memory at 0xfebc0000 [0xfebdffff]. > BAR1: I/O at 0xc000 [0xc03f]. > BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe]. > id "" > Bus 0, device 31, function 0: > ISA bridge: PCI device 8086:2918 > id "" > Bus 0, device 31, function 2: > SATA controller: PCI device 8086:2922 > IRQ 10. > BAR4: I/O at 0xc080 [0xc09f]. > BAR5: 32 bit memory at 0xfebf1000 [0xfebf1fff]. > id "" > Bus 0, device 31, function 3: > SMBus: PCI device 8086:2930 > IRQ 10. > BAR4: I/O at 0x0700 [0x073f]. > id "" >=20 > So maybe it is all right now? And I will go on the vtd emulation.:) > Thanks very much! Looks better :). Don't forget to send the patch against pci.c! Jan --060Kqg5sSmiPUSjLrWhgSPmppeNiAeDe6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlOysrgACgkQitSsb3rl5xT9/wCdFSliq4IUFCwRGhdjcMkP2U7K VJoAoLqq7WyzSh4yRn9lRM2kLgQQOqAJ =oF28 -----END PGP SIGNATURE----- --060Kqg5sSmiPUSjLrWhgSPmppeNiAeDe6--