From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Maulik Shah <maulik.shah@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org,
Marijn Suijten <marijn.suijten@somainline.org>,
Doug Anderson <dianders@chromium.org>
Subject: Re: [PATCH 1/3] soc: qcom: qcom_stats: Add support to read DDR statistic
Date: Tue, 29 Apr 2025 12:34:24 +0200 [thread overview]
Message-ID: <b3119bef-d045-467b-91cf-37fe6832ff63@oss.qualcomm.com> (raw)
In-Reply-To: <20250429-ddr_stats_-v1-1-4fc818aab7bb@oss.qualcomm.com>
On 4/29/25 5:52 AM, Maulik Shah wrote:
> DDR statistic provide different DDR LPM and DDR frequency statistic.
> Add support to read from MSGRAM and display via debugfs.
>
> Signed-off-by: Maulik Shah <maulik.shah@oss.qualcomm.com>
> ---
> drivers/soc/qcom/qcom_stats.c | 99 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 99 insertions(+)
>
> diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c
> index 5de99cf59b9fbe32c0580e371c3cc362dfabb895..ee11fb0919742454d40442112787c087ba8f6598 100644
> --- a/drivers/soc/qcom/qcom_stats.c
> +++ b/drivers/soc/qcom/qcom_stats.c
> @@ -1,8 +1,10 @@
> // SPDX-License-Identifier: GPL-2.0-only
> /*
> * Copyright (c) 2011-2021, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2022-2025, Qualcomm Innovation Center, Inc. All rights reserved.
> */
>
> +#include <linux/bitfield.h>
> #include <linux/debugfs.h>
> #include <linux/device.h>
> #include <linux/io.h>
> @@ -24,6 +26,17 @@
> #define ACCUMULATED_OFFSET 0x18
> #define CLIENT_VOTES_OFFSET 0x20
>
> +#define DDR_STATS_MAGIC_KEY 0xA1157A75
> +#define DDR_STATS_MAX_NUM_MODES 0x14
Numbers (count) make more sense in decimal
> +#define DDR_STATS_MAGIC_KEY_ADDR 0x0
> +#define DDR_STATS_NUM_MODES_ADDR 0x4
> +#define DDR_STATS_ENTRY_START_ADDR 0x8
[...]
> +static void qcom_ddr_stats_print(struct seq_file *s, struct ddr_stats_entry *data)
> +{
> + u32 cp_idx, name;
> +
> + /*
> + * DDR statistic have two different types of details encoded.
> + * (1) DDR LPM Stats
> + * (2) DDR Frequency Stats
> + *
> + * The name field have details like which type of DDR stat (bits 8:15)
> + * along with other details as explained below
> + *
> + * In case of DDR LPM stat, name field will be encoded as,
> + * Bits - Meaning
> + * 0:7 - DDR LPM name, can be of 0xd4, 0xd3, 0x11 and 0xd0.
> + * 8:15 - 0x0 (indicates its a LPM stat)
> + * 16:31 - Unused
> + *
> + * In case of DDR FREQ stats, name field will be encoded as,
> + * Bits - Meaning
> + * 0:4 - DDR Clock plan index (CP IDX)
> + * 5:7 - Unused
> + * 8:15 - 0x1 (indicates its Freq stat)
> + * 16:31 - Frequency value in Mhz
> + */
> + name = DDR_STATS_TYPE(data->name);
> + if (name == 0x0) {
> + name = DDR_STATS_LPM_NAME(data->name);
I'm not super keen on reusing the 'name' variable, maybe turn the
outer if-condition to switch(DDR_STATS_TYPE(data->name))
> + seq_printf(s, "DDR LPM Stat Name:0x%x\tcount:%u\tDuration (ticks):%llu\n",
> + name, data->count, data->duration);
> + } else if (name == 0x1) {
> + name = DDR_STATS_FREQ(data->name);
> + if (!name || !data->count)
> + return;
> +
> + cp_idx = DDR_STATS_CP_IDX(data->name);
> + seq_printf(s, "DDR Freq %uMhz:\tCP IDX:%u\tcount:%u\tDuration (ticks):%llu\n",
> + name, cp_idx, data->count, data->duration);
> + }
> +}
> +
> +static int qcom_ddr_stats_show(struct seq_file *s, void *d)
> +{
> + struct ddr_stats_entry data[DDR_STATS_MAX_NUM_MODES];
> + void __iomem *reg = (void __iomem *)s->private;
> + u32 entry_count;
> + int i;
> +
> + entry_count = readl_relaxed(reg + DDR_STATS_NUM_MODES_ADDR);
> + if (entry_count > DDR_STATS_MAX_NUM_MODES)
> + return 0;
-EINVAL
Konrad
next prev parent reply other threads:[~2025-04-29 10:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 3:52 [PATCH 0/3] soc: qcom: qcom_stats: Add DDR stats Maulik Shah
2025-04-29 3:52 ` [PATCH 1/3] soc: qcom: qcom_stats: Add support to read DDR statistic Maulik Shah
2025-04-29 10:34 ` Konrad Dybcio [this message]
2025-05-20 9:59 ` Maulik Shah (mkshah)
2025-05-20 14:41 ` Konrad Dybcio
2025-04-29 3:52 ` [PATCH 2/3] soc: qcom: qcom_stats: Add QMP support for syncing ddr stats Maulik Shah
2025-04-29 10:39 ` Konrad Dybcio
2025-05-20 9:55 ` Maulik Shah (mkshah)
2025-05-20 14:44 ` Konrad Dybcio
2025-04-29 3:52 ` [PATCH 3/3] arm64: dts: qcom: Add QMP handle for qcom_stats Maulik Shah
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3119bef-d045-467b-91cf-37fe6832ff63@oss.qualcomm.com \
--to=konrad.dybcio@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marijn.suijten@somainline.org \
--cc=maulik.shah@oss.qualcomm.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®