ia64/xen-unstable

changeset 18823:cd45b5c95612

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@intel.com>
Signed-off-by: Ke Liping <liping.ke@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Nov 24 11:06:16 2008 +0000 (2008-11-24)
parents e7da388ff95d
children 0b8c6c91c5a4
files tools/python/xen/xend/server/pciif.py xen/include/public/io/pciif.h
line diff
     1.1 --- a/tools/python/xen/xend/server/pciif.py	Thu Nov 20 14:23:59 2008 +0000
     1.2 +++ b/tools/python/xen/xend/server/pciif.py	Mon Nov 24 11:06:16 2008 +0000
     1.3 @@ -35,6 +35,8 @@ import resource
     1.4  import re
     1.5  
     1.6  from xen.xend.server.pciquirk import *
     1.7 +from xen.xend.xenstore.xstransact import xstransact
     1.8 +from xen.xend.xenstore.xswatch import xswatch
     1.9  
    1.10  xc = xen.lowlevel.xc.xc()
    1.11  
    1.12 @@ -58,6 +60,7 @@ def parse_hex(val):
    1.13  class PciController(DevController):
    1.14  
    1.15      def __init__(self, vm):
    1.16 +        self.aerStateWatch = None
    1.17          DevController.__init__(self, vm)
    1.18  
    1.19  
    1.20 @@ -431,8 +434,22 @@ class PciController(DevController):
    1.21  
    1.22          for (domain, bus, slot, func) in pci_dev_list:
    1.23              self.setupOneDevice(domain, bus, slot, func)
    1.24 +        wPath = '/local/domain/0/backend/pci/%u/0/aerState' % (self.getDomid())
    1.25 +        self.aerStatePath = xswatch(wPath, self._handleAerStateWatch)
    1.26 +        log.debug('pci: register aer watch %s', wPath)
    1.27 +        return
    1.28  
    1.29 -        return
    1.30 +    def _handleAerStateWatch(self, _):
    1.31 +        log.debug('XendDomainInfo.handleAerStateWatch')
    1.32 +        if self.getDomid() == 0:
    1.33 +            raise XendError('Domain 0 cannot be shutdown')
    1.34 +        readPath = '/local/domain/0/backend/pci/%u/0/aerState' % (self.getDomid())
    1.35 +        action = xstransact.Read(readPath)
    1.36 +        if action and action=='aerfail':
    1.37 +            log.debug('shutdown domain because of aer handle error')
    1.38 +            self.vm.shutdown('poweroff')
    1.39 +        return True
    1.40 +
    1.41  
    1.42      def cleanupOneDevice(self, domain, bus, slot, func):
    1.43          """ Detach I/O resources for device from frontend domain
    1.44 @@ -545,6 +562,22 @@ class PciController(DevController):
    1.45  
    1.46          return new_num_devs
    1.47  
    1.48 +    def destroyDevice(self, devid, force):
    1.49 +        DevController.destroyDevice(self, devid, True)
    1.50 +        log.debug('pci: unregister aer watch')
    1.51 +        self.unwatchAerState
    1.52 +
    1.53 +    def unwatchAerState(self):
    1.54 +        """Remove the watch on the domain's aerState node, if any."""
    1.55 +        try:
    1.56 +            try:
    1.57 +                if self.aerStateWatch:
    1.58 +                    self.aerStateWatch.unwatch()
    1.59 +            finally:
    1.60 +                self.aerStateWatch = None
    1.61 +        except:
    1.62 +            log.exception("Unwatching aerState failed.")
    1.63 +  
    1.64      def waitForBackend(self,devid):
    1.65          return (0, "ok - no hotplug")
    1.66  
     2.1 --- a/xen/include/public/io/pciif.h	Thu Nov 20 14:23:59 2008 +0000
     2.2 +++ b/xen/include/public/io/pciif.h	Mon Nov 24 11:06:16 2008 +0000
     2.3 @@ -30,14 +30,22 @@
     2.4  /* xen_pci_sharedinfo flags */
     2.5  #define _XEN_PCIF_active     (0)
     2.6  #define XEN_PCIF_active      (1<<_XEN_PCI_active)
     2.7 +#define _XEN_PCIB_AERHANDLER (1)
     2.8 +#define XEN_PCIB_AERHANDLER  (1<<_XEN_PCIB_AERHANDLER)
     2.9 +#define _XEN_PCIB_active     (2)
    2.10 +#define XEN_PCIB_active      (1<<_XEN_PCIB_active)
    2.11  
    2.12  /* xen_pci_op commands */
    2.13 -#define XEN_PCI_OP_conf_read    (0)
    2.14 -#define XEN_PCI_OP_conf_write   (1)
    2.15 -#define XEN_PCI_OP_enable_msi   (2)
    2.16 -#define XEN_PCI_OP_disable_msi  (3)
    2.17 -#define XEN_PCI_OP_enable_msix  (4)
    2.18 -#define XEN_PCI_OP_disable_msix (5)
    2.19 +#define XEN_PCI_OP_conf_read    	(0)
    2.20 +#define XEN_PCI_OP_conf_write   	(1)
    2.21 +#define XEN_PCI_OP_enable_msi   	(2)
    2.22 +#define XEN_PCI_OP_disable_msi  	(3)
    2.23 +#define XEN_PCI_OP_enable_msix  	(4)
    2.24 +#define XEN_PCI_OP_disable_msix 	(5)
    2.25 +#define XEN_PCI_OP_aer_detected 	(6)
    2.26 +#define XEN_PCI_OP_aer_resume		(7)
    2.27 +#define XEN_PCI_OP_aer_mmio		(8)
    2.28 +#define XEN_PCI_OP_aer_slotreset	(9)
    2.29  
    2.30  /* xen_pci_op error numbers */
    2.31  #define XEN_PCI_ERR_success          (0)
    2.32 @@ -82,10 +90,25 @@ struct xen_pci_op {
    2.33      struct xen_msix_entry msix_entries[SH_INFO_MAX_VEC];
    2.34  };
    2.35  
    2.36 +/*used for pcie aer handling*/
    2.37 +struct xen_pcie_aer_op
    2.38 +{
    2.39 +
    2.40 +    /* IN: what action to perform: XEN_PCI_OP_* */
    2.41 +    uint32_t cmd;
    2.42 +    /*IN/OUT: return aer_op result or carry error_detected state as input*/
    2.43 +    int32_t err;
    2.44 +
    2.45 +    /* IN: which device to touch */
    2.46 +    uint32_t domain; /* PCI Domain/Segment*/
    2.47 +    uint32_t bus;
    2.48 +    uint32_t devfn;
    2.49 +};
    2.50  struct xen_pci_sharedinfo {
    2.51      /* flags - XEN_PCIF_* */
    2.52      uint32_t flags;
    2.53      struct xen_pci_op op;
    2.54 +    struct xen_pcie_aer_op aer_op;
    2.55  };
    2.56  
    2.57  #endif /* __XEN_PCI_COMMON_H__ */