From: Pavan Kondeti <quic_pkondeti@quicinc.com>
To: Ninad Naik <quic_ninanaik@quicinc.com>
Cc: <agross@kernel.org>, <andersson@kernel.org>,
<konrad.dybcio@linaro.org>, <psodagud@quicinc.com>,
<quic_ppareek@quicinc.com>, <quic_kprasan@quicinc.com>,
<linux-kernel@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
<kernel@quicinc.com>
Subject: Re: [RFC PATCH 1/1] soc: qcom: Add driver to read secondary bootloader (XBL) log
Date: Tue, 22 Aug 2023 18:09:33 +0530 [thread overview]
Message-ID: <d0f663e7-cee4-451e-9b28-99ba7e6f674a@quicinc.com> (raw)
In-Reply-To: <20230822121512.8631-2-quic_ninanaik@quicinc.com>
On Tue, Aug 22, 2023 at 05:45:12PM +0530, Ninad Naik wrote:
> Qualcomm secondary bootloader (XBL) boot log holds information to
> identify various firmware configuration currently set on the SoC.
> The XBL log is stored in a predefined reserved memory region.
>
> This drivers provides a way to print XBL logs on the console. To
> do so, it provides a debugfs entry which captures the logs stored
> in this reserved memory region. This entry can now be used to read
> and print the XBL logs to console.
>
> User can use the below command to print XBL log to console:
> cat /sys/kernel/debug/xbl_log
>
> Signed-off-by: Ninad Naik <quic_ninanaik@quicinc.com>
> ---
For a single patch, cover letter may not be needed. The under cut
portion (this area) of the patch can be used to present the additional
details.
> drivers/soc/qcom/Kconfig | 13 +++
> drivers/soc/qcom/Makefile | 1 +
> drivers/soc/qcom/dump_xbl_log.c | 139 ++++++++++++++++++++++++++++++++
> 3 files changed, 153 insertions(+)
> create mode 100644 drivers/soc/qcom/dump_xbl_log.c
>
[...]
> +static int map_addr_range(struct device_node **parent, const char *name,
> + struct xbl_log_data *xbl_data)
> +{
> + struct device_node *node;
> + struct resource res;
> + int ret;
> +
> + node = of_find_node_by_name(*parent, name);
> + if (!node)
> + return -ENODEV;
> +
> + ret = of_address_to_resource(node, 0, &res);
> + if (ret) {
> + dev_err(xbl_data->dev, "Failed to parse memory region\n");
> + return ret;
> + }
> + of_node_put(node);
> +
> + if (!resource_size(&res)) {
> + dev_err(xbl_data->dev, "Failed to parse memory region size\n");
> + return -ENODEV;
> + }
> +
> + xbl_data->buf_size = resource_size(&res) - 1;
> + xbl_data->xbl_buf = devm_memremap(xbl_data->dev, res.start,
> + xbl_data->buf_size, MEMREMAP_WB);
> + if (!xbl_data->xbl_buf) {
> + dev_err(xbl_data->dev, "%s: memory remap failed\n", name);
> + return -ENOMEM;
> + }
> +
> + return 0;
> +}
> +
> +static int xbl_log_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct xbl_log_data *xbl_data;
> + struct device_node *parent;
> + int ret;
> +
> + xbl_data = devm_kzalloc(dev, sizeof(*xbl_data), GFP_KERNEL);
> + if (!xbl_data)
> + return -ENOMEM;
> +
> + xbl_data->dev = &pdev->dev;
> + platform_set_drvdata(pdev, xbl_data);
> +
> + parent = of_find_node_by_path("/reserved-memory");
> + if (!parent) {
> + dev_err(xbl_data->dev, "reserved-memory node missing\n");
> + return -ENODEV;
> + }
> +
You would need to present the Device Tree binding document for this. For
ex: pls see
Documentation/devicetree/bindings/reserved-memory/qcom,cmd-db.yaml
> + ret = map_addr_range(&parent, "uefi-log", xbl_data);
> + if (ret)
> + goto put_node;
> +
> + xbl_data->dbg_data.data = xbl_data->xbl_buf;
> + xbl_data->dbg_data.size = xbl_data->buf_size;
> + xbl_data->dbg_file = debugfs_create_blob("xbl_log", 0400, NULL,
> + &xbl_data->dbg_data);
> + if (IS_ERR(xbl_data->dbg_file)) {
> + dev_err(xbl_data->dev, "failed to create debugfs entry\n");
> + ret = PTR_ERR(xbl_data->dbg_file);
> + }
> +
> +put_node:
> + of_node_put(parent);
> + return ret;
> +}
> +
> +static int xbl_log_remove(struct platform_device *pdev)
> +{
> + struct xbl_log_data *xbl_data = platform_get_drvdata(pdev);
> +
> + debugfs_remove_recursive(xbl_data->dbg_file);
> + return 0;
> +}
> +
> +static struct platform_driver xbl_log_driver = {
> + .probe = xbl_log_probe,
> + .remove = xbl_log_remove,
> + .driver = {
> + .name = "xbl-log",
> + },
> +};
> +
> +static struct platform_device xbl_log_device = {
> + .name = "xbl-log",
> +};
> +
> +static int __init xbl_log_init(void)
> +{
> + int ret = 0;
> +
> + ret = platform_driver_register(&xbl_log_driver);
> + if (!ret) {
> + ret = platform_device_register(&xbl_log_device);
> + if (ret)
> + platform_driver_unregister(&xbl_log_driver);
> + }
> + return ret;
> +}
> +
The platform device registration, the resource parsing can be completely
avoided by adding your compatible entry to reserved_mem_matches
structure defined in drivers/of/platform.c . There are some Qualcomm SoC
devices also present in that list.
> +static void __exit xbl_log_exit(void)
> +{
> + platform_device_unregister(&xbl_log_device);
> + platform_driver_unregister(&xbl_log_driver);
> +}
> +
> +module_init(xbl_log_init);
> +module_exit(xbl_log_exit);
> +
> +MODULE_DESCRIPTION("Qualcomm Technologies, Inc. (QTI) XBL log driver");
> +MODULE_LICENSE("GPL");
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-08-22 12:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 12:15 [RFC PATCH 0/1] " Ninad Naik
2023-08-22 12:15 ` [RFC PATCH 1/1] soc: qcom: " Ninad Naik
2023-08-22 12:39 ` Pavan Kondeti [this message]
2023-08-23 11:06 ` Ninad Naik
2023-08-22 12:43 ` Bryan O'Donoghue
2023-08-22 15:14 ` Jeff Johnson
2023-08-23 11:08 ` Ninad Naik
2023-08-23 11:08 ` Ninad Naik
2023-08-22 13:41 ` Srinivas Kandagatla
2023-08-23 11:09 ` Ninad Naik
2023-08-22 16:08 ` Trilok Soni
2023-08-23 11:16 ` Ninad Naik
2023-08-23 19:32 ` Trilok Soni
2023-08-28 17:19 ` [RFC PATCH 0/1] " Arun Kumar Neelakantam
2023-08-28 18:44 ` Trilok Soni
2023-08-28 19:20 ` Bjorn Andersson
2023-09-12 16:08 ` Nikunj Kela
2023-09-12 16:11 ` Trilok Soni
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=d0f663e7-cee4-451e-9b28-99ba7e6f674a@quicinc.com \
--to=quic_pkondeti@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=kernel@quicinc.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=psodagud@quicinc.com \
--cc=quic_kprasan@quicinc.com \
--cc=quic_ninanaik@quicinc.com \
--cc=quic_ppareek@quicinc.com \
/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®