qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: mst@redhat.com, pbonzini@redhat.com, jan.kiszka@web.de,
	rkrcmar@redhat.com, alex.williamson@redhat.com,
	peterx@redhat.com
Subject: [Qemu-devel] [PATCH] pci: fix requester id to be the one on root bus
Date: Wed, 11 May 2016 14:40:31 +0800	[thread overview]
Message-ID: <1462948831-931-2-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1462948831-931-1-git-send-email-peterx@redhat.com>

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 <peterx@redhat.com>
---
 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

  reply	other threads:[~2016-05-11  6:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11  6:40 [Qemu-devel] [PATCH] pci: fix requester id with PCI bridges Peter Xu
2016-05-11  6:40 ` Peter Xu [this message]
2016-05-11 13:53   ` [Qemu-devel] [PATCH] pci: fix requester id to be the one on root bus Michael S. Tsirkin
2016-05-12  2:40     ` Peter Xu
2016-05-12  3:22       ` Alex Williamson
2016-05-12  4:43         ` Peter Xu
2016-05-11  6:53 ` [Qemu-devel] [PATCH] pci: fix requester id with PCI bridges Peter Xu
2016-05-12  7:11   ` Michael S. Tsirkin
2016-05-12  7:32     ` Peter Xu
2016-05-12  7:51       ` Michael S. Tsirkin
2016-05-16  7:23         ` Peter Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1462948831-931-2-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).