From patchwork Tue Aug 29 13:12:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Glauber X-Patchwork-Id: 9927325 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 D9DEE6022E for ; Tue, 29 Aug 2017 13:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3E28288F7 for ; Tue, 29 Aug 2017 13:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8EF3288FA; Tue, 29 Aug 2017 13:16:01 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW 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 8DF23288F7 for ; Tue, 29 Aug 2017 13:16:00 +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=L9484CRrurInZYnPf9ILRxyqf9Dsd3FjwJVKW5isGcE=; b=bj7VZWhSHo4MyIN+DbXZvOy7Ga 91oJzd93AW8YNmii2x2n1YnDw4lWdIlzOT9ui9eMLXsu2jfFgTSxhQYlPGQOvkHQbKzHqX73iKtGY Bo9ter388rzBUqp87waxa3axch9UFXnosTDPLnSCOfuLlwZ0U6VvePBklx23w8ASyVKqSfQXQkCI7 4z7gaFV4fqqZocgJ/RSGIAAmlLLr1PrczGsX81xP1A4XrFaQtA+jPRQq/je6SYW81dLxTl94BnUcW j6R8LlJupVfVEGrVx9fJnVAbwGloFf6OlNr3NcjOxZ3TsRxClUk5hOSP1zVdm1h/MxT7dIzQ9uklU 0Qtw1o/g==; 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 1dmgN1-0007fZ-IZ; Tue, 29 Aug 2017 13:15:55 +0000 Received: from mail-wr0-f195.google.com ([209.85.128.195]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmgKg-0004dq-Er for linux-arm-kernel@lists.infradead.org; Tue, 29 Aug 2017 13:13:38 +0000 Received: by mail-wr0-f195.google.com with SMTP id 40so2059192wrv.3 for ; Tue, 29 Aug 2017 06:13:09 -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=Cq3/fVhnlsfcLmbv2kt8BRDtVTAT50FFD0TwtsFmlag=; b=sa7T3Uw1dQ1toyXw9+F4BTOIUHQWDkHlzb5mKCVB8+EesIEkWRetqQltqIrNMQ5qFd U9mwjzZU4ud8Dl9k5izWxfJI66h8vfG+qEpywU76bq+OwiU9tR84nqaYvYj/3YrFtlDQ lD/UmyR17gK+aDovlAuiWa1sgcyKaIVWJN9m5iTJ8nisQ1C96gEO5LPTVfLlsGOPYhDD cUucR+rEWMCjoKbYUrIyn7DSW+FXKJbcbxP/IruYXNyfHVE/xRgfd2/znWGINJa8Xy2B BgczXlevQArKzsJLg1jYXkoWQk51/TRKveJRxapI4xQWg1CGi7z6ZQu28y+tVqSZyVRU x5XA== X-Gm-Message-State: AHYfb5jW8uU4+CbNoSOwmlvQX2oraF0zH/BN9NiKr0iIEKRBh8Uhj+CJ RjWeFxokmIkhBA== X-Received: by 10.223.150.71 with SMTP id c7mr212070wra.192.1504012388157; Tue, 29 Aug 2017 06:13:08 -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 52sm2589890wru.59.2017.08.29.06.13.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Aug 2017 06:13:07 -0700 (PDT) From: Jan Glauber To: Mark Rutland , Will Deacon Subject: [RFC PATCH v9 3/7] edac, soc: thunderx: Add wrapper for EDAC OCX PCI device Date: Tue, 29 Aug 2017 15:12:34 +0200 Message-Id: <20170829131238.4988-4-jglauber@cavium.com> X-Mailer: git-send-email 2.9.0.rc0.21.g7777322 In-Reply-To: <20170829131238.4988-1-jglauber@cavium.com> References: <20170829131238.4988-1-jglauber@cavium.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170829_061331_139395_9DC8A248 X-CRM114-Status: GOOD ( 21.11 ) 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, 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 an processor interconnect 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. Signed-off-by: Jan Glauber --- drivers/edac/Kconfig | 1 + drivers/edac/thunderx_edac.c | 42 +++++++------------------------------- drivers/soc/cavium/Kconfig | 4 ++++ drivers/soc/cavium/Makefile | 1 + drivers/soc/cavium/cavium_ocx.c | 45 +++++++++++++++++++++++++++++++++++++++++ include/linux/soc/cavium/ocx.h | 9 +++++++++ 6 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 drivers/soc/cavium/cavium_ocx.c create mode 100644 include/linux/soc/cavium/ocx.h diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig index 7330447..8304212 100644 --- a/drivers/edac/Kconfig +++ b/drivers/edac/Kconfig @@ -373,6 +373,7 @@ config EDAC_THUNDERX depends on PCI depends on m select CAVIUM_LMC + select CAVIUM_OCX 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 16f3d62..ddbda71 100644 --- a/drivers/edac/thunderx_edac.c +++ b/drivers/edac/thunderx_edac.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -814,8 +815,6 @@ EXPORT_SYMBOL_GPL(thunderx_edac_lmc_remove); /*---------------------- OCX driver ---------------------------------*/ -#define PCI_DEVICE_ID_THUNDER_OCX 0xa013 - #define OCX_LINK_INTS 3 #define OCX_INTS (OCX_LINK_INTS + 1) #define OCX_RX_LANES 24 @@ -1311,11 +1310,6 @@ struct debugfs_entry *ocx_dfs_ents[] = { &debugfs_com_int, }; -static const struct pci_device_id thunderx_ocx_pci_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, PCI_DEVICE_ID_THUNDER_OCX) }, - { 0, }, -}; - static void thunderx_ocx_clearstats(struct thunderx_ocx *ocx) { int lane, stat, cfg; @@ -1331,8 +1325,8 @@ static void thunderx_ocx_clearstats(struct thunderx_ocx *ocx) } } -static int thunderx_ocx_probe(struct pci_dev *pdev, - const struct pci_device_id *id) +int thunderx_edac_ocx_probe(struct pci_dev *pdev, + const struct pci_device_id *id) { struct thunderx_ocx *ocx; struct edac_device_ctl_info *edac_dev; @@ -1461,8 +1455,9 @@ static int thunderx_ocx_probe(struct pci_dev *pdev, return ret; } +EXPORT_SYMBOL_GPL(thunderx_edac_ocx_probe); -static void thunderx_ocx_remove(struct pci_dev *pdev) +void thunderx_edac_ocx_remove(struct pci_dev *pdev) { struct edac_device_ctl_info *edac_dev = pci_get_drvdata(pdev); struct thunderx_ocx *ocx = edac_dev->pvt_info; @@ -1480,15 +1475,7 @@ static void thunderx_ocx_remove(struct pci_dev *pdev) edac_device_del_device(&pdev->dev); edac_device_free_ctl_info(edac_dev); } - -MODULE_DEVICE_TABLE(pci, thunderx_ocx_pci_tbl); - -static struct pci_driver thunderx_ocx_driver = { - .name = "thunderx_ocx_edac", - .probe = thunderx_ocx_probe, - .remove = thunderx_ocx_remove, - .id_table = thunderx_ocx_pci_tbl, -}; +EXPORT_SYMBOL_GPL(thunderx_edac_ocx_remove); /*---------------------- L2C driver ---------------------------------*/ @@ -2104,27 +2091,12 @@ static struct pci_driver thunderx_l2c_driver = { static int __init thunderx_edac_init(void) { - int rc = 0; - - rc = pci_register_driver(&thunderx_ocx_driver); - if (rc) - return rc; - - rc = pci_register_driver(&thunderx_l2c_driver); - if (rc) - goto err_ocx; - - return rc; -err_ocx: - pci_unregister_driver(&thunderx_ocx_driver); - - return rc; + return pci_register_driver(&thunderx_l2c_driver); } static void __exit thunderx_edac_exit(void) { pci_unregister_driver(&thunderx_l2c_driver); - pci_unregister_driver(&thunderx_ocx_driver); } diff --git a/drivers/soc/cavium/Kconfig b/drivers/soc/cavium/Kconfig index 46ded89..fe56503 100644 --- a/drivers/soc/cavium/Kconfig +++ b/drivers/soc/cavium/Kconfig @@ -4,3 +4,7 @@ config CAVIUM_LMC depends on ARCH_THUNDER def_tristate m + +config CAVIUM_OCX + depends on ARCH_THUNDER + def_tristate m diff --git a/drivers/soc/cavium/Makefile b/drivers/soc/cavium/Makefile index 4ad0c7f..bf7ba25 100644 --- a/drivers/soc/cavium/Makefile +++ b/drivers/soc/cavium/Makefile @@ -1 +1,2 @@ obj-$(CONFIG_CAVIUM_LMC) += cavium_lmc.o +obj-$(CONFIG_CAVIUM_OCX) += cavium_ocx.o diff --git a/drivers/soc/cavium/cavium_ocx.c b/drivers/soc/cavium/cavium_ocx.c new file mode 100644 index 0000000..fa3341b --- /dev/null +++ b/drivers/soc/cavium/cavium_ocx.c @@ -0,0 +1,45 @@ +/* + * 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_ocx_probe(struct pci_dev *pdev, + const struct pci_device_id *ent) +{ + if (IS_ENABLED(CONFIG_EDAC_THUNDERX)) + thunderx_edac_ocx_probe(pdev, ent); + return 0; +} + +static void cvm_ocx_remove(struct pci_dev *pdev) +{ + if (IS_ENABLED(CONFIG_EDAC_THUNDERX)) + thunderx_edac_ocx_remove(pdev); +} + +static const struct pci_device_id cvm_ocx_pci_table[] = { + { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, 0xa013) }, + { 0, }, +}; + +MODULE_DEVICE_TABLE(pci, cvm_ocx_pci_table); + +static struct pci_driver cvm_ocx_pci_driver = { + .name = "Cavium ThunderX interconnect", + .id_table = cvm_ocx_pci_table, + .probe = cvm_ocx_probe, + .remove = cvm_ocx_remove, +}; + +module_pci_driver(cvm_ocx_pci_driver); + +MODULE_LICENSE("GPL v2"); +MODULE_AUTHOR("Cavium, Inc."); +MODULE_DESCRIPTION("PCI driver for Cavium ThunderX interconnect"); diff --git a/include/linux/soc/cavium/ocx.h b/include/linux/soc/cavium/ocx.h new file mode 100644 index 0000000..29f55b3 --- /dev/null +++ b/include/linux/soc/cavium/ocx.h @@ -0,0 +1,9 @@ +#ifndef _OCX_H +#define _OCX_H + +#include + +int thunderx_edac_ocx_probe(struct pci_dev *pdev, const struct pci_device_id *ent); +void thunderx_edac_ocx_remove(struct pci_dev *pdev); + +#endif