Release 4.11 drivers/edac/edac_pci.c
/*
* EDAC PCI component
*
* Author: Dave Jiang <djiang@mvista.com>
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*
*/
#include <asm/page.h>
#include <linux/uaccess.h>
#include <linux/ctype.h>
#include <linux/highmem.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/smp.h>
#include <linux/spinlock.h>
#include <linux/sysctl.h>
#include <linux/timer.h>
#include "edac_pci.h"
#include "edac_module.h"
static DEFINE_MUTEX(edac_pci_ctls_mutex);
static LIST_HEAD(edac_pci_list);
static atomic_t pci_indexes = ATOMIC_INIT(0);
struct edac_pci_ctl_info *edac_pci_alloc_ctl_info(unsigned int sz_pvt,
const char *edac_pci_name)
{
struct edac_pci_ctl_info *pci;
void *p = NULL, *pvt;
unsigned int size;
edac_dbg(1, "\n");
pci = edac_align_ptr(&p, sizeof(*pci), 1);
pvt = edac_align_ptr(&p, 1, sz_pvt);
size = ((unsigned long)pvt) + sz_pvt;
/* Alloc the needed control struct memory */
pci = kzalloc(size, GFP_KERNEL);
if (pci == NULL)
return NULL;
/* Now much private space */
pvt = sz_pvt ? ((char *)pci) + ((unsigned long)pvt) : NULL;
pci->pvt_info = pvt;
pci->op_state = OP_ALLOC;
snprintf(pci->name, strlen(edac_pci_name) + 1, "%s", edac_pci_name);
return pci;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 124 | 79.49% | 1 | 20.00% |
Mauro Carvalho Chehab | 20 | 12.82% | 2 | 40.00% |
Doug Thompson | 9 | 5.77% | 1 | 20.00% |
Joe Perches | 3 | 1.92% | 1 | 20.00% |
Total | 156 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_alloc_ctl_info);
void edac_pci_free_ctl_info(struct edac_pci_ctl_info *pci)
{
edac_dbg(1, "\n");
edac_pci_remove_sysfs(pci);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 14 | 63.64% | 1 | 25.00% |
Doug Thompson | 4 | 18.18% | 1 | 25.00% |
Joe Perches | 3 | 13.64% | 1 | 25.00% |
Mauro Carvalho Chehab | 1 | 4.55% | 1 | 25.00% |
Total | 22 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_free_ctl_info);
/*
* find_edac_pci_by_dev()
* scans the edac_pci list for a specific 'struct device *'
*
* return NULL if not found, or return control struct pointer
*/
static struct edac_pci_ctl_info *find_edac_pci_by_dev(struct device *dev)
{
struct edac_pci_ctl_info *pci;
struct list_head *item;
edac_dbg(1, "\n");
list_for_each(item, &edac_pci_list) {
pci = list_entry(item, struct edac_pci_ctl_info, link);
if (pci->dev == dev)
return pci;
}
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 60 | 93.75% | 1 | 33.33% |
Joe Perches | 3 | 4.69% | 1 | 33.33% |
Mauro Carvalho Chehab | 1 | 1.56% | 1 | 33.33% |
Total | 64 | 100.00% | 3 | 100.00% |
/*
* add_edac_pci_to_global_list
* Before calling this function, caller must assign a unique value to
* edac_dev->pci_idx.
* Return:
* 0 on success
* 1 on failure
*/
static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
{
struct list_head *item, *insert_before;
struct edac_pci_ctl_info *rover;
edac_dbg(1, "\n");
insert_before = &edac_pci_list;
/* Determine if already on the list */
rover = find_edac_pci_by_dev(pci->dev);
if (unlikely(rover != NULL))
goto fail0;
/* Insert in ascending order by 'pci_idx', so find position */
list_for_each(item, &edac_pci_list) {
rover = list_entry(item, struct edac_pci_ctl_info, link);
if (rover->pci_idx >= pci->pci_idx) {
if (unlikely(rover->pci_idx == pci->pci_idx))
goto fail1;
insert_before = item;
break;
}
}
list_add_tail_rcu(&pci->link, insert_before);
return 0;
fail0:
edac_printk(KERN_WARNING, EDAC_PCI,
"%s (%s) %s %s already assigned %d\n",
dev_name(rover->dev), edac_dev_name(rover),
rover->mod_name, rover->ctl_name, rover->pci_idx);
return 1;
fail1:
edac_printk(KERN_WARNING, EDAC_PCI,
"but in low-level driver: attempt to assign\n"
"\tduplicate pci_idx %d in %s()\n", rover->pci_idx,
__func__);
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 167 | 90.76% | 1 | 16.67% |
Doug Thompson | 9 | 4.89% | 1 | 16.67% |
Kay Sievers | 3 | 1.63% | 1 | 16.67% |
Joe Perches | 3 | 1.63% | 1 | 16.67% |
Mauro Carvalho Chehab | 1 | 0.54% | 1 | 16.67% |
Stephen Rothwell | 1 | 0.54% | 1 | 16.67% |
Total | 184 | 100.00% | 6 | 100.00% |
/*
* del_edac_pci_from_global_list
*
* remove the PCI control struct from the global list
*/
static void del_edac_pci_from_global_list(struct edac_pci_ctl_info *pci)
{
list_del_rcu(&pci->link);
/* these are for safe removal of devices from global list while
* NMI handlers may be traversing list
*/
synchronize_rcu();
INIT_LIST_HEAD(&pci->link);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 25 | 80.65% | 1 | 50.00% |
Lai Jiangshan | 6 | 19.35% | 1 | 50.00% |
Total | 31 | 100.00% | 2 | 100.00% |
/*
* edac_pci_workq_function()
*
* periodic function that performs the operation
* scheduled by a workq request, for a given PCI control struct
*/
static void edac_pci_workq_function(struct work_struct *work_req)
{
struct delayed_work *d_work = to_delayed_work(work_req);
struct edac_pci_ctl_info *pci = to_edac_pci_ctl_work(d_work);
int msec;
unsigned long delay;
edac_dbg(3, "checking\n");
mutex_lock(&edac_pci_ctls_mutex);
if (pci->op_state != OP_RUNNING_POLL) {
mutex_unlock(&edac_pci_ctls_mutex);
return;
}
if (edac_pci_get_check_errors())
pci->edac_check(pci);
/* if we are on a one second period, then use round */
msec = edac_pci_get_poll_msec();
if (msec == 1000)
delay = round_jiffies_relative(msecs_to_jiffies(msec));
else
delay = msecs_to_jiffies(msec);
edac_queue_work(&pci->work, delay);
mutex_unlock(&edac_pci_ctls_mutex);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 56 | 44.44% | 2 | 22.22% |
Doug Thompson | 52 | 41.27% | 1 | 11.11% |
Borislav Petkov | 10 | 7.94% | 2 | 22.22% |
Joe Perches | 3 | 2.38% | 1 | 11.11% |
Jean Delvare | 3 | 2.38% | 1 | 11.11% |
Mauro Carvalho Chehab | 1 | 0.79% | 1 | 11.11% |
Anton Blanchard | 1 | 0.79% | 1 | 11.11% |
Total | 126 | 100.00% | 9 | 100.00% |
int edac_pci_alloc_index(void)
{
return atomic_inc_return(&pci_indexes) - 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Harry Ciao | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
{
edac_dbg(0, "\n");
pci->pci_idx = edac_idx;
pci->start_time = jiffies;
mutex_lock(&edac_pci_ctls_mutex);
if (add_edac_pci_to_global_list(pci))
goto fail0;
if (edac_pci_create_sysfs(pci)) {
edac_pci_printk(pci, KERN_WARNING,
"failed to create sysfs pci\n");
goto fail1;
}
if (pci->edac_check) {
pci->op_state = OP_RUNNING_POLL;
INIT_DELAYED_WORK(&pci->work, edac_pci_workq_function);
edac_queue_work(&pci->work, msecs_to_jiffies(edac_pci_get_poll_msec()));
} else {
pci->op_state = OP_RUNNING_INTERRUPT;
}
edac_pci_printk(pci, KERN_INFO,
"Giving out device to module %s controller %s: DEV %s (%s)\n",
pci->mod_name, pci->ctl_name, pci->dev_name,
edac_op_state_to_string(pci->op_state));
mutex_unlock(&edac_pci_ctls_mutex);
return 0;
/* error unwind stack */
fail1:
del_edac_pci_from_global_list(pci);
fail0:
mutex_unlock(&edac_pci_ctls_mutex);
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 123 | 71.51% | 1 | 14.29% |
Doug Thompson | 23 | 13.37% | 2 | 28.57% |
Borislav Petkov | 19 | 11.05% | 1 | 14.29% |
Joe Perches | 3 | 1.74% | 1 | 14.29% |
Robert Richter | 3 | 1.74% | 1 | 14.29% |
Mauro Carvalho Chehab | 1 | 0.58% | 1 | 14.29% |
Total | 172 | 100.00% | 7 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_add_device);
struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
{
struct edac_pci_ctl_info *pci;
edac_dbg(0, "\n");
mutex_lock(&edac_pci_ctls_mutex);
/* ensure the control struct is on the global list
* if not, then leave
*/
pci = find_edac_pci_by_dev(dev);
if (pci == NULL) {
mutex_unlock(&edac_pci_ctls_mutex);
return NULL;
}
pci->op_state = OP_OFFLINE;
del_edac_pci_from_global_list(pci);
mutex_unlock(&edac_pci_ctls_mutex);
if (pci->edac_check)
edac_stop_work(&pci->work);
edac_printk(KERN_INFO, EDAC_PCI,
"Removed device %d for %s %s: DEV %s\n",
pci->pci_idx, pci->mod_name, pci->ctl_name, edac_dev_name(pci));
return pci;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 81 | 70.43% | 1 | 14.29% |
Doug Thompson | 19 | 16.52% | 1 | 14.29% |
Borislav Petkov | 10 | 8.70% | 2 | 28.57% |
Joe Perches | 3 | 2.61% | 1 | 14.29% |
Stephen Rothwell | 1 | 0.87% | 1 | 14.29% |
Mauro Carvalho Chehab | 1 | 0.87% | 1 | 14.29% |
Total | 115 | 100.00% | 7 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_del_device);
/*
* edac_pci_generic_check
*
* a Generic parity check API
*/
static void edac_pci_generic_check(struct edac_pci_ctl_info *pci)
{
edac_dbg(4, "\n");
edac_pci_do_parity_check();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 13 | 61.90% | 1 | 20.00% |
Doug Thompson | 3 | 14.29% | 1 | 20.00% |
Joe Perches | 3 | 14.29% | 1 | 20.00% |
Mauro Carvalho Chehab | 1 | 4.76% | 1 | 20.00% |
Adrian Bunk | 1 | 4.76% | 1 | 20.00% |
Total | 21 | 100.00% | 5 | 100.00% |
/* free running instance index counter */
static int edac_pci_idx;
#define EDAC_PCI_GENCTL_NAME "EDAC PCI controller"
struct edac_pci_gen_data {
int edac_idx;
};
struct edac_pci_ctl_info *edac_pci_create_generic_ctl(struct device *dev,
const char *mod_name)
{
struct edac_pci_ctl_info *pci;
struct edac_pci_gen_data *pdata;
pci = edac_pci_alloc_ctl_info(sizeof(*pdata), EDAC_PCI_GENCTL_NAME);
if (!pci)
return NULL;
pdata = pci->pvt_info;
pci->dev = dev;
dev_set_drvdata(pci->dev, pci);
pci->dev_name = pci_name(to_pci_dev(dev));
pci->mod_name = mod_name;
pci->ctl_name = EDAC_PCI_GENCTL_NAME;
if (edac_op_state == EDAC_OPSTATE_POLL)
pci->edac_check = edac_pci_generic_check;
pdata->edac_idx = edac_pci_idx++;
if (edac_pci_add_device(pci, pdata->edac_idx) > 0) {
edac_dbg(3, "failed edac_pci_add_device()\n");
edac_pci_free_ctl_info(pci);
return NULL;
}
return pci;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 135 | 93.10% | 1 | 25.00% |
Borislav Petkov | 6 | 4.14% | 1 | 25.00% |
Joe Perches | 3 | 2.07% | 1 | 25.00% |
Mauro Carvalho Chehab | 1 | 0.69% | 1 | 25.00% |
Total | 145 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_create_generic_ctl);
void edac_pci_release_generic_ctl(struct edac_pci_ctl_info *pci)
{
edac_dbg(0, "pci mod=%s\n", pci->mod_name);
edac_pci_del_device(pci->dev);
edac_pci_free_ctl_info(pci);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 22 | 66.67% | 1 | 25.00% |
Doug Thompson | 7 | 21.21% | 1 | 25.00% |
Joe Perches | 3 | 9.09% | 1 | 25.00% |
Mauro Carvalho Chehab | 1 | 3.03% | 1 | 25.00% |
Total | 33 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(edac_pci_release_generic_ctl);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dave Jiang | 906 | 75.31% | 2 | 8.70% |
Doug Thompson | 131 | 10.89% | 2 | 8.70% |
Borislav Petkov | 45 | 3.74% | 5 | 21.74% |
Mauro Carvalho Chehab | 39 | 3.24% | 3 | 13.04% |
Joe Perches | 30 | 2.49% | 1 | 4.35% |
Harry Ciao | 30 | 2.49% | 1 | 4.35% |
Lai Jiangshan | 6 | 0.50% | 1 | 4.35% |
Jean Delvare | 3 | 0.25% | 1 | 4.35% |
Kay Sievers | 3 | 0.25% | 1 | 4.35% |
Robert Richter | 3 | 0.25% | 1 | 4.35% |
Stephen Rothwell | 2 | 0.17% | 1 | 4.35% |
Robert P. J. Day | 2 | 0.17% | 1 | 4.35% |
Adrian Bunk | 1 | 0.08% | 1 | 4.35% |
Anton Blanchard | 1 | 0.08% | 1 | 4.35% |
Linus Torvalds | 1 | 0.08% | 1 | 4.35% |
Total | 1203 | 100.00% | 23 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.