From patchwork Fri Nov 5 02:56:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lan Chunhe-B25806 X-Patchwork-Id: 70234 X-Patchwork-Delegate: galak@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id D3276100C45 for ; Fri, 5 Nov 2010 15:18:29 +1100 (EST) Received: by ozlabs.org (Postfix) id 7BEC31007DD; Fri, 5 Nov 2010 14:08:38 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org X-Greylist: delayed 906 seconds by postgrey-1.32 at bilbo; Fri, 05 Nov 2010 14:08:37 EST Received: from AM1EHSOBE006.bigfish.com (am1ehsobe006.messaging.microsoft.com [213.199.154.209]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Cybertrust SureServer Standard Validation CA" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 6DE621007D5 for ; Fri, 5 Nov 2010 14:08:37 +1100 (EST) Received: from mail75-am1-R.bigfish.com (10.3.201.246) by AM1EHSOBE006.bigfish.com (10.3.204.26) with Microsoft SMTP Server id 14.1.225.8; Fri, 5 Nov 2010 02:53:26 +0000 Received: from mail75-am1 (localhost.localdomain [127.0.0.1]) by mail75-am1-R.bigfish.com (Postfix) with ESMTP id F27FC1E8340 for ; Fri, 5 Nov 2010 02:53:25 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bh8275dhz2dh2a8h62h) X-Spam-TCS-SCL: 1:0 X-Forefront-Antispam-Report: KIP:(null); UIP:(null); IPVD:NLI; H:de01egw01.freescale.net; RD:de01egw01.freescale.net; EFVD:NLI Received: from mail75-am1 (localhost.localdomain [127.0.0.1]) by mail75-am1 (MessageSwitch) id 1288925604825694_1805; Fri, 5 Nov 2010 02:53:24 +0000 (UTC) Received: from AM1EHSMHS006.bigfish.com (unknown [10.3.201.246]) by mail75-am1.bigfish.com (Postfix) with ESMTP id C5FC911E804F for ; Fri, 5 Nov 2010 02:53:24 +0000 (UTC) Received: from de01egw01.freescale.net (192.88.165.102) by AM1EHSMHS006.bigfish.com (10.3.207.106) with Microsoft SMTP Server (TLS) id 14.1.225.8; Fri, 5 Nov 2010 02:53:20 +0000 Received: from az33smr02.freescale.net (az33smr02.freescale.net [10.64.34.200]) by de01egw01.freescale.net (8.14.3/8.14.3) with ESMTP id oA52sMCH009612 for ; Thu, 4 Nov 2010 19:54:22 -0700 (MST) Received: from zch01exm28.fsl.freescale.net (zch01exm28.ap.freescale.net [10.192.129.225]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id oA52rGpB016005 for ; Thu, 4 Nov 2010 21:53:17 -0500 (CDT) Received: from localhost.localdomain ([10.193.20.71]) by zch01exm28.fsl.freescale.net with Microsoft SMTPSVC(6.0.3790.4675); Fri, 5 Nov 2010 10:53:57 +0800 From: Lan Chunhe To: Subject: [PATCH 2/3] edac/85xx: PCI/PCIE error interrupt edac support Date: Fri, 5 Nov 2010 10:56:31 +0800 Message-ID: <1288925791-1240-1-git-send-email-b25806@freescale.com> X-Mailer: git-send-email 1.5.4.5 X-OriginalArrivalTime: 05 Nov 2010 02:53:57.0947 (UTC) FILETIME=[B12950B0:01CB7C94] MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Mailman-Approved-At: Fri, 05 Nov 2010 15:17:56 +1100 Cc: Lan Chunhe , akpm@linux-foundation.org, "Kai.Jiang" , dougthompson@xmission.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Add pcie error interrupt edac support for mpc85xx and p4080. mpc85xx uses the legacy interrupt report mechanism - the error interrupts are reported directly to mpic. While, p4080 attaches most of error interrupts to interrupt 0. And report error interrupt to mpic via interrupt 0. This patch can handle both of them. Due to the error management register offset and definition difference between pci and pcie, use ccsr_pci structure to merge pci and pcie edac code into one. Signed-off-by: Kai.Jiang Signed-off-by: Kumar Gala Signed-off-by: Lan Chunhe --- drivers/edac/mpc85xx_edac.c | 243 +++++++++++++++++++++++++++++++++---------- drivers/edac/mpc85xx_edac.h | 9 ++- 2 files changed, 194 insertions(+), 58 deletions(-) diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index b123bb3..c878527 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c @@ -1,5 +1,6 @@ /* * Freescale MPC85xx Memory Controller kenel module + * Copyright (c) 2010 Freescale Semiconductor, Inc. * * Author: Dave Jiang * @@ -21,6 +22,7 @@ #include #include +#include #include "edac_module.h" #include "edac_core.h" #include "mpc85xx_edac.h" @@ -37,13 +39,8 @@ static u32 orig_ddr_err_sbe; /* * PCI Err defines */ -#ifdef CONFIG_PCI -static u32 orig_pci_err_cap_dr; -static u32 orig_pci_err_en; -#endif - static u32 orig_l2_err_disable; -#ifdef CONFIG_FSL_SOC_BOOKE +#if defined(CONFIG_FSL_SOC_BOOKE) && !defined(CONFIG_PPC_E500MC) static u32 orig_hid1[2]; #endif @@ -151,37 +148,52 @@ static void mpc85xx_pci_check(struct edac_pci_ctl_info *pci) { struct mpc85xx_pci_pdata *pdata = pci->pvt_info; u32 err_detect; + struct ccsr_pci *reg = pdata->pci_reg; + + err_detect = in_be32(&pdata->pci_reg->pex_err_dr); + + if (pdata->pcie_flag) { + printk(KERN_ERR "PCIE error(s) detected\n"); + printk(KERN_ERR "PCIE ERR_DR register: 0x%08x\n", err_detect); + printk(KERN_ERR "PCIE ERR_CAP_STAT register: 0x%08x\n", + in_be32(®->pex_err_cap_stat)); + printk(KERN_ERR "PCIE ERR_CAP_R0 register: 0x%08x\n", + in_be32(®->pex_err_cap_r0)); + printk(KERN_ERR "PCIE ERR_CAP_R1 register: 0x%08x\n", + in_be32(®->pex_err_cap_r1)); + printk(KERN_ERR "PCIE ERR_CAP_R2 register: 0x%08x\n", + in_be32(®->pex_err_cap_r2)); + printk(KERN_ERR "PCIE ERR_CAP_R3 register: 0x%08x\n", + in_be32(®->pex_err_cap_r3)); + } else { + /* master aborts can happen during PCI config cycles */ + if (!(err_detect & ~(PCI_EDE_MULTI_ERR | PCI_EDE_MST_ABRT))) { + out_be32(®->pex_err_dr, err_detect); + return; + } - err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR); - - /* master aborts can happen during PCI config cycles */ - if (!(err_detect & ~(PCI_EDE_MULTI_ERR | PCI_EDE_MST_ABRT))) { - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect); - return; + printk(KERN_ERR "PCI error(s) detected\n"); + printk(KERN_ERR "PCI/X ERR_DR register: 0x%08x\n", err_detect); + printk(KERN_ERR "PCI/X ERR_ATTRIB register: 0x%08x\n", + in_be32(®->pex_err_attrib)); + printk(KERN_ERR "PCI/X ERR_ADDR register: 0x%08x\n", + in_be32(®->pex_err_disr)); + printk(KERN_ERR "PCI/X ERR_EXT_ADDR register: 0x%08x\n", + in_be32(®->pex_err_ext_addr)); + printk(KERN_ERR "PCI/X ERR_DL register: 0x%08x\n", + in_be32(®->pex_err_dl)); + printk(KERN_ERR "PCI/X ERR_DH register: 0x%08x\n", + in_be32(®->pex_err_dh)); + + if (err_detect & PCI_EDE_PERR_MASK) + edac_pci_handle_pe(pci, pci->ctl_name); + + if (err_detect & ~(PCI_EDE_MULTI_ERR | PCI_EDE_PERR_MASK)) + edac_pci_handle_npe(pci, pci->ctl_name); } - printk(KERN_ERR "PCI error(s) detected\n"); - printk(KERN_ERR "PCI/X ERR_DR register: %#08x\n", err_detect); - - printk(KERN_ERR "PCI/X ERR_ATTRIB register: %#08x\n", - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ATTRIB)); - printk(KERN_ERR "PCI/X ERR_ADDR register: %#08x\n", - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR)); - printk(KERN_ERR "PCI/X ERR_EXT_ADDR register: %#08x\n", - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EXT_ADDR)); - printk(KERN_ERR "PCI/X ERR_DL register: %#08x\n", - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DL)); - printk(KERN_ERR "PCI/X ERR_DH register: %#08x\n", - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DH)); - /* clear error bits */ - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect); - - if (err_detect & PCI_EDE_PERR_MASK) - edac_pci_handle_pe(pci, pci->ctl_name); - - if ((err_detect & ~PCI_EDE_MULTI_ERR) & ~PCI_EDE_PERR_MASK) - edac_pci_handle_npe(pci, pci->ctl_name); + out_be32(®->pex_err_dr, err_detect); } static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) @@ -190,7 +202,7 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) struct mpc85xx_pci_pdata *pdata = pci->pvt_info; u32 err_detect; - err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR); + err_detect = in_be32(&pdata->pci_reg->pex_err_dr); if (!err_detect) return IRQ_NONE; @@ -200,12 +212,103 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id) return IRQ_HANDLED; } +/* + * This function is for error interrupt ORed mechanism. + * This mechanism attaches most functions' error interrupts to interrupt 0. + * And report error interrupt to mpic via interrupt 0. + * EIMR0 - Error Interrupt Mask Register 0. + * + * This function check whether the device support error interrupt ORed + * mechanism via device tree. If supported, umask pcie error interrupt + * bit in EIMR0. + */ +static int mpc85xx_err_int_en(struct platform_device *op) +{ + u32 *int_cell; + struct device_node *np; + void __iomem *mpic_base; + u32 reg_tmp; + u32 int_len; + struct resource r; + int res; + + if (!op->dev.of_node) + return -EINVAL; + + /* + * Unmask pcie error interrupt bit in EIMR0. + * Extend interrupt specifier has 4 cells. + * For the 3rd cell: + * 0 -- normal interrupt; + * 1 -- error interrupt. + */ + int_cell = (u32 *)of_get_property(op->dev.of_node, "interrupts", + &int_len); + if ((int_len/sizeof(u32)) == 4) { + /* soc has error interrupt integration handling mechanism */ + if (*(int_cell + 2) == 1) { + np = of_find_node_by_type(NULL, "open-pic"); + + if (of_address_to_resource(np, 0, &r)) { + printk(KERN_ERR "%s: Failed to map mpic regs\n", + __func__); + of_node_put(np); + res = -ENOMEM; + goto err; + } + + if (!request_mem_region(r.start, r.end - r.start + 1, + "mpic")) { + printk(KERN_ERR "%s: Error while requesting " + "mem region\n", __func__); + res = -EBUSY; + goto err; + } + + mpic_base = ioremap(r.start, r.end - r.start + 1); + if (!mpic_base) { + printk(KERN_ERR "%s: Unable to map mpic regs\n", + __func__); + res = -ENOMEM; + goto err_ioremap; + } + + reg_tmp = in_be32(mpic_base + MPC85XX_MPIC_EIMR0); + out_be32(mpic_base + MPC85XX_MPIC_EIMR0, + reg_tmp & ~(1 << (31 - *(int_cell + 3)))); + iounmap(mpic_base); + release_mem_region(r.start, r.end - r.start + 1); + of_node_put(np); + } + } + + return 0; + +err_ioremap: + release_mem_region(r.start, r.end - r.start + 1); +err: + return res; +} + +static int mpc85xx_pcie_find_capability(struct device_node *np) +{ + struct pci_controller *hose; + + if (!np) + return -EINVAL; + + hose = pci_find_hose_for_OF_device(np); + return early_find_capability(hose, hose->bus->number, 0, + PCI_CAP_ID_EXP); +} + static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, const struct of_device_id *match) { struct edac_pci_ctl_info *pci; struct mpc85xx_pci_pdata *pdata; struct resource r; + struct ccsr_pci *reg; int res = 0; if (!devres_open_group(&op->dev, mpc85xx_pci_err_probe, GFP_KERNEL)) @@ -218,6 +321,9 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, pdata = pci->pvt_info; pdata->name = "mpc85xx_pci_err"; pdata->irq = NO_IRQ; + if (mpc85xx_pcie_find_capability(op->dev.of_node) > 0) + pdata->pcie_flag = 1; + dev_set_drvdata(&op->dev, pci); pci->dev = &op->dev; pci->mod_name = EDAC_MOD_STR; @@ -236,9 +342,6 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, goto err; } - /* we only need the error registers */ - r.start += 0xe00; - if (!devm_request_mem_region(&op->dev, r.start, resource_size(&r), pdata->name)) { printk(KERN_ERR "%s: Error while requesting mem region\n", @@ -247,26 +350,32 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, goto err; } - pdata->pci_vbase = devm_ioremap(&op->dev, r.start, resource_size(&r)); - if (!pdata->pci_vbase) { + pdata->pci_reg = devm_ioremap(&op->dev, r.start, resource_size(&r)); + if (!pdata->pci_reg) { printk(KERN_ERR "%s: Unable to setup PCI err regs\n", __func__); res = -ENOMEM; goto err; } - orig_pci_err_cap_dr = - in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR); - - /* PCI master abort is expected during config cycles */ - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR, 0x40); + if (mpc85xx_err_int_en(op) < 0) + goto err; - orig_pci_err_en = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN); + reg = pdata->pci_reg; + /* disable pci/pcie error detect */ + if (pdata->pcie_flag) { + pdata->orig_pci_err_dr = in_be32(®->pex_err_disr); + out_be32(®->pex_err_disr, ~0); + } else { + pdata->orig_pci_err_dr = in_be32(®->pex_err_cap_dr); + out_be32(®->pex_err_cap_dr, ~0); + } - /* disable master abort reporting */ - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, ~0x40); + /* disable all pcie error interrupt */ + pdata->orig_pci_err_en = in_be32(®->pex_err_en); + out_be32(®->pex_err_en, 0); - /* clear error bits */ - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, ~0); + /* clear all error bits */ + out_be32(®->pex_err_dr, ~0); if (edac_pci_add_device(pci, pdata->edac_idx) > 0) { debugf3("%s(): failed edac_pci_add_device()\n", __func__); @@ -276,7 +385,7 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, if (edac_op_state == EDAC_OPSTATE_INT) { pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0); res = devm_request_irq(&op->dev, pdata->irq, - mpc85xx_pci_isr, IRQF_DISABLED, + mpc85xx_pci_isr, IRQF_SHARED, "[EDAC] PCI err", pci); if (res < 0) { printk(KERN_ERR @@ -291,6 +400,17 @@ static int __devinit mpc85xx_pci_err_probe(struct platform_device *op, pdata->irq); } + if (pdata->pcie_flag) { + /* enable all pcie error interrupt & error detect */ + out_be32(®->pex_err_en, ~0); + out_be32(®->pex_err_disr, 0); + } else { + /* PCI master abort is expected during config cycles */ + out_be32(®->pex_err_cap_dr, PCI_ERR_CAP_DR_DIS_MST); + /* disable master abort reporting */ + out_be32(®->pex_err_en, PCI_ERR_EN_DIS_MST); + } + devres_remove_group(&op->dev, mpc85xx_pci_err_probe); debugf3("%s(): success\n", __func__); printk(KERN_INFO EDAC_MOD_STR " PCI err registered\n"); @@ -312,10 +432,13 @@ static int mpc85xx_pci_err_remove(struct platform_device *op) debugf0("%s()\n", __func__); - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR, - orig_pci_err_cap_dr); + if (pdata->pcie_flag) + out_be32(&pdata->pci_reg->pex_err_disr, pdata->orig_pci_err_dr); + else + out_be32(&pdata->pci_reg->pex_err_cap_dr, + pdata->orig_pci_err_dr); - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en); + out_be32(&pdata->pci_reg->pex_err_en, pdata->orig_pci_err_en); edac_pci_del_device(pci->dev); @@ -334,6 +457,12 @@ static struct of_device_id mpc85xx_pci_err_of_match[] = { { .compatible = "fsl,mpc8540-pci", }, + { + .compatible = "fsl,mpc8548-pcie", + }, + { + .compatible = "fsl,p4080-pcie", + }, {}, }; MODULE_DEVICE_TABLE(of, mpc85xx_pci_err_of_match); @@ -1146,7 +1275,7 @@ static struct of_platform_driver mpc85xx_mc_err_driver = { }, }; -#ifdef CONFIG_FSL_SOC_BOOKE +#if defined(CONFIG_FSL_SOC_BOOKE) && !defined(CONFIG_PPC_E500MC) static void __init mpc85xx_mc_clear_rfxe(void *data) { orig_hid1[smp_processor_id()] = mfspr(SPRN_HID1); @@ -1185,7 +1314,7 @@ static int __init mpc85xx_mc_init(void) printk(KERN_WARNING EDAC_MOD_STR "PCI fails to register\n"); #endif -#ifdef CONFIG_FSL_SOC_BOOKE +#if defined(CONFIG_FSL_SOC_BOOKE) && !defined(CONFIG_PPC_E500MC) /* * need to clear HID1[RFXE] to disable machine check int * so we can catch it @@ -1199,7 +1328,7 @@ static int __init mpc85xx_mc_init(void) module_init(mpc85xx_mc_init); -#ifdef CONFIG_FSL_SOC_BOOKE +#if defined(CONFIG_FSL_SOC_BOOKE) && !defined(CONFIG_PPC_E500MC) static void __exit mpc85xx_mc_restore_hid1(void *data) { mtspr(SPRN_HID1, orig_hid1[smp_processor_id()]); @@ -1208,7 +1337,7 @@ static void __exit mpc85xx_mc_restore_hid1(void *data) static void __exit mpc85xx_mc_exit(void) { -#ifdef CONFIG_FSL_SOC_BOOKE +#if defined(CONFIG_FSL_SOC_BOOKE) && !defined(CONFIG_PPC_E500MC) on_each_cpu(mpc85xx_mc_restore_hid1, NULL, 0); #endif #ifdef CONFIG_PCI diff --git a/drivers/edac/mpc85xx_edac.h b/drivers/edac/mpc85xx_edac.h index 099581d..604f181 100644 --- a/drivers/edac/mpc85xx_edac.h +++ b/drivers/edac/mpc85xx_edac.h @@ -133,6 +133,10 @@ #define PCI_EDE_PERR_MASK (PCI_EDE_TGT_PERR | PCI_EDE_MST_PERR | \ PCI_EDE_ADDR_PERR) +#define PCI_ERR_CAP_DR_DIS_MST 0x40 +#define PCI_ERR_EN_DIS_MST (~PCI_ERR_CAP_DR_DIS_MST) +#define MPC85XX_MPIC_EIMR0 0x3910 + struct mpc85xx_mc_pdata { char *name; int edac_idx; @@ -149,8 +153,11 @@ struct mpc85xx_l2_pdata { struct mpc85xx_pci_pdata { char *name; + u8 pcie_flag; int edac_idx; - void __iomem *pci_vbase; + struct ccsr_pci *pci_reg; + u32 orig_pci_err_dr; + u32 orig_pci_err_en; int irq; };