qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 1/2] pcie_aer: get rid of recursion
Date: Wed, 17 Nov 2010 16:06:43 +0200	[thread overview]
Message-ID: <0dbf2e843eb860498d43004bc0a93f99cf163fd1.1290002681.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1290002681.git.mst@redhat.com>

Added some TODOs: they are trivial but omitted here
to make the patch logic as transparent as possible.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pcie_aer.c |   48 +++++++++++++++++++++++++++++++-----------------
 1 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
index acf826a..c565d39 100644
--- a/hw/pcie_aer.c
+++ b/hw/pcie_aer.c
@@ -176,14 +176,8 @@ static void pcie_aer_update_uncor_status(PCIDevice *dev)
 }
 
 /*
- * pcie_aer_msg() is called recursively by
- * pcie_aer_msg_alldev(), pci_aer_msg_vbridge() and pcie_aer_msg_root_port()
- */
-static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg);
-
-/*
  * return value:
- * true: error message is sent up
+ * true: error message needs to be sent up
  * false: error message is masked
  *
  * 6.2.6 Error Message Control
@@ -193,8 +187,6 @@ static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg);
 static bool
 pcie_aer_msg_alldev(PCIDevice *dev, const PCIEAERMsg *msg)
 {
-    PCIDevice *parent_port;
-
     if (!(pcie_aer_msg_is_uncor(msg) &&
           (pci_get_word(dev->config + PCI_COMMAND) & PCI_COMMAND_SERR))) {
         return false;
@@ -220,13 +212,21 @@ pcie_aer_msg_alldev(PCIDevice *dev, const PCIEAERMsg *msg)
     }
 
     /* send up error message */
+    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 notify system itself,
+        /* Root port can notify system itself,
            or send the error message to root complex event collector. */
         /*
-         * if root port is associated to event collector, set
-         * parent_port = 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;
@@ -236,11 +236,10 @@ pcie_aer_msg_alldev(PCIDevice *dev, const PCIEAERMsg *msg)
     if (parent_port) {
         if (!pci_is_express(parent_port)) {
             /* just ignore it */
-            return false;
+            return NULL;
         }
-        pcie_aer_msg(parent_port, msg);
     }
-    return true;
+    return parent_port;
 }
 
 /*
@@ -381,8 +380,12 @@ 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.
  */
-static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg)
+static bool pcie_send_aer_msg(PCIDevice *dev, const PCIEAERMsg *msg)
 {
     uint8_t type;
     bool msg_sent;
@@ -402,6 +405,18 @@ static void pcie_aer_msg(PCIDevice *dev, const PCIEAERMsg *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)) {
+            return;
+        }
+        dev =  pcie_aer_parent_port(dev);
+    }
 }
 
 static void pcie_aer_update_log(PCIDevice *dev, const PCIEAERErr *err)
@@ -824,4 +839,3 @@ const VMStateDescription vmstate_pcie_aer_log = {
         VMSTATE_END_OF_LIST()
     }
 };
-
-- 
1.7.3.2.91.g446ac

  reply	other threads:[~2010-11-17 14:06 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     ` Michael S. Tsirkin [this message]
2010-11-17 14:06     ` [Qemu-devel] [PATCH 2/2] pcie_aer: complete unwinding recursion Michael S. Tsirkin
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=0dbf2e843eb860498d43004bc0a93f99cf163fd1.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).