Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp19218imm; Tue, 5 Jun 2018 14:13:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICmTjBcHStya/d+f7lyiCgbbnHe5UDXZX5hCJcCRfS32iwJlBrLy0UWs7LwK2QtVQW7BDS X-Received: by 2002:a17:902:8a:: with SMTP id a10-v6mr248747pla.89.1528233229942; Tue, 05 Jun 2018 14:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528233229; cv=none; d=google.com; s=arc-20160816; b=HpFjzJ6bumZgUretT0lcXHfWLdCZVtOOPpydt1S/kPGTim7n2gbPZS4N1sYX72gZhm aJMLSdcimmDrOpo/HYT9r2u6HuGOdCNuvcrYeIpSFKiezNvF1P/ApEdtviY3eUlo/22m 6cVe/GXKh474nrbBDM688i1fKULStLvfBufRRdmKNHOaQewOD2vp9itFsfkuSY9Mxu+U yz0Pv2RCv38+qrw4WZW4Tt0r6zzra6V5B5L+RkTKHE73vBXHDL7d2lhYQwNEf4XLkRBb z8oQ4lH+FieM/2QRKlfo5GqggbH+Q//9x/vw2fCMMCWXRN8W9IU9q4STwpwGdmVhhU0h K+Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=vYzk56lczmEMnsPCjwCyp3zdZGnTE413l9k7zkkdGZI=; b=OOcaMkQz4Dlu/SM4bUoaRo//hYBt1pJzvkRQF+o0poSui5RDDLmtiNaBMy+LU+BPTS Lq/h+BFz1q1ax331JVX6zeQPFlxVb5DcHg0lzneN6iX0bjHufMlOEEUpCs6WUaeV2gkv Eb1OSBMMySxmYC21FgnOO3fWczT32hLmKai0FQEVBpCBZgYzf/wMlpIJHv55hQJ778zf SEzAStmoYxn8zj1W25CqmJeQOCBbATaqaX76Acfamc3qkiXSaBNwd3k/0eoZW0viZxod Q02NI21q5EBfMYfWx7YOhQB+rbMXVHSKj1nUeFTg6P80aaRF/gH7gu0xKUET7aTk5z9Q +NTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 38-v6si3117497pln.390.2018.06.05.14.13.30; Tue, 05 Jun 2018 14:13:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752769AbeFEVLO (ORCPT + 99 others); Tue, 5 Jun 2018 17:11:14 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33642 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751951AbeFEVHr (ORCPT ); Tue, 5 Jun 2018 17:07:47 -0400 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 2F99316A3; Tue, 5 Jun 2018 14:07:47 -0700 (PDT) Received: from localhost.localdomain (unknown [10.118.17.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 181633F59D; Tue, 5 Jun 2018 14:07:46 -0700 (PDT) From: Kim Phillips To: Mathieu Poirier Cc: Leo Yan , Suzuki K Poulose , Greg Kroah-Hartman , Alexander Shishkin , Alex Williamson , Andrew Morton , David Howells , Eric Auger , Eric Biederman , Gargi Sharma , Geert Uytterhoeven , Kefeng Wang , Kirill Tkhai , Mike Rapoport , Oleg Nesterov , Pavel Tatashin , Rik van Riel , Robin Murphy , Russell King , Thierry Reding , Todd Kjos , Randy Dunlap , linux-arm-kernel , Linux Kernel Mailing List , Kim Phillips Subject: [PATCH v4 12/14] coresight: allow tmc to be built as a module Date: Tue, 5 Jun 2018 16:07:08 -0500 Message-Id: <20180605210710.22227-13-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow to build coresight-tmc as a module, for ease of development. - Kconfig becomes a tristate, to allow =m - append -core to source file name to allow module to be called coresight-tmc by the Makefile - add an tmc_remove function, for module unload - 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 | 6 ++--- .../{coresight-tmc.c => coresight-tmc-core.c} | 22 ++++++++++++++++++- 3 files changed, 28 insertions(+), 5 deletions(-) rename drivers/hwtracing/coresight/{coresight-tmc.c => coresight-tmc-core.c} (95%) diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig index 2f44adb82361..ae05b4b89ff9 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -22,7 +22,7 @@ config CORESIGHT_LINKS_AND_SINKS entity at run time to form a complete trace path. config CORESIGHT_LINK_AND_SINK_TMC - bool "Coresight generic TMC driver" + tristate "Coresight generic TMC driver" depends on CORESIGHT_LINKS_AND_SINKS help This enables support for the Trace Memory Controller driver. @@ -31,6 +31,9 @@ config CORESIGHT_LINK_AND_SINK_TMC complies with the generic implementation of the component without special enhancement or added features. + To compile this driver as a module, choose M here: the + module will be called coresight-tmc. + config CORESIGHT_SINK_TPIU tristate "Coresight generic TPIU driver" depends on CORESIGHT_LINKS_AND_SINKS diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 1623ed266b04..45d7a0f34170 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -4,9 +4,9 @@ # obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o obj-$(CONFIG_OF) += of_coresight.o -obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o \ - coresight-tmc-etf.o \ - coresight-tmc-etr.o +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 obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o obj-$(CONFIG_CORESIGHT_SINK_ETBV10) += coresight-etb10.o obj-$(CONFIG_CORESIGHT_LINKS_AND_SINKS) += coresight-funnel.o \ diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc-core.c similarity index 95% rename from drivers/hwtracing/coresight/coresight-tmc.c rename to drivers/hwtracing/coresight/coresight-tmc-core.c index 1b817ec1192c..ec4867b81be8 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c @@ -474,6 +474,19 @@ static int tmc_probe(struct amba_device *adev, const struct amba_id *id) return ret; } +static int __exit tmc_remove(struct amba_device *adev) +{ + struct tmc_drvdata *drvdata = dev_get_drvdata(&adev->dev); + + /* free ETB/ETF or ETR memory */ + tmc_read_unprepare(drvdata); + + misc_deregister(&drvdata->miscdev); + coresight_unregister(drvdata->csdev); + + return 0; +} + static const struct amba_id tmc_ids[] = { { .id = 0x000bb961, @@ -498,6 +511,8 @@ static const struct amba_id tmc_ids[] = { { 0, 0}, }; +MODULE_DEVICE_TABLE(amba, tmc_ids); + static struct amba_driver tmc_driver = { .drv = { .name = "coresight-tmc", @@ -505,6 +520,11 @@ static struct amba_driver tmc_driver = { .suppress_bind_attrs = true, }, .probe = tmc_probe, + .remove = tmc_remove, .id_table = tmc_ids, }; -builtin_amba_driver(tmc_driver); +module_amba_driver(tmc_driver); + +MODULE_AUTHOR("Pratik Patel "); +MODULE_DESCRIPTION("Arm CoreSight Trace Memory Controller driver"); +MODULE_LICENSE("GPL v2"); -- 2.17.0