Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5802028pxu; Thu, 22 Oct 2020 11:22:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPSxZmOrTfsGnE/crD++SJkhnwjAsO8WbEdtmT48JS/z41BZnZd6EDhev5Y5MG4U4Ykpvs X-Received: by 2002:aa7:df0c:: with SMTP id c12mr3504187edy.234.1603390976957; Thu, 22 Oct 2020 11:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603390976; cv=none; d=google.com; s=arc-20160816; b=KmzW6wiN+efsuM1qrECldnhzqA8LoFms7sOxXxHyUVkHIO6O1125nZA0Wz/5g5fBSO os7nyh4uasb1XvB9mmSyy49FZXQ/7PwjTaw7WmjCU2Ot3o0SeYsFXuPflM2l11exR49/ vNlXqq5aYcjFglgpzMNOPOERCc4vePmKyXWkeZ9BHb83ORWyNJ09gIF7Bt1Oi97J74SV e/iLoD97j+hoFDYYDBPA1J6TvG1pamu5QqbGyJ02kGcM6s52jjLxkoxjBfyqINoUOUcR YCuVtpVOLuI3EMf8+/8/sw5ZkweS9bxrFU4YDRi+B4CTrHZRux19EyCX7xbzymkFpmkQ 4/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=wxOHue2BkzYY1LLb53+foSFWS+cuHJ2IStm1xjmkKr8=; b=On2OEvhfqW3Bfk/YOylPvUOKF397CYi4TXUaPaUvoqT42ssuxFbdhG0Te9WBtYjpK0 cdMSIAnesqblc/cjdoIdPY4UXI2IfFHKNfSHVWsnySnBJ+7jLYWhoFrQMrinIdcSb7HA BqdoLUPI8PfNPLZQfjmONi67JxgAK91kIwftmYW8pFlGus6+e0QlVCeKm8obUxVHLzT2 2hrLVXVlmXJtRU3/zI/kLOtfZWWRfH3tCQl55XrNwNuRliW+onDPgWtxlkamr2uyPJWh HjJEh8Cd0Gu+atKqG8gBGizdlOMtAdKr3ia3B9zTSjAsWXQnA2+99pNxi+RMtGQ3JTj+ kEzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iiwjPK9C; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si1422445edy.179.2020.10.22.11.22.34; Thu, 22 Oct 2020 11:22:56 -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=pass header.i=@google.com header.s=20161025 header.b=iiwjPK9C; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2900548AbgJVRem (ORCPT + 99 others); Thu, 22 Oct 2020 13:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2900539AbgJVRem (ORCPT ); Thu, 22 Oct 2020 13:34:42 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4D8C0613CE for ; Thu, 22 Oct 2020 10:34:40 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id z4so1271579pgv.13 for ; Thu, 22 Oct 2020 10:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=wxOHue2BkzYY1LLb53+foSFWS+cuHJ2IStm1xjmkKr8=; b=iiwjPK9CFBKzwxj+yijsRhqmNhIuROH2A3N4gt2PTU++/FcbBJzQvSXs8boXJHVbfe EV2zaRzDg6sh8d6+b9D4bgMdvCsW6rRj6N9rlwi3zw9kb0lFbMhlIsRtbELNKCLiSxAE V8MrDapqFmGnAneZuUYpdAhvPI1NVJ0L+CXJda+66WkG3oY00ui4ifytjpKhf4zCyfm1 rRjwwibtRYekvdQiAX/zXcEhhhamY9BOUG4vZfT24t+H1+oF1g+AlDHFvv/tD/P21+O0 26rCT2ZVAb2cQlxkfjkLMLx7b3b1vFyjMivt4cDfo5RbaIG5Bevu7pJ/xJ5VQXZuHi/1 V5/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=wxOHue2BkzYY1LLb53+foSFWS+cuHJ2IStm1xjmkKr8=; b=QcP1Ezeq2iuxu0m58XxYMLCi5kz24oPplnGinkFPEjfUBZVyLvnGa4BvTWCgOnOyKH X1670B4Tefum6OYxg+OT84/t3+9KjTwDNPvs4aaL8in5dpMlKnladpj+yVTlp4moyYrf tCAZ0DtjL/WPZWD/K/NjI3NC1AVyXYTG3A8X2Tc+IL3bRVyx/wfVDfS/qzCBr/Jdyhoy 6ZIgdE7/pGeqmhMStK/tpvccBfm3ZRt7BUtzMIa7YrxKJ1WF0pyoPSlCgeSy/j+vu/9H 2vkumipVv0wD4NtozM2S/53ylmHPgDK0FF/ZoMfkacoPf5t1zM/JD+gHIcw2j9L23H4Q QWrw== X-Gm-Message-State: AOAM53219fjgFbXg30KewFtXYWRHy6lH+jZZ5TrUWFVIYne931uMCbQ/ vP4KI8Yp3t46bUBxa7rvYfiulCU= Sender: "lpy via sendgmr" X-Received: from lpy-goobuntu.mtv.corp.google.com ([2620:15c:211:2:5265:f3ff:fe23:c8be]) (user=lpy job=sendgmr) by 2002:a17:90a:8684:: with SMTP id p4mr3209296pjn.232.1603388080013; Thu, 22 Oct 2020 10:34:40 -0700 (PDT) Date: Thu, 22 Oct 2020 10:34:34 -0700 In-Reply-To: <20200820162738.33053904@oasis.local.home> Message-Id: <20201022173434.910879-1-lpy@google.com> Mime-Version: 1.0 References: <20200820162738.33053904@oasis.local.home> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog Subject: [PATCH v4] Add power/gpu_frequency tracepoint. From: Peiyong Lin To: rostedt@goodmis.org Cc: amit.kucheria@linaro.org, android-kernel@google.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, lpy@google.com, mingo@redhat.com, paul.walmsley@sifive.com, pavel@ucw.cz, prahladk@google.com, rafael.j.wysocki@intel.com, ulf.hansson@linaro.org, yamada.masahiro@socionext.com, zzyiwei@android.com, sidaths@google.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Historically there is no common trace event for GPU frequency, in downstream Android each different hardware vendor implements their own way to expose GPU frequency, for example as a debugfs node. This patch standardize it as a common trace event in upstream linux kernel to help the ecosystem have a common implementation across hardware vendors. Toolings in the Linux ecosystem will benefit from this especially in the downstream Android, where this information is critical to graphics developers. Signed-off-by: Peiyong Lin --- Changelog since v3: - Correct copyright title. Changelog since v2: - Add more comments to indicate when the event should be emitted. - Change state to frequency. Changelog since v1: - Use %u in TP_printk drivers/gpu/Makefile | 1 + drivers/gpu/trace/Kconfig | 3 +++ drivers/gpu/trace/Makefile | 1 + drivers/gpu/trace/trace_gpu_frequency.c | 13 ++++++++++ include/trace/events/power.h | 33 +++++++++++++++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 drivers/gpu/trace/trace_gpu_frequency.c diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile index 835c88318cec..f289a47eb031 100644 --- a/drivers/gpu/Makefile +++ b/drivers/gpu/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_TEGRA_HOST1X) += host1x/ obj-y += drm/ vga/ obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ obj-$(CONFIG_TRACE_GPU_MEM) += trace/ +obj-$(CONFIG_TRACE_GPU_FREQUENCY) += trace/ diff --git a/drivers/gpu/trace/Kconfig b/drivers/gpu/trace/Kconfig index c24e9edd022e..ac4aec8d5845 100644 --- a/drivers/gpu/trace/Kconfig +++ b/drivers/gpu/trace/Kconfig @@ -2,3 +2,6 @@ config TRACE_GPU_MEM bool + +config TRACE_GPU_FREQUENCY + bool diff --git a/drivers/gpu/trace/Makefile b/drivers/gpu/trace/Makefile index b70fbdc5847f..2b7ae69327d6 100644 --- a/drivers/gpu/trace/Makefile +++ b/drivers/gpu/trace/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_TRACE_GPU_MEM) += trace_gpu_mem.o +obj-$(CONFIG_TRACE_GPU_FREQUENCY) += trace_gpu_frequency.o diff --git a/drivers/gpu/trace/trace_gpu_frequency.c b/drivers/gpu/trace/trace_gpu_frequency.c new file mode 100644 index 000000000000..668fabd6b77a --- /dev/null +++ b/drivers/gpu/trace/trace_gpu_frequency.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * GPU frequency trace points + * + * Copyright (C) 2020 Google LLC + */ + +#include + +#define CREATE_TRACE_POINTS +#include + +EXPORT_TRACEPOINT_SYMBOL(gpu_frequency); diff --git a/include/trace/events/power.h b/include/trace/events/power.h index af5018aa9517..343825a76953 100644 --- a/include/trace/events/power.h +++ b/include/trace/events/power.h @@ -500,6 +500,39 @@ DEFINE_EVENT(dev_pm_qos_request, dev_pm_qos_remove_request, TP_ARGS(name, type, new_value) ); + +/** + * gpu_frequency - Reports the GPU frequency in GPU clock domains. + * + * This event should be emitted whenever there's a GPU frequency change happens, + * or a GPU goes from idle state to active state, or vice versa. + * + * When the GPU goes from idle state to active state, this event should report + * the GPU frequency of the active state. When the GPU goes from active state to + * idle state, this event should report a zero frequency value. + * + * @frequency: New frequency (in KHz) + * @gpu_id: Id for each GPU clock domain + */ +TRACE_EVENT(gpu_frequency, + + TP_PROTO(unsigned int frequency, unsigned int gpu_id), + + TP_ARGS(frequency, gpu_id), + + TP_STRUCT__entry( + __field(unsigned int, frequency) + __field(unsigned int, gpu_id) + ), + + TP_fast_assign( + __entry->frequency = frequency; + __entry->gpu_id = gpu_id; + ), + + TP_printk("frequency=%u gpu_id=%u", + __entry->frequency, __entry->gpu_id) +); #endif /* _TRACE_POWER_H */ /* This part must be outside protection */ -- 2.29.0.rc1.297.gfa9743e501-goog