From: Souradeep Chowdhury <quic_schowdhu@quicinc.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Andy Gross <agross@kernel.org>,
Konrad Dybcio <konrad.dybcio@somainline.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Bjorn Andersson <andersson@kernel.org>,
Rob Herring <robh+dt@kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<devicetree@vger.kernel.org>,
Sibi Sankar <quic_sibis@quicinc.com>,
"Rajendra Nayak" <quic_rjendra@quicinc.com>
Subject: Re: [PATCH V6 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats
Date: Thu, 11 May 2023 11:12:37 +0530 [thread overview]
Message-ID: <d5341357-e0f4-afb1-20db-7c2d926662fe@quicinc.com> (raw)
In-Reply-To: <CAA8EJprKumrq=Zy0gBqSZ9Dga5mZuauCC4U0GpTs0T4YADrSoA@mail.gmail.com>
On 5/9/2023 6:31 PM, Dmitry Baryshkov wrote:
> On Tue, 9 May 2023 at 15:27, Souradeep Chowdhury
> <quic_schowdhu@quicinc.com> wrote:
>>
>>
>>
>> On 5/9/2023 5:09 PM, Dmitry Baryshkov wrote:
>>> On Tue, 9 May 2023 at 13:53, Souradeep Chowdhury
>>> <quic_schowdhu@quicinc.com> wrote:
>
>
>>>> diff --git a/drivers/soc/qcom/boot_stats.c b/drivers/soc/qcom/boot_stats.c
>>>> new file mode 100644
>>>> index 000000000000..ca67b6b5d8eb
>>>> --- /dev/null
>>>> +++ b/drivers/soc/qcom/boot_stats.c
>>>> @@ -0,0 +1,100 @@
>>>> +// SPDX-License-Identifier: GPL-2.0-only
>>>> +/*
>>>> + * Copyright (c) 2013-2019, 2021 The Linux Foundation. All rights reserved.
>>>> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>>>> + */
>>>> +
>>>> +#include <linux/debugfs.h>
>>>> +#include <linux/err.h>
>>>> +#include <linux/io.h>
>>>> +#include <linux/init.h>
>>>> +#include <linux/kernel.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/of.h>
>>>> +#include <linux/of_address.h>
>>>> +#include <linux/platform_device.h>
>>>> +
>>>> +#define TO_MS(timestamp) ((timestamp * 1000) / 32768)
>>>
>>> Quoting v4 question, which got no answer:
>>>
>>> Some of the platforms DTs define 32KHz clock instead of 32.768 KHz
>>> What should be the divisor in this case?
>>
>> This is the standard divisor used to calculate the pre_abl and abl times
>> across most QCOM SoCs. Can you give an example where the sleep_stat
>> counter has a different frequency?
>
> Following SoCs declare 37000 as sleep_clk frequency:
> ipq6018, qdu1000, qru1000, sc7280, sm6125, sm6375, sm8350, sm8450, sm8550.
>
> This might be an error in the dtsi, or might be not.
This sleep_clk is different from the sleep_stats counter of the module
power manager(MPM) which is used to log the timestamps. This driver is
tested and verified with sm8450(waipio) which uses the same
frequency(32768).
>
>>
>>>
>>>> +
>>>> +/**
>>>> + * struct boot_stats - timestamp information related to boot stats
>>>> + * @abl_start: Time for the starting point of the abl
>>>> + * @abl_end: Time when the kernel starts loading from abl
>>>> + */
>>>> +struct boot_stats {
>>>> + u32 abl_start;
>>>> + u32 abl_end;
>>>> +} __packed;
>>>> +
>>>> +struct bs_data {
>>>> + struct boot_stats __iomem *b_stats;
>>>> + struct dentry *dbg_dir;
>>>> +};
>>>> +
>>>> +static void populate_boot_stats(char *abl_str, char *pre_abl_str, struct bs_data *drvdata)
>>>> +{
>>>> + u32 abl_time, pre_abl_time;
>>>> +
>>>> + abl_time = TO_MS(drvdata->b_stats->abl_end) - TO_MS(drvdata->b_stats->abl_start);
>>>> + sprintf(abl_str, "%u ms", abl_time);
>>>> +
>>>> + pre_abl_time = TO_MS(drvdata->b_stats->abl_start);
>>>> + sprintf(pre_abl_str, "%u ms", pre_abl_time);
>>>
>>> Another point from v4:
>>>
>>> It would be better to move the unit to the file name and include just
>>> the number.
>>
>> Clarified from your first comment
>>
>>>
>>>> +}
>>>> +
>>>> +static int boot_stats_probe(struct platform_device *pdev)
>>>> +{
>>>> + char abl_str[20], pre_abl_str[20], *abl, *pre_abl;
>>>> + struct device *bootstat_dev = &pdev->dev;
>>>> + struct bs_data *drvdata;
>>>> +
>>>> + drvdata = devm_kzalloc(bootstat_dev, sizeof(*drvdata), GFP_KERNEL);
>>>> + if (!drvdata)
>>>> + return dev_err_probe(bootstat_dev, -ENOMEM, "failed to allocate memory");
>>>> + platform_set_drvdata(pdev, drvdata);
>>>> +
>>>> + drvdata->b_stats = devm_of_iomap(bootstat_dev, bootstat_dev->of_node, 0, NULL);
>>>> + if (IS_ERR(drvdata->b_stats))
>>>> + return dev_err_probe(bootstat_dev, PTR_ERR(drvdata->b_stats),
>>>> + "failed to map imem region");
>>>> +
>>>> + drvdata->dbg_dir = debugfs_create_dir("qcom_boot_stats", NULL);
>>>> + if (IS_ERR(drvdata->dbg_dir))
>>>> + return dev_err_probe(bootstat_dev, PTR_ERR(drvdata->dbg_dir),
>>>> + "failed to create debugfs directory");
>>>> +
>>>> + populate_boot_stats(abl_str, pre_abl_str, drvdata);
>>>> + abl = abl_str;
>>>> + pre_abl = pre_abl_str;
>>>> +
>>>> + debugfs_create_str("pre_abl_time", 0400, drvdata->dbg_dir, (char **)&pre_abl);
>>>> + debugfs_create_str("abl_time", 0400, drvdata->dbg_dir, (char **)&abl);
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +void boot_stats_remove(struct platform_device *pdev)
>>>> +{
>>>> + struct bs_data *drvdata = platform_get_drvdata(pdev);
>>>> +
>>>> + debugfs_remove_recursive(drvdata->dbg_dir);
>>>> +}
>>>> +
>>>> +static const struct of_device_id boot_stats_dt_match[] = {
>>>> + { .compatible = "qcom,imem-bootstats" },
>>>> + { }
>>>> +};
>>>> +MODULE_DEVICE_TABLE(of, boot_stats_dt_match);
>>>> +
>>>> +static struct platform_driver boot_stat_driver = {
>>>> + .probe = boot_stats_probe,
>>>> + .remove_new = boot_stats_remove,
>>>> + .driver = {
>>>> + .name = "qcom-boot-stats",
>>>> + .of_match_table = boot_stats_dt_match,
>>>> + },
>>>> +};
>>>> +module_platform_driver(boot_stat_driver);
>>>> +
>>>> +MODULE_DESCRIPTION("Qualcomm Technologies Inc. Boot Stat driver");
>>>> +MODULE_LICENSE("GPL");
>>>> --
>>>> 2.17.1
>>>>
>>>
>>>
>
>
>
next prev parent reply other threads:[~2023-05-11 5:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 10:52 [PATCH V6 0/3] soc: qcom: boot_stats: Add driver support for boot_stats Souradeep Chowdhury
2023-05-09 10:52 ` [PATCH V6 1/3] dt-bindings: sram: qcom,imem: Add Boot Stat region within IMEM Souradeep Chowdhury
2023-05-09 11:35 ` Dmitry Baryshkov
2023-05-09 12:21 ` Souradeep Chowdhury
2023-05-09 13:05 ` Dmitry Baryshkov
2023-05-11 5:59 ` Souradeep Chowdhury
2023-05-16 8:16 ` Arnd Bergmann
2023-05-16 18:34 ` Trilok Soni
2023-05-16 18:41 ` Arnd Bergmann
2023-05-16 19:17 ` Dmitry Baryshkov
2023-05-16 21:58 ` Trilok Soni
2023-05-09 10:52 ` [PATCH V6 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats Souradeep Chowdhury
2023-05-09 11:39 ` Dmitry Baryshkov
2023-05-09 12:26 ` Souradeep Chowdhury
2023-05-09 13:01 ` Dmitry Baryshkov
2023-05-11 5:42 ` Souradeep Chowdhury [this message]
2023-05-09 14:06 ` kernel test robot
2023-05-10 8:18 ` kernel test robot
2023-05-11 17:07 ` Bjorn Andersson
2023-05-11 17:11 ` Trilok Soni
2023-05-12 11:46 ` Souradeep Chowdhury
2023-05-15 4:31 ` Satya Durga Srinivasu Prabhala
2023-05-16 8:19 ` Arnd Bergmann
2023-05-17 0:09 ` Dmitry Baryshkov
2023-05-09 10:52 ` [PATCH V6 3/3] MAINTAINERS: Add the entry for boot_stats driver support Souradeep Chowdhury
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=d5341357-e0f4-afb1-20db-7c2d926662fe@quicinc.com \
--to=quic_schowdhu@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.baryshkov@linaro.org \
--cc=konrad.dybcio@somainline.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_rjendra@quicinc.com \
--cc=quic_sibis@quicinc.com \
--cc=robh+dt@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