From patchwork Tue Jun 5 21:07:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Phillips X-Patchwork-Id: 10449267 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 B6E8C60234 for ; Tue, 5 Jun 2018 21:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83FC29CCA for ; Tue, 5 Jun 2018 21:15:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B91229CCF; Tue, 5 Jun 2018 21:15:30 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 3030429CCA for ; Tue, 5 Jun 2018 21:15:30 +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=zHNXvZ8V7SU4cx5TBF8YoywoZxe0Tefcfp3cQRyams4=; b=ZGwm0T3z8yb987kgbKSNYEcHRd jiU1r8DBCSdjKJMcMOQ+QF73eRdVErlczV4qXBTFuoCCwECd82HNIr7nV1NzOH0kZICnsqFtby8kR WCg9y0FZdCUYBs1zmWdhpwHAtsDdwJip1NuF3Z257V5ezL4Bi1aCx+FQxLInJdMKaOs8hq604S0/e pYIof4jw+nS9gyi65DbWrdSe2/sEBbQrknWXhXX8LllGXzgzGSOV6IXXD2k2CPXsiaeYVp+c8uq2E AWtYm8yPz+CdeiA6+QMl/1LVUbAPNnrNLMumMAdMuHjy1FFJzSokPGPFFJNNmrUCoVesKVUaGFad4 bgFe2Rgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQJIV-0005QN-JX; Tue, 05 Jun 2018 21:15:19 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQJBP-0007sz-PX for linux-arm-kernel@lists.infradead.org; Tue, 05 Jun 2018 21:08:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 74AD016EA; Tue, 5 Jun 2018 14:07:49 -0700 (PDT) Received: from localhost.localdomain (unknown [10.118.17.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5DF013F59D; Tue, 5 Jun 2018 14:07:48 -0700 (PDT) From: Kim Phillips To: Mathieu Poirier Subject: [PATCH v4 14/14] coresight: allow the coresight core driver to be built as a module Date: Tue, 5 Jun 2018 16:07:10 -0500 Message-Id: <20180605210710.22227-15-kim.phillips@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605210710.22227-1-kim.phillips@arm.com> References: <20180605210710.22227-1-kim.phillips@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180605_140800_032035_3F9FFEC8 X-CRM114-Status: GOOD ( 17.57 ) 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: Kefeng Wang , Kim Phillips , Geert Uytterhoeven , Alexander Shishkin , Gargi Sharma , David Howells , Russell King , Pavel Tatashin , Thierry Reding , Rik van Riel , Suzuki K Poulose , Eric Auger , Alex Williamson , Mike Rapoport , linux-arm-kernel , Greg Kroah-Hartman , Randy Dunlap , Oleg Nesterov , Linux Kernel Mailing List , Kirill Tkhai , Eric Biederman , Leo Yan , Andrew Morton , Robin Murphy , Todd Kjos 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 Allow to build coresight as a module. This enhances coresight developer efficiency by allowing the development to take place exclusively on the target, and without needing to reboot in between changes. - Kconfig becomes a tristate, to allow =m - append -core to source file name to allow module to be called coresight by the Makefile - modules can have only one init/exit, so we add the core bus register/unregister function calls to the etm_perf init/exit functions, since coresight.c does not have etm_pmu defined. - add a MODULE_DEVICE_TABLE for autoloading on boot Cc: Mathieu Poirier Cc: Leo Yan Cc: Alexander Shishkin Cc: Randy Dunlap Cc: Suzuki K Poulose Cc: Greg Kroah-Hartman Cc: Russell King Signed-off-by: Kim Phillips --- drivers/hwtracing/coresight/Kconfig | 5 ++++- drivers/hwtracing/coresight/Makefile | 7 +++++-- .../coresight/{coresight.c => coresight-core.c} | 6 ------ .../hwtracing/coresight/coresight-etm-perf.c | 17 ++++++++++++++++- 4 files changed, 25 insertions(+), 10 deletions(-) rename drivers/hwtracing/coresight/{coresight.c => coresight-core.c} (99%) diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig index 181a44ea2d61..c05b265f7731 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -2,7 +2,7 @@ # Coresight configuration # menuconfig CORESIGHT - bool "CoreSight Tracing Support" + tristate "CoreSight Tracing Support" select ARM_AMBA select PERF_EVENTS help @@ -12,6 +12,9 @@ menuconfig CORESIGHT specification and configure the right series of components when a trace source gets enabled. + To compile this driver as a module, choose M here: the + module will be called coresight. + if CORESIGHT config CORESIGHT_LINKS_AND_SINKS tristate "CoreSight Link and Sink drivers" diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 45d7a0f34170..ed2d4bcb017b 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -2,8 +2,11 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o -obj-$(CONFIG_OF) += of_coresight.o +obj-$(CONFIG_CORESIGHT) += coresight.o +coresight-objs := coresight-core.o coresight-etm-perf.o +ifeq ($(CONFIG_OF), y) +coresight-objs += of_coresight.o +endif obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-objs := coresight-tmc-core.o coresight-tmc-etf.o \ coresight-tmc-etr.o diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight-core.c similarity index 99% rename from drivers/hwtracing/coresight/coresight.c rename to drivers/hwtracing/coresight/coresight-core.c index 1c941351f1d1..f96258de1e9b 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -948,12 +948,6 @@ struct bus_type coresight_bustype = { .name = "coresight", }; -static int __init coresight_init(void) -{ - return bus_register(&coresight_bustype); -} -postcore_initcall(coresight_init); - struct coresight_device *coresight_register(struct coresight_desc *desc) { int i; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 0fe7e43ea1c4..ceac9aee4a82 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -472,6 +472,10 @@ static int __init etm_perf_init(void) { int ret; + ret = bus_register(&coresight_bustype); + if (ret) + return ret; + etm_pmu.capabilities = PERF_PMU_CAP_EXCLUSIVE; etm_pmu.attr_groups = etm_pmu_attr_groups; @@ -494,4 +498,15 @@ static int __init etm_perf_init(void) return ret; } -device_initcall(etm_perf_init); +postcore_initcall(etm_perf_init); + +static void __exit etm_perf_exit(void) +{ + perf_pmu_unregister(&etm_pmu); + bus_unregister(&coresight_bustype); +} +module_exit(etm_perf_exit); + +MODULE_AUTHOR("Mathieu Poirier "); +MODULE_DESCRIPTION("Arm CoreSight tracer driver"); +MODULE_LICENSE("GPL v2");