Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7ecd891 authored by Dave Peterson's avatar Dave Peterson Committed by Linus Torvalds
Browse files

[PATCH] EDAC: formatting cleanup



Cosmetic indentation/formatting cleanup for EDAC code.  Make sure we
are using tabs rather than spaces to indent, etc.

Signed-off-by: default avatarDavid S. Peterson <dsp@llnl.gov>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 54933ddd
Loading
Loading
Loading
Loading
+36 −55
Original line number Diff line number Diff line
@@ -12,33 +12,26 @@
 *
 */


#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>

#include <linux/pci.h>
#include <linux/pci_ids.h>

#include <linux/slab.h>

#include "edac_mc.h"


#define amd76x_printk(level, fmt, arg...) \
	edac_printk(level, "amd76x", fmt, ##arg)


#define amd76x_mc_printk(mci, level, fmt, arg...) \
	edac_mc_chipset_printk(mci, level, "amd76x", fmt, ##arg)


#define AMD76X_NR_CSROWS 8
#define AMD76X_NR_CHANS  1
#define AMD76X_NR_DIMMS  4


/* AMD 76x register addresses - device 0 function 0 - PCI bridge */

#define AMD76X_ECC_MODE_STATUS	0x48	/* Mode and status of ECC (32b)
					 *
					 * 31:16 reserved
@@ -50,6 +43,7 @@
					 *  7:4  UE cs row
					 *  3:0  CE cs row
					 */

#define AMD76X_DRAM_MODE_STATUS	0x58	/* DRAM Mode and status (32b)
					 *
					 * 31:26 clock disable 5 - 0
@@ -64,6 +58,7 @@
					 * 15:8  reserved
					 *  7:0  x4 mode enable 7 - 0
					 */

#define AMD76X_MEM_BASE_ADDR	0xC0	/* Memory base address (8 x 32b)
					 *
					 * 31:23 chip-select base
@@ -74,29 +69,28 @@
					 *  0    chip-select enable
					 */


struct amd76x_error_info {
	u32 ecc_mode_status;
};


enum amd76x_chips {
	AMD761 = 0,
	AMD762
};


struct amd76x_dev_info {
	const char *ctl_name;
};


static const struct amd76x_dev_info amd76x_devs[] = {
	[AMD761] = {.ctl_name = "AMD761"},
	[AMD762] = {.ctl_name = "AMD762"},
	[AMD761] = {
		.ctl_name = "AMD761"
	},
	[AMD762] = {
		.ctl_name = "AMD762"
	},
};


/**
 *	amd76x_get_error_info	-	fetch error information
 *	@mci: Memory controller
@@ -105,7 +99,6 @@ static const struct amd76x_dev_info amd76x_devs[] = {
 *	Fetch and store the AMD76x ECC status. Clear pending status
 *	on the chip so that further errors will be reported
 */

static void amd76x_get_error_info(struct mem_ctl_info *mci,
		struct amd76x_error_info *info)
{
@@ -121,7 +114,6 @@ static void amd76x_get_error_info (struct mem_ctl_info *mci,
				(u32) BIT(9), (u32) BIT(9));
}


/**
 *	amd76x_process_error_info	-	Error check
 *	@mci: Memory controller
@@ -132,7 +124,6 @@ static void amd76x_get_error_info (struct mem_ctl_info *mci,
 *	A return of 1 indicates an error. Also if handle_errors is true
 *	then attempt to handle and clean up after the error
 */

static int amd76x_process_error_info(struct mem_ctl_info *mci,
		struct amd76x_error_info *info, int handle_errors)
{
@@ -149,9 +140,8 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,

		if (handle_errors) {
			row = (info->ecc_mode_status >> 4) & 0xf;
			edac_mc_handle_ue(mci,
			    mci->csrows[row].first_page, 0, row,
			    mci->ctl_name);
			edac_mc_handle_ue(mci, mci->csrows[row].first_page, 0,
				row, mci->ctl_name);
		}
	}

@@ -163,11 +153,11 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,

		if (handle_errors) {
			row = info->ecc_mode_status & 0xf;
			edac_mc_handle_ce(mci,
			    mci->csrows[row].first_page, 0, 0, row, 0,
			    mci->ctl_name);
			edac_mc_handle_ce(mci, mci->csrows[row].first_page, 0,
				0, row, 0, mci->ctl_name);
		}
	}

	return error_found;
}

