Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp995658pxa; Wed, 19 Aug 2020 22:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN2wVtTO6ikEgkwICs0hkhnnGQjdPYZO1642O8QrfCqJzoXozNt1PDerrwc+94Ecs93u18 X-Received: by 2002:a50:bf08:: with SMTP id f8mr1307619edk.207.1597902898868; Wed, 19 Aug 2020 22:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597902898; cv=none; d=google.com; s=arc-20160816; b=JJy9QvAKhhJ4kqRb/bAk3yGZff27j0UQ9uRusRRwtg1OTXYi7z7G+wOPs+r87QFRgr biuO+zRegeTk51eSaqOQ2wCF0Bx1MhFPFXFwRcltbiL8GL0x7moBrtbE6+LjTyXKxp8Z biUamsXyBDAWLn9FaTrbm+DCNSlwYN7J9XSLmmsevwo3fcU45LtHv49O5d61lbXdaK42 V4E3TjkD9lBqDWNOm0Tp1CI/ADIIitp1/cRWWfYY7c/bK5Rf8zhCwgnBA8TSZB3/zF81 EicvG4aZm3NBe22PUksrSFLkuBm3oJhq1J09pIgjgZTuw6pH/LXvVP5cLiSZkVcFTDe/ UEmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=MVSR5eo3ekzMPEuamuESKWHSSG+RGv5XuMCArPFpmFo=; b=LCVzT5Fxi4xsISYYxcEib/xzcr4TGDtZOA1syHpfmBCwoSkVzEgF4N3ZaK891cfNhe lboa2+yQE3lsI4YSG5Fpgb22/LRTWIAsvlL89o2x54XT6siWNKToFk5JvFsK5Yq4BvPe rWo4Agf1/UQZHiYtMRJw+lcGlyg8LGy7n9AQ+7LlReJHx4NiAMiOQT2rzbXAVQYymUhP gzBmko6HiJl9Kn6jOLWClW4kkf0TbpTzP1Y2SpfIKfnRQ1gaOhy1r+OEUu7yuBfu4ddv tbBXg8GV3LryBymIyVAiLnuf0yrEXZg32SuRmxoxRKL9VkvIgIEjNsGKghi4lZmykN2x DpVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=kSs9AFV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si436408ejr.323.2020.08.19.22.54.35; Wed, 19 Aug 2020 22:54:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=kSs9AFV8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727831AbgHTFvY (ORCPT + 99 others); Thu, 20 Aug 2020 01:51:24 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:57742 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727033AbgHTFvX (ORCPT ); Thu, 20 Aug 2020 01:51:23 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597902683; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=MVSR5eo3ekzMPEuamuESKWHSSG+RGv5XuMCArPFpmFo=; b=kSs9AFV8/jfAflWpNsjJTQRhISpumjsPQmI2kLKLeiXXCYCF8lZA38DVNGoN5yTEZDDI3RzK wyOEVz53DqIazn36wZp2NtfJ9nu2J2ebb2ZS8BNMPht03xX27I3GqzMMH3s/XiO4eQCOCfDy NIDKnjUyHS03foTsk6kMwFgUp5U= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-west-2.postgun.com with SMTP id 5f3e0f5ae8bbfbec10d39c63 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 20 Aug 2020 05:51:22 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7C63BC433AD; Thu, 20 Aug 2020 05:51:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from tingweiz-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tingwei) by smtp.codeaurora.org (Postfix) with ESMTPSA id 33267C433BA; Thu, 20 Aug 2020 05:51:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 33267C433BA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=tingwei@codeaurora.org From: Tingwei Zhang To: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Mike Leach Cc: Mian Yousaf Kaukab , Greg Kroah-Hartman , Leo Yan , Randy Dunlap , Russell King , Kim Phillips , tsoni@codeaurora.org, Sai Prakash Ranjan , Mao Jinlong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Tingwei Zhang Subject: [PATCH v9 22/24] coresight: tmc-etr: add function to register catu ops Date: Thu, 20 Aug 2020 13:47:16 +0800 Message-Id: <20200820054718.20115-23-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200820054718.20115-1-tingwei@codeaurora.org> References: <20200820054718.20115-1-tingwei@codeaurora.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mian Yousaf Kaukab Make etr_catu_buf_ops static. Instead of directly accessing it in etr_buf_ops[], add a function to let catu driver register the ops at runtime. Break circular dependency between tmc-etr and catu drivers. Signed-off-by: Mian Yousaf Kaukab Signed-off-by: Tingwei Zhang Reviewed-by: Suzuki K Poulose Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-catu.c | 22 +++++++++++++++++-- drivers/hwtracing/coresight/coresight-catu.h | 2 -- .../hwtracing/coresight/coresight-tmc-etr.c | 15 +++++++++++-- drivers/hwtracing/coresight/coresight-tmc.h | 3 +++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 1801804a7762..47696a7d24a7 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -358,7 +358,7 @@ static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata, return 0; } -const struct etr_buf_operations etr_catu_buf_ops = { +static const struct etr_buf_operations etr_catu_buf_ops = { .alloc = catu_alloc_etr_buf, .free = catu_free_etr_buf, .sync = catu_sync_etr_buf, @@ -582,4 +582,22 @@ static struct amba_driver catu_driver = { .id_table = catu_ids, }; -builtin_amba_driver(catu_driver); +static int __init catu_init(void) +{ + int ret; + + ret = amba_driver_register(&catu_driver); + if (ret) + pr_info("Error registering catu driver\n"); + tmc_etr_set_catu_ops(&etr_catu_buf_ops); + return ret; +} + +static void __exit catu_exit(void) +{ + tmc_etr_remove_catu_ops(); + amba_driver_unregister(&catu_driver); +} + +module_init(catu_init); +module_exit(catu_exit); diff --git a/drivers/hwtracing/coresight/coresight-catu.h b/drivers/hwtracing/coresight/coresight-catu.h index 80ceee3c739c..6160c2d75a56 100644 --- a/drivers/hwtracing/coresight/coresight-catu.h +++ b/drivers/hwtracing/coresight/coresight-catu.h @@ -108,6 +108,4 @@ static inline bool coresight_is_catu_device(struct coresight_device *csdev) return true; } -extern const struct etr_buf_operations etr_catu_buf_ops; - #endif diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index ad991a37e2d2..714f9e867e5f 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -794,10 +794,21 @@ static inline void tmc_etr_disable_catu(struct tmc_drvdata *drvdata) static const struct etr_buf_operations *etr_buf_ops[] = { [ETR_MODE_FLAT] = &etr_flat_buf_ops, [ETR_MODE_ETR_SG] = &etr_sg_buf_ops, - [ETR_MODE_CATU] = IS_ENABLED(CONFIG_CORESIGHT_CATU) - ? &etr_catu_buf_ops : NULL, + [ETR_MODE_CATU] = NULL, }; +void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu) +{ + etr_buf_ops[ETR_MODE_CATU] = catu; +} +EXPORT_SYMBOL_GPL(tmc_etr_set_catu_ops); + +void tmc_etr_remove_catu_ops(void) +{ + etr_buf_ops[ETR_MODE_CATU] = NULL; +} +EXPORT_SYMBOL_GPL(tmc_etr_remove_catu_ops); + static inline int tmc_etr_mode_alloc_buf(int mode, struct tmc_drvdata *drvdata, struct etr_buf *etr_buf, int node, diff --git a/drivers/hwtracing/coresight/coresight-tmc.h b/drivers/hwtracing/coresight/coresight-tmc.h index 6e8d2dc33d17..b91ec7dde7bc 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.h +++ b/drivers/hwtracing/coresight/coresight-tmc.h @@ -326,4 +326,7 @@ tmc_sg_table_buf_size(struct tmc_sg_table *sg_table) struct coresight_device *tmc_etr_get_catu_device(struct tmc_drvdata *drvdata); +void tmc_etr_set_catu_ops(const struct etr_buf_operations *catu); +void tmc_etr_remove_catu_ops(void); + #endif -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project