From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0UaR-00088R-K4 for qemu-devel@nongnu.org; Wed, 11 May 2016 09:54:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0UaM-0007ty-Fb for qemu-devel@nongnu.org; Wed, 11 May 2016 09:54:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44880) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0UaM-0007ta-AI for qemu-devel@nongnu.org; Wed, 11 May 2016 09:53:58 -0400 Date: Wed, 11 May 2016 16:53:54 +0300 From: "Michael S. Tsirkin" Message-ID: <20160511165251-mutt-send-email-mst@redhat.com> References: <1462948831-931-1-git-send-email-peterx@redhat.com> <1462948831-931-2-git-send-email-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1462948831-931-2-git-send-email-peterx@redhat.com> Subject: Re: [Qemu-devel] [PATCH] pci: fix requester id to be the one on root bus List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: qemu-devel@nongnu.org, pbonzini@redhat.com, jan.kiszka@web.de, rkrcmar@redhat.com, alex.williamson@redhat.com On Wed, May 11, 2016 at 02:40:31PM +0800, Peter Xu wrote: > When there are devices under PCI bridge (or bridges), PCI requester ID > should be the one that hooked on the root PCI bus, not the PCI device > itself. > > Signed-off-by: Peter Xu I think this is only correct for pci bridges, and wrong for pci express bridges. How exactly do you test this? > --- > hw/pci/msi.c | 2 +- > hw/pci/pci.c | 9 +++++++++ > include/hw/pci/pci.h | 2 ++ > 3 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/hw/pci/msi.c b/hw/pci/msi.c > index e0e64c2..1719716 100644 > --- a/hw/pci/msi.c > +++ b/hw/pci/msi.c > @@ -315,7 +315,7 @@ void msi_send_message(PCIDevice *dev, MSIMessage msg) > { > MemTxAttrs attrs = {}; > > - attrs.requester_id = pci_requester_id(dev); > + attrs.requester_id = pci_requester_id_recursive(dev); > address_space_stl_le(&dev->bus_master_as, msg.address, msg.data, > attrs, NULL); > } > diff --git a/hw/pci/pci.c b/hw/pci/pci.c > index bb605ef..c14299b 100644 > --- a/hw/pci/pci.c > +++ b/hw/pci/pci.c > @@ -2498,6 +2498,15 @@ PCIDevice *pci_get_function_0(PCIDevice *pci_dev) > } > } > > +uint16_t pci_requester_id_recursive(PCIDevice *dev) > +{ > + while (pci_bus_num(dev->bus)) { > + /* This is not on root PCI bus, we find its parent */ > + dev = dev->bus->parent_dev; > + } > + return pci_requester_id(dev); > +} > + > static const TypeInfo pci_device_type_info = { > .name = TYPE_PCI_DEVICE, > .parent = TYPE_DEVICE, > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h > index ef6ba51..4cb5b50 100644 > --- a/include/hw/pci/pci.h > +++ b/include/hw/pci/pci.h > @@ -776,4 +776,6 @@ extern const VMStateDescription vmstate_pci_device; > .offset = vmstate_offset_pointer(_state, _field, PCIDevice), \ > } > > +uint16_t pci_requester_id_recursive(PCIDevice *dev); > + > #endif > -- > 2.4.11