@@ -178,7 +168,6 @@ static int amd76x_process_error_info (struct mem_ctl_info *mci,
 *	Called by the poll handlers this function reads the status
 *	from the controller and checks for errors.
 */

static void amd76x_check(struct mem_ctl_info *mci)
{
	struct amd76x_error_info info;
@@ -187,7 +176,6 @@ static void amd76x_check(struct mem_ctl_info *mci)
	amd76x_process_error_info(mci, &info, 1);
}


/**
 *	amd76x_probe1	-	Perform set up for detected device
 *	@pdev; PCI device detected
@@ -197,7 +185,6 @@ static void amd76x_check(struct mem_ctl_info *mci)
 *	controller status reporting. We configure and set up the
 *	memory controller reporting and claim the device.
 */

static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
{
	int rc = -ENODEV;
@@ -214,10 +201,8 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
	struct amd76x_error_info discard;

	debugf0("%s()\n", __func__);

	pci_read_config_dword(pdev, AMD76X_ECC_MODE_STATUS, &ems);
	ems_mode = (ems >> 10) & 0x3;

	mci = edac_mc_alloc(0, AMD76X_NR_CSROWS, AMD76X_NR_CHANS);

	if (mci == NULL) {
@@ -226,14 +211,11 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)
	}

	debugf0("%s(): mci = %p\n", __func__, mci);

	mci->pdev = pdev;
	mci->mtype_cap = MEM_FLAG_RDDR;

	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_EC | EDAC_FLAG_SECDED;
	mci->edac_cap = ems_mode ?
			(EDAC_FLAG_EC | EDAC_FLAG_SECDED) : EDAC_FLAG_NONE;

	mci->mod_name = EDAC_MOD_STR;
	mci->mod_ver = "$Revision: 1.4.2.5 $";
	mci->ctl_name = amd76x_devs[dev_idx].ctl_name;
@@ -249,18 +231,15 @@ static int amd76x_probe1(struct pci_dev *pdev, int dev_idx)

		/* find the DRAM Chip Select Base address and mask */
		pci_read_config_dword(mci->pdev,
				      AMD76X_MEM_BASE_ADDR + (index * 4),
				      &mba);
				AMD76X_MEM_BASE_ADDR + (index * 4), &mba);

		if (!(mba & BIT(0)))
			continue;

		mba_base = mba & 0xff800000UL;
		mba_mask = ((mba & 0xff80) << 16) | 0x7fffffUL;

		pci_read_config_dword(mci->pdev, AMD76X_DRAM_MODE_STATUS,
				&dms);

		csrow->first_page = mba_base >> PAGE_SHIFT;
		csrow->nr_pages = (mba_mask + 1) >> PAGE_SHIFT;
		csrow->last_page = csrow->first_page + csrow->nr_pages - 1;
@@ -298,7 +277,6 @@ static int __devinit amd76x_init_one(struct pci_dev *pdev,
	return amd76x_probe1(pdev, ent->driver_data);
}


/**
 *	amd76x_remove_one	-	driver shutdown
 *	@pdev: PCI device being handed back
@@ -307,7 +285,6 @@ static int __devinit amd76x_init_one(struct pci_dev *pdev,
 *	structure for the device then delete the mci and free the
 *	resources.
 */

static void __devexit amd76x_remove_one(struct pci_dev *pdev)
{
	struct mem_ctl_info *mci;
@@ -320,18 +297,22 @@ static void __devexit amd76x_remove_one(struct pci_dev *pdev)
	edac_mc_free(mci);
}


static const struct pci_device_id amd76x_pci_tbl[] __devinitdata = {
	{PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 AMD762},
	{PCI_VEND_DEV(AMD, FE_GATE_700E), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 AMD761},
	{0,}			/* 0 terminated list. */
	{
		PCI_VEND_DEV(AMD, FE_GATE_700C), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		AMD762
	},
	{
		PCI_VEND_DEV(AMD, FE_GATE_700E), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		AMD761
	},
	{
		0,
	}	/* 0 terminated list. */
};

MODULE_DEVICE_TABLE(pci, amd76x_pci_tbl);


static struct pci_driver amd76x_driver = {
	.name = EDAC_MOD_STR,
	.probe = amd76x_init_one,
+134 −100
Original line number Diff line number Diff line
@@ -17,27 +17,20 @@
 *
 */


#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>

#include <linux/pci.h>
#include <linux/pci_ids.h>

#include <linux/slab.h>

#include "edac_mc.h"


#define e752x_printk(level, fmt, arg...) \
	edac_printk(level, "e752x", fmt, ##arg)


#define e752x_mc_printk(mci, level, fmt, arg...) \
	edac_mc_chipset_printk(mci, level, "e752x", fmt, ##arg)


#ifndef PCI_DEVICE_ID_INTEL_7520_0
#define PCI_DEVICE_ID_INTEL_7520_0      0x3590
#endif				/* PCI_DEVICE_ID_INTEL_7520_0      */
@@ -64,7 +57,6 @@

#define E752X_NR_CSROWS		8	/* number of csrows */


/* E752X register addresses - device 0 function 0 */
#define E752X_DRB		0x60	/* DRAM row boundary register (8b) */
#define E752X_DRA		0x70	/* DRAM row attribute register (8b) */
@@ -164,7 +156,6 @@ enum e752x_chips {
	E7320 = 2
};


struct e752x_pvt {
	struct pci_dev *bridge_ck;
	struct pci_dev *dev_d0f0;
@@ -178,7 +169,6 @@ struct e752x_pvt {
	const struct e752x_dev_info *dev_info;
};


struct e752x_dev_info {
	u16 err_dev;
	u16 ctl_dev;
@@ -209,18 +199,20 @@ static const struct e752x_dev_info e752x_devs[] = {
	[E7520] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7520_1_ERR,
		.ctl_dev = PCI_DEVICE_ID_INTEL_7520_0,
		   .ctl_name = "E7520"},
		.ctl_name = "E7520"
	},
	[E7525] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7525_1_ERR,
		.ctl_dev = PCI_DEVICE_ID_INTEL_7525_0,
		   .ctl_name = "E7525"},
		.ctl_name = "E7525"
	},
	[E7320] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7320_1_ERR,
		.ctl_dev = PCI_DEVICE_ID_INTEL_7320_0,
		   .ctl_name = "E7320"},
		.ctl_name = "E7320"
	},
};


