[RFC PATCH 0/6] Add basic Minidump kernel driver support

From: Mukesh Ojha
Date: Tue Feb 21 2023 - 06:26:35 EST


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 ramdumps 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 which snippets should be
included in the ramdump.

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 SMEM to minidump table i.e also called
global table of content (G-ToC). Each subsystem (APSS, ADSP, ...) has
their own table of segments to be included in the minidump and all get
their reference from G-ToC. Each segment/region has some details like
name, physical address and it's size etc. and it could be anywhere
scattered in the DDR.

Existing upstream Qualcomm remoteproc driver[1] already supports minidump
feature for remoteproc instances like ADSP, MODEM, ... where predefined
selective segments of subsystem region can be dumped as part of
coredump collection which generates smaller size artifacts compared to
complete coredump of subsystem on crash.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/drivers/remoteproc/qcom_common.c#n142

In addition to managing and querying the APSS minidump description,
the Linux driver maintains a ELF header in a segment. This segment
gets updated with section/program header whenever a new entry gets
registered.

Patch 1/6 is very trivial change.
Patch 2/6 moves the minidump specific data structure and macro to
qcom_minidump.h so that (3/6) minidump driver can use.
Patch 3/6 implements qualcomm minidump kernel driver and exports
symbol which other minidump kernel client can use.
Patch 4/6 enables the qualcomm minidump driver.
Patch 5/6 Use the exported symbol from minidump driver in qcom_common
for querying minidump descriptor for a subsystem.
Patch 6/6 Register pstore region with minidump.

Testing of the patches has been done on sm8450 target with the help
of out of tree patch which helps to set the download mode and storage
type(on which dump will be saved) for which i will send separate series.

Mukesh Ojha (6):
remoteproc: qcom: Expand MD_* as MINIDUMP_*
remoteproc: qcom: Move minidump specific data to qcom_minidump.h
soc: qcom: Add Qualcomm minidump kernel driver
arm64: defconfig: Enable Qualcomm minidump driver
remoterproc: qcom: refactor to leverage exported minidump symbol
pstore/ram: Register context with minidump

arch/arm64/configs/defconfig | 1 +
drivers/remoteproc/qcom_common.c | 75 +-----
drivers/soc/qcom/Kconfig | 14 ++
drivers/soc/qcom/Makefile | 1 +
drivers/soc/qcom/qcom_minidump.c | 490 +++++++++++++++++++++++++++++++++++++++++
fs/pstore/ram.c | 77 ++++++
include/soc/qcom/minidump.h | 40 ++++
include/soc/qcom/qcom_minidump.h | 88 +++++++
8 files changed, 717 insertions(+), 69 deletions(-)
create mode 100644 drivers/soc/qcom/qcom_minidump.c
create mode 100644 include/soc/qcom/minidump.h
create mode 100644 include/soc/qcom/qcom_minidump.h

--
2.7.4