linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Mukesh Ojha <quic_mojha@quicinc.com>
Cc: 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,
	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
Subject: Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
Date: Wed, 28 Jun 2023 16:43:34 +0300	[thread overview]
Message-ID: <CAHp75VfF=TVBiTBGeDuGdROPFbS=zbc4ABjPL1cCfWe0rTxhQA@mail.gmail.com> (raw)
In-Reply-To: <1687955688-20809-5-git-send-email-quic_mojha@quicinc.com>

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> 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 region should
> be included in the ramdump. The solution supports extracting the
> ramdump/minidump produced either over USB or stored to an attached
> storage device.
>
> Minidump kernel driver implementation is divided into two parts for
> simplicity, one is minidump core which can also be called minidump
> frontend(As API gets exported from this driver for registration with
> backend) and the other part is minidump backend i.e, where the underlying
> implementation of minidump will be there. There could be different way
> how the backend is implemented like Shared memory, Memory mapped IO
> or Resource manager based where the guest region information is passed
> to hypervisor via hypercalls.
>
> 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)
>
> Here, we will be giving all analogy of backend with SMEM as it is the
> only implemented backend at present but general idea remains the same.

the general

>
> 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

the minidump

> global table of content (G-ToC). Each subsystem (APSS, ADSP, ...) has
> their 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 it's size etc. and it
> could be anywhere scattered in the DDR.
>
> qcom_minidump(core or frontend) driver adds the capability to add APSS
> region to be dumped as part of ram dump collection. It provides
> appropriate symbol register/unregister client regions.
>
> To simplify post mortem debugging, it creates and maintain an ELF
> header as first region that gets updated upon registration
> of a new region.

...

> +#include <linux/device.h>
> +#include <linux/export.h>
> +#include <linux/kallsyms.h>

> +#include <linux/kernel.h>

Why?

And again a lot of missing headers, like

bug.h
dev_printk.h
errno.h
export.h
mutex.h
slab.h

> +#include <linux/module.h>
> +#include <linux/printk.h>
> +#include <linux/string.h>

...

> +/*
> + * In some of the Old Qualcomm devices, boot firmware statically allocates 300
> + * as total number of supported region (including all co-processors) in

regions

> + * minidump table out of which linux was using 201. In future, this limitation
> + * from boot firmware might get removed by allocating the region dynamically.
> + * So, keep it compatible with older devices, we can keep the current limit for

So, to keep...

> + * Linux to 201.
> + */

...

> +static struct elf_shdr *elf_shdr_entry_addr(struct elfhdr *ehdr, int idx)
> +{
> +       struct elf_shdr *eshdr = (struct elf_shdr *)((size_t)ehdr + ehdr->e_shoff);

Interesting casting pointer to a size_t. Perhaps void * would work
more explicitly?
Ditto for all other cases like this.

> +       return &eshdr[idx];
> +}

...

> +       old_idx += strscpy((strtab + old_idx), name, MAX_REGION_NAME_LENGTH);

(Parentheses are not needed)

strscpy() might return a very big number in this case. Is it a problem?

...

> +unlock:

out_unlock: ?

Ditto for other similar cases.

> +       mutex_unlock(&md_lock);
> +       return ret;

...

> +       /*
> +        * Above are some prdefined sections/program header used

predefined

> +        * for debug, update their count here.
> +        */

...

> +#ifndef _QCOM_MINIDUMP_INTERNAL_H_
> +#define _QCOM_MINIDUMP_INTERNAL_H_

> +#include <linux/elf.h>

Not sure I see how it's used. You may provide forward declarations for
the pointers.

> +#include <soc/qcom/qcom_minidump.h>

+ kconfig.h for IS_ENABLED() ?

MIssing forward declaration:
struct device;

...

>  #ifndef _QCOM_MINIDUMP_H_
>  #define _QCOM_MINIDUMP_H_

+ types.h for phys_addr_t.

...

> + * @size:      Number of byte to dump from @address location,

bytes

> + *             and it should be 4 byte aligned.

-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2023-06-28 13:44 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 ` [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide Mukesh Ojha
2023-06-28 23:21   ` 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 [this message]
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='CAHp75VfF=TVBiTBGeDuGdROPFbS=zbc4ABjPL1cCfWe0rTxhQA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --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=quic_mojha@quicinc.com \
    --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).