static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
		unsigned long page)
{
@@ -231,11 +223,15 @@ static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,

	if (page < pvt->tolm)
		return page;

	if ((page >= 0x100000) && (page < pvt->remapbase))
		return page;

	remap = (page - pvt->tolm) + pvt->remapbase;

	if (remap < pvt->remaplimit)
		return remap;

	e752x_printk(KERN_ERR, "Invalid page %lx - out of range\n", page);
	return pvt->tolm - 1;
}
@@ -259,17 +255,18 @@ static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
		/* chip select are bits 14 & 13 */
		row = ((page >> 1) & 3);
		e752x_printk(KERN_WARNING,
			     "Test row %d Table %d %d %d %d %d %d %d %d\n",
			     row, pvt->map[0], pvt->map[1], pvt->map[2],
			     pvt->map[3], pvt->map[4], pvt->map[5],
			     pvt->map[6], pvt->map[7]);
			"Test row %d Table %d %d %d %d %d %d %d %d\n", row,
			pvt->map[0], pvt->map[1], pvt->map[2], pvt->map[3],
			pvt->map[4], pvt->map[5], pvt->map[6], pvt->map[7]);

		/* test for channel remapping */
		for (i = 0; i < 8; i++) {
			if (pvt->map[i] == row)
				break;
		}

		e752x_printk(KERN_WARNING, "Test computed row %d\n", i);

		if (i < 8)
			row = i;
		else
@@ -277,16 +274,17 @@ static void do_process_ce(struct mem_ctl_info *mci, u16 error_one,
				"row %d not found in remap table\n", row);
	} else
		row = edac_mc_find_csrow_by_page(mci, page);

	/* 0 = channel A, 1 = channel B */
	channel = !(error_one & 1);

	if (!pvt->map_type)
		row = 7 - row;

	edac_mc_handle_ce(mci, page, 0, sec1_syndrome, row, channel,
		"e752x CE");
}


static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
		u32 sec1_add, u16 sec1_syndrome, int *error_found,
		int handle_error)
@@ -297,8 +295,8 @@ static inline void process_ce(struct mem_ctl_info *mci, u16 error_one,
		do_process_ce(mci, error_one, sec1_add, sec1_syndrome);
}

static void do_process_ue(struct mem_ctl_info *mci, u16 error_one, u32 ded_add,
		u32 scrb_add)
