Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1746181pxa; Thu, 20 Aug 2020 20:49:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxg/VBCOL9n3ixUDFQv2vad7CstbFsZwqPL6cT494lNbJC6xyvx724lxI4zu9thEBA3uUSn X-Received: by 2002:a17:906:2e09:: with SMTP id n9mr1121591eji.0.1597981743172; Thu, 20 Aug 2020 20:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597981743; cv=none; d=google.com; s=arc-20160816; b=RXQojW67dg53mZjOEbT6+iAlR7YhG9kHXmkUvPF9mYJUkft3hAWA7pcYUxqRHLJD5a ynccXSC2b/B1c1VJwmSPt0WvI2xel0bdYCYI+/JouskljOJEZHCvz4t0a2QWY/JSsU3i E+S7C6x4ViaMh75EyUIivFSapbXudiYWsNgmyH5IasmdL3tCTZloxtUMO3WRo2m2ICah rvqN+UuORLJCC3L+CRfgxhssD2estkLaDXv5FLiW1VSsqhn96z3apIEJpBnat5nQN1qH 0O6Zcdhe1Ox1PE7sVA5q1jSxMIojmvl2J/UwmUG+ntsj11Yzz4PrWGebua4UXed27dAY Hmkw== 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=JV5LYb+pQ/k/kmURgoFe8GIflpwBNk2ibnmax8Q8GeM=; b=oN/9kCKhvKaMvd3zE6AJxA8fnKMzaXnxWHAYaGUXek5tn/RJNXWTc2WXDJzg91nwQ5 KfPVqghAfo+n4gIOf9wNi+RYTHu5otSveoeyPEPpuoqa2/5J1B+nY5ux9VC/uXUjiPNs YUOVT23aj0/XCrMAlk5PGIozOMUSEY/XcF9/XebFJCBh1gEQOdniIcOCMn3NE2NCEGKS mjdaFyEkE0smwVX86sRkEVimMSWQYM1j/Hdj/xLUKV4teEMnJ7iJbVF/+ogoAs2lI0ku vE6q0wuiLBjMSLPcGoiuzGe5u+pw1GVHuuyf9o+59TW9c+zHu1kjQE7bKGzN1gzzuo73 C+Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=MmJiCzGL; 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 kt14si270277ejb.281.2020.08.20.20.48.39; Thu, 20 Aug 2020 20:49:03 -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=MmJiCzGL; 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 S1727841AbgHUDrR (ORCPT + 99 others); Thu, 20 Aug 2020 23:47:17 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:20819 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727820AbgHUDrG (ORCPT ); Thu, 20 Aug 2020 23:47:06 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597981625; h=Content-Transfer-Encoding: MIME-Version: References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=JV5LYb+pQ/k/kmURgoFe8GIflpwBNk2ibnmax8Q8GeM=; b=MmJiCzGL4eVGDxpbRn2dnBPKhKvuRHQo5aZki9Hus/qOmO+5p91WFBc4YlwSWM3we9UeAlwg yulNKoO0x/sus6A7LhRYX5lrpEMDC41rhW12xxO37kKtzK8cNYUo4BWwsJBQitHjMrXhrf3C f0FcL+2zHEUsgr9sf3G7GptTGiQ= 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-n05.prod.us-west-2.postgun.com with SMTP id 5f3f43b8797e7ddecc305d4e (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 21 Aug 2020 03:47:04 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 12A65C43395; Fri, 21 Aug 2020 03:47:04 +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 16E61C43391; Fri, 21 Aug 2020 03:46:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 16E61C43391 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: Tingwei Zhang , Greg Kroah-Hartman , Leo Yan , Randy Dunlap , Russell King , Kim Phillips , Mian Yousaf Kaukab , tsoni@codeaurora.org, Sai Prakash Ranjan , Mao Jinlong , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH v10 16/24] coresight: cti: add function to register cti associate ops Date: Fri, 21 Aug 2020 11:44:37 +0800 Message-Id: <20200821034445.967-17-tingwei@codeaurora.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20200821034445.967-1-tingwei@codeaurora.org> References: <20200821034445.967-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 Add static cti_assoc_ops to coresight core driver. Let cti driver register the add_assoc and remove_assoc call back. Avoid coresight core driver to depend on cti driver. Signed-off-by: Tingwei Zhang Tested-by: Mike Leach Reported-by: kernel test robot Reviewed-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-cti.c | 36 +++++++++++++++++--- drivers/hwtracing/coresight/coresight-priv.h | 14 ++++---- drivers/hwtracing/coresight/coresight.c | 21 ++++++++++-- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index 3ccc703dc940..b031c9dbe026 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -556,7 +556,7 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, * This will set the association if CTI declared before the CS device. * (called from coresight_register() with coresight_mutex locked). */ -void cti_add_assoc_to_csdev(struct coresight_device *csdev) +static void cti_add_assoc_to_csdev(struct coresight_device *csdev) { struct cti_drvdata *ect_item; struct cti_device *ctidev; @@ -589,13 +589,12 @@ void cti_add_assoc_to_csdev(struct coresight_device *csdev) cti_add_done: mutex_unlock(&ect_mutex); } -EXPORT_SYMBOL_GPL(cti_add_assoc_to_csdev); /* * Removing the associated devices is easier. * A CTI will not have a value for csdev->ect_dev. */ -void cti_remove_assoc_from_csdev(struct coresight_device *csdev) +static void cti_remove_assoc_from_csdev(struct coresight_device *csdev) { struct cti_drvdata *ctidrv; struct cti_trig_con *tc; @@ -616,7 +615,15 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev) } mutex_unlock(&ect_mutex); } -EXPORT_SYMBOL_GPL(cti_remove_assoc_from_csdev); + +/* + * Operations to add and remove associated CTI. + * Register to coresight core driver as call back function. + */ +static struct cti_assoc_op cti_assoc_ops = { + .add = cti_add_assoc_to_csdev, + .remove = cti_remove_assoc_from_csdev +}; /* * Update the cross references where the associated device was found @@ -972,4 +979,23 @@ static struct amba_driver cti_driver = { .probe = cti_probe, .id_table = cti_ids, }; -builtin_amba_driver(cti_driver); + +static int __init cti_init(void) +{ + int ret; + + ret = amba_driver_register(&cti_driver); + if (ret) + pr_info("Error registering cti driver\n"); + coresight_set_cti_ops(&cti_assoc_ops); + return ret; +} + +static void __exit cti_exit(void) +{ + coresight_remove_cti_ops(); + amba_driver_unregister(&cti_driver); +} + +module_init(cti_init); +module_exit(cti_exit); diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index dcb8aeb6af62..6cde6cf42554 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -173,15 +173,13 @@ static inline int etm_readl_cp14(u32 off, unsigned int *val) { return 0; } static inline int etm_writel_cp14(u32 off, u32 val) { return 0; } #endif -#ifdef CONFIG_CORESIGHT_CTI -extern void cti_add_assoc_to_csdev(struct coresight_device *csdev); -extern void cti_remove_assoc_from_csdev(struct coresight_device *csdev); +struct cti_assoc_op { + void (*add)(struct coresight_device *csdev); + void (*remove)(struct coresight_device *csdev); +}; -#else -static inline void cti_add_assoc_to_csdev(struct coresight_device *csdev) {} -static inline void -cti_remove_assoc_from_csdev(struct coresight_device *csdev) {} -#endif +extern void coresight_set_cti_ops(const struct cti_assoc_op *cti_op); +extern void coresight_remove_cti_ops(void); /* * Macros and inline functions to handle CoreSight UCI data and driver diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index b040d4421f84..c2174fed263b 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -56,6 +56,20 @@ static struct list_head *stm_path; const u32 coresight_barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff}; EXPORT_SYMBOL_GPL(coresight_barrier_pkt); +static const struct cti_assoc_op *cti_assoc_ops; + +void coresight_set_cti_ops(const struct cti_assoc_op *cti_op) +{ + cti_assoc_ops = cti_op; +} +EXPORT_SYMBOL_GPL(coresight_set_cti_ops); + +void coresight_remove_cti_ops(void) +{ + cti_assoc_ops = NULL; +} +EXPORT_SYMBOL_GPL(coresight_remove_cti_ops); + static int coresight_id_match(struct device *dev, void *data) { int trace_id, i_trace_id; @@ -1240,7 +1254,8 @@ static void coresight_device_release(struct device *dev) { struct coresight_device *csdev = to_coresight_device(dev); - cti_remove_assoc_from_csdev(csdev); + if (cti_assoc_ops && cti_assoc_ops->remove) + cti_assoc_ops->remove(csdev); fwnode_handle_put(csdev->dev.fwnode); kfree(csdev->refcnt); kfree(csdev); @@ -1551,8 +1566,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) ret = coresight_fixup_device_conns(csdev); if (!ret) ret = coresight_fixup_orphan_conns(csdev); - if (!ret) - cti_add_assoc_to_csdev(csdev); + if (!ret && cti_assoc_ops && cti_assoc_ops->add) + cti_assoc_ops->add(csdev); mutex_unlock(&coresight_mutex); if (ret) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project