[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] PCI interface changes for PCIE-AER enabling



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1227524776 0
# Node ID cd45b5c9561250b999476227dbc7f7ede377d3d4
# Parent  e7da388ff95de8e17ad2d92989d5c375411bc5ad
PCI interface changes for PCIE-AER enabling

This patch reflects some pci interface changes in pciif.h in XEN head
file. And also add domain shutdown support in xend for shutting domain
from DOM0 kernel when non-recoverable uncorrected pci error happens.

Signed-off-by: Jiang Yunhong <yunhong.jiang@xxxxxxxxx>
Signed-off-by: Ke Liping <liping.ke@xxxxxxxxx>
---
 tools/python/xen/xend/server/pciif.py |   35 +++++++++++++++++++++++++++++++++-
 xen/include/public/io/pciif.h         |   35 ++++++++++++++++++++++++++++------
 2 files changed, 63 insertions(+), 7 deletions(-)

diff -r e7da388ff95d -r cd45b5c95612 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py     Thu Nov 20 14:23:59 2008 +0000
+++ b/tools/python/xen/xend/server/pciif.py     Mon Nov 24 11:06:16 2008 +0000
@@ -35,6 +35,8 @@ import re
 import re
 
 from xen.xend.server.pciquirk import *
+from xen.xend.xenstore.xstransact import xstransact
+from xen.xend.xenstore.xswatch import xswatch
 
 xc = xen.lowlevel.xc.xc()
 
@@ -58,6 +60,7 @@ class PciController(DevController):
 class PciController(DevController):
 
     def __init__(self, vm):
+        self.aerStateWatch = None
         DevController.__init__(self, vm)
 
 
@@ -431,8 +434,22 @@ class PciController(DevController):
 
         for (domain, bus, slot, func) in pci_dev_list:
             self.setupOneDevice(domain, bus, slot, func)
-
+        wPath = '/local/domain/0/backend/pci/%u/0/aerState' % (self.getDomid())
+        self.aerStatePath = xswatch(wPath, self._handleAerStateWatch)
+        log.debug('pci: register aer watch %s', wPath)
         return
+
+    def _handleAerStateWatch(self, _):
+        log.debug('XendDomainInfo.handleAerStateWatch')
+        if self.getDomid() == 0:
+            raise XendError('Domain 0 cannot be shutdown')
+        readPath = '/local/domain/0/backend/pci/%u/0/aerState' % 
(self.getDomid())
+        action = xstransact.Read(readPath)
+        if action and action=='aerfail':
+            log.debug('shutdown domain because of aer handle error')
+            self.vm.shutdown('poweroff')
+        return True
+
 
     def cleanupOneDevice(self, domain, bus, slot, func):
         """ Detach I/O resources for device from frontend domain
@@ -545,6 +562,22 @@ class PciController(DevController):
 
         return new_num_devs
 
+    def destroyDevice(self, devid, force):
+        DevController.destroyDevice(self, devid, True)
+        log.debug('pci: unregister aer watch')
+        self.unwatchAerState
+
+    def unwatchAerState(self):
+        """Remove the watch on the domain's aerState node, if any."""
+        try:
+            try:
+                if self.aerStateWatch:
+                    self.aerStateWatch.unwatch()
+            finally:
+                self.aerStateWatch = None
+        except:
+            log.exception("Unwatching aerState failed.")
+  
     def waitForBackend(self,devid):
         return (0, "ok - no hotplug")
 
diff -r e7da388ff95d -r cd45b5c95612 xen/include/public/io/pciif.h
--- a/xen/include/public/io/pciif.h     Thu Nov 20 14:23:59 2008 +0000
+++ b/xen/include/public/io/pciif.h     Mon Nov 24 11:06:16 2008 +0000
@@ -30,14 +30,22 @@
 /* xen_pci_sharedinfo flags */
 #define _XEN_PCIF_active     (0)
 #define XEN_PCIF_active      (1<<_XEN_PCI_active)
+#define _XEN_PCIB_AERHANDLER (1)
+#define XEN_PCIB_AERHANDLER  (1<<_XEN_PCIB_AERHANDLER)
+#define _XEN_PCIB_active     (2)
+#define XEN_PCIB_active      (1<<_XEN_PCIB_active)
 
 /* xen_pci_op commands */
-#define XEN_PCI_OP_conf_read    (0)
-#define XEN_PCI_OP_conf_write   (1)
-#define XEN_PCI_OP_enable_msi   (2)
-#define XEN_PCI_OP_disable_msi  (3)
-#define XEN_PCI_OP_enable_msix  (4)
-#define XEN_PCI_OP_disable_msix (5)
+#define XEN_PCI_OP_conf_read           (0)
+#define XEN_PCI_OP_conf_write          (1)
+#define XEN_PCI_OP_enable_msi          (2)
+#define XEN_PCI_OP_disable_msi         (3)
+#define XEN_PCI_OP_enable_msix         (4)
+#define XEN_PCI_OP_disable_msix        (5)
+#define XEN_PCI_OP_aer_detected        (6)
+#define XEN_PCI_OP_aer_resume          (7)
+#define XEN_PCI_OP_aer_mmio            (8)
+#define XEN_PCI_OP_aer_slotreset       (9)
 
 /* xen_pci_op error numbers */
 #define XEN_PCI_ERR_success          (0)
@@ -82,10 +90,25 @@ struct xen_pci_op {
     struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
 };
 
+/*used for pcie aer handling*/
+struct xen_pcie_aer_op
+{
+
+    /* IN: what action to perform: XEN_PCI_OP_* */
+    uint32_t cmd;
+    /*IN/OUT: return aer_op result or carry error_detected state as input*/
+    int32_t err;
+
+    /* IN: which device to touch */
+    uint32_t domain; /* PCI Domain/Segment*/
+    uint32_t bus;
+    uint32_t devfn;
+};
 struct xen_pci_sharedinfo {
     /* flags - XEN_PCIF_* */
     uint32_t flags;
     struct xen_pci_op op;
+    struct xen_pcie_aer_op aer_op;
 };
 
 #endif /* __XEN_PCI_COMMON_H__ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.