2006-07-31 14:21:33 +07:00
|
|
|
/*
|
|
|
|
* drivers/pci/pcie/aer/aerdrv.c
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* This file implements the AER root port service driver. The driver will
|
|
|
|
* register an irq handler. When root port triggers an AER interrupt, the irq
|
|
|
|
* handler will collect root port status and schedule a work.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Intel Corp.
|
|
|
|
* Tom Long Nguyen (tom.l.nguyen@intel.com)
|
|
|
|
* Zhang Yanmin (yanmin.zhang@intel.com)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/pci.h>
|
2011-01-07 06:55:09 +07:00
|
|
|
#include <linux/pci-acpi.h>
|
2009-10-07 20:09:06 +07:00
|
|
|
#include <linux/sched.h>
|
2006-07-31 14:21:33 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pcieport_if.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
#include "aerdrv.h"
|
2008-06-05 00:39:07 +07:00
|
|
|
#include "../../pci.h"
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Version Information
|
|
|
|
*/
|
|
|
|
#define DRIVER_VERSION "v1.0"
|
|
|
|
#define DRIVER_AUTHOR "tom.l.nguyen@intel.com"
|
|
|
|
#define DRIVER_DESC "Root Port Advanced Error Reporting Driver"
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
static int __devinit aer_probe(struct pcie_device *dev);
|
2006-07-31 14:21:33 +07:00
|
|
|
static void aer_remove(struct pcie_device *dev);
|
|
|
|
static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
|
|
|
|
enum pci_channel_state error);
|
|
|
|
static void aer_error_resume(struct pci_dev *dev);
|
|
|
|
static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
|
|
|
|
|
2012-09-07 23:33:14 +07:00
|
|
|
static const struct pci_error_handlers aer_error_handlers = {
|
2006-07-31 14:21:33 +07:00
|
|
|
.error_detected = aer_error_detected,
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
.resume = aer_error_resume,
|
2006-07-31 14:21:33 +07:00
|
|
|
};
|
|
|
|
|
2007-02-27 16:22:00 +07:00
|
|
|
static struct pcie_port_service_driver aerdriver = {
|
2006-07-31 14:21:33 +07:00
|
|
|
.name = "aer",
|
2009-11-25 19:06:15 +07:00
|
|
|
.port_type = PCI_EXP_TYPE_ROOT_PORT,
|
2009-01-13 20:46:46 +07:00
|
|
|
.service = PCIE_PORT_SERVICE_AER,
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
.probe = aer_probe,
|
|
|
|
.remove = aer_remove,
|
|
|
|
|
|
|
|
.err_handler = &aer_error_handlers,
|
|
|
|
|
|
|
|
.reset_link = aer_root_reset,
|
|
|
|
};
|
|
|
|
|
2007-10-06 03:17:58 +07:00
|
|
|
static int pcie_aer_disable;
|
|
|
|
|
|
|
|
void pci_no_aer(void)
|
|
|
|
{
|
|
|
|
pcie_aer_disable = 1; /* has priority over 'forceload' */
|
|
|
|
}
|
|
|
|
|
2010-08-21 06:50:52 +07:00
|
|
|
bool pci_aer_available(void)
|
|
|
|
{
|
|
|
|
return !pcie_aer_disable && pci_msi_enabled();
|
|
|
|
}
|
|
|
|
|
2010-04-15 11:10:53 +07:00
|
|
|
static int set_device_error_reporting(struct pci_dev *dev, void *data)
|
|
|
|
{
|
|
|
|
bool enable = *((bool *)data);
|
2012-07-24 16:20:03 +07:00
|
|
|
int type = pci_pcie_type(dev);
|
2010-04-15 11:10:53 +07:00
|
|
|
|
2012-07-24 16:20:03 +07:00
|
|
|
if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
|
|
|
|
(type == PCI_EXP_TYPE_UPSTREAM) ||
|
|
|
|
(type == PCI_EXP_TYPE_DOWNSTREAM)) {
|
2010-04-15 11:10:53 +07:00
|
|
|
if (enable)
|
|
|
|
pci_enable_pcie_error_reporting(dev);
|
|
|
|
else
|
|
|
|
pci_disable_pcie_error_reporting(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
pcie_set_ecrc_checking(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* set_downstream_devices_error_reporting - enable/disable the error reporting bits on the root port and its downstream ports.
|
|
|
|
* @dev: pointer to root port's pci_dev data structure
|
|
|
|
* @enable: true = enable error reporting, false = disable error reporting.
|
|
|
|
*/
|
|
|
|
static void set_downstream_devices_error_reporting(struct pci_dev *dev,
|
|
|
|
bool enable)
|
|
|
|
{
|
|
|
|
set_device_error_reporting(dev, &enable);
|
|
|
|
|
|
|
|
if (!dev->subordinate)
|
|
|
|
return;
|
|
|
|
pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_enable_rootport - enable Root Port's interrupts when receiving messages
|
|
|
|
* @rpc: pointer to a Root Port data structure
|
|
|
|
*
|
|
|
|
* Invoked when PCIe bus loads AER service driver.
|
|
|
|
*/
|
|
|
|
static void aer_enable_rootport(struct aer_rpc *rpc)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = rpc->rpd->port;
|
2012-07-24 16:20:11 +07:00
|
|
|
int aer_pos;
|
2010-04-15 11:10:53 +07:00
|
|
|
u16 reg16;
|
|
|
|
u32 reg32;
|
|
|
|
|
|
|
|
/* Clear PCIe Capability's Device Status */
|
2012-07-24 16:20:11 +07:00
|
|
|
pcie_capability_read_word(pdev, PCI_EXP_DEVSTA, ®16);
|
|
|
|
pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, reg16);
|
2010-04-15 11:10:53 +07:00
|
|
|
|
|
|
|
/* Disable system error generation in response to error messages */
|
2012-07-24 16:20:11 +07:00
|
|
|
pcie_capability_clear_word(pdev, PCI_EXP_RTCTL,
|
|
|
|
SYSTEM_ERROR_INTR_ON_MESG_MASK);
|
2010-04-15 11:10:53 +07:00
|
|
|
|
|
|
|
aer_pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
|
|
|
|
/* Clear error status */
|
|
|
|
pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, ®32);
|
|
|
|
pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32);
|
|
|
|
pci_read_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, ®32);
|
|
|
|
pci_write_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, reg32);
|
|
|
|
pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, ®32);
|
|
|
|
pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable error reporting for the root port device and downstream port
|
|
|
|
* devices.
|
|
|
|
*/
|
|
|
|
set_downstream_devices_error_reporting(pdev, true);
|
|
|
|
|
|
|
|
/* Enable Root Port's interrupt in response to error messages */
|
|
|
|
pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, ®32);
|
|
|
|
reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
|
|
|
|
pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, reg32);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_disable_rootport - disable Root Port's interrupts when receiving messages
|
|
|
|
* @rpc: pointer to a Root Port data structure
|
|
|
|
*
|
|
|
|
* Invoked when PCIe bus unloads AER service driver.
|
|
|
|
*/
|
|
|
|
static void aer_disable_rootport(struct aer_rpc *rpc)
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = rpc->rpd->port;
|
|
|
|
u32 reg32;
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable error reporting for the root port device and downstream port
|
|
|
|
* devices.
|
|
|
|
*/
|
|
|
|
set_downstream_devices_error_reporting(pdev, false);
|
|
|
|
|
|
|
|
pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ERR);
|
|
|
|
/* Disable Root's interrupt in response to error messages */
|
|
|
|
pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, ®32);
|
|
|
|
reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
|
|
|
|
pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, reg32);
|
|
|
|
|
|
|
|
/* Clear Root's error status reg */
|
|
|
|
pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, ®32);
|
|
|
|
pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, reg32);
|
|
|
|
}
|
|
|
|
|
2006-07-31 14:21:33 +07:00
|
|
|
/**
|
|
|
|
* aer_irq - Root Port's ISR
|
|
|
|
* @irq: IRQ assigned to Root Port
|
|
|
|
* @context: pointer to Root Port data structure
|
|
|
|
*
|
|
|
|
* Invoked when Root Port detects AER messages.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2009-04-24 09:45:23 +07:00
|
|
|
irqreturn_t aer_irq(int irq, void *context)
|
2006-07-31 14:21:33 +07:00
|
|
|
{
|
|
|
|
unsigned int status, id;
|
|
|
|
struct pcie_device *pdev = (struct pcie_device *)context;
|
|
|
|
struct aer_rpc *rpc = get_service_data(pdev);
|
|
|
|
int next_prod_idx;
|
|
|
|
unsigned long flags;
|
|
|
|
int pos;
|
|
|
|
|
2008-10-19 07:33:19 +07:00
|
|
|
pos = pci_find_ext_capability(pdev->port, PCI_EXT_CAP_ID_ERR);
|
2006-07-31 14:21:33 +07:00
|
|
|
/*
|
|
|
|
* Must lock access to Root Error Status Reg, Root Error ID Reg,
|
|
|
|
* and Root error producer/consumer index
|
|
|
|
*/
|
|
|
|
spin_lock_irqsave(&rpc->e_lock, flags);
|
|
|
|
|
|
|
|
/* Read error status */
|
|
|
|
pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
|
2010-04-15 11:18:26 +07:00
|
|
|
if (!(status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) {
|
2006-07-31 14:21:33 +07:00
|
|
|
spin_unlock_irqrestore(&rpc->e_lock, flags);
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read error source and clear error status */
|
2010-04-15 11:17:33 +07:00
|
|
|
pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_ERR_SRC, &id);
|
2006-07-31 14:21:33 +07:00
|
|
|
pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
|
|
|
|
|
|
|
|
/* Store error source for later DPC handler */
|
|
|
|
next_prod_idx = rpc->prod_idx + 1;
|
|
|
|
if (next_prod_idx == AER_ERROR_SOURCES_MAX)
|
|
|
|
next_prod_idx = 0;
|
|
|
|
if (next_prod_idx == rpc->cons_idx) {
|
|
|
|
/*
|
|
|
|
* Error Storm Condition - possibly the same error occurred.
|
|
|
|
* Drop the error.
|
|
|
|
*/
|
|
|
|
spin_unlock_irqrestore(&rpc->e_lock, flags);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
rpc->e_sources[rpc->prod_idx].status = status;
|
|
|
|
rpc->e_sources[rpc->prod_idx].id = id;
|
|
|
|
rpc->prod_idx = next_prod_idx;
|
|
|
|
spin_unlock_irqrestore(&rpc->e_lock, flags);
|
|
|
|
|
|
|
|
/* Invoke DPC handler */
|
|
|
|
schedule_work(&rpc->dpc_handler);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
2009-04-24 09:45:23 +07:00
|
|
|
EXPORT_SYMBOL_GPL(aer_irq);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_alloc_rpc - allocate Root Port data structure
|
|
|
|
* @dev: pointer to the pcie_dev data structure
|
|
|
|
*
|
|
|
|
* Invoked when Root Port's AER service is loaded.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
|
2006-07-31 14:21:33 +07:00
|
|
|
{
|
|
|
|
struct aer_rpc *rpc;
|
|
|
|
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL);
|
|
|
|
if (!rpc)
|
2006-07-31 14:21:33 +07:00
|
|
|
return NULL;
|
|
|
|
|
2010-04-15 11:22:11 +07:00
|
|
|
/* Initialize Root lock access, e_lock, to Root Error Status Reg */
|
2007-07-10 01:55:54 +07:00
|
|
|
spin_lock_init(&rpc->e_lock);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
rpc->rpd = dev;
|
2006-11-22 21:55:48 +07:00
|
|
|
INIT_WORK(&rpc->dpc_handler, aer_isr);
|
2006-07-31 14:21:33 +07:00
|
|
|
mutex_init(&rpc->rpc_mutex);
|
|
|
|
init_waitqueue_head(&rpc->wait_release);
|
|
|
|
|
2009-12-03 18:49:24 +07:00
|
|
|
/* Use PCIe bus function to store rpc into PCIe device */
|
2006-07-31 14:21:33 +07:00
|
|
|
set_service_data(dev, rpc);
|
|
|
|
|
|
|
|
return rpc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_remove - clean up resources
|
|
|
|
* @dev: pointer to the pcie_dev data structure
|
|
|
|
*
|
|
|
|
* Invoked when PCI Express bus unloads or AER probe fails.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static void aer_remove(struct pcie_device *dev)
|
|
|
|
{
|
|
|
|
struct aer_rpc *rpc = get_service_data(dev);
|
|
|
|
|
|
|
|
if (rpc) {
|
|
|
|
/* If register interrupt service, it must be free. */
|
|
|
|
if (rpc->isr)
|
|
|
|
free_irq(dev->irq, dev);
|
|
|
|
|
|
|
|
wait_event(rpc->wait_release, rpc->prod_idx == rpc->cons_idx);
|
|
|
|
|
2010-04-15 11:10:03 +07:00
|
|
|
aer_disable_rootport(rpc);
|
|
|
|
kfree(rpc);
|
2006-07-31 14:21:33 +07:00
|
|
|
set_service_data(dev, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_probe - initialize resources
|
|
|
|
* @dev: pointer to the pcie_dev data structure
|
|
|
|
* @id: pointer to the service id data structure
|
|
|
|
*
|
|
|
|
* Invoked when PCI Express bus loads AER service driver.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
static int __devinit aer_probe(struct pcie_device *dev)
|
2006-07-31 14:21:33 +07:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
struct aer_rpc *rpc;
|
|
|
|
struct device *device = &dev->device;
|
|
|
|
|
|
|
|
/* Init */
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
status = aer_init(dev);
|
|
|
|
if (status)
|
2006-07-31 14:21:33 +07:00
|
|
|
return status;
|
|
|
|
|
|
|
|
/* Alloc rpc data structure */
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
rpc = aer_alloc_rpc(dev);
|
|
|
|
if (!rpc) {
|
2008-06-13 23:52:12 +07:00
|
|
|
dev_printk(KERN_DEBUG, device, "alloc rpc failed\n");
|
2006-07-31 14:21:33 +07:00
|
|
|
aer_remove(dev);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Request IRQ ISR */
|
PCI: pcie, aer: checkpatch style cleanup in pcie/aer/*
Before:
drivers/pci/pcie/aer/aer_inject.c
total: 4 errors, 4 warnings, 473 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 5 errors, 2 warnings, 333 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 1 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 4 errors, 3 warnings, 872 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 12 errors, 11 warnings, 248 lines checked
After:
drivers/pci/pcie/aer/aer_inject.c
total: 0 errors, 0 warnings, 466 lines checked
drivers/pci/pcie/aer/aerdrv.c
total: 0 errors, 0 warnings, 335 lines checked
drivers/pci/pcie/aer/aerdrv.h
total: 0 errors, 0 warnings, 139 lines checked
drivers/pci/pcie/aer/aerdrv_core.c
total: 0 errors, 0 warnings, 869 lines checked
drivers/pci/pcie/aer/aerdrv_errprint.c
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Reviewed-by: Andrew Patterson <andrew.patterson@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2009-09-07 15:07:29 +07:00
|
|
|
status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", dev);
|
|
|
|
if (status) {
|
2008-06-13 23:52:12 +07:00
|
|
|
dev_printk(KERN_DEBUG, device, "request IRQ failed\n");
|
2006-07-31 14:21:33 +07:00
|
|
|
aer_remove(dev);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
rpc->isr = 1;
|
|
|
|
|
|
|
|
aer_enable_rootport(rpc);
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_root_reset - reset link on Root Port
|
|
|
|
* @dev: pointer to Root Port's pci_dev data structure
|
|
|
|
*
|
|
|
|
* Invoked by Port Bus driver when performing link reset at Root Port.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
|
|
|
|
{
|
2010-04-15 11:09:13 +07:00
|
|
|
u32 reg32;
|
2006-07-31 14:21:33 +07:00
|
|
|
int pos;
|
|
|
|
|
2008-10-19 07:33:19 +07:00
|
|
|
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
/* Disable Root's interrupt in response to error messages */
|
2010-04-15 11:09:13 +07:00
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, ®32);
|
|
|
|
reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
|
|
|
|
pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
2010-04-15 11:21:27 +07:00
|
|
|
aer_do_secondary_bus_reset(dev);
|
2008-06-13 23:52:12 +07:00
|
|
|
dev_printk(KERN_DEBUG, &dev->dev, "Root Port link has been reset\n");
|
2006-07-31 14:21:33 +07:00
|
|
|
|
2010-04-15 11:09:13 +07:00
|
|
|
/* Clear Root Error Status */
|
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, ®32);
|
|
|
|
pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, reg32);
|
|
|
|
|
2006-07-31 14:21:33 +07:00
|
|
|
/* Enable Root Port's interrupt in response to error messages */
|
2010-04-15 11:09:13 +07:00
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, ®32);
|
|
|
|
reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
|
|
|
|
pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
return PCI_ERS_RESULT_RECOVERED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_error_detected - update severity status
|
|
|
|
* @dev: pointer to Root Port's pci_dev data structure
|
|
|
|
* @error: error severity being notified by port bus
|
|
|
|
*
|
|
|
|
* Invoked by Port Bus driver during error recovery.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
|
|
|
|
enum pci_channel_state error)
|
|
|
|
{
|
|
|
|
/* Root Port has no impact. Always recovers. */
|
|
|
|
return PCI_ERS_RESULT_CAN_RECOVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_error_resume - clean up corresponding error status bits
|
|
|
|
* @dev: pointer to Root Port's pci_dev data structure
|
|
|
|
*
|
|
|
|
* Invoked by Port Bus driver during nonfatal recovery.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static void aer_error_resume(struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
u32 status, mask;
|
|
|
|
u16 reg16;
|
|
|
|
|
|
|
|
/* Clean up Root device status */
|
2012-07-24 16:20:11 +07:00
|
|
|
pcie_capability_read_word(dev, PCI_EXP_DEVSTA, ®16);
|
|
|
|
pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16);
|
2006-07-31 14:21:33 +07:00
|
|
|
|
|
|
|
/* Clean AER Root Error Status */
|
2008-10-19 07:33:19 +07:00
|
|
|
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
|
2006-07-31 14:21:33 +07:00
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
|
|
|
|
pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask);
|
|
|
|
if (dev->error_state == pci_channel_io_normal)
|
|
|
|
status &= ~mask; /* Clear corresponding nonfatal bits */
|
|
|
|
else
|
|
|
|
status &= mask; /* Clear corresponding fatal bits */
|
|
|
|
pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_service_init - register AER root service driver
|
|
|
|
*
|
|
|
|
* Invoked when AER root service driver is loaded.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static int __init aer_service_init(void)
|
|
|
|
{
|
2010-09-20 23:50:00 +07:00
|
|
|
if (!pci_aer_available() || aer_acpi_firmware_first())
|
2009-09-17 03:40:22 +07:00
|
|
|
return -ENXIO;
|
2007-02-27 16:22:00 +07:00
|
|
|
return pcie_port_service_register(&aerdriver);
|
2006-07-31 14:21:33 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* aer_service_exit - unregister AER root service driver
|
|
|
|
*
|
|
|
|
* Invoked when AER root service driver is unloaded.
|
2010-04-15 11:22:11 +07:00
|
|
|
*/
|
2006-07-31 14:21:33 +07:00
|
|
|
static void __exit aer_service_exit(void)
|
|
|
|
{
|
2007-02-27 16:22:00 +07:00
|
|
|
pcie_port_service_unregister(&aerdriver);
|
2006-07-31 14:21:33 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(aer_service_init);
|
|
|
|
module_exit(aer_service_exit);
|