From: "Michael S. Tsirkin" <mst@redhat.com>
To: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: skandasa@cisco.com, adnan@khaleel.us, etmartin@cisco.com,
qemu-devel@nongnu.org, wexu2@cisco.com
Subject: [Qemu-devel] [PATCH 2/2] pcie_aer: complete unwinding recursion
Date: Wed, 17 Nov 2010 16:06:47 +0200 [thread overview]
Message-ID: <12e6522e9895a1e507617dd3b5de2fd36fbff9a3.1290002681.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1290002681.git.mst@redhat.com>
Open-code functions created in the previous patch,
to make code more compact and clear.
Detcted and documented what looks like a bug in code
that becomes apparent from this refactoring.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/pcie_aer.c | 80 +++++++++++++++++++-------------------------------------
1 files changed, 27 insertions(+), 53 deletions(-)
diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
index c565d39..6621918 100644
--- a/hw/pcie_aer.c
+++ b/hw/pcie_aer.c
@@ -215,33 +215,6 @@ pcie_aer_msg_alldev(PCIDevice *dev, const PCIEAERMsg *msg)
return true;
}
-/* Get parent port to send up error message on.
- * TODO: clean up and open-code this logic */
-static PCIDevice *pcie_aer_parent_port(PCIDevice *dev)
-{
- PCIDevice *parent_port;
- if (pci_is_express(dev) &&
- pcie_cap_get_type(dev) == PCI_EXP_TYPE_ROOT_PORT) {
- /* Root port can notify system itself,
- or send the error message to root complex event collector. */
- /*
- * if root port is associated with an event collector,
- * return the root complex event collector here.
- * For now root complex event collector isn't supported.
- */
- parent_port = NULL;
- } else {
- parent_port = pci_bridge_get_device(dev->bus);
- }
- if (parent_port) {
- if (!pci_is_express(parent_port)) {
- /* just ignore it */
- return NULL;
- }
- }
- return parent_port;
-}
-
/*
* return value:
* true: error message is sent up
@@ -381,41 +354,42 @@ static bool pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg)
/*
* 6.2.6 Error Message Control Figure 6-3
*
- * Returns true in case the error needs to
- * be propagated up.
- * TODO: open-code.
+ * Walk up the bus tree from the device, propagate the error message.
*/
-static bool pcie_send_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg)
+static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg)
{
uint8_t type;
- bool msg_sent;
-
- assert(pci_is_express(dev));
- type = pcie_cap_get_type(dev);
- if (type == PCI_EXP_TYPE_ROOT_PORT ||
- type == PCI_EXP_TYPE_UPSTREAM ||
- type == PCI_EXP_TYPE_DOWNSTREAM) {
- msg_sent = pcie_aer_msg_vbridge(dev, msg);
- if (!msg_sent) {
+ while (dev) {
+ if (!pci_is_express(parent_port)) {
+ /* just ignore it */
+ /* TODO: Shouldn't we set PCI_STATUS_SIG_SYSTEM_ERROR?
+ * Consider e.g. a PCI bridge above a PCI Express device. */
return;
}
- }
- msg_sent = pcie_aer_msg_alldev(dev, msg);
- if (type == PCI_EXP_TYPE_ROOT_PORT && msg_sent) {
- pcie_aer_msg_root_port(dev, msg);
- }
- return msg_sent;
-}
-static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg)
-{
- bool send_to_parent;
- while (dev) {
- if (!pcie_send_aer_msg(dev, msg)) {
+ type = pcie_cap_get_type(dev);
+ if ((type == PCI_EXP_TYPE_ROOT_PORT ||
+ type == PCI_EXP_TYPE_UPSTREAM ||
+ type == PCI_EXP_TYPE_DOWNSTREAM) &&
+ !pcie_aer_msg_vbridge(dev, msg)) {
+ return;
+ }
+ if (!pcie_aer_msg_alldev(dev, msg)) {
+ return;
+ }
+ if (type == PCI_EXP_TYPE_ROOT_PORT) {
+ pcie_aer_msg_root_port(dev, msg);
+ /* Root port can notify system itself,
+ or send the error message to root complex event collector. */
+ /*
+ * if root port is associated with an event collector,
+ * return the root complex event collector here.
+ * For now root complex event collector isn't supported.
+ */
return;
}
- dev = pcie_aer_parent_port(dev);
+ dev = pci_bridge_get_device(dev->bus);
}
}
--
1.7.3.2.91.g446ac
next prev parent reply other threads:[~2010-11-17 14:07 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-16 8:26 [Qemu-devel] [PATCH v9 0/8] pcie port switch emulators Isaku Yamahata
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 1/8] pci: revise pci command register initialization Isaku Yamahata
2010-11-16 10:50 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-17 2:03 ` Isaku Yamahata
2010-11-17 12:02 ` Michael S. Tsirkin
2010-11-18 2:08 ` Isaku Yamahata
2010-11-18 6:42 ` Michael S. Tsirkin
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 2/8] pci: fix accesses to pci status register Isaku Yamahata
2010-11-16 10:52 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-17 4:17 ` Isaku Yamahata
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 3/8] pci: clean up of " Isaku Yamahata
2010-11-16 14:01 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 4/8] pcie_regs.h: more constants Isaku Yamahata
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 5/8] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-11-17 14:06 ` [Qemu-devel] [PATCH 0/2] " Michael S. Tsirkin
2010-11-17 14:06 ` [Qemu-devel] [PATCH 1/2] pcie_aer: get rid of recursion Michael S. Tsirkin
2010-11-17 14:06 ` Michael S. Tsirkin [this message]
2010-11-18 8:11 ` [Qemu-devel] Re: [PATCH 0/2] Re: [PATCH v9 5/8] pcie/aer: helper functions for pcie aer capability Isaku Yamahata
2010-11-18 8:52 ` Michael S. Tsirkin
2010-11-19 9:42 ` Isaku Yamahata
2010-11-19 12:03 ` Michael S. Tsirkin
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 6/8] ioh3420: support aer Isaku Yamahata
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 7/8] x3130/upstream: " Isaku Yamahata
2010-11-16 8:26 ` [Qemu-devel] [PATCH v9 8/8] x3130/downstream: " Isaku Yamahata
[not found] ` <1289930315.27724.18.camel@etmartin-lnx>
2010-11-16 18:57 ` [Qemu-devel] " Etienne Martineau
2010-11-17 4:07 ` Isaku Yamahata
2010-11-17 5:31 ` Etienne Martineau
2010-11-18 2:19 ` Isaku Yamahata
2010-11-17 14:38 ` [Qemu-devel] Re: [PATCH v9 0/8] pcie port switch emulators Michael S. Tsirkin
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=12e6522e9895a1e507617dd3b5de2fd36fbff9a3.1290002681.git.mst@redhat.com \
--to=mst@redhat.com \
--cc=adnan@khaleel.us \
--cc=etmartin@cisco.com \
--cc=qemu-devel@nongnu.org \
--cc=skandasa@cisco.com \
--cc=wexu2@cisco.com \
--cc=yamahata@valinux.co.jp \
/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).