Patchwork [v11,5/5] pcie/aer: use fw device path as fallback for aer injection command

login
register
mail settings
Submitter Isaku Yamahata
Date Dec. 24, 2010, 3:14 a.m.
Message ID <d09a6b4f62fc2e8c094c343c741c9edbb0e24dfd.1293160345.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/76587/
State New
Headers show

Comments

Isaku Yamahata - Dec. 24, 2010, 3:14 a.m.
pcie_aer_inject command: When qdev id failed, try fw device path as
fallback.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hmp-commands.hx |    7 ++++++-
 hw/pcie_aer.c   |   12 ++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 8d84ddc..928ded4 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -878,12 +878,17 @@  ETEXI
 	              "id:s,error_status:s,"
 	              "header0:i?,header1:i?,header2:i?,header3:i?,"
 	              "prefix0:i?,prefix1:i?,prefix2:i?,prefix3:i?",
-        .params     = "[-a] [-c] id "
+        .params     = "[-a] [-c] [id|pci_fw_dev_path] "
                       "<error_status> [<tlp header> [<tlp header prefix>]]",
         .help       = "inject pcie aer error\n\t\t\t"
 	              " -a for advisory non fatal error\n\t\t\t"
 	              " -c for correctable error\n\t\t\t"
                       "<id> = qdev device id\n\t\t\t"
+                      "<pci_fw_dev_path> = fw device path to pci device"
+	              "\n\t\t\t/pci@<ioport or mmio(hex)>"
+                      "[<fw_name>]@<slot(hex)>,<func(hex)>/.../"
+                      "[<fw_name>]@<slot(hex)>,<func(hex)>\n\t\t\t"
+	              "e.g. /pci@i0cf8/@1,1\n\t\t\t"
                       "<error_status> = error string or 32bit\n\t\t\t"
                       "<tlb header> = 32bit x 4\n\t\t\t"
                       "<tlb header prefix> = 32bit x 4",
diff --git a/hw/pcie_aer.c b/hw/pcie_aer.c
index 6e653dd..6bad79c 100644
--- a/hw/pcie_aer.c
+++ b/hw/pcie_aer.c
@@ -969,10 +969,14 @@  int do_pcie_aer_inejct_error(Monitor *mon,
 
     ret = pci_qdev_find_device(id, &dev);
     if (ret < 0) {
-        monitor_printf(mon,
-                       "id or pci device path is invalid or device not "
-                       "found. %s\n", id);
-        return ret;
+        /* fall back to fw device path */
+        ret = pci_parse_fw_dev_path(id, &dev);
+        if (ret < 0) {
+            monitor_printf(mon,
+                           "id or pci device path is invalid or device not "
+                           "found. %s\n", id);
+            return ret;
+        }
     }
     if (!pci_is_express(dev)) {
         monitor_printf(mon, "the device doesn't support pci express. %s\n",