WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [linux-2.6.18-xen] PCI-Express AER implemetation: pcie_p

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [linux-2.6.18-xen] PCI-Express AER implemetation: pcie_portdrv error handler.
From: "Xen patchbot-linux-2.6.18-xen" <patchbot-linux-2.6.18-xen@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 Nov 2008 12:00:14 -0800
Delivery-date: Wed, 26 Nov 2008 12:00:15 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1227524563 0
# Node ID df84c4c22a0a692ef8da7d31108b2d6055fef675
# Parent  30524c484bbb93c696f5c848614748c83b24ca55
PCI-Express AER implemetation: pcie_portdrv error handler.

Signed-off-by: Zhang Yanmin <yanmin.zhang@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
 drivers/pci/pcie/portdrv_pci.c |  224 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 189 insertions(+), 35 deletions(-)

diff -r 30524c484bbb -r df84c4c22a0a drivers/pci/pcie/portdrv_pci.c
--- a/drivers/pci/pcie/portdrv_pci.c    Mon Nov 24 11:02:14 2008 +0000
+++ b/drivers/pci/pcie/portdrv_pci.c    Mon Nov 24 11:02:43 2008 +0000
@@ -14,8 +14,10 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <linux/pcieport_if.h>
+#include <linux/aer.h>
 
 #include "portdrv.h"
+#include "aer/aerdrv.h"
 
 /*
  * Version Information
@@ -29,6 +31,43 @@ MODULE_LICENSE("GPL");
 
 /* global data */
 static const char device_name[] = "pcieport-driver";
