From patchwork Mon Nov 16 21:44:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishabh Bhatnagar X-Patchwork-Id: 11910909 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDD9CC6379F for ; Mon, 16 Nov 2020 21:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 683D32225B for ; Mon, 16 Nov 2020 21:45:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="Nq26B6U8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729882AbgKPVpD (ORCPT ); Mon, 16 Nov 2020 16:45:03 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:10732 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729913AbgKPVpD (ORCPT ); Mon, 16 Nov 2020 16:45:03 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605563102; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=+zEDTiLq7GfQV55evuzjiO5PkHq5EWyk6PMHJKtc7kk=; b=Nq26B6U8p1nvKCyp1bZvQ/qmNnFZxTgzQGC4XsDqJdtMIA8pdykGPPpIb72niSLbx3yIhOwT mBXaQLgiq4DihpOQCD0k2R9hIWtAHGOXxqif19+6LvabTdRKYQis+kzmivKoQVI5a2Sv93Hx jGWhBZ10J/U0Zsvd+1xPs5Ra9zg= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI4ZWZiZiIsICJsaW51eC1yZW1vdGVwcm9jQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n09.prod.us-east-1.postgun.com with SMTP id 5fb2f2d4d6e6336a4ec39ed4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 16 Nov 2020 21:44:52 GMT Sender: rishabhb=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4C24FC43462; Mon, 16 Nov 2020 21:44:51 +0000 (UTC) Received: from rishabhb-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rishabhb) by smtp.codeaurora.org (Postfix) with ESMTPSA id 75389C43460; Mon, 16 Nov 2020 21:44:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 75389C43460 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=fail smtp.mailfrom=rishabhb@codeaurora.org From: Rishabh Bhatnagar To: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bjorn.andersson@linaro.org, tsoni@codeaurora.org, psodagud@codeaurora.org, sidgup@codeaurora.org, Rishabh Bhatnagar Subject: [PATCH v2 1/3] soc: qcom: Add tracepoints to mdt loader Date: Mon, 16 Nov 2020 13:44:42 -0800 Message-Id: <1605563084-30385-2-git-send-email-rishabhb@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> References: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add trace events to the mdt loader driver. These events can help us trace the region where we are loading the segments and the time it takes to initialize the image and setup the memory region. Signed-off-by: Rishabh Bhatnagar --- drivers/soc/qcom/mdt_loader.c | 7 +++++++ include/trace/events/mdt_loader.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 include/trace/events/mdt_loader.h diff --git a/drivers/soc/qcom/mdt_loader.c b/drivers/soc/qcom/mdt_loader.c index 24cd193..96dc912 100644 --- a/drivers/soc/qcom/mdt_loader.c +++ b/drivers/soc/qcom/mdt_loader.c @@ -17,6 +17,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + static bool mdt_phdr_valid(const struct elf32_phdr *phdr) { if (phdr->p_type != PT_LOAD) @@ -198,6 +201,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, if (pas_init) { ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr); + if (ret) { dev_err(dev, "unable to setup relocation\n"); goto out; @@ -232,6 +236,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, ptr = mem_region + offset; + if (phdr->p_filesz && phdr->p_offset < fw->size) { /* Firmware is large enough to be non-split */ if (phdr->p_offset + phdr->p_filesz > fw->size) { @@ -256,6 +261,8 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw, release_firmware(seg_fw); } + trace_qcom_mdt_load_segment(mem_phys + offset, phdr->p_filesz, + fw_name); if (phdr->p_memsz > phdr->p_filesz) memset(ptr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); } diff --git a/include/trace/events/mdt_loader.h b/include/trace/events/mdt_loader.h new file mode 100644 index 0000000..01c2461 --- /dev/null +++ b/include/trace/events/mdt_loader.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2020, The Linux Foundation. All rights reserved. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM mdt_loader + +#if !defined(_TRACE_MDT_LOADER_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_MDT_LOADER_H + +#include +#include + +TRACE_EVENT(qcom_mdt_load_segment, + + TP_PROTO(phys_addr_t region_start, size_t region_size, const char *fw), + + TP_ARGS(region_start, region_size, fw), + + TP_STRUCT__entry( + __field(phys_addr_t, region_start) + __field(size_t, region_size) + __string(fw, fw) + ), + + TP_fast_assign( + __entry->region_start = region_start; + __entry->region_size = region_size; + __assign_str(fw, fw); + ), + + TP_printk("firmware:%s region start=%pa size=%zx", + __get_str(fw), __entry->region_start, __entry->region_size) +); + +#endif +#include From patchwork Mon Nov 16 21:44:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishabh Bhatnagar X-Patchwork-Id: 11910905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4879CC63798 for ; Mon, 16 Nov 2020 21:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7F252225B for ; Mon, 16 Nov 2020 21:45:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="e2hM8o7h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729977AbgKPVoz (ORCPT ); Mon, 16 Nov 2020 16:44:55 -0500 Received: from m42-4.mailgun.net ([69.72.42.4]:10732 "EHLO m42-4.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726235AbgKPVox (ORCPT ); Mon, 16 Nov 2020 16:44:53 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605563092; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=KOp6edaSdp4EA6F1wsybQ0yhLlIQtFM9uSCrsTJodEI=; b=e2hM8o7hn/RuqMwBjXU+mKedbIGwcu60Oly8eH+sqpVRD1ZZMnHMDqBmCzMjJqXoVHFkW6BL TpaD13fIu2Dxo94Ml1Zvi9lyom10xldxeib2d1S5YkAcFLfWeqq9bZzwWL7IW48OD0zueMjF i8WgPKA9SyAxskGpsRPwWUH+uak= X-Mailgun-Sending-Ip: 69.72.42.4 X-Mailgun-Sid: WyI4ZWZiZiIsICJsaW51eC1yZW1vdGVwcm9jQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== 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-east-1.postgun.com with SMTP id 5fb2f2d4d6e6336a4ec39fd3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 16 Nov 2020 21:44:52 GMT Sender: rishabhb=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EF0C0C43465; Mon, 16 Nov 2020 21:44:51 +0000 (UTC) Received: from rishabhb-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rishabhb) by smtp.codeaurora.org (Postfix) with ESMTPSA id 11965C433ED; Mon, 16 Nov 2020 21:44:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11965C433ED 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=fail smtp.mailfrom=rishabhb@codeaurora.org From: Rishabh Bhatnagar To: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bjorn.andersson@linaro.org, tsoni@codeaurora.org, psodagud@codeaurora.org, sidgup@codeaurora.org, Rishabh Bhatnagar Subject: [PATCH v2 2/3] firmware: scm: Add tracepoints to scm driver for pas calls Date: Mon, 16 Nov 2020 13:44:43 -0800 Message-Id: <1605563084-30385-3-git-send-email-rishabhb@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> References: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add trace events to the qcom_scm driver to trace pas calls. These events can help us analyze the time impact for each scm operation and can also serve as standard checkpoints in code. Signed-off-by: Rishabh Bhatnagar --- drivers/firmware/qcom_scm.c | 9 +++++++++ include/trace/events/qcom_scm.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 include/trace/events/qcom_scm.h diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 7be48c1..5bc9b65 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -19,6 +19,9 @@ #include "qcom_scm.h" +#define CREATE_TRACE_POINTS +#include + static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT); module_param(download_mode, bool, 0); @@ -442,6 +445,7 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) }; struct qcom_scm_res res; + trace_qcom_scm_call("Start scm_pas_init_image"); /* * During the scm call memory protection will be enabled for the meta * data blob, so make sure it's physically contiguous, 4K aligned and @@ -467,6 +471,7 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) free_metadata: dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); + trace_qcom_scm_call("Complete scm_pas_init_image"); return ret ? : res.result[0]; } @@ -495,6 +500,7 @@ int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size) }; struct qcom_scm_res res; + trace_qcom_scm_call("Start scm_pas_mem_setup"); ret = qcom_scm_clk_enable(); if (ret) return ret; @@ -502,6 +508,7 @@ int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size) ret = qcom_scm_call(__scm->dev, &desc, &res); qcom_scm_clk_disable(); + trace_qcom_scm_call("Complete scm_pas_mem_setup"); return ret ? : res.result[0]; } EXPORT_SYMBOL(qcom_scm_pas_mem_setup); @@ -525,6 +532,7 @@ int qcom_scm_pas_auth_and_reset(u32 peripheral) }; struct qcom_scm_res res; + trace_qcom_scm_call("Start auth_and_reset"); ret = qcom_scm_clk_enable(); if (ret) return ret; @@ -532,6 +540,7 @@ int qcom_scm_pas_auth_and_reset(u32 peripheral) ret = qcom_scm_call(__scm->dev, &desc, &res); qcom_scm_clk_disable(); + trace_qcom_scm_call("Complete auth_and_reset"); return ret ? : res.result[0]; } EXPORT_SYMBOL(qcom_scm_pas_auth_and_reset); diff --git a/include/trace/events/qcom_scm.h b/include/trace/events/qcom_scm.h new file mode 100644 index 0000000..d918332 --- /dev/null +++ b/include/trace/events/qcom_scm.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2020, The Linux Foundation. All rights reserved. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM qcom_scm + +#if !defined(_TRACE_QCOM_SCM_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_QCOM_SCM_H + +#include +#include + +TRACE_EVENT(qcom_scm_call, + + TP_PROTO(const char *event), + + TP_ARGS(event), + + TP_STRUCT__entry( + __string(event, event) + ), + + TP_fast_assign( + __assign_str(event, event); + ), + + TP_printk("qcom_scm_call event:%s", __get_str(event)) +); + +#endif +#include + From patchwork Mon Nov 16 21:44:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rishabh Bhatnagar X-Patchwork-Id: 11910907 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 677B0C388F9 for ; Mon, 16 Nov 2020 21:45:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 07FB92225B for ; Mon, 16 Nov 2020 21:45:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="SgdpG7NQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729927AbgKPVoz (ORCPT ); Mon, 16 Nov 2020 16:44:55 -0500 Received: from z5.mailgun.us ([104.130.96.5]:55724 "EHLO z5.mailgun.us" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729905AbgKPVoz (ORCPT ); Mon, 16 Nov 2020 16:44:55 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1605563094; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=JtI5umkAy/zKKFxCc4JX+CMjJy9n7mqCYE038wfHtTw=; b=SgdpG7NQRGOTuUK653WJhOjt1qzGHW66y/PDkBjfVYHI/1YcBKPkN99+yzqOD6O+prbSRUYA nIldNcnH4z1u3iDTW7hAr6J5V1ODBn9R4hZOTcMbk2HIdvLIRqqziCYZhXH8QjsSTYBOc7ig yvjTu+QpERSJ1c7QOBda9yXoyBo= X-Mailgun-Sending-Ip: 104.130.96.5 X-Mailgun-Sid: WyI4ZWZiZiIsICJsaW51eC1yZW1vdGVwcm9jQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5fb2f2d48e090a8886329bb3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 16 Nov 2020 21:44:52 GMT Sender: rishabhb=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8D589C433ED; Mon, 16 Nov 2020 21:44:52 +0000 (UTC) Received: from rishabhb-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rishabhb) by smtp.codeaurora.org (Postfix) with ESMTPSA id A3D10C43460; Mon, 16 Nov 2020 21:44:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A3D10C43460 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=fail smtp.mailfrom=rishabhb@codeaurora.org From: Rishabh Bhatnagar To: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: bjorn.andersson@linaro.org, tsoni@codeaurora.org, psodagud@codeaurora.org, sidgup@codeaurora.org, Rishabh Bhatnagar Subject: [PATCH v2 3/3] remoteproc: Add ftrace events to trace lifecycle of remoteprocs Date: Mon, 16 Nov 2020 13:44:44 -0800 Message-Id: <1605563084-30385-4-git-send-email-rishabhb@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> References: <1605563084-30385-1-git-send-email-rishabhb@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add trace events to trace bootup/shutdown/recovery of remote processors. These events are useful in analyzing the time spent in each step in the life cycle and can be used for performace analysis. Also these serve as standard checkpoints in debugging. Signed-off-by: Rishabh Bhatnagar --- drivers/remoteproc/remoteproc_core.c | 19 +++++++- include/trace/events/remoteproc.h | 91 ++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 include/trace/events/remoteproc.h diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index dab2c0f..39da409 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -42,6 +42,9 @@ #include "remoteproc_internal.h" +#define CREATE_TRACE_POINTS +#include + #define HIGH_BITS_MASK 0xFFFFFFFF00000000ULL static DEFINE_MUTEX(rproc_list_mutex); @@ -1164,6 +1167,7 @@ static int rproc_prepare_subdevices(struct rproc *rproc) struct rproc_subdev *subdev; int ret; + trace_rproc_subdevices("Prepare subdevices", rproc->name); list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->prepare) { ret = subdev->prepare(subdev); @@ -1188,6 +1192,7 @@ static int rproc_start_subdevices(struct rproc *rproc) struct rproc_subdev *subdev; int ret; + trace_rproc_subdevices("Start subdevices", rproc->name); list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->start) { ret = subdev->start(subdev); @@ -1211,6 +1216,7 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) { struct rproc_subdev *subdev; + trace_rproc_subdevices("Stop subdevices", rproc->name); list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { if (subdev->stop) subdev->stop(subdev, crashed); @@ -1221,6 +1227,7 @@ static void rproc_unprepare_subdevices(struct rproc *rproc) { struct rproc_subdev *subdev; + trace_rproc_subdevices("Unprepare subdevices", rproc->name); list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { if (subdev->unprepare) subdev->unprepare(subdev); @@ -1357,6 +1364,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) struct device *dev = &rproc->dev; int ret; + trace_rproc_boot("loading firmware segments into memory", rproc->name); /* load the ELF segments to memory */ ret = rproc_load_segments(rproc, fw); if (ret) { @@ -1385,6 +1393,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) goto reset_table_ptr; } + trace_rproc_boot("starting remoteproc", rproc->name); /* power up the remote processor */ ret = rproc->ops->start(rproc); if (ret) { @@ -1402,6 +1411,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw) rproc->state = RPROC_RUNNING; + trace_rproc_boot("remoteproc is up", rproc->name); dev_info(dev, "remote processor %s is now up\n", rproc->name); return 0; @@ -1648,6 +1658,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed) /* the installed resource table is no longer accessible */ rproc->table_ptr = rproc->cached_table; + trace_rproc_shutdown("Stopping the remoteproc", rproc->name); /* power off the remote processor */ ret = rproc->ops->stop(rproc); if (ret) { @@ -1697,6 +1708,7 @@ int rproc_trigger_recovery(struct rproc *rproc) if (rproc->state != RPROC_CRASHED) goto unlock_mutex; + trace_rproc_recovery("Recover remoteproc", rproc->name); dev_err(dev, "recovering %s\n", rproc->name); ret = rproc_stop(rproc, true); @@ -1716,6 +1728,7 @@ int rproc_trigger_recovery(struct rproc *rproc) /* boot the remote processor up again */ ret = rproc_start(rproc, firmware_p); + trace_rproc_recovery("Recovery completed", rproc->name); release_firmware(firmware_p); unlock_mutex: @@ -1796,6 +1809,7 @@ int rproc_boot(struct rproc *rproc) /* skip the boot or attach process if rproc is already powered up */ if (atomic_inc_return(&rproc->power) > 1) { ret = 0; + trace_rproc_boot("Incrementing ref count and exiting", rproc->name); goto unlock_mutex; } @@ -1804,6 +1818,7 @@ int rproc_boot(struct rproc *rproc) ret = rproc_actuate(rproc); } else { + trace_rproc_boot("requesting firmware", rproc->name); dev_info(dev, "powering up %s\n", rproc->name); /* load firmware */ @@ -1858,8 +1873,10 @@ void rproc_shutdown(struct rproc *rproc) } /* if the remote proc is still needed, bail out */ - if (!atomic_dec_and_test(&rproc->power)) + if (!atomic_dec_and_test(&rproc->power)) { + trace_rproc_shutdown("Decrementing ref count and exiting", rproc->name); goto out; + } ret = rproc_stop(rproc, false); if (ret) { diff --git a/include/trace/events/remoteproc.h b/include/trace/events/remoteproc.h new file mode 100644 index 0000000..341bf4b --- /dev/null +++ b/include/trace/events/remoteproc.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2020, The Linux Foundation. All rights reserved. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM remoteproc + +#if !defined(_TRACE_REMOTEPROC_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_REMOTEPROC_H + +#include + +TRACE_EVENT(rproc_boot, + + TP_PROTO(const char *event, const char *rproc_name), + + TP_ARGS(event, rproc_name), + + TP_STRUCT__entry( + __string(event, event) + __string(rproc_name, rproc_name) + ), + + TP_fast_assign( + __assign_str(event, event); + __assign_str(rproc_name, rproc_name); + ), + + TP_printk("rproc_boot: %s: %s", __get_str(rproc_name), __get_str(event)) +); + +TRACE_EVENT(rproc_shutdown, + + TP_PROTO(const char *event, const char *rproc_name), + + TP_ARGS(event, rproc_name), + + TP_STRUCT__entry( + __string(event, event) + __string(rproc_name, rproc_name) + ), + + TP_fast_assign( + __assign_str(event, event); + __assign_str(rproc_name, rproc_name); + ), + + TP_printk("rproc_shutdown: %s: %s", __get_str(rproc_name), __get_str(event)) +); + +TRACE_EVENT(rproc_recovery, + + TP_PROTO(const char *event, const char *rproc_name), + + TP_ARGS(event, rproc_name), + + TP_STRUCT__entry( + __string(event, event) + __string(rproc_name, rproc_name) + ), + + TP_fast_assign( + __assign_str(event, event); + __assign_str(rproc_name, rproc_name); + ), + + TP_printk("rproc_recovery: %s: %s", __get_str(rproc_name), __get_str(event)) +); + +TRACE_EVENT(rproc_subdevices, + + TP_PROTO(const char *event, const char *rproc_name), + + TP_ARGS(event, rproc_name), + + TP_STRUCT__entry( + __string(event, event) + __string(rproc_name, rproc_name) + ), + + TP_fast_assign( + __assign_str(event, event); + __assign_str(rproc_name, rproc_name); + ), + + TP_printk("rproc_subdevices: %s: %s", __get_str(rproc_name), __get_str(event)) +); +#endif +#include +