From patchwork Mon Sep 25 12:34:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 9969893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFEE1602CB for ; Mon, 25 Sep 2017 12:37:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E03D8205AB for ; Mon, 25 Sep 2017 12:37:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D555D22230; Mon, 25 Sep 2017 12:37:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96FF22684F for ; Mon, 25 Sep 2017 12:37:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LYqG6w1k6x8wG1I0zMJ0lIYAXSpBdR0UsPoV8HvigQ8=; b=n4GYKj1vRzjhzXQFxV7k+tPjrz ryVm35F7pvslwJDZrBGAVqIDl/Q4UJ9aPZ6x7HAxrmR0lErxC0AyHPCJ7TofX5O39ltI42dglrq2+ 90pJ4auPoU0WMfET70iM0aRh8t3SV1Lgv/khjBGIV7EuWJrwjZ+aHmoVWxIfEXOrV9yWXF+ufC5c+ 87vyMIuj1U9QsDPzKwM+CupTI+ekk5qTkTThTV3YE8SPpAyH495i+PHQ+TZ//DZmGgqZq086SAIX8 2wLkxOz3KKkWtuam1hgH7X/vv81fIcfLcTc3RTW6HeYBMHW+AaifgQV9ST/fCb/7FNRjNhT24Q9ZM zMmRYFWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dwSdV-0007jY-62; Mon, 25 Sep 2017 12:37:21 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dwSbr-0006Ww-BC for linux-arm-kernel@lists.infradead.org; Mon, 25 Sep 2017 12:35:42 +0000 Received: by mail-wm0-f68.google.com with SMTP id x17so7047626wmd.5 for ; Mon, 25 Sep 2017 05:35:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DaINiGHnO/8FIyOzBPLtiQEHZJ5NYu1BfoYcz/ZZo2U=; b=aUDJB0IMl4ygqQhUD1EWJ2/CZq7Lif8ksGzDgvcDJcSq6ks8dXeugXsss6A9sZdzTs KwqG4N7XR+0vWHYTAFYB17E/dWO1GIA9tc1axCah1vz4TbnnDz6OX1VieB6pUx2PYyjk +tr3sTmyLthobPYq52xYaSo96kpGUVEj59Rry0fnzcl2LB9B/wGiRaLIUnZjoBudiTQr W+yk6X7dIoSaldEe1FVf763+ju5Tj+bNMDJWvo1Cy5pZA3Nkcd9jmbCSposXtmWZIIj1 kjg0kxBjQH91jvsh1Rrs2pfQPNCYF73ZpRJ8RCslSRxpwHUgiXGJ+inhFcs3JfXe5hvL m0ow== X-Gm-Message-State: AHPjjUg40dEOjTD0RD0gcWgW0Pr/nILL/hYZDXseovwthlETrfqXjQEM wlBxwmJZZ+QfKDg7qcqtZbI= X-Google-Smtp-Source: AOwi7QB3hIn+C0ApsjlSlzm0kJbicavczWZnaHUnbPiTF8mrJaYWBx2OZ8xP7vExMvgZGRKDbl+MhQ== X-Received: by 10.80.147.193 with SMTP id o59mr14040114eda.88.1506342917373; Mon, 25 Sep 2017 05:35:17 -0700 (PDT) Received: from localhost.localdomain (dslb-088-067-130-225.088.067.pools.vodafone-ip.de. [88.67.130.225]) by smtp.gmail.com with ESMTPSA id a99sm3792589edf.54.2017.09.25.05.35.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Sep 2017 05:35:16 -0700 (PDT) From: Jan Glauber To: Mark Rutland , Will Deacon Subject: [PATCH v10 3/7] edac, soc: thunderx: Add wrapper for EDAC LMC PCI device Date: Mon, 25 Sep 2017 14:34:58 +0200 Message-Id: <20170925123502.17289-4-jglauber@cavium.com> X-Mailer: git-send-email 2.9.0.rc0.21.g7777322 In-Reply-To: <20170925123502.17289-1-jglauber@cavium.com> References: <20170925123502.17289-1-jglauber@cavium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170925_053539_628425_50E52552 X-CRM114-Status: GOOD ( 22.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney , Suzuki K Poulose , linux-kernel@vger.kernel.org, Zhangshaokun , Borislav Petkov , Jan Glauber , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Cavium SOCs contain a memory controller that is presented as a PCI device. This PCI device will be used by an EDAC driver and by a PMU driver. To allow both subsystems to access the device a small wrapper is introduced that multi-plexes PCI probe and removal calls of the device to the EDAC driver. The same mechanism will be used later to call the PMU driver. The ThunderX EDAC driver is limited to only build as module with this patch. The reason is that with multiple users of the multi-plexer all users must be either builtin or modules. Signed-off-by: Jan Glauber --- drivers/edac/Kconfig | 2 ++ drivers/edac/thunderx_edac.c | 27 ++++++----------------- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/cavium/Kconfig | 6 +++++ drivers/soc/cavium/Makefile | 1 + drivers/soc/cavium/cavium_lmc.c | 49 +++++++++++++++++++++++++++++++++++++++++ include/linux/soc/cavium/lmc.h | 9 ++++++++ 8 files changed, 76 insertions(+), 20 deletions(-) create mode 100644 drivers/soc/cavium/Kconfig create mode 100644 drivers/soc/cavium/Makefile create mode 100644 drivers/soc/cavium/cavium_lmc.c create mode 100644 include/linux/soc/cavium/lmc.h diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 96afb2aeed18..7330447c43d1 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -371,6 +371,8 @@ config EDAC_THUNDERX tristate "Cavium ThunderX EDAC" depends on ARM64 depends on PCI + depends on m + select CAVIUM_LMC help Support for error detection and correction on the Cavium ThunderX memory controllers (LMC), Cache diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c index 4803c6468bab..a6a89bf0a457 100644 --- a/drivers/edac/thunderx_edac.c +++ b/drivers/edac/thunderx_edac.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include @@ -654,8 +656,7 @@ static inline int pci_dev_to_mc_idx(struct pci_dev *pdev) return ret; } -static int thunderx_lmc_probe(struct pci_dev *pdev, - const struct pci_device_id *id) +int thunderx_edac_lmc_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct thunderx_lmc *lmc; struct edac_mc_layer layer; @@ -795,8 +796,9 @@ static int thunderx_lmc_probe(struct pci_dev *pdev, return ret; } +EXPORT_SYMBOL_GPL(thunderx_edac_lmc_probe); -static void thunderx_lmc_remove(struct pci_dev *pdev) +void thunderx_edac_lmc_remove(struct pci_dev *pdev) { struct mem_ctl_info *mci = pci_get_drvdata(pdev); struct thunderx_lmc *lmc = mci->pvt_info; @@ -806,15 +808,7 @@ static void thunderx_lmc_remove(struct pci_dev *pdev) edac_mc_del_mc(&pdev->dev); edac_mc_free(mci); } - -MODULE_DEVICE_TABLE(pci, thunderx_lmc_pci_tbl); - -static struct pci_driver thunderx_lmc_driver = { - .name = "thunderx_lmc_edac", - .probe = thunderx_lmc_probe, - .remove = thunderx_lmc_remove, - .id_table = thunderx_lmc_pci_tbl, -}; +EXPORT_SYMBOL_GPL(thunderx_edac_lmc_remove); /*---------------------- OCX driver ---------------------------------*/ @@ -2110,13 +2104,9 @@ static int __init thunderx_edac_init(void) { int rc = 0; - rc = pci_register_driver(&thunderx_lmc_driver); - if (rc) - return rc; - rc = pci_register_driver(&thunderx_ocx_driver); if (rc) - goto err_lmc; + return rc; rc = pci_register_driver(&thunderx_l2c_driver); if (rc) @@ -2125,8 +2115,6 @@ static int __init thunderx_edac_init(void) return rc; err_ocx: pci_unregister_driver(&thunderx_ocx_driver); -err_lmc: - pci_unregister_driver(&thunderx_lmc_driver); return rc; } @@ -2135,7 +2123,6 @@ static void __exit thunderx_edac_exit(void) { pci_unregister_driver(&thunderx_l2c_driver); pci_unregister_driver(&thunderx_ocx_driver); - pci_unregister_driver(&thunderx_lmc_driver); } diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index fc9e98047421..f19f6237f336 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -4,6 +4,7 @@ source "drivers/soc/actions/Kconfig" source "drivers/soc/amlogic/Kconfig" source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" +source "drivers/soc/cavium/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/imx/Kconfig" source "drivers/soc/mediatek/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 2fcaff864584..a2027196d0fb 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_ARCH_ACTIONS) += actions/ obj-$(CONFIG_ARCH_AT91) += atmel/ obj-y += bcm/ +obj-$(CONFIG_ARCH_THUNDER) += cavium/ obj-$(CONFIG_ARCH_DOVE) += dove/ obj-$(CONFIG_MACH_DOVE) += dove/ obj-y += fsl/ diff --git a/drivers/soc/cavium/Kconfig b/drivers/soc/cavium/Kconfig new file mode 100644 index 000000000000..46ded89fb696 --- /dev/null +++ b/drivers/soc/cavium/Kconfig @@ -0,0 +1,6 @@ +# +# Cavium ThunderX Soc drivers +# +config CAVIUM_LMC + depends on ARCH_THUNDER + def_tristate m diff --git a/drivers/soc/cavium/Makefile b/drivers/soc/cavium/Makefile new file mode 100644 index 000000000000..4ad0c7f923fa --- /dev/null +++ b/drivers/soc/cavium/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_CAVIUM_LMC) += cavium_lmc.o diff --git a/drivers/soc/cavium/cavium_lmc.c b/drivers/soc/cavium/cavium_lmc.c new file mode 100644 index 000000000000..87248e83c55b --- /dev/null +++ b/drivers/soc/cavium/cavium_lmc.c @@ -0,0 +1,49 @@ +/* + * These PCI devices contain RAS functionality and PMU counters. To allow + * independent RAS and PMU drivers this driver registers for the PCI devices + * and multi-plexes probe and removal. + * + * 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. + * + * Copyright: Cavium, Inc. (C) 2017 + * + */ +#include +#include +#include + +static int cvm_lmc_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + if (IS_ENABLED(CONFIG_EDAC_THUNDERX)) + thunderx_edac_lmc_probe(pdev, ent); + return 0; +} + +static void cvm_lmc_remove(struct pci_dev *pdev) +{ + if (IS_ENABLED(CONFIG_EDAC_THUNDERX)) + thunderx_edac_lmc_remove(pdev); +} + +static const struct pci_device_id cvm_lmc_pci_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, 0xa022) }, + { 0, }, +}; + +MODULE_DEVICE_TABLE(pci, cvm_lmc_pci_table); + +static struct pci_driver cvm_lmc_pci_driver = { + .name = "Cavium SOC memory controller", + .id_table = cvm_lmc_pci_table, + .probe = cvm_lmc_probe, + .remove = cvm_lmc_remove, +}; + +module_pci_driver(cvm_lmc_pci_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Cavium, Inc."); +MODULE_DESCRIPTION("PCI driver for Cavium SOC memory controller"); diff --git a/include/linux/soc/cavium/lmc.h b/include/linux/soc/cavium/lmc.h new file mode 100644 index 000000000000..336f467e154f --- /dev/null +++ b/include/linux/soc/cavium/lmc.h @@ -0,0 +1,9 @@ +#ifndef _LMC_H +#define _LMC_H + +#include + +int thunderx_edac_lmc_probe(struct pci_dev *pdev, const struct pci_device_id *ent); +void thunderx_edac_lmc_remove(struct pci_dev *pdev); + +#endif