+
+static int pcie_portdrv_save_config(struct pci_dev *dev)
+{
+       return pci_save_state(dev);
+}
+
+#ifdef CONFIG_PM
+static int pcie_portdrv_restore_config(struct pci_dev *dev)
+{
+       int retval;
+
+       pci_restore_state(dev);
+       retval = pci_enable_device(dev);
+       if (retval)
+               return retval;
+       pci_set_master(dev);
+       return 0;
+}
+
+static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
+{
+       int ret = pcie_port_device_suspend(dev, state);
+
+       if (!ret)
+               ret = pcie_portdrv_save_config(dev);
+       return ret;
+}
+
+static int pcie_portdrv_resume(struct pci_dev *dev)
+{
+       pcie_portdrv_restore_config(dev);
+       return pcie_port_device_resume(dev);
+}
+#else
+#define pcie_portdrv_suspend NULL
+#define pcie_portdrv_resume NULL
+#endif
 
 /*
  * pcie_portdrv_probe - Probe PCI-Express port devices
@@ -61,6 +100,10 @@ static int __devinit pcie_portdrv_probe 
                return -ENOMEM;
        }
 
+       pcie_portdrv_save_config(dev);
+
+       pci_enable_pcie_error_reporting(dev);
+
        return 0;
 }
 
@@ -70,39 +113,143 @@ static void pcie_portdrv_remove (struct 
        kfree(pci_get_drvdata(dev));
 }
 
-#ifdef CONFIG_PM
-static int pcie_portdrv_save_config(struct pci_dev *dev)
-{
-       return pci_save_state(dev);
-}
-
-static int pcie_portdrv_restore_config(struct pci_dev *dev)
-{
-       int retval;
-
-       pci_restore_state(dev);
-       retval = pci_enable_device(dev);
-       if (retval)
-               return retval;
-       pci_set_master(dev);
-       return 0;
-}
-
-static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state)
-{
-       int ret = pcie_port_device_suspend(dev, state);
-
-       if (!ret)
-               ret = pcie_portdrv_save_config(dev);
-       return ret;
-}
-
-static int pcie_portdrv_resume (struct pci_dev *dev)
-{
-       pcie_portdrv_restore_config(dev);
-       return pcie_port_device_resume(dev);
-}
-#endif
+static int error_detected_iter(struct device *device, void *data)
+{
+       struct pcie_device *pcie_device;
+       struct pcie_port_service_driver *driver;
+       struct aer_broadcast_data *result_data;
+       pci_ers_result_t status;
+
+       result_data = (struct aer_broadcast_data *) data;
+
+       if (device->bus == &pcie_port_bus_type && device->driver) {
+               driver = to_service_driver(device->driver);
+               if (!driver ||
+                       !driver->err_handler ||
+                       !driver->err_handler->error_detected)
+                       return 0;
+
+               pcie_device = to_pcie_device(device);
+
+               /* Forward error detected message to service drivers */
+               status = driver->err_handler->error_detected(
+                       pcie_device->port,
+                       result_data->state);
+               result_data->result =
+                       merge_result(result_data->result, status);
+       }
+
+       return 0;
+}
+
+static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev,
+                                       enum pci_channel_state error)
+{
+       struct aer_broadcast_data result_data =
+                       {error, PCI_ERS_RESULT_CAN_RECOVER};
+
+       device_for_each_child(&dev->dev, &result_data, error_detected_iter);
+
+       return result_data.result;
+}
+
+static int mmio_enabled_iter(struct device *device, void *data)
+{
+       struct pcie_device *pcie_device;
+       struct pcie_port_service_driver *driver;
+       pci_ers_result_t status, *result;
+
+       result = (pci_ers_result_t *) data;
+
+       if (device->bus == &pcie_port_bus_type && device->driver) {
+               driver = to_service_driver(device->driver);
+               if (driver &&
+                       driver->err_handler &&
+                       driver->err_handler->mmio_enabled) {
+                       pcie_device = to_pcie_device(device);
+
+                       /* Forward error message to service drivers */
+                       status = driver->err_handler->mmio_enabled(
+                                       pcie_device->port);
+                       *result = merge_result(*result, status);
+               }
+       }
+
+       return 0;
+}
+
+static pci_ers_result_t pcie_portdrv_mmio_enabled(struct pci_dev *dev)
+{
+       pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED;
+
+       device_for_each_child(&dev->dev, &status, mmio_enabled_iter);
+       return status;
+}
+
+static int slot_reset_iter(struct device *device, void *data)
+{
+       struct pcie_device *pcie_device;
+       struct pcie_port_service_driver *driver;
+       pci_ers_result_t status, *result;
+
+       result = (pci_ers_result_t *) data;
+
+       if (device->bus == &pcie_port_bus_type && device->driver) {
+               driver = to_service_driver(device->driver);
+               if (driver &&
+                       driver->err_handler &&
+                       driver->err_handler->slot_reset) {
+                       pcie_device = to_pcie_device(device);
+
+                       /* Forward error message to service drivers */
+                       status = driver->err_handler->slot_reset(
+                                       pcie_device->port);
+                       *result = merge_result(*result, status);
+               }
+       }
+
+       return 0;
+}
+
+static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
+{
+       pci_ers_result_t status;
+
+       /* If fatal, restore cfg space for possible link reset at upstream */
+       if (dev->error_state == pci_channel_io_frozen) {
+               pcie_portdrv_restore_config(dev);
+               pci_enable_pcie_error_reporting(dev);
+       }
+
+       device_for_each_child(&dev->dev, &status, slot_reset_iter);
+
+       return status;
+}
+
+static int resume_iter(struct device *device, void *data)
+{
+       struct pcie_device *pcie_device;
+       struct pcie_port_service_driver *driver;
+
+       if (device->bus == &pcie_port_bus_type && device->driver) {
+               driver = to_service_driver(device->driver);
+               if (driver &&
+                       driver->err_handler &&
+                       driver->err_handler->resume) {
+                       pcie_device = to_pcie_device(device);
+
+                       /* Forward error message to service drivers */
+                       driver->err_handler->resume(pcie_device->port);
+               }
+       }
+
+       return 0;
+}
+
+static void pcie_portdrv_err_resume(struct pci_dev *dev)
+{
+       device_for_each_child(&dev->dev, NULL, resume_iter);
+}
 
 /*
  * LINUX Device Driver Model
@@ -114,6 +261,13 @@ static const struct pci_device_id port_p
 };
 MODULE_DEVICE_TABLE(pci, port_pci_ids);
 
+static struct pci_error_handlers pcie_portdrv_err_handler = {
+               .error_detected = pcie_portdrv_error_detected,
+               .mmio_enabled = pcie_portdrv_mmio_enabled,
+               .slot_reset = pcie_portdrv_slot_reset,
+               .resume = pcie_portdrv_err_resume,
+};
+
 static struct pci_driver pcie_portdrv = {
        .name           = (char *)device_name,
        .id_table       = &port_pci_ids[0],
@@ -121,10 +275,10 @@ static struct pci_driver pcie_portdrv = 
        .probe          = pcie_portdrv_probe,
        .remove         = pcie_portdrv_remove,
 
-#ifdef CONFIG_PM
        .suspend        = pcie_portdrv_suspend,
        .resume         = pcie_portdrv_resume,
-#endif /* PM */
+
+       .err_handler    = &pcie_portdrv_err_handler,
 };
 
 static int __init pcie_portdrv_init(void)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [linux-2.6.18-xen] PCI-Express AER implemetation: pcie_portdrv error handler., Xen patchbot-linux-2.6.18-xen <=