From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr582-0007Da-Tz for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:21:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zr57y-0003iz-TF for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:21:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36178) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zr57y-0003iW-OS for qemu-devel@nongnu.org; Tue, 27 Oct 2015 10:21:30 -0400 Message-ID: <1445955689.8018.223.camel@redhat.com> From: Alex Williamson Date: Tue, 27 Oct 2015 08:21:29 -0600 In-Reply-To: <1445950308-10329-3-git-send-email-caoj.fnst@cn.fujitsu.com> References: <1445950308-10329-1-git-send-email-caoj.fnst@cn.fujitsu.com> <1445950308-10329-3-git-send-email-caoj.fnst@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 2/2] enable multi-function hot-add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cao jin Cc: izumi.taku@jp.fujitsu.com, qemu-devel@nongnu.org, mst@redhat.com On Tue, 2015-10-27 at 20:51 +0800, Cao jin wrote: > Enable PCIe device multi-function hot-add, just ensure function 0 is added > last, then driver will got the notification to scan the slot. > > Signed-off-by: Cao jin > --- > hw/pci/pci.c | 40 +++++++++++++++++++++++++++++++++++++++- > hw/pci/pci_host.c | 13 +++++++++++-- > hw/pci/pcie.c | 18 +++++++++--------- > include/hw/pci/pci.h | 1 + > 4 files changed, 60 insertions(+), 12 deletions(-) > diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c > index 3e26f92..63d7d2f 100644 > --- a/hw/pci/pci_host.c > +++ b/hw/pci/pci_host.c > @@ -20,6 +20,7 @@ > > #include "hw/pci/pci.h" > #include "hw/pci/pci_host.h" > +#include "hw/pci/pci_bus.h" > #include "trace.h" > > /* debug PCI */ > @@ -75,7 +76,11 @@ void pci_data_write(PCIBus *s, uint32_t addr, uint32_t val, int len) > PCIDevice *pci_dev = pci_dev_find_by_addr(s, addr); > uint32_t config_addr = addr & (PCI_CONFIG_SPACE_SIZE - 1); > > - if (!pci_dev) { > + /* non-zero functions are only exposed when function 0 is present, > + * allowing direct removal of unexposed functions. > + */ > + if (!pci_dev || > + (pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev))) { > return; > } > > @@ -91,7 +96,11 @@ uint32_t pci_data_read(PCIBus *s, uint32_t addr, int len) > uint32_t config_addr = addr & (PCI_CONFIG_SPACE_SIZE - 1); > uint32_t val; > > - if (!pci_dev) { > + /* non-zero functions are only exposed when function 0 is present, > + * allowing direct removal of unexposed functions. > + */ > + if (!pci_dev || > + (pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev))) { > return ~0x0; > } Don't we need to do this in pci_host_config_read_common() and pci_host_config_write_common() instead? Otherwise I don't think we catch config access via mmcfg. Thanks, Alex