From: Mukesh Ojha <quic_mojha@quicinc.com>
To: <corbet@lwn.net>, <agross@kernel.org>, <andersson@kernel.org>,
<konrad.dybcio@linaro.org>, <robh+dt@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <conor+dt@kernel.org>,
<keescook@chromium.org>, <tony.luck@intel.com>,
<gpiccoli@igalia.com>, <mathieu.poirier@linaro.org>,
<catalin.marinas@arm.com>, <will@kernel.org>,
<linus.walleij@linaro.org>, <andy.shevchenko@gmail.com>
Cc: <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-hardening@vger.kernel.org>,
<linux-remoteproc@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-gpio@vger.kernel.org>,
"Mukesh Ojha" <quic_mojha@quicinc.com>
Subject: [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide
Date: Wed, 28 Jun 2023 18:04:28 +0530 [thread overview]
Message-ID: <1687955688-20809-2-git-send-email-quic_mojha@quicinc.com> (raw)
In-Reply-To: <1687955688-20809-1-git-send-email-quic_mojha@quicinc.com>
Add the qualcomm minidump guide for the users which
tries to cover the dependency and the way to test
and collect minidump on Qualcomm supported platforms.
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
Documentation/admin-guide/index.rst | 1 +
Documentation/admin-guide/qcom_minidump.rst | 293 ++++++++++++++++++++++++++++
2 files changed, 294 insertions(+)
create mode 100644 Documentation/admin-guide/qcom_minidump.rst
diff --git a/Documentation/admin-guide/index.rst b/Documentation/admin-guide/index.rst
index 43ea35613dfc..251d070486c2 100644
--- a/Documentation/admin-guide/index.rst
+++ b/Documentation/admin-guide/index.rst
@@ -120,6 +120,7 @@ configure specific aspects of kernel behavior to your liking.
perf-security
pm/index
pnp
+ qcom_minidump
rapidio
ras
rtc
diff --git a/Documentation/admin-guide/qcom_minidump.rst b/Documentation/admin-guide/qcom_minidump.rst
new file mode 100644
index 000000000000..a3a8cfee4555
--- /dev/null
+++ b/Documentation/admin-guide/qcom_minidump.rst
@@ -0,0 +1,293 @@
+Qualcomm Minidump Feature
+=========================
+
+Introduction
+------------
+
+Minidump is a best effort mechanism to collect useful and predefined
+data for first level of debugging on end user devices running on
+Qualcomm SoCs. It is built on the premise that System on Chip (SoC)
+or subsystem part of SoC crashes, due to a range of hardware and
+software bugs. Hence, the ability to collect accurate data is only
+a best-effort. The data collected could be invalid or corrupted, data
+collection itself could fail, and so on.
+
+Qualcomm devices in engineering mode provides a mechanism for generating
+full system RAM dumps for post-mortem debugging. But in some cases it's
+however not feasible to capture the entire content of RAM. The minidump
+mechanism provides the means for selecting region should be included in
+the ramdump.
+
+::
+
+ +-----------------------------------------------+
+ | DDR +-------------+ |
+ | | SS0-ToC| |
+ | +----------------+ +----------------+ | |
+ | |Shared memory | | SS1-ToC| | |
+ | |(SMEM) | | | | |
+ | | | +-->|--------+ | | |
+ | |G-ToC | | | SS-ToC \ | | |
+ | |+-------------+ | | | +-----------+ | | |
+ | ||-------------| | | | |-----------| | | |
+ | || SS0-ToC | | | +-|<|SS1 region1| | | |
+ | ||-------------| | | | | |-----------| | | |
+ | || SS1-ToC |-|>+ | | |SS1 region2| | | |
+ | ||-------------| | | | |-----------| | | |
+ | || SS2-ToC | | | | | ... | | | |
+ | ||-------------| | | | |-----------| | | |
+ | || ... | | |-|<|SS1 regionN| | | |
+ | ||-------------| | | | |-----------| | | |
+ | || SSn-ToC | | | | +-----------+ | | |
+ | |+-------------+ | | | | | |
+ | | | | |----------------| | |
+ | | | +>| regionN | | |
+ | | | | |----------------| | |
+ | +----------------+ | | | | |
+ | | |----------------| | |
+ | +>| region1 | | |
+ | |----------------| | |
+ | | | | |
+ | |----------------|-+ |
+ | | region5 | |
+ | |----------------| |
+ | | | |
+ | Region information +----------------+ |
+ | +---------------+ |
+ | |region name | |
+ | |---------------| |
+ | |region address | |
+ | |---------------| |
+ | |region size | |
+ | +---------------+ |
+ +-----------------------------------------------+
+ G-ToC: Global table of contents
+ SS-ToC: Subsystem table of contents
+ SS0-SSn: Subsystem numbered from 0 to n
+
+It depends on targets how the underlying hardware taking care of the
+implementation part for minidump like above diagram is for shared
+memory and it is possible that this could be implemented via memory
+mapped regions but the general idea remain same.
+
+In this document, SMEM will be used as the backend implementation of
+minidump.
+
+SMEM as backend
+----------------
+
+The core of minidump feature is part of Qualcomm's boot firmware code.
+It initializes shared memory (SMEM), which is a part of DDR and
+allocates a small section of it to minidump table, i.e. also called
+global table of contents (G-ToC). Each subsystem (APSS, ADSP, ...) has
+its own table of segments to be included in the minidump, all
+references from a descriptor in SMEM (G-ToC). Each segment/region has
+some details like name, physical address and its size etc. and it
+could be anywhere scattered in the DDR.
+
+Minidump kernel driver concept
+------------------------------
+::
+
+ Minidump Client-1 Client-2 Client-5 Client-n
+ | | | |
+ | | ... | ... |
+ | | | |
+ | | | |
+ | | | |
+ | | | |
+ | | | |
+ | | | |
+ | +---+--------------+----+ |
+ +-----------+ qcom_minidump(core) +--------+
+ | |
+ +------+-----+------+---+
+ | | |
+ | | |
+ +---------------+ | +--------------------+
+ | | |
+ | | |
+ | | |
+ v v v
+ +-------------------+ +-------------------+ +------------------+
+ |qcom_minidump_smem | |qcom_minidump_mmio | | qcom_minidump_rm |
+ | | | | | |
+ +-------------------+ +-------------------+ +------------------+
+ Shared memory Memory mapped IO Resource manager
+ (backend) (backend) (backend)
+
+
+Kernel implementation of minidump driver is divided into two parts one is,
+the core implementation called frontend driver ``qcom_minidump.c`` and this
+is the driver will be exposing the API for clients and the other part is,
+backend driver and its depends whether it is based on SMEM, MMIO or some
+other way corressponding driver will be hooking itself up with the core
+driver to get itself working. As of now, at a time one and only one backend
+can be attached to the front-end either it is HOST or a guest VM.
+
+Qualcomm minidump kernel driver adds the capability to add Linux region
+to be dumped as part of RAM dump collection. At the moment, shared memory
+driver creates platform device for minidump driver and give a means to
+APSS minidump to initialize itself on probe.
+
+This driver provides ``qcom_minidump_region_register`` and
+``qcom_minidump_region_unregister`` API's to register and unregister
+APSS minidump region. It also gives a mechanism to update physical/virtual
+address for the client whose addresses keeps on changing, e.g., current stack
+address of task keeps on changing on context switch for each core. So these
+clients can update their addresses with ``qcom_minidump_update_region``
+API.
+
+The driver also supports registration for the clients who came before
+minidump driver was initialized. It maintains pending list of clients
+who came before minidump and once minidump is initialized it registers
+them in one go.
+
+To simplify post-mortem debugging, driver creates and maintain an ELF
+header as first region that gets updated each time a new region gets
+registered.
+
+The solution supports extracting the RAM dump/minidump produced either
+over USB or stored to an attached storage device.
+
+Dependency of minidump kernel driver
+------------------------------------
+
+It is to note that whole of minidump depends on Qualcomm boot
+firmware whether it supports minidump or not. So, if the minidump
+SMEM ID is present in shared memory, it indicates that minidump
+is supported from boot firmware and it is possible to dump Linux
+(APSS) region as part of minidump collection.
+
+How a kernel client driver can register region with minidump
+------------------------------------------------------------
+
+Client driver can use ``qcom_minidump_region_register`` API's to
+register and ``qcom_minidump_region_unregister`` to unregister
+their region from minidump driver.
+
+Client needs to fill their region by filling ``qcom_minidump_region``
+structure object which consists of the region name, region's
+virtual and physical address and its size.
+
+Below is one sample client driver snippet which tries to allocate
+a region from kernel heap of certain size and it writes a certain
+known pattern (that can help in verification after collection
+that we got the exact pattern, what we wrote) and registers it with
+minidump.
+
+ .. code-block:: c
+
+ #include <soc/qcom/qcom_minidump.h>
+ [...]
+
+
+ [... inside a function ...]
+ struct qcom_minidump_region region;
+
+ [...]
+
+ client_mem_region = kzalloc(region_size, GFP_KERNEL);
+ if (!client_mem_region)
+ return -ENOMEM;
+
+ [... Just write a pattern ...]
+ memset(client_mem_region, 0xAB, region_size);
+
+ [... Fill up the region object ...]
+ strlcpy(region.name, "REGION_A", sizeof(region.name));
+ region.virt_addr = client_mem_region;
+ region.phys_addr = virt_to_phys(client_mem_region);
+ region.size = region_size;
+
+ ret = qcom_minidump_region_register(®ion);
+ if (ret < 0) {
+ pr_err("failed to add region in minidump: err: %d\n", ret);
+ return ret;
+ }
+
+ [...]
+
+
+Test
+----
+
+Existing Qualcomm devices already supports entire RAM dump (also called
+full dump) by writing appropriate value to Qualcomm's top control and
+status register (tcsr) in ``driver/firmware/qcom_scm.c`` .
+
+SCM device Tree bindings required to support download mode
+For example (sm8450) ::
+
+ / {
+
+ [...]
+
+ firmware {
+ scm: scm {
+ compatible = "qcom,scm-sm8450", "qcom,scm";
+ [... tcsr register ... ]
+ qcom,dload-mode = <&tcsr 0x13000>;
+
+ [...]
+ };
+ };
+
+ [...]
+
+ soc: soc@0 {
+
+ [...]
+
+ tcsr: syscon@1fc0000 {
+ compatible = "qcom,sm8450-tcsr", "syscon";
+ reg = <0x0 0x1fc0000 0x0 0x30000>;
+ };
+
+ [...]
+ };
+ [...]
+
+ };
+
+User of minidump can pass ``qcom_scm.download_mode="mini"`` to kernel
+commandline to set the current download mode to minidump.
+Similarly, ``"full"`` is passed to set the download mode to full dump
+where entire RAM dump will be collected while setting it ``"full,mini"``
+will collect minidump along with fulldump.
+
+Writing to sysfs node can also be used to set the mode to minidump::
+
+ echo "mini" > /sys/module/qcom_scm/parameter/download_mode
+
+Once the download mode is set, any kind of crash will make the device collect
+respective dump as per set download mode.
+
+Dump collection
+---------------
+
+The solution supports extracting the minidump produced either over USB or
+stored to an attached storage device.
+
+By default, dumps are downloaded via USB to the attached x86_64 machine
+running PCAT (Qualcomm tool) software. Upon download, we will see
+a set of binary blobs starting with name ``md_*`` in PCAT configured directory
+in x86_64 machine, so for above example from the client it will be
+``md_REGION_A.BIN``. This binary blob depends on region content to determine
+whether it needs external parser support to get the content of the region,
+so for simple plain ASCII text we don't need any parsing and the content
+can be seen just opening the binary file.
+
+To collect the dump to attached storage type, one needs to write appropriate
+value to IMEM register, in that case dumps are collected in rawdump
+partition on the target device itself.
+
+One needs to read the entire rawdump partition and pull out content to
+save it onto the attached x86_64 machine over USB. Later, this rawdump
+can be passed to another tool (``dexter.exe`` [Qualcomm tool]) which converts
+this into the similar binary blobs which we have got it when download type
+was set to USB, i.e. a set of registered regions as blobs and their name
+starts with ``md_*``.
+
+Replacing the ``dexter.exe`` with some open source tool can be added as future
+scope of this document.
--
2.7.4
next prev parent reply other threads:[~2023-06-28 12:38 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-28 12:34 [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support Mukesh Ojha
2023-06-28 12:34 ` Mukesh Ojha [this message]
2023-06-28 23:21 ` [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide Rob Herring
2023-06-28 12:34 ` [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name Mukesh Ojha
2023-06-28 13:24 ` Andy Shevchenko
2023-06-28 15:04 ` Mukesh Ojha
2023-06-28 13:53 ` Pavan Kondeti
2023-06-28 15:22 ` Mukesh Ojha
2023-06-28 15:32 ` Will Deacon
2023-06-28 15:43 ` Greg KH
2023-06-28 12:34 ` [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module Mukesh Ojha
2023-06-28 13:31 ` Andy Shevchenko
2023-06-28 15:47 ` Greg KH
2023-06-28 12:34 ` [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support Mukesh Ojha
2023-06-28 13:43 ` Andy Shevchenko
2023-06-29 2:33 ` Pavan Kondeti
2023-06-30 7:15 ` Mukesh Ojha
2023-06-30 8:38 ` Pavan Kondeti
2023-06-28 12:34 ` [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support Mukesh Ojha
2023-06-28 13:51 ` Andy Shevchenko
2023-06-28 12:34 ` [PATCH v4 06/21] soc: qcom: minidump: Add pending region registration support Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 07/21] soc: qcom: minidump: Add update region support Mukesh Ojha
2023-06-29 2:49 ` Pavan Kondeti
2023-06-28 12:34 ` [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding Mukesh Ojha
2023-06-28 14:10 ` Pavan Kondeti
2023-06-28 23:17 ` Rob Herring
2023-06-29 1:45 ` Pavan Kondeti
2023-06-28 14:47 ` Rob Herring
2023-06-28 15:01 ` Mukesh Ojha
2023-07-02 8:12 ` Krzysztof Kozlowski
2023-07-03 6:21 ` Mukesh Ojha
2023-07-03 7:20 ` Krzysztof Kozlowski
2023-07-03 15:55 ` Mukesh Ojha
2023-07-04 5:57 ` Krzysztof Kozlowski
2023-07-19 10:29 ` Luca Stefani
2023-06-28 12:34 ` [PATCH v4 09/21] pstore/ram : Export ramoops_parse_dt() symbol Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support Mukesh Ojha
2023-06-28 22:57 ` Rob Herring
2023-06-29 9:16 ` Mukesh Ojha
2023-07-05 23:27 ` Rob Herring
2023-06-28 12:34 ` [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump Mukesh Ojha
2023-06-30 4:55 ` Pavan Kondeti
2023-06-30 9:25 ` Andy Shevchenko
2023-06-28 12:34 ` [PATCH v4 12/21] remoteproc: qcom: Expand MD_* as MINIDUMP_* Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol Mukesh Ojha
2023-06-28 15:51 ` Pavan Kondeti
2023-06-29 9:20 ` Mukesh Ojha
2023-06-30 3:41 ` Pavan Kondeti
2023-06-28 12:34 ` [PATCH v4 14/21] MAINTAINERS: Add entry for minidump driver related support Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 15/21] arm64: defconfig: Enable Qualcomm Minidump related drivers Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 16/21] arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function Mukesh Ojha
2023-06-30 5:01 ` Pavan Kondeti
2023-06-28 12:34 ` [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field() Mukesh Ojha
2023-06-28 13:44 ` Andy Shevchenko
2023-06-30 14:58 ` Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register Mukesh Ojha
2023-06-28 15:20 ` Konrad Dybcio
2023-06-30 14:57 ` Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode Mukesh Ojha
2023-06-30 5:25 ` Pavan Kondeti
2023-06-30 9:28 ` Andy Shevchenko
2023-06-28 12:34 ` [PATCH v4 21/21] firmware: qcom_scm: Add multiple download mode support Mukesh Ojha
2023-06-28 15:45 ` [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support Greg KH
2023-06-28 16:20 ` Mukesh Ojha
2023-06-28 16:53 ` Greg KH
2023-06-28 23:12 ` Rob Herring
2023-06-30 16:04 ` Mukesh Ojha
2023-07-02 8:29 ` Krzysztof Kozlowski
2023-07-03 21:05 ` Trilok Soni
2023-07-06 17:20 ` Mathieu Poirier
2023-07-18 15:03 ` Mukesh Ojha
2023-08-07 13:46 ` Mukesh Ojha
2023-07-06 17:40 ` Rob Herring
2023-07-06 18:07 ` Trilok Soni
2023-08-10 16:47 ` Mukesh Ojha
2023-07-04 9:27 ` Linus Walleij
2023-07-05 17:29 ` Trilok Soni
2023-07-14 23:45 ` Trilok Soni
2023-07-18 5:47 ` Mukesh Ojha
2023-07-18 13:35 ` Greg KH
2023-07-18 13:55 ` Mukesh Ojha
2023-07-18 14:41 ` Greg KH
2023-07-18 16:22 ` Trilok Soni
2023-07-02 8:08 ` Krzysztof Kozlowski
2023-07-13 4:39 ` Kathiravan T
2023-07-14 15:25 ` Mukesh Ojha
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=1687955688-20809-2-git-send-email-quic_mojha@quicinc.com \
--to=quic_mojha@quicinc.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=gpiccoli@igalia.com \
--cc=keescook@chromium.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=robh+dt@kernel.org \
--cc=tony.luck@intel.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).