Received: from eggs.gnu.org ([2001:4830:134:3::10]:35829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOoOr-0003ZK-Av for qemu-devel@nongnu.org; Tue, 02 Sep 2014 09:45:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOoOk-0005Uk-9J for qemu-devel@nongnu.org; Tue, 02 Sep 2014 09:45:33 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:24999) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOoOk-0005UT-25 for qemu-devel@nongnu.org; Tue, 02 Sep 2014 09:45:26 -0400 Message-ID: <1409665468.848.198.camel@ori.omang.mine.nu> From: Knut Omang Date: Tue, 02 Sep 2014 15:44:28 +0200 In-Reply-To: <20140902130323.GB14127@redhat.com> References: <1409655606-19150-1-git-send-email-knut.omang@oracle.com> <1409655606-19150-2-git-send-email-knut.omang@oracle.com> <20140902130323.GB14127@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 1/4] pci: Make use of the devfn property when registering new devices List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Peter Maydell , Peter Crosthwaite , Stefan Hajnoczi , Laszlo Ersek , Alexander Graf , qemu-devel@nongnu.org, Fabien Chouteau , Luiz Capitulino , Beniamino Galvani , Alex Williamson , "Gonglei (Arei)" , Jan Kiszka , Anthony Liguori , Paolo Bonzini , Amos Kong , Gabriel Somlo On Tue, 2014-09-02 at 16:03 +0300, Michael S. Tsirkin wrote: > On Tue, Sep 02, 2014 at 01:00:03PM +0200, Knut Omang wrote: > > Without this, the devfn argument to pci_create_*() > > does not affect the assigned devfn. > > > > Needed to support (VF_STRIDE,VF_OFFSET) values other than (1,1) > > for SR/IOV. > > > > Signed-off-by: Knut Omang > > Sorry, I don't understand the explanation exactly. > pci_dev->devfn is not set correctly? why? This probably has been broken by some of the qom adaptation if I understand it right: The devfn parameter in pci_create_multifunction() is only used to set the "addr" property, which in turn is not used anywhere as far as I can see. So the pci_dev->devfn has it's default value. What I observe is that when I enable VFs with the igb example device, now with stride = 2 and offset 0x80 (as my real lab hardware implements) and enable some VFs, this yields devfn's of 0x80, 0x82, 0x84... sent as parameters to pci_create..(), I still end up with this (eg. the "natural" next function will be selected instead of the provided devfn): 01:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 01:00.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:00.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:00.3 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:00.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) With this patch applied, I get the expected: 01:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01) 01:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:10.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) 01:10.6 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01) > > --- > > hw/pci/pci.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > > index daeaeac..6b21dee 100644 > > --- a/hw/pci/pci.c > > +++ b/hw/pci/pci.c > > @@ -1757,7 +1757,7 @@ static int pci_qdev_init(DeviceState *qdev) > > bus = PCI_BUS(qdev_get_parent_bus(qdev)); > > pci_dev = do_pci_register_device(pci_dev, bus, > > object_get_typename(OBJECT(qdev)), > > - pci_dev->devfn); > > + object_property_get_int(OBJECT(qdev), "addr", NULL)); > > if (pci_dev == NULL) > > return -1; > > > > -- > > 1.9.0