static void do_process_ue(struct mem_ctl_info *mci, u16 error_one,
		u32 ded_add, u32 scrb_add)
{
	u32 error_2b, block_page;
	int row;
@@ -308,23 +306,29 @@ static void do_process_ue(struct mem_ctl_info *mci, u16 error_one, u32 ded_add,

	if (error_one & 0x0202) {
		error_2b = ded_add;

		/* convert to 4k address */
		block_page = error_2b >> (PAGE_SHIFT - 4);

		row = pvt->mc_symmetric ?
			/* chip select are bits 14 & 13 */
			((block_page >> 1) & 3) :
			edac_mc_find_csrow_by_page(mci, block_page);

		edac_mc_handle_ue(mci, block_page, 0, row,
			"e752x UE from Read");
	}
	if (error_one & 0x0404) {
		error_2b = scrb_add;

		/* convert to 4k address */
		block_page = error_2b >> (PAGE_SHIFT - 4);

		row = pvt->mc_symmetric ?
			/* chip select are bits 14 & 13 */
			((block_page >> 1) & 3) :
			edac_mc_find_csrow_by_page(mci, block_page);

		edac_mc_handle_ue(mci, block_page, 0, row,
				"e752x UE from Scruber");
	}
@@ -508,27 +512,36 @@ static void e752x_check_hub_interface (struct e752x_error_info *info,
	u8 stat8;

	//pci_read_config_byte(dev,E752X_HI_FERR,&stat8);

	stat8 = info->hi_ferr;

	if(stat8 & 0x7f) { /* Error, so process */
		stat8 &= 0x7f;

		if(stat8 & 0x2b)
			hub_error(1, stat8 & 0x2b, error_found, handle_error);

		if(stat8 & 0x54)
			hub_error(0, stat8 & 0x54, error_found, handle_error);
	}

	//pci_read_config_byte(dev,E752X_HI_NERR,&stat8);

	stat8 = info->hi_nerr;

	if(stat8 & 0x7f) { /* Error, so process */
		stat8 &= 0x7f;

		if (stat8 & 0x2b)
			hub_error(1, stat8 & 0x2b, error_found, handle_error);

		if(stat8 & 0x54)
			hub_error(0, stat8 & 0x54, error_found, handle_error);
	}
}

static void e752x_check_sysbus (struct e752x_error_info *info, int *error_found,
		int handle_error)
static void e752x_check_sysbus(struct e752x_error_info *info,
		int *error_found, int handle_error)
{
	u32 stat32, error32;

@@ -540,27 +553,34 @@ static void e752x_check_sysbus (struct e752x_error_info *info, int *error_found,

	error32 = (stat32 >> 16) & 0x3ff;
	stat32 = stat32 & 0x3ff;

	if(stat32 & 0x083)
		sysbus_error(1, stat32 & 0x083, error_found, handle_error);

	if(stat32 & 0x37c)
		sysbus_error(0, stat32 & 0x37c, error_found, handle_error);

	if(error32 & 0x083)
		sysbus_error(1, error32 & 0x083, error_found, handle_error);

	if(error32 & 0x37c)
		sysbus_error(0, error32 & 0x37c, error_found, handle_error);
}

static void e752x_check_membuf (struct e752x_error_info *info, int *error_found,
		int handle_error)
static void e752x_check_membuf (struct e752x_error_info *info,
		int *error_found, int handle_error)
{
	u8 stat8;

	stat8 = info->buf_ferr;

	if (stat8 & 0x0f) { /* Error, so process */
		stat8 &= 0x0f;
		membuf_error(stat8, error_found, handle_error);
	}

	stat8 = info->buf_nerr;

	if (stat8 & 0x0f) { /* Error, so process */
		stat8 &= 0x0f;
		membuf_error(stat8, error_found, handle_error);
@@ -568,7 +588,8 @@ static void e752x_check_membuf (struct e752x_error_info *info, int *error_found,
}

static void e752x_check_dram (struct mem_ctl_info *mci,
		struct e752x_error_info *info, int *error_found, int handle_error)
		struct e752x_error_info *info, int *error_found,
		int handle_error)
{
	u16 error_one, error_next;

@@ -626,7 +647,6 @@ static void e752x_get_error_info (struct mem_ctl_info *mci,
	memset(info, 0, sizeof(*info));
	pvt = (struct e752x_pvt *) mci->pvt_info;
	dev = pvt->dev_d0f1;

	pci_read_config_dword(dev, E752X_FERR_GLOBAL, &info->ferr_global);

	if (info->ferr_global) {
@@ -737,6 +757,7 @@ static int e752x_process_error_info (struct mem_ctl_info *mci,
static void e752x_check(struct mem_ctl_info *mci)
{
	struct e752x_error_info info;

	debugf3("%s()\n", __func__);
	e752x_get_error_info(mci, &info);
	e752x_process_error_info(mci, &info, 1);
@@ -785,7 +806,6 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	}

	debugf3("%s(): init mci\n", __func__);

	mci->mtype_cap = MEM_FLAG_RDDR;
	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
	    EDAC_FLAG_S4ECD4ED;
@@ -800,17 +820,19 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
					pvt->dev_info->err_dev,
					pvt->bridge_ck);

	if (pvt->bridge_ck == NULL)
		pvt->bridge_ck = pci_scan_single_device(pdev->bus,
					PCI_DEVFN(0, 1));

	if (pvt->bridge_ck == NULL) {
		e752x_printk(KERN_ERR, "error reporting device not found:"
			"vendor %x device 0x%x (broken BIOS?)\n",
			PCI_VENDOR_ID_INTEL, e752x_devs[dev_idx].err_dev);
		goto fail;
	}
	pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);

	pvt->mc_symmetric = ((ddrcsr & 0x10) != 0);
	debugf3("%s(): more mci init\n", __func__);
	mci->ctl_name = pvt->dev_info->ctl_name;
	mci->edac_check = e752x_check;
@@ -828,6 +850,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	for (last_cumul_size = index = 0; index < mci->nr_csrows; index++) {
		u8 value;
		u32 cumul_size;

		/* mem_dev 0=x8, 1=x4 */
		int mem_dev = (dra >> (index * 4 + 2)) & 0x3;
		struct csrow_info *csrow = &mci->csrows[index];
@@ -838,6 +861,7 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
		cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
		debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
			cumul_size);

		if (cumul_size == last_cumul_size)
			continue; /* not populated */

@@ -870,10 +894,11 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
		u8 value;
		u8 last = 0;
		u8 row = 0;
		for (index = 0; index < 8; index += 2) {

		for (index = 0; index < 8; index += 2) {
			pci_read_config_byte(mci->pdev, E752X_DRB + index,
					&value);

			/* test if there is a dimm in this slot */
			if (value == last) {
				/* no dimm in the slot, so flag it as empty */
@@ -890,9 +915,11 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
						&value);
				pvt->map[index + 1] = (value == last) ?
					0xff :	/* the dimm is single sided,
						   so flag as empty */
						 * so flag as empty
						 */
					row;	/* this is a double sided dimm
						   to save the next row # */
						 * to save the next row #
						 */
				row++;
				last = value;
			}
@@ -904,8 +931,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	pvt->map_type = ((stat8 & 0x0f) > ((stat8 >> 4) & 0x0f));

	mci->edac_cap |= EDAC_FLAG_NONE;

	debugf3("%s(): tolm, remapbase, remaplimit\n", __func__);

	/* load the top of low memory, remap base, and remap limit vars */
	pci_read_config_word(mci->pdev, E752X_TOLM, &pci_data);
	pvt->tolm = ((u32) pci_data) << 4;
@@ -914,8 +941,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	pci_read_config_word(mci->pdev, E752X_REMAPLIMIT, &pci_data);
	pvt->remaplimit = ((u32) pci_data) << 14;
	e752x_printk(KERN_INFO,
		     "tolm = %x, remapbase = %x, remaplimit = %x\n",
		     pvt->tolm, pvt->remapbase, pvt->remaplimit);
		"tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
		pvt->remapbase, pvt->remaplimit);

	if (edac_mc_add_mc(mci)) {
		debugf3("%s(): failed edac_mc_add_mc()\n", __func__);
@@ -936,8 +963,8 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	pci_write_config_byte(dev, E752X_BUF_SMICMD, 0x00);
	pci_write_config_byte(dev, E752X_DRAM_ERRMASK, 0x00);
	pci_write_config_byte(dev, E752X_DRAM_SMICMD, 0x00);
	/* clear other MCH errors */
	e752x_get_error_info(mci, &discard);

	e752x_get_error_info(mci, &discard); /* clear other MCH errors */

	/* get this far and it's successful */
	debugf3("%s(): success\n", __func__);
@@ -947,12 +974,16 @@ static int e752x_probe1(struct pci_dev *pdev, int dev_idx)
	if (mci) {
		if (pvt->dev_d0f0)
			pci_dev_put(pvt->dev_d0f0);

		if (pvt->dev_d0f1)
			pci_dev_put(pvt->dev_d0f1);

		if (pvt->bridge_ck)
			pci_dev_put(pvt->bridge_ck);

		edac_mc_free(mci);
	}

	return rc;
}

@@ -965,10 +996,10 @@ static int __devinit e752x_init_one(struct pci_dev *pdev,
	/* wake up and enable device */
	if(pci_enable_device(pdev) < 0)
		return -EIO;

	return e752x_probe1(pdev, ent->driver_data);
}


static void __devexit e752x_remove_one(struct pci_dev *pdev)
{
	struct mem_ctl_info *mci;
@@ -986,20 +1017,26 @@ static void __devexit e752x_remove_one(struct pci_dev *pdev)
	edac_mc_free(mci);
}


static const struct pci_device_id e752x_pci_tbl[] __devinitdata = {
	{PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7520},
	{PCI_VEND_DEV(INTEL, 7525_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7525},
	{PCI_VEND_DEV(INTEL, 7320_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7320},
	{0,}			/* 0 terminated list. */
	{
		PCI_VEND_DEV(INTEL, 7520_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7520
	},
	{
		PCI_VEND_DEV(INTEL, 7525_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7525
	},
	{
		PCI_VEND_DEV(INTEL, 7320_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7320
	},
	{
		0,
	}	/* 0 terminated list. */
};

MODULE_DEVICE_TABLE(pci, e752x_pci_tbl);


static struct pci_driver e752x_driver = {
	.name = EDAC_MOD_STR,
	.probe = e752x_init_one,
@@ -1007,7 +1044,6 @@ static struct pci_driver e752x_driver = {
	.id_table = e752x_pci_tbl,
};


static int __init e752x_init(void)
{
	int pci_rc;
@@ -1017,14 +1053,12 @@ static int __init e752x_init(void)
	return (pci_rc < 0) ? pci_rc : 0;
}


static void __exit e752x_exit(void)
{
	debugf3("%s()\n", __func__);
	pci_unregister_driver(&e752x_driver);
}


module_init(e752x_init);
module_exit(e752x_exit);

+79 −86
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
 *
 */


#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -31,15 +30,12 @@
#include <linux/slab.h>
#include "edac_mc.h"


#define e7xxx_printk(level, fmt, arg...) \
	edac_printk(level, "e7xxx", fmt, ##arg)


#define e7xxx_mc_printk(mci, level, fmt, arg...) \
	edac_mc_chipset_printk(mci, level, "e7xxx", fmt, ##arg)


#ifndef PCI_DEVICE_ID_INTEL_7205_0
#define PCI_DEVICE_ID_INTEL_7205_0	0x255d
#endif				/* PCI_DEVICE_ID_INTEL_7205_0 */
@@ -72,11 +68,9 @@
#define PCI_DEVICE_ID_INTEL_7505_1_ERR	0x2551
#endif				/* PCI_DEVICE_ID_INTEL_7505_1_ERR */


#define E7XXX_NR_CSROWS		8	/* number of csrows */
#define E7XXX_NR_DIMMS		8	/* FIXME - is this correct? */


/* E7XXX register addresses - device 0 function 0 */
#define E7XXX_DRB		0x60	/* DRAM row boundary register (8b) */
#define E7XXX_DRA		0x70	/* DRAM row attribute register (8b) */
@@ -126,7 +120,6 @@ enum e7xxx_chips {
	E7205,
};


struct e7xxx_pvt {
	struct pci_dev *bridge_ck;
	u32 tolm;
@@ -135,13 +128,11 @@ struct e7xxx_pvt {
	const struct e7xxx_dev_info *dev_info;
};


struct e7xxx_dev_info {
	u16 err_dev;
	const char *ctl_name;
};


struct e7xxx_error_info {
	u8 dram_ferr;
	u8 dram_nerr;
@@ -153,19 +144,22 @@ struct e7xxx_error_info {
static const struct e7xxx_dev_info e7xxx_devs[] = {
	[E7500] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7500_1_ERR,
		   .ctl_name = "E7500"},
		.ctl_name = "E7500"
	},
	[E7501] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7501_1_ERR,
		   .ctl_name = "E7501"},
		.ctl_name = "E7501"
	},
	[E7505] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7505_1_ERR,
		   .ctl_name = "E7505"},
		.ctl_name = "E7505"
	},
	[E7205] = {
		.err_dev = PCI_DEVICE_ID_INTEL_7205_1_ERR,
		   .ctl_name = "E7205"},
		.ctl_name = "E7205"
	},
};


/* FIXME - is this valid for both SECDED and S4ECD4ED? */
static inline int e7xxx_find_channel(u16 syndrome)
{
@@ -173,16 +167,18 @@ static inline int e7xxx_find_channel(u16 syndrome)

	if ((syndrome & 0xff00) == 0)
		return 0;

	if ((syndrome & 0x00ff) == 0)
		return 1;

	if ((syndrome & 0xf000) == 0 || (syndrome & 0x0f00) == 0)
		return 0;

	return 1;
}


static unsigned long
ctl_page_to_phys(struct mem_ctl_info *mci, unsigned long page)
static unsigned long ctl_page_to_phys(struct mem_ctl_info *mci,
		unsigned long page)
{
	u32 remap;
	struct e7xxx_pvt *pvt = (struct e7xxx_pvt *) mci->pvt_info;
@@ -192,15 +188,18 @@ ctl_page_to_phys(struct mem_ctl_info *mci, unsigned long page)
	if ((page < pvt->tolm) ||
			((page >= 0x100000) && (page < pvt->remapbase)))
		return page;

	remap = (page - pvt->tolm) + pvt->remapbase;

	if (remap < pvt->remaplimit)
		return remap;

	e7xxx_printk(KERN_ERR, "Invalid page %lx - out of range\n", page);
	return pvt->tolm - 1;
}


static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
static void process_ce(struct mem_ctl_info *mci,
		struct e7xxx_error_info *info)
{
	u32 error_1b, page;
	u16 syndrome;
@@ -208,7 +207,6 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
	int channel;

	debugf3("%s()\n", __func__);

	/* read the error address */
	error_1b = info->dram_celog_add;
	/* FIXME - should use PAGE_SHIFT */
@@ -219,25 +217,22 @@ static void process_ce(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
	row = edac_mc_find_csrow_by_page(mci, page);
	/* convert syndrome to channel */
	channel = e7xxx_find_channel(syndrome);
	edac_mc_handle_ce(mci, page, 0, syndrome, row, channel,
			       "e7xxx CE");
	edac_mc_handle_ce(mci, page, 0, syndrome, row, channel, "e7xxx CE");
}


static void process_ce_no_info(struct mem_ctl_info *mci)
{
	debugf3("%s()\n", __func__);
	edac_mc_handle_ce_no_info(mci, "e7xxx CE log register overflow");
}


static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
static void process_ue(struct mem_ctl_info *mci,
		struct e7xxx_error_info *info)
{
	u32 error_2b, block_page;
	int row;

	debugf3("%s()\n", __func__);

	/* read the error address */
	error_2b = info->dram_uelog_add;
	/* FIXME - should use PAGE_SHIFT */
@@ -246,14 +241,12 @@ static void process_ue(struct mem_ctl_info *mci, struct e7xxx_error_info *info)
	edac_mc_handle_ue(mci, block_page, 0, row, "e7xxx UE");
}


static void process_ue_no_info(struct mem_ctl_info *mci)
{
	debugf3("%s()\n", __func__);
	edac_mc_handle_ue_no_info(mci, "e7xxx UE log register overflow");
}


static void e7xxx_get_error_info (struct mem_ctl_info *mci,
		struct e7xxx_error_info *info)
{
@@ -269,7 +262,8 @@ static void e7xxx_get_error_info (struct mem_ctl_info *mci,
		pci_read_config_dword(pvt->bridge_ck, E7XXX_DRAM_CELOG_ADD,
				&info->dram_celog_add);
		pci_read_config_word(pvt->bridge_ck,
		    E7XXX_DRAM_CELOG_SYNDROME, &info->dram_celog_syndrome);
				E7XXX_DRAM_CELOG_SYNDROME,
				&info->dram_celog_syndrome);
	}

	if ((info->dram_ferr & 2) || (info->dram_nerr & 2))
@@ -277,15 +271,12 @@ static void e7xxx_get_error_info (struct mem_ctl_info *mci,
				&info->dram_uelog_add);

	if (info->dram_ferr & 3)
		pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03,
		    0x03);
		pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_FERR, 0x03, 0x03);

	if (info->dram_nerr & 3)
		pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03,
		    0x03);
		pci_write_bits8(pvt->bridge_ck, E7XXX_DRAM_NERR, 0x03, 0x03);
}


static int e7xxx_process_error_info (struct mem_ctl_info *mci,
		struct e7xxx_error_info *info, int handle_errors)
{
@@ -333,7 +324,6 @@ static int e7xxx_process_error_info (struct mem_ctl_info *mci,
	return error_found;
}


static void e7xxx_check(struct mem_ctl_info *mci)
{
	struct e7xxx_error_info info;
@@ -343,7 +333,6 @@ static void e7xxx_check(struct mem_ctl_info *mci)
	e7xxx_process_error_info(mci, &info, 1);
}


static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
{
	int rc = -ENODEV;
@@ -363,13 +352,14 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)

	/* need to find out the number of channels */
	pci_read_config_dword(pdev, E7XXX_DRC, &drc);

	/* only e7501 can be single channel */
	if (dev_idx == E7501) {
		drc_chan = ((drc >> 22) & 0x1);
		drc_drbg = (drc >> 18) & 0x3;
	}
	drc_ddim = (drc >> 20) & 0x3;

	drc_ddim = (drc >> 20) & 0x3;
	mci = edac_mc_alloc(sizeof(*pvt), E7XXX_NR_CSROWS, drc_chan + 1);

	if (mci == NULL) {
@@ -378,10 +368,9 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
	}

	debugf3("%s(): init mci\n", __func__);

	mci->mtype_cap = MEM_FLAG_RDDR;
	mci->edac_ctl_cap =
	    EDAC_FLAG_NONE | EDAC_FLAG_SECDED | EDAC_FLAG_S4ECD4ED;
	mci->edac_ctl_cap = EDAC_FLAG_NONE | EDAC_FLAG_SECDED |
			EDAC_FLAG_S4ECD4ED;
	/* FIXME - what if different memory types are in different csrows? */
	mci->mod_name = EDAC_MOD_STR;
	mci->mod_ver = "$Revision: 1.5.2.9 $";
@@ -393,17 +382,16 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
	pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
					pvt->dev_info->err_dev,
					pvt->bridge_ck);

	if (!pvt->bridge_ck) {
		e7xxx_printk(KERN_ERR, "error reporting device not found:"
			"vendor %x device 0x%x (broken BIOS?)\n",
			     PCI_VENDOR_ID_INTEL,
			     e7xxx_devs[dev_idx].err_dev);
			PCI_VENDOR_ID_INTEL, e7xxx_devs[dev_idx].err_dev);
		goto fail;
	}

	debugf3("%s(): more mci init\n", __func__);
	mci->ctl_name = pvt->dev_info->ctl_name;

	mci->edac_check = e7xxx_check;
	mci->ctl_page_to_phys = ctl_page_to_phys;

@@ -428,6 +416,7 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
		cumul_size = value << (25 + drc_drbg - PAGE_SHIFT);
		debugf3("%s(): (%d) cumul_size 0x%x\n", __func__, index,
			cumul_size);

		if (cumul_size == last_cumul_size)
			continue;  /* not populated */

@@ -466,8 +455,8 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
	pci_read_config_word(mci->pdev, E7XXX_REMAPLIMIT, &pci_data);
	pvt->remaplimit = ((u32) pci_data) << 14;
	e7xxx_printk(KERN_INFO,
		     "tolm = %x, remapbase = %x, remaplimit = %x\n",
		     pvt->tolm, pvt->remapbase, pvt->remaplimit);
		"tolm = %x, remapbase = %x, remaplimit = %x\n", pvt->tolm,
		pvt->remapbase, pvt->remaplimit);

	/* clear any pending errors, or initial state bits */
	e7xxx_get_error_info(mci, &discard);
@@ -492,8 +481,8 @@ static int e7xxx_probe1(struct pci_dev *pdev, int dev_idx)
}

/* returns count (>= 0), or negative on error */
static int __devinit
e7xxx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
static int __devinit e7xxx_init_one(struct pci_dev *pdev,
		const struct pci_device_id *ent)
{
	debugf0("%s()\n", __func__);

@@ -502,7 +491,6 @@ e7xxx_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
		-EIO : e7xxx_probe1(pdev, ent->driver_data);
}


static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
{
	struct mem_ctl_info *mci;
@@ -518,22 +506,30 @@ static void __devexit e7xxx_remove_one(struct pci_dev *pdev)
	edac_mc_free(mci);
}


static const struct pci_device_id e7xxx_pci_tbl[] __devinitdata = {
	{PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7205},
	{PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7500},
	{PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7501},
	{PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
	 E7505},
	{0,}			/* 0 terminated list. */
	{
		PCI_VEND_DEV(INTEL, 7205_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7205
	},
	{
		PCI_VEND_DEV(INTEL, 7500_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7500
	},
	{
		PCI_VEND_DEV(INTEL, 7501_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7501
	},
	{
		PCI_VEND_DEV(INTEL, 7505_0), PCI_ANY_ID, PCI_ANY_ID, 0, 0,
		E7505
	},
	{
		0,
	}	/* 0 terminated list. */
};

MODULE_DEVICE_TABLE(pci, e7xxx_pci_tbl);


static struct pci_driver e7xxx_driver = {
	.name = EDAC_MOD_STR,
	.probe = e7xxx_init_one,
@@ -541,13 +537,11 @@ static struct pci_driver e7xxx_driver = {
	.id_table = e7xxx_pci_tbl,
};


static int __init e7xxx_init(void)
{
	return pci_register_driver(&e7xxx_driver);
}


static void __exit e7xxx_exit(void)
{
	pci_unregister_driver(&e7xxx_driver);
@@ -556,7 +550,6 @@ static void __exit e7xxx_exit(void)
module_init(e7xxx_init);
module_exit(e7xxx_exit);


MODULE_LICENSE("GPL");
MODULE_AUTHOR("Linux Networx (http://lnxi.com) Thayne Harbaugh et al\n"
	"Based on.work by Dan Hollis et al");
+149 −176

File changed.

Preview size limit exceeded, changes collapsed.

+43 −53
Original line number Diff line number Diff line
@@ -15,11 +15,9 @@
 *
 */


#ifndef _EDAC_MC_H_
#define _EDAC_MC_H_


#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/types.h>
@@ -33,7 +31,6 @@
#include <linux/completion.h>
#include <linux/kobject.h>


#define EDAC_MC_LABEL_LEN	31
#define MC_PROC_NAME_MAX_LEN 7

@@ -71,14 +68,16 @@ extern int edac_debug_level;
#define debugf2( ... ) edac_debug_printk(2, __VA_ARGS__ )
#define debugf3( ... ) edac_debug_printk(3, __VA_ARGS__ )
#define debugf4( ... ) edac_debug_printk(4, __VA_ARGS__ )

#else  /* !CONFIG_EDAC_DEBUG */

#define debugf0( ... )
#define debugf1( ... )
#define debugf2( ... )
#define debugf3( ... )
#define debugf4( ... )
#endif				/* !CONFIG_EDAC_DEBUG */

#endif  /* !CONFIG_EDAC_DEBUG */

#define edac_xstr(s) edac_str(s)
#define edac_str(s) #s
@@ -86,7 +85,8 @@ extern int edac_debug_level;

#define BIT(x) (1 << (x))

#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, PCI_DEVICE_ID_ ## vend ## _ ## dev
#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
	PCI_DEVICE_ID_ ## vend ## _ ## dev

/* memory devices */
enum dev_type {
@@ -136,7 +136,6 @@ enum mem_type {
#define MEM_FLAG_RDDR		BIT(MEM_RDDR)
#define MEM_FLAG_RMBS		BIT(MEM_RMBS)


/* chipset Error Detection and Correction capabilities and mode */
enum edac_type {
	EDAC_UNKNOWN = 0,	/* Unknown if ECC is available */
@@ -161,7 +160,6 @@ enum edac_type {
#define EDAC_FLAG_S8ECD8ED	BIT(EDAC_S8ECD8ED)
#define EDAC_FLAG_S16ECD16ED	BIT(EDAC_S16ECD16ED)


/* scrubbing capabilities */
enum scrub_type {
	SCRUB_UNKNOWN = 0,	/* Unknown if scrubber is available */
@@ -269,7 +267,6 @@ enum scrub_type {
 * PS - I enjoyed writing all that about as much as you enjoyed reading it.
 */


struct channel_info {
	int chan_idx;		/* channel index */
	u32 ce_count;		/* Correctable Errors for this CHANNEL */
@@ -277,12 +274,12 @@ struct channel_info {
	struct csrow_info *csrow;	/* the parent */
};


struct csrow_info {
	unsigned long first_page;	/* first page number in dimm */
	unsigned long last_page;	/* last page number in dimm */
	unsigned long page_mask;	/* used for interleaving -
					   0UL for non intlv */
					 * 0UL for non intlv
					 */
	u32 nr_pages;		/* number of pages in csrow */
	u32 grain;		/* granularity of reported error in bytes */
	int csrow_idx;		/* the chip-select row */
@@ -301,18 +298,18 @@ struct csrow_info {
	struct channel_info *channels;
};


struct mem_ctl_info {
	struct list_head link;  /* for global list of mem_ctl_info structs */
	unsigned long mtype_cap;	/* memory types supported by mc */
	unsigned long edac_ctl_cap;	/* Mem controller EDAC capabilities */
	unsigned long edac_cap;	/* configuration capabilities - this is
				   closely related to edac_ctl_cap.  The
				   difference is that the controller
				   may be capable of s4ecd4ed which would
				   be listed in edac_ctl_cap, but if
				   channels aren't capable of s4ecd4ed then the
				   edac_cap would not have that capability. */
				 * closely related to edac_ctl_cap.  The
				 * difference is that the controller may be
				 * capable of s4ecd4ed which would be listed
				 * in edac_ctl_cap, but if channels aren't
				 * capable of s4ecd4ed then the edac_cap would
				 * not have that capability.
				 */
	unsigned long scrub_cap;	/* chipset scrub capabilities */
	enum scrub_type scrub_mode;	/* current scrub mode */

@@ -356,53 +353,54 @@ struct mem_ctl_info {
	struct completion kobj_complete;
};



/* write all or some bits in a byte-register*/
static inline void pci_write_bits8(struct pci_dev *pdev, int offset,
				   u8 value, u8 mask)
static inline void pci_write_bits8(struct pci_dev *pdev, int offset, u8 value,
		u8 mask)
{
	if (mask != 0xff) {
		u8 buf;

		pci_read_config_byte(pdev, offset, &buf);
		value &= mask;
		buf &= ~mask;
		value |= buf;
	}

	pci_write_config_byte(pdev, offset, value);
}


/* write all or some bits in a word-register*/
static inline void pci_write_bits16(struct pci_dev *pdev, int offset,
		u16 value, u16 mask)
{
	if (mask != 0xffff) {
		u16 buf;

		pci_read_config_word(pdev, offset, &buf);
		value &= mask;
		buf &= ~mask;
		value |= buf;
	}

	pci_write_config_word(pdev, offset, value);
}


/* write all or some bits in a dword-register*/
static inline void pci_write_bits32(struct pci_dev *pdev, int offset,
		u32 value, u32 mask)
{
	if (mask != 0xffff) {
		u32 buf;

		pci_read_config_dword(pdev, offset, &buf);
		value &= mask;
		buf &= ~mask;
		value |= buf;
	}

	pci_write_config_dword(pdev, offset, value);
}


#ifdef CONFIG_EDAC_DEBUG
void edac_mc_dump_channel(struct channel_info *chan);
void edac_mc_dump_mci(struct mem_ctl_info *mci);
@@ -411,12 +409,10 @@ void edac_mc_dump_csrow(struct csrow_info *csrow);

extern int edac_mc_add_mc(struct mem_ctl_info *mci);
extern struct mem_ctl_info * edac_mc_del_mc(struct pci_dev *pdev);

extern int edac_mc_find_csrow_by_page(struct mem_ctl_info *mci,
					unsigned long page);

extern void edac_mc_scrub_block(unsigned long page,
				     unsigned long offset, u32 size);
extern void edac_mc_scrub_block(unsigned long page, unsigned long offset,
		u32 size);

/*
 * The no info errors are used when error overflows are reported.
@@ -429,19 +425,14 @@ extern void edac_mc_scrub_block(unsigned long page,
 * statement clutter and extra function arguments.
 */
extern void edac_mc_handle_ce(struct mem_ctl_info *mci,
				   unsigned long page_frame_number,
				   unsigned long offset_in_page,
				   unsigned long syndrome,
				   int row, int channel, const char *msg);

		unsigned long page_frame_number, unsigned long offset_in_page,
		unsigned long syndrome, int row, int channel,
		const char *msg);
extern void edac_mc_handle_ce_no_info(struct mem_ctl_info *mci,
		const char *msg);

extern void edac_mc_handle_ue(struct mem_ctl_info *mci,
				   unsigned long page_frame_number,
				   unsigned long offset_in_page,
		unsigned long page_frame_number, unsigned long offset_in_page,
		int row, const char *msg);

extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
		const char *msg);

@@ -449,11 +440,10 @@ extern void edac_mc_handle_ue_no_info(struct mem_ctl_info *mci,
 * This kmalloc's and initializes all the structures.
 * Can't be used if all structures don't have the same lifetime.
 */
extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt,
		unsigned nr_csrows, unsigned nr_chans);
extern struct mem_ctl_info *edac_mc_alloc(unsigned sz_pvt, unsigned nr_csrows,
		unsigned nr_chans);

/* Free an mc previously allocated by edac_mc_alloc() */
extern void edac_mc_free(struct mem_ctl_info *mci);


#endif				/* _EDAC_MC_H_ */
Loading