From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4wU2-0001gP-9E for qemu-devel@nongnu.org; Fri, 04 Dec 2015 14:57:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4wTy-00046K-8z for qemu-devel@nongnu.org; Fri, 04 Dec 2015 14:57:34 -0500 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]:33105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4wTx-000468-V4 for qemu-devel@nongnu.org; Fri, 04 Dec 2015 14:57:30 -0500 Received: by wmec201 with SMTP id c201so89577557wme.0 for ; Fri, 04 Dec 2015 11:57:29 -0800 (PST) Date: Fri, 4 Dec 2015 21:57:26 +0200 From: Shmulik Ladkani Message-ID: <20151204215726.7b04e578@halley> In-Reply-To: <566153B0.3030405@redhat.com> References: <1449069991-6109-1-git-send-email-shmulik.ladkani@ravellosystems.com> <1449069991-6109-5-git-send-email-shmulik.ladkani@ravellosystems.com> <566153B0.3030405@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 4/5] vmxnet3: The vmxnet3 device is a PCIE endpoint List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: Dmitry Fleytman , Marcel Apfelbaum , idan.brown@ravellosystems.com, qemu-devel@nongnu.org Thanks Jason, On Fri, 4 Dec 2015 16:49:52 +0800 Jason Wang wrote: > > @@ -2257,6 +2262,10 @@ static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp) > > > > vmxnet3_net_init(s); > > > > + if (pci_is_express(pci_dev) && pci_bus_is_express(pci_dev->bus)) { > > Looks like pci_bus_is_express() has been checked in > pcie_endpoint_cap_init(). Yes, but only for toggling between 'type = PCI_EXP_TYPE_ENDPOINT' vs. 'type = PCI_EXP_TYPE_RC_END'. We would not like to expose the capability stating device is an express endpoint (of any kind) unless it is located on a pcie bus. > > +static void vmxnet3_realize(DeviceState *qdev, Error **errp) > > +{ > > + VMXNET3Class *vc = VMXNET3_DEVICE_GET_CLASS(qdev); > > + PCIDevice *pci_dev = PCI_DEVICE(qdev); > > + VMXNET3State *s = VMXNET3(qdev); > > + > > + if (!(s->compat_flags & VMXNET3_COMPAT_FLAG_DISABLE_PCIE)) { > > + pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS; > > + } > > + > > + vc->parent_dc_realize(qdev, errp); > > +} > > It's not clear that how the class helps here. Why not simply do > everthing in vmxnet3_pci_realize()? Since 'vmxnet3_pci_realize' is invoked too late. By the time it's invoked, the config space is already allocated during 'pci_qdev_realize', without correctly knowing whether the device is pci or pcie. We must call 'pci_qdev_realize' (parent_dc_realize) only after 'cap_present' is properly set. See discussion here: https://lists.nongnu.org/archive/html/qemu-devel/2015-12/msg00043.html Regards, Shmulik