From patchwork Thu Dec 10 00:00:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Wood X-Patchwork-Id: 554908 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BF2CB140E59 for ; Thu, 10 Dec 2015 11:01:23 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id A5C771A1706 for ; Thu, 10 Dec 2015 11:01:23 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bbn0106.outbound.protection.outlook.com [157.56.111.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id B27941A05C8 for ; Thu, 10 Dec 2015 11:00:25 +1100 (AEDT) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=scottwood@freescale.com; Received: from snotra.am.freescale.net (192.88.168.50) by BY1PR03MB1484.namprd03.prod.outlook.com (10.162.210.142) with Microsoft SMTP Server (TLS) id 15.1.337.19; Thu, 10 Dec 2015 00:00:16 +0000 From: Scott Wood To: , Subject: [PATCH] EDAC, mpc85xx: Make mpc85xx-pci-edac a platform device Date: Wed, 9 Dec 2015 18:00:03 -0600 Message-ID: <1449705603-8342-1-git-send-email-scottwood@freescale.com> X-Mailer: git-send-email 2.5.0 MIME-Version: 1.0 X-Originating-IP: [192.88.168.50] X-ClientProxiedBy: SN1PR17CA0009.namprd17.prod.outlook.com (25.169.33.147) To BY1PR03MB1484.namprd03.prod.outlook.com (25.162.210.142) X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1484; 2:8DZh8sdBdzejIOwm67IaO7iXb3PvSUmicR4DD9Q/8qltP/w6vK06h6LwUcdf6RdHyjc9FqlbP7v3Fm/Sq2hZr1jMSWJrpDzzb4iNgtrrbJeWORAGknTJJmuQFjnPlLCYxZicoRxqFJ86UQOimj9R7g==; 3:1SN8V33rrTgnJflhOe2Qfu0OyDimvnTNu1q7nhJ4RLXkUYdTSAJvMqnEC8THq5FOLTweqnadQ2EaDxAN3+eTaJ0+YfhdAGneRHyHyjetpxzlj97yQn8EuQOicehluStu; 25:sriUd5slqZKffYEqVp3q2F+cjNny8/mJLXKQXH23BizKMj3O07QVfgE9PRkKqGdvC88KcVeHohn6QwAfMTmiDW/VYiZXRrO5Ko9/6MWel3qfXBF7ISHh9HWN0uzH/MQItkRFMrT1kPudsVqAHDD2dJNgkffurklf18llBWkDfH/KNTYBwFGSpZ+xjNUjw5UMoFTx8L3HwebeQbeK4mgUARGtLQj2gd7jJ8hZMLrmJtb1bgWdQdmKAAe4TequIo36 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR03MB1484; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1484; 20:3vbsVR2CiXmgwIWus9+nDQh7F0q79cB1ID7XWMAG80YtsK81CCdgD3zKep9DjY1hyNyrm2YfdoRc3AUbR+RoMASA8VfDMRRuWd36te0wnob8FJtDTx36KkCxH80M2qc5y4iQcBJB66Esj0xIIW1glMCYMQQmXX7ITrBlvxch5PTW1j9XReXHxA9uL+r4sNlg9fztppHKnscTo2K8nyMcY6jA+ZXVWod8r49YAEG1vKhJOEY7uAXO9WZRIblc6VjLydXRKRTlqlbCdDeyel4/MzOM+l5Z2fHyWQFCU2GIX5rdFBJ567OwJHXI9jXYIFMxC8+Zu0oFiwc+h52ttFgj83P97Iz5YEcxdc0vfFisMXF0lwV8h6Xj04gtcVPLJMJGRIap+74tXsKubyEIe8ZAC+FMbWeljSeb9xxRB1dB+n+7eYqRUYKscmAmwZkRfKTtewZAcdaDGr4RQFjm4S1bK/ZexRkpXqN4VW9OZrFkURKQHmlfpMr6MMW3dFjLzxISz8SGzHlcVQkPJos+Gi+eEKclcepn/OtQS2NYmrkef5SQq8yPYvsnOMx3ypym6AYMoqjefnmz+d/PWHc73KJIfQzbkbdipuqxXcUFbwzviss= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:BY1PR03MB1484; BCL:0; PCL:0; RULEID:; SRVR:BY1PR03MB1484; X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1484; 4:LS/tJXdKAPiRRND11QcLzPHZl5DCI0KT13VL0OnezMmvx4mPsb9zRbx/GHlUPmRmPZxOjx66axIxagj+ZL1oeastYpJdkRXmkwLZBTPnhPA0u5WHl7PSnu4EFmqAue9bdGgeOV8GAgVzj3WrajCBlq376dBcpVF5P+5gAL4LUbW6ArPnYk9U4J3+wf7t7jdlGPe0t6/wkcfUW/nz6Yg7r+o8tG9yUunTDT23IcwEzQIvKyMUC/XyOJbmEzZB3vUZcSG8wpeadtSKrhmZVO3A9Ap5kAhyaQUehzSKPU1Cgo7h0yPnx2OTilVBReHyf3y9wP9g/iD46OWlUhaL77QC0C0e5mS5Mi1i4bp800VlSULnD2pFs4n65C+2v6GIjBxiOcPHpLJ6ts7f6gnr6QaILq/0WYZT8TDVpFrITb07xR8= X-Forefront-PRVS: 078693968A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(189002)(199003)(77096005)(230783001)(586003)(229853001)(92566002)(101416001)(122386002)(47776003)(97736004)(42186005)(5001960100002)(33646002)(5001770100001)(66066001)(5003940100001)(105586002)(189998001)(87976001)(50466002)(36756003)(50986999)(19580405001)(106356001)(19580395003)(81156007)(48376002)(5004730100002)(6116002)(86362001)(50226001)(40100003)(1096002)(5008740100001)(3846002)(2101003); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR03MB1484; H:snotra.am.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: freescale.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY1PR03MB1484; 23:NPho0/lZ0T+Sq/8Q6677cjoWv2RscG3HbSa9wylR4?= =?us-ascii?Q?CUG0MxfxtQbKvPJRTm7FDotdE5IX5ZkLjJuiNLfDYFUIJ3ggTXrZCCcnNqXO?= =?us-ascii?Q?0v+m+QUJhkHAgH/gX2WWQVax0otVDfklcFL2OZAowpY5pmdS2OLcFbpazwA8?= =?us-ascii?Q?UouaHjjBYg1bJLTxtu2M0ahIyPjUwF0h8AtbgxL+pldLzYxSr90exAsHOa5l?= =?us-ascii?Q?37lxvMautl1aqEFWgP7fkKltW1WliF2DIGTxYKVOzajXFMW9PpgJ8+w0y4oy?= =?us-ascii?Q?BzBSgQOgb7wArfEh7lvXIpF0hScVSW9tEcs5XdEHGdl5cwsMqrhzZTXMf9z3?= =?us-ascii?Q?YMJO7H0smIO+2mEhSFqj2L1BGrH6vohJjv3gzFEGiPwV39svE9VcI4wvxrnr?= =?us-ascii?Q?Zh5Jw3AghyxLF8oSQzYAqjyKVyiwgqeNJZnZTNqzGBNSYCo4suOHlZS0DLhW?= =?us-ascii?Q?+aCPFVOqcZP96AgAVXiSpZPawg/vxo7neSTLkKa1frJ0OrOk7cLSeE6jD6Ow?= =?us-ascii?Q?dHHDWY3a0YMPDH2w8/IjsVdHInaRS/xy86h1Fpn56cjV4e1zSAb6R68AfZGC?= =?us-ascii?Q?koDvibAKIX0iQcC9bSBO8n7WXn4skl3i2uoVzl2Z3F+PMHkzs+mDWPG+Cs2F?= =?us-ascii?Q?fSMMa0RL7qhXO9X3KvmXjm3THKSOjgsb/2I99UlwMfkNLRv48vc8r4uUw2ve?= =?us-ascii?Q?FYviXwEEaS2LQa5W3fBeWo9EINjrCqPrI8EKTQWhV75ekjyU9kI38SDLqRI7?= =?us-ascii?Q?FG4vtZw1zibVK0hGfdkiiJLvPe8BX7o61t/aih12Rd/MgwSO0fctXXVp1fu7?= =?us-ascii?Q?C+ZakE8qv7UPlZnkzZIOs8vObftgovvmXcDRWebuClAXrGx/hB8yMsjcTaal?= =?us-ascii?Q?ZsQGTNDuyvCZeE8YSUHzG8boPw3UTPMlYVWsXNzRAbq1btmxy8JJqN06CCnl?= =?us-ascii?Q?1gUkZm++CQwyHAQbJ8fQofcDBfdF/5Mt/ff59m1dEDC0IsitQOtZehK8gDDo?= =?us-ascii?Q?IGlHThyw4NqI+HxUpYXFPkVNAGgmG/qUXQJMx05HeLu+Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY1PR03MB1484; 5:Yw6TrMclsER0DSCjiD8xQSyExINt/dKuDSIGIz8Jw8Td9jTOY5zVoVQPucCSbpDUFTNZuyJAi8OrtFNYUppfbmXUZNqM/ZlPSA1SWngnJeItx9KnotNQIQglDaUZHYKnyrSKe7LEsHK/QxfuYu8IvQ==; 24:yxf3xI5i60H4G1G/75Wqm9PzrcnZOX2gjYd6UZTbsdaMAi4MmeJU/ujrdRy/hW+iyD99RXXD8DPAIH30sd6QuNi5HhJYA+i/OIqLFh368Z0= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2015 00:00:16.6310 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR03MB1484 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Scott Wood , Borislav Petkov , Johannes Thumshirn , Jia Hongtao Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Originally the mpc85xx-pci-edac driver bound directly to the PCI controller node. Commit 905e75c46dba5f30 ("powerpc/fsl-pci: Unify pci/pcie initialization code") turned the PCI controller code into a platform device. Since we can't have two drivers binding to the same device, the edac code was changed to be called into as a library-style submodule. However, this doesn't work if the edac driver is built as a module. Commit 8d8fcba6d1eab ("EDAC: Rip out the edac_subsys reference counting") exposed another problem with this approach -- mpc85xx_pci_err_probe() was being called in the same early boot phase that the PCI controller is initialized, rather than in the device_initcall phase that the EDAC layer expects. This caused a crash on boot. To fix this, the PCI controller code now creates a child platform device specifically for EDAC, which the mpc85xx-pci-edac driver binds to. Signed-off-by: Scott Wood Cc: Jia Hongtao Cc: Borislav Petkov Cc: Johannes Thumshirn Cc: Michael Ellerman --- arch/powerpc/sysdev/fsl_pci.c | 28 +++++++++++++++++++++++++++- arch/powerpc/sysdev/fsl_pci.h | 9 --------- drivers/edac/mpc85xx_edac.c | 34 ++++++++++++++++++++++++++++++---- include/linux/fsl/edac.h | 8 ++++++++ 4 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 include/linux/fsl/edac.h diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 610f472..a1ac80b 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -21,10 +21,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -1255,6 +1257,25 @@ void fsl_pcibios_fixup_phb(struct pci_controller *phb) #endif } +static int add_err_dev(struct platform_device *pdev) +{ + struct platform_device *errdev; + struct mpc85xx_edac_pci_plat_data pd = { + .of_node = pdev->dev.of_node + }; + + errdev = platform_device_register_resndata(&pdev->dev, + "mpc85xx-pci-edac", + PLATFORM_DEVID_AUTO, + pdev->resource, + pdev->num_resources, + &pd, sizeof(pd)); + if (IS_ERR(errdev)) + return PTR_ERR(errdev); + + return 0; +} + static int fsl_pci_probe(struct platform_device *pdev) { struct device_node *node; @@ -1262,8 +1283,13 @@ static int fsl_pci_probe(struct platform_device *pdev) node = pdev->dev.of_node; ret = fsl_add_bridge(pdev, fsl_pci_primary == node); + if (ret) + return ret; - mpc85xx_pci_err_probe(pdev); + ret = add_err_dev(pdev); + if (ret) + dev_err(&pdev->dev, "couldn't register error device: %d\n", + ret); return 0; } diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h index c1cec77..1515885 100644 --- a/arch/powerpc/sysdev/fsl_pci.h +++ b/arch/powerpc/sysdev/fsl_pci.h @@ -130,15 +130,6 @@ void fsl_pci_assign_primary(void); static inline void fsl_pci_assign_primary(void) {} #endif -#ifdef CONFIG_EDAC_MPC85XX -int mpc85xx_pci_err_probe(struct platform_device *op); -#else -static inline int mpc85xx_pci_err_probe(struct platform_device *op) -{ - return -ENOTSUPP; -} -#endif - #ifdef CONFIG_FSL_PCI extern int fsl_pci_mcheck_exception(struct pt_regs *); #else diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c index 3eab063..cbc740f 100644 --- a/drivers/edac/mpc85xx_edac.c +++ b/drivers/edac/mpc85xx_edac.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -242,6 +243,8 @@ int mpc85xx_pci_err_probe(struct platform_device *op) { struct edac_pci_ctl_info *pci; struct mpc85xx_pci_pdata *pdata; + struct mpc85xx_edac_pci_plat_data *plat_data; + struct device_node *of_node; struct resource r; int res = 0; @@ -266,7 +269,15 @@ int mpc85xx_pci_err_probe(struct platform_device *op) pdata->name = "mpc85xx_pci_err"; pdata->irq = NO_IRQ; - if (mpc85xx_pcie_find_capability(op->dev.of_node) > 0) + plat_data = op->dev.platform_data; + if (!plat_data) { + dev_err(&op->dev, "no platform data"); + res = -ENXIO; + goto err; + } + of_node = plat_data->of_node; + + if (mpc85xx_pcie_find_capability(of_node) > 0) pdata->is_pcie = true; dev_set_drvdata(&op->dev, pci); @@ -284,7 +295,7 @@ int mpc85xx_pci_err_probe(struct platform_device *op) pdata->edac_idx = edac_pci_idx++; - res = of_address_to_resource(op->dev.of_node, 0, &r); + res = of_address_to_resource(of_node, 0, &r); if (res) { printk(KERN_ERR "%s: Unable to get resource for " "PCI err regs\n", __func__); @@ -339,7 +350,7 @@ int 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); + pdata->irq = irq_of_parse_and_map(of_node, 0); res = devm_request_irq(&op->dev, pdata->irq, mpc85xx_pci_isr, IRQF_SHARED, @@ -386,8 +397,22 @@ err: devres_release_group(&op->dev, mpc85xx_pci_err_probe); return res; } -EXPORT_SYMBOL(mpc85xx_pci_err_probe); +static const struct platform_device_id mpc85xx_pci_err_match[] = { + { + .name = "mpc85xx-pci-edac" + }, + {} +}; + +static struct platform_driver mpc85xx_pci_err_driver = { + .probe = mpc85xx_pci_err_probe, + .id_table = mpc85xx_pci_err_match, + .driver = { + .name = "mpc85xx_pci_err", + .suppress_bind_attrs = true, + }, +}; #endif /* CONFIG_PCI */ /**************************** L2 Err device ***************************/ @@ -1211,6 +1236,7 @@ static void __init mpc85xx_mc_clear_rfxe(void *data) static struct platform_driver * const drivers[] = { &mpc85xx_mc_err_driver, &mpc85xx_l2_err_driver, + &mpc85xx_pci_err_driver, }; static int __init mpc85xx_mc_init(void) diff --git a/include/linux/fsl/edac.h b/include/linux/fsl/edac.h new file mode 100644 index 0000000..90d64d4 --- /dev/null +++ b/include/linux/fsl/edac.h @@ -0,0 +1,8 @@ +#ifndef FSL_EDAC_H +#define FSL_EDAC_H + +struct mpc85xx_edac_pci_plat_data { + struct device_node *of_node; +}; + +#endif