soc: qcom: boot_stats: Add driver support for boot_stats
v5 cover soc: qcom: boot_stats: Add driver support for boot_stats
Qualcomm's proprietary Android boot-loaders capture boot time stats, like the time when the bootloader started execution and at what point the bootloader handed over control to the kernel etc. in the IMEM region. This information is captured in a specific format by this driver by mapping a structure to the IMEM memory region and then accessing the members of the structure to log the information in a debugfs file. This information is useful in verifying if existing boot KPIs have regressed or not.
A sample log in SM8450(waipio) device is as follows:-
/sys/kernel/debug/146aa6b0.boot_stats # cat abl_time 17898 ms/sys/kernel/debug/146aa6b0.boot_stats # cat pre_abl_time 2879 ms
The Module Power Manager(MPM) sleep counter starts ticking at the PBL stage and the timestamp generated by the sleep counter is logged by the Qualcomm proprietary bootloader(ABL) at two points-> First when it starts execution which is logged here as "pre_abl_time" and the second when it is about to load the kernel logged as "abl_time". Both these values are read up by the driver from IMEM region and printed as above.
Changes in V5
*Fixed the build warning in V4 of the patch.
Souradeep Chowdhury (3):
dt-bindings: sram: qcom,imem: Add Boot Stat region within IMEM
soc: qcom: boot_stat: Add Driver Support for Boot Stats
MAINTAINERS: Add the entry for boot_stats driver support
Documentation/ABI/testing/debugfs-driver-bootstat | 17 ++++ .../devicetree/bindings/sram/qcom,imem.yaml | 22 +++++ MAINTAINERS | 7 ++ drivers/soc/qcom/Kconfig | 9 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/boot_stats.c | 101 +++++++++++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-driver-bootstat create mode 100644 drivers/soc/qcom/boot_stats.c
--
2.7.4
PATCH v5 1/3 dt-bindings: sram: qcom,imem: Add Boot Stat region within IMEM
All Qualcomm bootloaders log useful timestamp information related to bootloader stats in the IMEM region. Add the child node within IMEM for the boot stat region containing register address and compatible string.
--- .../devicetree/bindings/sram/qcom,imem.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
Documentation/devicetree/bindings/sram/qcom,imem.yaml +22 -0
@@ -49,6 +49,28 @@ patternProperties: $ref: /schemas/remoteproc/qcom,pil-info.yaml# description: Peripheral image loader relocation region + "^stats@[0-9a-f]+$": + type: object + description: + Imem region dedicated for storing timestamps related + information regarding bootstats. + + additionalProperties: false + + properties: + compatible: + items: + - enum: + - qcom,sm8450-bootstats + - const: qcom,imem-bootstats + + reg: + maxItems: 1 + + required: + - compatible + - reg + required: - compatible - reg
Signature · 1 line
2.7.4
Re: [PATCH V5 1/3] dt-bindings: sram: qcom,imem: Add Boot Stat region within IMEM
Quoted 6 lines · Souradeep Chowdhury
All Qualcomm bootloaders log useful timestamp information related to bootloader stats in the IMEM region. Add the child node within IMEM for the boot stat region containing register address and compatible string.
Signed-off-by Souradeep Chowdhury <[email protected]>
This is a friendly reminder during the review process.
It looks like you received a tag and forgot to add it.
If you do not know the process, here is a short explanation:
Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540
If a tag was not added on purpose, please state why and what changed.
Best regards,
Krzysztof
Re: [PATCH V5 1/3] dt-bindings: sram: qcom,imem: Add Boot Stat region within IMEM
In reply to Souradeep ChowdhuryQuoted 7 lines · Souradeep Chowdhury
All Qualcomm bootloaders log useful timestamp information related to bootloader stats in the IMEM region. Add the child node within IMEM for the boot stat region containing register address and compatible string.
Signed-off-by Souradeep Chowdhury <[email protected]>---
Best regards,
Krzysztof
PATCH v5 2/3 soc: qcom: boot_stat: Add Driver Support for Boot Stats
In reply to Souradeep ChowdhuryAll of Qualcomm's proprietary Android boot-loaders capture boot time stats, like the time when the bootloader started execution and at what point the bootloader handed over control to the kernel etc. in the IMEM region. This information is captured in a specific format by this driver by mapping a structure to the IMEM memory region and then accessing the members of the structure to show the information within debugfs file. This information is useful in verifying if the existing boot KPIs have regressed or not. The information is shown in milliseconds, a sample log from sm8450(waipio) device is as follows:-
/sys/kernel/debug/146aa6b0.boot_stats # cat abl_time 17898 ms/sys/kernel/debug/146aa6b0.boot_stats # cat pre_abl_time 2879 ms
The Module Power Manager(MPM) sleep counter starts ticking at the PBL stage and the timestamp generated by the sleep counter is logged by the Qualcomm proprietary bootloader(ABL) at two points-> First when it starts execution which is logged here as "pre_abl_time" and the second when it is about to load the kernel logged as "abl_time". Documentation details are also added in Documentation/ABI/testing/debugfs-driver-bootstat
--- Documentation/ABI/testing/debugfs-driver-bootstat | 17 ++++ drivers/soc/qcom/Kconfig | 9 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/boot_stats.c | 101 ++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 Documentation/ABI/testing/debugfs-driver-bootstat create mode 100644 drivers/soc/qcom/boot_stats.c
Documentation/ABI/testing/debugfs-driver-bootstat new file +17 -0
@@ -0,0 +1,17 @@ +What: /sys/kernel/debug/...stats/pre_abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value pre abl time. + It shows the time in milliseconds from the starting + point of PBL to the point when the control shifted + to ABL(Qualcomm proprietary bootloader). + +What: /sys/kernel/debug/...stats/abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value abl time. + It show the duration in milliseconds from the + time control switched to ABL to the point when + the linux kernel started getting loaded.
drivers/soc/qcom/Kconfig +9 -0
@@ -16,6 +16,15 @@ config QCOM_AOSS_QMP subsystems as well as controlling the debug clocks exposed by the Always On Subsystem (AOSS) using Qualcomm Messaging Protocol (QMP). +config QCOM_BOOTSTAT + tristate "Qualcomm Technologies, Boot Stat driver" + depends on ARCH_QCOM || COMPILE_TEST + help + This option enables driver support for boot stats. Boot stat driver logs + the kernel bootloader information by accessing the imem region. These + information are exposed in the form of debugfs files. This is used to + determine if there is any regression in boot timings. + config QCOM_COMMAND_DB tristate "Qualcomm Command DB" depends on ARCH_QCOM || COMPILE_TEST
drivers/soc/qcom/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS_rpmh-rsc.o := -I$(src) obj-$(CONFIG_QCOM_AOSS_QMP) += qcom_aoss.o +obj-$(CONFIG_QCOM_BOOTSTAT) += boot_stats.o obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_CPR) += cpr.o
drivers/soc/qcom/boot_stats.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH V5 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats
Quoted 100 lines · Souradeep Chowdhury
All of Qualcomm's proprietary Android boot-loaders capture boot time stats, like the time when the bootloader started execution and at what point the bootloader handed over control to the kernel etc. in the IMEM region. This information is captured in a specific format by this driver by mapping a structure to the IMEM memory region and then accessing the members of the structure to show the information within debugfs file. This information is useful in verifying if the existing boot KPIs have regressed or not. The information is shown in milliseconds, a sample log from sm8450(waipio) device is as follows:-
/sys/kernel/debug/146aa6b0.boot_stats# catabl_time17898 ms/sys/kernel/debug/146aa6b0.boot_stats# catpre_abl_time2879 msThe Module Power Manager(MPM) sleep counter starts ticking at the PBL stage and the timestamp generated by the sleep counter is logged by the Qualcomm proprietary bootloader(ABL) at two points-> First when it starts execution which is logged here as "
pre_abl_time" and the second when it is about to load the kernel logged as "abl_time". Documentation details are also added inDocumentation/ABI/testing/debugfs-driver-bootstatSigned-off-by Souradeep Chowdhury <[email protected]>--- Documentation/ABI/testing/debugfs-driver-bootstat | 17 ++++ drivers/soc/qcom/Kconfig | 9 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/boot_stats.c | 101 ++++++++++++++++++++++ 4 files changed, 128 insertions(+)create mode 100644
Documentation/ABI/testing/debugfs-driver-bootstatcreate mode 100644drivers/soc/qcom/boot_stats.cDocumentation/ABI/testing/debugfs-driver-bootstat new file +17
-0@@ -0,0 +1,17 @@ +What: /sys/kernel/debug/...stats/pre_abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value pre abl time. + It shows the time in milliseconds from the starting + point of PBL to the point when the control shifted + to ABL(Qualcomm proprietary bootloader). + +What: /sys/kernel/debug/...stats/abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value abl time. + It show the duration in milliseconds from the + time control switched to ABL to the point when + the linux kernel started getting loaded.drivers/soc/qcom/Kconfig +9
-0@@ -16,6 +16,15 @@ config QCOM_AOSS_QMP subsystems as well as controlling the debug clocks exposed by the Always On Subsystem (AOSS) using Qualcomm Messaging Protocol (QMP). +config QCOM_BOOTSTAT + tristate "Qualcomm Technologies, Boot Stat driver" + depends on ARCH_QCOM || COMPILE_TEST + help + This option enables driver support for boot stats. Boot stat driver logs + the kernel bootloader information by accessing the imem region. These + information are exposed in the form of debugfs files. This is used to + determine if there is any regression in boot timings. + config QCOM_COMMAND_DB tristate "Qualcomm Command DB" depends on ARCH_QCOM || COMPILE_TESTdrivers/soc/qcom/Makefile +1
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS_rpmh-rsc.o := -I$(src) obj-$(CONFIG_QCOM_AOSS_QMP) += qcom_aoss.o +obj-$(CONFIG_QCOM_BOOTSTAT) += boot_stats.o obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o obj-$(CONFIG_QCOM_CPR) += cpr.odrivers/soc/qcom/boot_stats.c new file +7
-0@@ -0,0 +1,101 @@ +// 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>
drivers/soc/qcom/boot_stats.c line 17
Quoted 10 lines
drivers/soc/qcom/boot_stats.c new file +10
-0+#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)
Is this related to the sleep_clk, if not, what is the refrence clock ?
Is this value constant across different SoCs i.e. will this run and produce meaningful results on an msm8916 ?
---
bod
Re: [PATCH V5 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats
Quoted 119 lines · Bryan O'Donoghue
Quoted 105 lines · Souradeep Chowdhury
All of Qualcomm's proprietary Android boot-loaders capture boot time stats, like the time when the bootloader started execution and at what point the bootloader handed over control to the kernel etc. in the IMEM region. This information is captured in a specific format by this driver by mapping a structure to the IMEM memory region and then accessing the members of the structure to show the information within debugfs file. This information is useful in verifying if the existing boot KPIs have regressed or not. The information is shown in milliseconds, a sample log from sm8450(waipio) device is as follows:-
/sys/kernel/debug/146aa6b0.boot_stats# catabl_time17898 ms/sys/kernel/debug/146aa6b0.boot_stats# catpre_abl_time2879 msThe Module Power Manager(MPM) sleep counter starts ticking at the PBL stage and the timestamp generated by the sleep counter is logged by the Qualcomm proprietary bootloader(ABL) at two points-> First when it starts execution which is logged here as "
pre_abl_time" and the second when it is about to load the kernel logged as "abl_time". Documentation details are also added inDocumentation/ABI/testing/debugfs-driver-bootstatSigned-off-by Souradeep Chowdhury <[email protected]>---
Documentation/ABI/testing/debugfs-driver-bootstat| 17 ++++ drivers/soc/qcom/Kconfig | 9 ++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/boot_stats.c | 101
++++++++++++++++++++++4 files changed, 128 insertions(+)create mode 100644
Documentation/ABI/testing/debugfs-driver-bootstatcreate mode 100644drivers/soc/qcom/boot_stats.cDocumentation/ABI/testing/debugfs-driver-bootstat new file +17
-0@@ -0,0 +1,17 @@ +What: /sys/kernel/debug/...stats/pre_abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value pre abl time. + It shows the time in milliseconds from the starting + point of PBL to the point when the control shifted + to ABL(Qualcomm proprietary bootloader). + +What: /sys/kernel/debug/...stats/abl_time +Date: April 2023 +Contact: Souradeep Chowdhury <[email protected]> +Description: + This file is used to read the KPI value abl time. + It show the duration in milliseconds from the + time control switched to ABL to the point when + the linux kernel started getting loaded.drivers/soc/qcom/Kconfig +0
-0@@ -16,6 +16,15 @@ config QCOM_AOSS_QMPsubsystems as well as controlling the debug clocks exposed by the Always On Subsystem (AOSS) using Qualcomm Messaging Protocol (QMP). +config
QCOM_BOOTSTAT
+ tristate "Qualcomm Technologies, Boot Stat driver"
+ depends onARCH_QCOM||COMPILE_TEST
+ help
+ This option enables driver support for boot stats. Boot stat driver logs
+ the kernel bootloader information by accessing the imem region. These
+ information are exposed in the form of debugfs files. This is used to
+ determine if there is any regression in boot timings.
+
configQCOM_COMMAND_DB
tristate "Qualcomm Command DB"
depends onARCH_QCOM||COMPILE_TESTdrivers/soc/qcom/Makefile +0
-0@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS_rpmh-rsc.o := -I$(src)obj-$(CONFIG_QCOM_AOSS_QMP) += qcom_aoss.o
+obj-$(CONFIG_QCOM_BOOTSTAT) += boot_stats.o
obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o
obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
obj-$(CONFIG_QCOM_CPR) += cpr.odrivers/soc/qcom/boot_stats.c new file +3
-0@@ -0,0 +1,101 @@ +// 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.
+ */drivers/soc/qcom/boot_stats.c new file +2
-0+ +#include <linux/debugfs.h> drivers/soc/qcom/boot_stats.c line 17
Quoted 10 lines
drivers/soc/qcom/boot_stats.c new file +10
-0+#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)Is this related to the
sleep_clk, if not, what is the refrence clock ?
Quoted 1 line
Is this value constant across different SoCs i.e. will this run and produce meaningful results on an msm8916 ?
This is the sleep counter of MPM(Module Power Manager), yes, it will produce meaningful results on almost all QCOM SoCs including msm8916.
Quoted 3 lines
---
bod
kernel test robot
build botRe: [PATCH V5 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats
In reply to Souradeep Chowdhurykernel test robot noticed the following build warnings:
Hi Souradeep,
kernel test robot noticed the following build warnings:
[auto build test WARNING on robh/for-next]
[also build test WARNING on krzk-dt/for-next linus/master v6.3-rc7 next-20230421] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Souradeep-Chowdhury/dt-bindings-sram-qcom-imem-Add-Boot-Stat-region-within-IMEM/20230418-144757 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/142bfd034c12c245cda9f1dee20a05188b63494d.1681799201.git.quic_schowdhu%40quicinc.com patch subject: [PATCH V5 2/3] soc: qcom: boot_stat: Add Driver Support for Boot Stats config: nios2-randconfig-s033-20230423 (https://download.01.org/0day-ci/archive/20230423/[email protected]/config) compiler: nios2-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/1e2fc43bcc0869349f7e3698fceebbcc8333d1f3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Souradeep-Chowdhury/dt-bindings-sram-qcom-imem-Add-Boot-Stat-region-within-IMEM/20230418-144757
git checkout 1e2fc43bcc0869349f7e3698fceebbcc8333d1f3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash drivers/soc/qcom/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
>> drivers/soc/qcom/boot_stats.c:70:36: sparse: sparse: incorrect type in argument 4 (different address spaces) @@ expected void *data @@ got struct boot_stats [noderef] __iomem *b_stats @@
drivers/soc/qcom/boot_stats.c:70:36: sparse: expected void *data
drivers/soc/qcom/boot_stats.c:70:36: sparse: got struct boot_stats [noderef] __iomem *b_stats
drivers/soc/qcom/boot_stats.c:71:72: sparse: sparse: incorrect type in argument 4 (different address spaces) @@ expected void *data @@ got struct boot_stats [noderef] __iomem *b_stats @@
drivers/soc/qcom/boot_stats.c:71:72: sparse: expected void *data
drivers/soc/qcom/boot_stats.c:71:72: sparse: got struct boot_stats [noderef] __iomem *b_stats
vim +70 drivers/soc/qcom/boot_stats.c
52
53 static int boot_stats_probe(struct platform_device *pdev)
54 {
55 struct device *bootstat_dev = &pdev->dev;
56 struct bs_data *drvdata;
57
58 drvdata = devm_kzalloc(bootstat_dev, sizeof(*drvdata), GFP_KERNEL);
59 platform_set_drvdata(pdev, drvdata);
60
61 drvdata->dbg_dir = debugfs_create_dir(dev_name(bootstat_dev), NULL);
62 if (IS_ERR(drvdata->dbg_dir))
63 return dev_err_probe(bootstat_dev, -ENOENT, "failed to create debugfs directory");
64
65 drvdata->b_stats = devm_of_iomap(bootstat_dev, bootstat_dev->of_node, 0, NULL);
66 if (!drvdata->b_stats)
67 return dev_err_probe(bootstat_dev, -ENOMEM, "failed to map imem region\n");
68
69 debugfs_create_file("pre_abl_time", 0200, drvdata->dbg_dir,
> 70 drvdata->b_stats, &pre_abl_time_fops);
71 debugfs_create_file("abl_time", 0200, drvdata->dbg_dir, drvdata->b_stats, &abl_time_fops);
72
73 return 0;
74 }
75 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
PATCH v5 3/3 MAINTAINERS: Add the entry for boot_stats driver support
In reply to Souradeep ChowdhuryAdd the entries for all the files added as a part of driver support for boot stats.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -17055,6 +17055,13 @@ L: [email protected] S: Supported F: drivers/net/ipa/ +QCOM BOOT_STATS DRIVER +M: Souradeep Chowdhury <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/ABI/testing/debugfs-driver-bootstat +F: drivers/soc/qcom/boot_stats.c + QEMU MACHINE EMULATOR AND VIRTUALIZER SUPPORT M: Gabriel Somlo <[email protected]> M: "Michael S. Tsirkin" <[email protected]>
Signature · 1 line
2.7.4