From patchwork Mon Sep 28 16:35:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11804085 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C5026CB for ; Mon, 28 Sep 2020 16:40:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6EFA32080C for ; Mon, 28 Sep 2020 16:40:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3YTuc6Yv"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="rrpGDK1P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EFA32080C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=mIRImkNJWTux7cte31C7i9QS/PYJUU9co2SA6e/Y6aU=; b=3YTuc6YvmtIi2M5iAHmWPE3P8 7P7TxgaO58ePV5igvhwHwsZOQyXe0YoEvJtCIcwvmxDXo2nq+pbXdLix+s0b9r6fRthnI4Q2Teeep J3JFdjWaPYNsZmUXyCFllhQ1nap6EAjHmm6ufXrecr7fFuAfY9llvrSDD698EPaklitW747WKbM8G tcCbyFT0J+aJwLIqKgqKqF+ZXRz8+STey2/yEm9O9oa/BYbnqfjqZa9jWyT69pFwR9+tsx0LlK0LD 2tnTU/JdIY0aKjd8VpOvPdidOxpvxCuYK5cQBLpo2/pgq2HKSkLGHEyePYmdbCujEuw8hrbLPWJz6 oz4+d6eUA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMwBo-0002E7-2Y; Mon, 28 Sep 2020 16:39:48 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMw7g-0000bk-Mo for linux-arm-kernel@lists.infradead.org; Mon, 28 Sep 2020 16:35:38 +0000 Received: by mail-pf1-x443.google.com with SMTP id d9so1531463pfd.3 for ; Mon, 28 Sep 2020 09:35:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XIx91CccDaMdjV0kYj3bzRvAnnTG3Y6NVqg6FhgtymQ=; b=rrpGDK1PuYY26QV/Qus8zZSUEzEBSvGPLngFW0TycgAyGD79W5dMo5/vXMLrEbUD41 I2ZBHj7Gjlf68vM/vDyCkHh//H+n3mYuJYzcIaHhbPHWUsYCAT+2F5V4+aNP2jk9rMQs w2KUFCOlcOgqH6EodqIa3EReq8joBWWZSLWgLJz7wmUsXrclUgwws68zy/Taw4mPnrzt GulDmVJcEcKiIWdzYmrfu6UqTlEC0AFWPDziF/D9psjPyxrDBZGHvIQE5Y1xInQUFSXV z9wslKx3T7Xm+TnC1avXJGh2b+veo8PJdxKa8N2aljQbglb3FiRvGB/hoCGWlfIj+dwq IUPA== 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:mime-version:content-transfer-encoding; bh=XIx91CccDaMdjV0kYj3bzRvAnnTG3Y6NVqg6FhgtymQ=; b=uQ5O4VN7cREEbvWjmWnX6JLRIR0Qf0Gnsj/CMWUGWu00xZcAVNzY2pw7vPkDMqt/xK S1/6S0bVYv1uV11rnAHtDKEmCs3LMeI1wqYpGPUtMFPeTIamUDhicSS8hvK2bpRiyKti b+WQ3d+4o8dWOtes/h54EOLbxCJoGfbu+kD5InrejB1KiHxoUyDvACnIdHih/iQEi0XH lMg+UQdGX5KvyxaKswrLSAaWLLLnjxB7ZhjaBft2AuakWoKrZT0s8IY7m4VXUHKGQ1FV HvlU3eByRjjy+hFADKRXPDp2LyeSiROL2+Ip+YSdLCS7sBPWqF+q4Xmu936/W9oguH8B c2Rw== X-Gm-Message-State: AOAM532YCZXkQPL6xOqzf5Zbl+/QmaPjFBDzdmqqmBtUz0CzzVtXJQbr YyBjjswbUOcXCnYCF2i3KpxQ4w== X-Google-Smtp-Source: ABdhPJxjBK1zCvQQ8uD6VTpZqiRhqtDxs2lAKFsh4876s8nAKwAUjuZQHqZOEg200ziiFRoqSmPqwQ== X-Received: by 2002:a17:902:a407:b029:d2:2113:7f8f with SMTP id p7-20020a170902a407b02900d221137f8fmr360285plq.70.1601310930991; Mon, 28 Sep 2020 09:35:30 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id f19sm2345640pfd.45.2020.09.28.09.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:35:30 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 15/25] coresight: replicator: Allow replicator driver to be built as module Date: Mon, 28 Sep 2020 10:35:03 -0600 Message-Id: <20200928163513.70169-16-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200928163513.70169-1-mathieu.poirier@linaro.org> References: <20200928163513.70169-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200928_123532_816097_018763E5 X-CRM114-Status: GOOD ( 21.54 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:443 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Kim Phillips Allow to build coresight-replicator as modules, for ease of development. - Kconfig becomes a tristate, to allow =m - combine static and dynamic replicator init into single module_init/exit call - add replicator_remove functions, 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 Co-developed-by: Mian Yousaf Kaukab Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Tingwei Zhang Tested-by: Mike Leach Reviewed-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/Kconfig | 5 +- .../coresight/coresight-replicator.c | 65 ++++++++++++++++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig index fc48ae086746..f31778dd0b5d 100644 --- a/drivers/hwtracing/coresight/Kconfig +++ b/drivers/hwtracing/coresight/Kconfig @@ -17,13 +17,16 @@ menuconfig CORESIGHT if CORESIGHT config CORESIGHT_LINKS_AND_SINKS - bool "CoreSight Link and Sink drivers" + tristate "CoreSight Link and Sink drivers" help This enables support for CoreSight link and sink drivers that are responsible for transporting and collecting the trace data respectively. Link and sinks are dynamically aggregated with a trace entity at run time to form a complete trace path. + To compile these drivers as modules, choose M here: the + modules will be called coresight-funnel and coresight-replicator. + config CORESIGHT_LINK_AND_SINK_TMC tristate "Coresight generic TMC driver" diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c index 78acf29c49ca..62afdde0e5ea 100644 --- a/drivers/hwtracing/coresight/coresight-replicator.c +++ b/drivers/hwtracing/coresight/coresight-replicator.c @@ -291,6 +291,14 @@ static int replicator_probe(struct device *dev, struct resource *res) return ret; } +static int __exit replicator_remove(struct device *dev) +{ + struct replicator_drvdata *drvdata = dev_get_drvdata(dev); + + coresight_unregister(drvdata->csdev); + return 0; +} + static int static_replicator_probe(struct platform_device *pdev) { int ret; @@ -310,6 +318,13 @@ static int static_replicator_probe(struct platform_device *pdev) return ret; } +static int __exit static_replicator_remove(struct platform_device *pdev) +{ + replicator_remove(&pdev->dev); + pm_runtime_disable(&pdev->dev); + return 0; +} + #ifdef CONFIG_PM static int replicator_runtime_suspend(struct device *dev) { @@ -343,24 +358,29 @@ static const struct of_device_id static_replicator_match[] = { {} }; +MODULE_DEVICE_TABLE(of, static_replicator_match); + #ifdef CONFIG_ACPI static const struct acpi_device_id static_replicator_acpi_ids[] = { {"ARMHC985", 0}, /* ARM CoreSight Static Replicator */ {} }; + +MODULE_DEVICE_TABLE(acpi, static_replicator_acpi_ids); #endif static struct platform_driver static_replicator_driver = { .probe = static_replicator_probe, + .remove = static_replicator_remove, .driver = { .name = "coresight-static-replicator", + .owner = THIS_MODULE, .of_match_table = of_match_ptr(static_replicator_match), .acpi_match_table = ACPI_PTR(static_replicator_acpi_ids), .pm = &replicator_dev_pm_ops, .suppress_bind_attrs = true, }, }; -builtin_platform_driver(static_replicator_driver); static int dynamic_replicator_probe(struct amba_device *adev, const struct amba_id *id) @@ -368,19 +388,60 @@ static int dynamic_replicator_probe(struct amba_device *adev, return replicator_probe(&adev->dev, &adev->res); } +static int __exit dynamic_replicator_remove(struct amba_device *adev) +{ + return replicator_remove(&adev->dev); +} + static const struct amba_id dynamic_replicator_ids[] = { CS_AMBA_ID(0x000bb909), CS_AMBA_ID(0x000bb9ec), /* Coresight SoC-600 */ {}, }; +MODULE_DEVICE_TABLE(amba, dynamic_replicator_ids); + static struct amba_driver dynamic_replicator_driver = { .drv = { .name = "coresight-dynamic-replicator", .pm = &replicator_dev_pm_ops, + .owner = THIS_MODULE, .suppress_bind_attrs = true, }, .probe = dynamic_replicator_probe, + .remove = dynamic_replicator_remove, .id_table = dynamic_replicator_ids, }; -builtin_amba_driver(dynamic_replicator_driver); + +static int __init replicator_init(void) +{ + int ret; + + ret = platform_driver_register(&static_replicator_driver); + if (ret) { + pr_info("Error registering platform driver\n"); + return ret; + } + + ret = amba_driver_register(&dynamic_replicator_driver); + if (ret) { + pr_info("Error registering amba driver\n"); + platform_driver_unregister(&static_replicator_driver); + } + + return ret; +} + +static void __exit replicator_exit(void) +{ + platform_driver_unregister(&static_replicator_driver); + amba_driver_unregister(&dynamic_replicator_driver); +} + +module_init(replicator_init); +module_exit(replicator_exit); + +MODULE_AUTHOR("Pratik Patel "); +MODULE_AUTHOR("Mathieu Poirier "); +MODULE_DESCRIPTION("Arm CoreSight Replicator Driver"); +MODULE_LICENSE("GPL v2");