All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 12:34 ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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.

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(gunyah) 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 core of SMEM based 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 SMEM
based 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.


 docs: qcom: Add qualcomm minidump guide
  kallsyms: Export kallsyms_lookup_name
  soc: qcom: Add qcom_minidump_smem module
  soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  soc: qcom: Add linux minidump smem backend driver support
  soc: qcom: minidump: Add pending region registration support
  soc: qcom: minidump: Add update region support
  dt-bindings: reserved-memory: Add qcom,ramoops binding
  pstore/ram : Export ramoops_parse_dt() symbol
  soc: qcom: Add qcom's pstore minidump driver support
  soc: qcom: Register pstore frontend region with minidump
  remoteproc: qcom: Expand MD_* as MINIDUMP_*
  remoterproc: qcom: refactor to leverage exported minidump symbol
  MAINTAINERS: Add entry for minidump driver related support
  arm64: defconfig: Enable Qualcomm Minidump related drivers
  arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
  firmware: qcom_scm: provide a read-modify-write function
  pinctrl: qcom: Use qcom_scm_io_update_field()
  firmware: scm: Modify only the download bits in TCSR register
  firmware: qcom_scm: Refactor code to support multiple download mode
  firmware: qcom_scm: Add multiple download mode support

Patch 1/21 is qualcomm minidump document
Patch 2/21 will export kallsyms_lookup_name will be needed for minidump module
Patch 3/21 moves the minidump specific data structure and macro to
 qcom_minidump_smem.c and later 13/21 will use the API and remove
 minidump specific code to qcom_minidump_smem file.
Patch 4/21 is qualcomm minidump core(frontend) driver
Patch 5/21 implements qualcomm smem backend kernel driver
Patch 6/21 add pending region support for the clients who came for
 registration before minidump.
Patch 7/21 add update region support for registered clients.
Patch 8/21 Add dt-binding for qualcomm ramoops driver which is also a minidump client driver
Patch 9/21 exported symbol from ramoops driver to avoid copy of the code.
Patch 10/21 Add qcom's pstore minidump driver support which adds ramoops platform device
            and 11/21 register existing pstore frontend regions.
Patch 12/21 and 13/21 does some clean up and code reuse.
Patch 16/21 enable qcom_ramoops driver for sm8450
Patch 17-21 are not new and has already been through 6 versions and
reason of adding here is for minidump testing purpose and it will be rebased
automatically along with new version of minidump series.

Testing of the patches has been done on sm8450 target after enabling config like
CONFIG_PSTORE_RAM and CONFIG_PSTORE_CONSOLE and once the device boots up.
Try crashing it via devmem2 0xf11c000(this is known to create xpu violation and
and put the device in download mode) on command prompt.

I have added download patch here numbered from 14/18 to 18/18
Earlier download mode setting patches were sent separately
https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Default storage type is set to via USB, so minidump would be downloaded with the
help of x86_64 machine (running PCAT tool) attached to Qualcomm device which has
backed minidump boot firmware support (more can be found patch 3/18)

Below patch [1] is to warm reset Qualcomm device which has upstream qcom
watchdog driver support.

After applying all patches, we can boot the device and can execute
following command.

echo mini > /sys/module/qcom_scm/parameters/download_mode
echo c > /proc/sysrq-trigger

This will make the device go to download mode and collect the minidump on to the
attached x86 machine running the Qualcomm PCAT tool(This comes as part Qualcomm
package manager kit).
After that we will see a bunch of predefined registered region as binary blobs files
starts with md_* downloaded on the x86 machine on given location in PCAT tool from
the target device.

A sample client example to dump a linux region has been given in patch 3/18 and as
well as can be seen in patch 12/18.

[1]
--------------------------->8-------------------------------------

commit f1124ccebd47550b4c9627aa162d9cdceba2b76f
Author: Mukesh Ojha <quic_mojha@quicinc.com>
Date:   Thu Mar 16 14:08:35 2023 +0530

    do not merge: watchdog bite on panic

    Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index 0d2209c..767e84a 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/watchdog.h>
 #include <linux/of_device.h>
+#include <linux/panic.h>

 enum wdt_reg {
        WDT_RST,
@@ -114,12 +115,28 @@ static int qcom_wdt_set_pretimeout(struct watchdog_device *wdd,
        return qcom_wdt_start(wdd);
 }

+static void qcom_wdt_bite_on_panic(struct qcom_wdt *wdt)
+{
+       writel(0, wdt_addr(wdt, WDT_EN));
+       writel(1, wdt_addr(wdt, WDT_BITE_TIME));
+       writel(1, wdt_addr(wdt, WDT_RST));
+       writel(QCOM_WDT_ENABLE, wdt_addr(wdt, WDT_EN));
+
+       wmb();
+
+       while(1)
+               udelay(1);
+}
+
 static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,
                            void *data)
 {
        struct qcom_wdt *wdt = to_qcom_wdt(wdd);
        u32 timeout;

+       if (in_panic)
+               qcom_wdt_bite_on_panic(wdt);
+
        /*
         * Trigger watchdog bite:
         *    Setup BITE_TIME to be 128ms, and enable WDT.
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 979b776..f913629 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -22,6 +22,7 @@ extern int panic_on_oops;
 extern int panic_on_unrecovered_nmi;
 extern int panic_on_io_nmi;
 extern int panic_on_warn;
+extern bool in_panic;

 extern unsigned long panic_on_taint;
 extern bool panic_on_taint_nousertaint;
diff --git a/kernel/panic.c b/kernel/panic.c
index 487f5b0..714f7f4 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -65,6 +65,8 @@ static unsigned int warn_limit __read_mostly;

 int panic_timeout = CONFIG_PANIC_TIMEOUT;
 EXPORT_SYMBOL_GPL(panic_timeout);
+bool in_panic = false;
+EXPORT_SYMBOL_GPL(in_panic);

 #define PANIC_PRINT_TASK_INFO          0x00000001
 #define PANIC_PRINT_MEM_INFO           0x00000002
@@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
        int old_cpu, this_cpu;
        bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;

+       in_panic = true;
        if (panic_on_warn) {
                /*
                 * This thread may hit another WARN() in the panic path.
--------------------------------------------------------------------------

Changes in v4:
 - Redesigned the driver and divided the driver into front end and backend (smem) so
   that any new backend can be attached easily to avoid code duplication.
 - Patch reordering as per the driver and subsystem to easier review of the code.
 - Removed minidump specific code from remoteproc to minidump smem based driver.
 - Enabled the all the driver as modules.
 - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]
 - Address comments made qcom_pstore_minidump driver and given its Device tree
   same set of properties as ramoops. [Luca/Kees]
 - Added patch for MAINTAINER file.
 - Include defconfig change as one patch as per [Krzysztof] suggestion.
 - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
 - Addressed comments made on dload mode patch v6 version 
   https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Changes in v3: https://lore.kernel.org/lkml/1683133352-10046-1-git-send-email-quic_mojha@quicinc.com/
 - Addressed most of the comments by Srini on v2 and refactored the minidump driver.
    - Added platform device support
    - Unregister region support.
 - Added update region for clients.
 - Added pending region support.
 - Modified the documentation guide accordingly.
 - Added qcom_pstore_ramdump client driver which happen to add ramoops platform
   device and also registers ramoops region with minidump.
 - Added download mode patch series with this minidump series. 
    https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Changes in v2: https://lore.kernel.org/lkml/1679491817-2498-1-git-send-email-quic_mojha@quicinc.com/
 - Addressed review comment made by [quic_tsoni/bmasney] to add documentation.
 - Addressed comments made by [srinivas.kandagatla]
 - Dropped pstore 6/6 from the last series, till i get conclusion to get pstore
   region in minidump.
 - Fixed issue reported by kernel test robot.

Changes in v1: https://lore.kernel.org/lkml/1676978713-7394-1-git-send-email-quic_mojha@quicinc.com/

Mukesh Ojha (21):
  docs: qcom: Add qualcomm minidump guide
  kallsyms: Export kallsyms_lookup_name
  soc: qcom: Add qcom_minidump_smem module
  soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  soc: qcom: Add linux minidump smem backend driver support
  soc: qcom: minidump: Add pending region registration support
  soc: qcom: minidump: Add update region support
  dt-bindings: reserved-memory: Add qcom,ramoops binding
  pstore/ram : Export ramoops_parse_dt() symbol
  soc: qcom: Add qcom's pstore minidump driver support
  soc: qcom: Register pstore frontend region with minidump
  remoteproc: qcom: Expand MD_* as MINIDUMP_*
  remoterproc: qcom: refactor to leverage exported minidump symbol
  MAINTAINERS: Add entry for minidump driver related support
  arm64: defconfig: Enable Qualcomm Minidump related drivers
  arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
  firmware: qcom_scm: provide a read-modify-write function
  pinctrl: qcom: Use qcom_scm_io_update_field()
  firmware: scm: Modify only the download bits in TCSR register
  firmware: qcom_scm: Refactor code to support multiple download mode
  firmware: qcom_scm: Add multiple download mode support

 Documentation/admin-guide/index.rst                |   1 +
 Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
 .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
 MAINTAINERS                                        |  15 +
 arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
 arch/arm64/configs/defconfig                       |   4 +
 drivers/firmware/Kconfig                           |  11 -
 drivers/firmware/qcom_scm.c                        |  85 ++-
 drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
 drivers/remoteproc/qcom_common.c                   | 142 +----
 drivers/soc/qcom/Kconfig                           |  39 ++
 drivers/soc/qcom/Makefile                          |   3 +
 drivers/soc/qcom/qcom_minidump.c                   | 582 +++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
 drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
 drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
 drivers/soc/qcom/smem.c                            |   9 +
 fs/pstore/ram.c                                    |  26 +-
 include/linux/firmware/qcom/qcom_scm.h             |   2 +
 include/linux/pstore_ram.h                         |   2 +
 include/soc/qcom/qcom_minidump.h                   |  64 +++
 kernel/kallsyms.c                                  |   2 +-
 22 files changed, 1973 insertions(+), 152 deletions(-)
 create mode 100644 Documentation/admin-guide/qcom_minidump.rst
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
 create mode 100644 drivers/soc/qcom/qcom_minidump.c
 create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
 create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
 create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
 create mode 100644 include/soc/qcom/qcom_minidump.h

-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 12:34 ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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.

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(gunyah) 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 core of SMEM based 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 SMEM
based 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.


 docs: qcom: Add qualcomm minidump guide
  kallsyms: Export kallsyms_lookup_name
  soc: qcom: Add qcom_minidump_smem module
  soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  soc: qcom: Add linux minidump smem backend driver support
  soc: qcom: minidump: Add pending region registration support
  soc: qcom: minidump: Add update region support
  dt-bindings: reserved-memory: Add qcom,ramoops binding
  pstore/ram : Export ramoops_parse_dt() symbol
  soc: qcom: Add qcom's pstore minidump driver support
  soc: qcom: Register pstore frontend region with minidump
  remoteproc: qcom: Expand MD_* as MINIDUMP_*
  remoterproc: qcom: refactor to leverage exported minidump symbol
  MAINTAINERS: Add entry for minidump driver related support
  arm64: defconfig: Enable Qualcomm Minidump related drivers
  arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
  firmware: qcom_scm: provide a read-modify-write function
  pinctrl: qcom: Use qcom_scm_io_update_field()
  firmware: scm: Modify only the download bits in TCSR register
  firmware: qcom_scm: Refactor code to support multiple download mode
  firmware: qcom_scm: Add multiple download mode support

Patch 1/21 is qualcomm minidump document
Patch 2/21 will export kallsyms_lookup_name will be needed for minidump module
Patch 3/21 moves the minidump specific data structure and macro to
 qcom_minidump_smem.c and later 13/21 will use the API and remove
 minidump specific code to qcom_minidump_smem file.
Patch 4/21 is qualcomm minidump core(frontend) driver
Patch 5/21 implements qualcomm smem backend kernel driver
Patch 6/21 add pending region support for the clients who came for
 registration before minidump.
Patch 7/21 add update region support for registered clients.
Patch 8/21 Add dt-binding for qualcomm ramoops driver which is also a minidump client driver
Patch 9/21 exported symbol from ramoops driver to avoid copy of the code.
Patch 10/21 Add qcom's pstore minidump driver support which adds ramoops platform device
            and 11/21 register existing pstore frontend regions.
Patch 12/21 and 13/21 does some clean up and code reuse.
Patch 16/21 enable qcom_ramoops driver for sm8450
Patch 17-21 are not new and has already been through 6 versions and
reason of adding here is for minidump testing purpose and it will be rebased
automatically along with new version of minidump series.

Testing of the patches has been done on sm8450 target after enabling config like
CONFIG_PSTORE_RAM and CONFIG_PSTORE_CONSOLE and once the device boots up.
Try crashing it via devmem2 0xf11c000(this is known to create xpu violation and
and put the device in download mode) on command prompt.

I have added download patch here numbered from 14/18 to 18/18
Earlier download mode setting patches were sent separately
https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Default storage type is set to via USB, so minidump would be downloaded with the
help of x86_64 machine (running PCAT tool) attached to Qualcomm device which has
backed minidump boot firmware support (more can be found patch 3/18)

Below patch [1] is to warm reset Qualcomm device which has upstream qcom
watchdog driver support.

After applying all patches, we can boot the device and can execute
following command.

echo mini > /sys/module/qcom_scm/parameters/download_mode
echo c > /proc/sysrq-trigger

This will make the device go to download mode and collect the minidump on to the
attached x86 machine running the Qualcomm PCAT tool(This comes as part Qualcomm
package manager kit).
After that we will see a bunch of predefined registered region as binary blobs files
starts with md_* downloaded on the x86 machine on given location in PCAT tool from
the target device.

A sample client example to dump a linux region has been given in patch 3/18 and as
well as can be seen in patch 12/18.

[1]
--------------------------->8-------------------------------------

commit f1124ccebd47550b4c9627aa162d9cdceba2b76f
Author: Mukesh Ojha <quic_mojha@quicinc.com>
Date:   Thu Mar 16 14:08:35 2023 +0530

    do not merge: watchdog bite on panic

    Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
index 0d2209c..767e84a 100644
--- a/drivers/watchdog/qcom-wdt.c
+++ b/drivers/watchdog/qcom-wdt.c
@@ -12,6 +12,7 @@
 #include <linux/platform_device.h>
 #include <linux/watchdog.h>
 #include <linux/of_device.h>
+#include <linux/panic.h>

 enum wdt_reg {
        WDT_RST,
@@ -114,12 +115,28 @@ static int qcom_wdt_set_pretimeout(struct watchdog_device *wdd,
        return qcom_wdt_start(wdd);
 }

+static void qcom_wdt_bite_on_panic(struct qcom_wdt *wdt)
+{
+       writel(0, wdt_addr(wdt, WDT_EN));
+       writel(1, wdt_addr(wdt, WDT_BITE_TIME));
+       writel(1, wdt_addr(wdt, WDT_RST));
+       writel(QCOM_WDT_ENABLE, wdt_addr(wdt, WDT_EN));
+
+       wmb();
+
+       while(1)
+               udelay(1);
+}
+
 static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,
                            void *data)
 {
        struct qcom_wdt *wdt = to_qcom_wdt(wdd);
        u32 timeout;

+       if (in_panic)
+               qcom_wdt_bite_on_panic(wdt);
+
        /*
         * Trigger watchdog bite:
         *    Setup BITE_TIME to be 128ms, and enable WDT.
diff --git a/include/linux/panic.h b/include/linux/panic.h
index 979b776..f913629 100644
--- a/include/linux/panic.h
+++ b/include/linux/panic.h
@@ -22,6 +22,7 @@ extern int panic_on_oops;
 extern int panic_on_unrecovered_nmi;
 extern int panic_on_io_nmi;
 extern int panic_on_warn;
+extern bool in_panic;

 extern unsigned long panic_on_taint;
 extern bool panic_on_taint_nousertaint;
diff --git a/kernel/panic.c b/kernel/panic.c
index 487f5b0..714f7f4 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -65,6 +65,8 @@ static unsigned int warn_limit __read_mostly;

 int panic_timeout = CONFIG_PANIC_TIMEOUT;
 EXPORT_SYMBOL_GPL(panic_timeout);
+bool in_panic = false;
+EXPORT_SYMBOL_GPL(in_panic);

 #define PANIC_PRINT_TASK_INFO          0x00000001
 #define PANIC_PRINT_MEM_INFO           0x00000002
@@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
        int old_cpu, this_cpu;
        bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;

+       in_panic = true;
        if (panic_on_warn) {
                /*
                 * This thread may hit another WARN() in the panic path.
--------------------------------------------------------------------------

Changes in v4:
 - Redesigned the driver and divided the driver into front end and backend (smem) so
   that any new backend can be attached easily to avoid code duplication.
 - Patch reordering as per the driver and subsystem to easier review of the code.
 - Removed minidump specific code from remoteproc to minidump smem based driver.
 - Enabled the all the driver as modules.
 - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]
 - Address comments made qcom_pstore_minidump driver and given its Device tree
   same set of properties as ramoops. [Luca/Kees]
 - Added patch for MAINTAINER file.
 - Include defconfig change as one patch as per [Krzysztof] suggestion.
 - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
 - Addressed comments made on dload mode patch v6 version 
   https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Changes in v3: https://lore.kernel.org/lkml/1683133352-10046-1-git-send-email-quic_mojha@quicinc.com/
 - Addressed most of the comments by Srini on v2 and refactored the minidump driver.
    - Added platform device support
    - Unregister region support.
 - Added update region for clients.
 - Added pending region support.
 - Modified the documentation guide accordingly.
 - Added qcom_pstore_ramdump client driver which happen to add ramoops platform
   device and also registers ramoops region with minidump.
 - Added download mode patch series with this minidump series. 
    https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/

Changes in v2: https://lore.kernel.org/lkml/1679491817-2498-1-git-send-email-quic_mojha@quicinc.com/
 - Addressed review comment made by [quic_tsoni/bmasney] to add documentation.
 - Addressed comments made by [srinivas.kandagatla]
 - Dropped pstore 6/6 from the last series, till i get conclusion to get pstore
   region in minidump.
 - Fixed issue reported by kernel test robot.

Changes in v1: https://lore.kernel.org/lkml/1676978713-7394-1-git-send-email-quic_mojha@quicinc.com/

Mukesh Ojha (21):
  docs: qcom: Add qualcomm minidump guide
  kallsyms: Export kallsyms_lookup_name
  soc: qcom: Add qcom_minidump_smem module
  soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  soc: qcom: Add linux minidump smem backend driver support
  soc: qcom: minidump: Add pending region registration support
  soc: qcom: minidump: Add update region support
  dt-bindings: reserved-memory: Add qcom,ramoops binding
  pstore/ram : Export ramoops_parse_dt() symbol
  soc: qcom: Add qcom's pstore minidump driver support
  soc: qcom: Register pstore frontend region with minidump
  remoteproc: qcom: Expand MD_* as MINIDUMP_*
  remoterproc: qcom: refactor to leverage exported minidump symbol
  MAINTAINERS: Add entry for minidump driver related support
  arm64: defconfig: Enable Qualcomm Minidump related drivers
  arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
  firmware: qcom_scm: provide a read-modify-write function
  pinctrl: qcom: Use qcom_scm_io_update_field()
  firmware: scm: Modify only the download bits in TCSR register
  firmware: qcom_scm: Refactor code to support multiple download mode
  firmware: qcom_scm: Add multiple download mode support

 Documentation/admin-guide/index.rst                |   1 +
 Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
 .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
 MAINTAINERS                                        |  15 +
 arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
 arch/arm64/configs/defconfig                       |   4 +
 drivers/firmware/Kconfig                           |  11 -
 drivers/firmware/qcom_scm.c                        |  85 ++-
 drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
 drivers/remoteproc/qcom_common.c                   | 142 +----
 drivers/soc/qcom/Kconfig                           |  39 ++
 drivers/soc/qcom/Makefile                          |   3 +
 drivers/soc/qcom/qcom_minidump.c                   | 582 +++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
 drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
 drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
 drivers/soc/qcom/smem.c                            |   9 +
 fs/pstore/ram.c                                    |  26 +-
 include/linux/firmware/qcom/qcom_scm.h             |   2 +
 include/linux/pstore_ram.h                         |   2 +
 include/soc/qcom/qcom_minidump.h                   |  64 +++
 kernel/kallsyms.c                                  |   2 +-
 22 files changed, 1973 insertions(+), 152 deletions(-)
 create mode 100644 Documentation/admin-guide/qcom_minidump.rst
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
 create mode 100644 drivers/soc/qcom/qcom_minidump.c
 create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
 create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
 create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
 create mode 100644 include/soc/qcom/qcom_minidump.h

-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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(&region);
+  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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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(&region);
+  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


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Module like minidump providing debugging support will need to
get the symbol information from the core kernel e.g to get
the linux_banner, kernel section addresses bss, data, ro etc.

commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
 and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
due to lack of in-tree user of the symbol. Now, that minidump
will one of its user, export it.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 77747391f49b..34a074f58736 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -283,7 +283,7 @@ unsigned long kallsyms_lookup_name(const char *name)
 
 	return module_kallsyms_lookup_name(name);
 }
-
+EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
 /*
  * Iterate over all symbols in vmlinux.  For symbols from modules use
  * module_kallsyms_on_each_symbol instead.
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Module like minidump providing debugging support will need to
get the symbol information from the core kernel e.g to get
the linux_banner, kernel section addresses bss, data, ro etc.

commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
 and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
due to lack of in-tree user of the symbol. Now, that minidump
will one of its user, export it.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 77747391f49b..34a074f58736 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -283,7 +283,7 @@ unsigned long kallsyms_lookup_name(const char *name)
 
 	return module_kallsyms_lookup_name(name);
 }
-
+EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
 /*
  * Iterate over all symbols in vmlinux.  For symbols from modules use
  * module_kallsyms_on_each_symbol instead.
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add qcom_minidump_smem module in a preparation to remove smem
based minidump specific code from driver/remoteproc/qcom_common.c
and provide needed exported API, this abstract minidump specific
data layout from qualcomm's remoteproc driver.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig              |   8 ++
 drivers/soc/qcom/qcom_minidump_smem.c | 147 ++++++++++++++++++++++++++++++++++
 include/soc/qcom/qcom_minidump.h      |  24 ++++++
 3 files changed, 179 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
 create mode 100644 include/soc/qcom/qcom_minidump.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index a491718f8064..982310b5a1cb 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -279,4 +279,12 @@ config QCOM_INLINE_CRYPTO_ENGINE
 	tristate
 	select QCOM_SCM
 
+config QCOM_MINIDUMP_SMEM
+	tristate "QCOM Minidump SMEM (as backend) Support"
+	depends on ARCH_QCOM
+	depends on QCOM_SMEM
+	help
+	  Enablement of core minidump feature is controlled from boot firmware
+	  side, and this config allow linux to query minidump segments associated
+	  with the remote processor and check its validity.
 endmenu
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
new file mode 100644
index 000000000000..b588833ea26e
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
+#include <linux/soc/qcom/smem.h>
+#include <soc/qcom/qcom_minidump.h>
+
+#define MAX_NUM_OF_SS           10
+#define MAX_REGION_NAME_LENGTH  16
+#define SBL_MINIDUMP_SMEM_ID	602
+#define MINIDUMP_REGION_VALID	('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_SS_ENCR_DONE	('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED	('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+/**
+ * struct minidump_region - Minidump region
+ * @name		: Name of the region to be dumped
+ * @seq_num:		: Use to differentiate regions with same name.
+ * @valid		: This entry to be dumped (if set to 1)
+ * @address		: Physical address of region to be dumped
+ * @size		: Size of the region
+ */
+struct minidump_region {
+	char	name[MAX_REGION_NAME_LENGTH];
+	__le32	seq_num;
+	__le32	valid;
+	__le64	address;
+	__le64	size;
+};
+
+/**
+ * struct minidump_subsystem - Subsystem's SMEM Table of content
+ * @status : Subsystem toc init status
+ * @enabled : if set to 1, this region would be copied during coredump
+ * @encryption_status: Encryption status for this subsystem
+ * @encryption_required : Decides to encrypt the subsystem regions or not
+ * @region_count : Number of regions added in this subsystem toc
+ * @regions_baseptr : regions base pointer of the subsystem
+ */
+struct minidump_subsystem {
+	__le32	status;
+	__le32	enabled;
+	__le32	encryption_status;
+	__le32	encryption_required;
+	__le32	region_count;
+	__le64	regions_baseptr;
+};
+
+/**
+ * struct minidump_global_toc - Global Table of Content
+ * @status : Global Minidump init status
+ * @md_revision : Minidump revision
+ * @enabled : Minidump enable status
+ * @subsystems : Array of subsystems toc
+ */
+struct minidump_global_toc {
+	__le32				status;
+	__le32				md_revision;
+	__le32				enabled;
+	struct minidump_subsystem	subsystems[MAX_NUM_OF_SS];
+};
+
+/**
+ * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address
+ * for given minidump index.
+ *
+ * @minidump_id: Subsystem minidump index.
+ * @seg_cnt:	 Segment count for a given minidump index
+ *
+ * Return: On success, it returns iomapped base segment address, otherwise NULL on error.
+ */
+void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt)
+{
+	struct minidump_global_toc *toc;
+	struct minidump_subsystem *subsystem;
+
+	/*
+	 * Get global minidump ToC and check if global table
+	 * pointer exists and init is set.
+	 */
+	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
+	if (IS_ERR(toc) || !toc->status)
+		return NULL;
+
+	/* Get subsystem table of contents using the minidump id */
+	subsystem = &toc->subsystems[minidump_id];
+
+	/**
+	 * Collect minidump if SS ToC is valid and segment table
+	 * is initialized in memory and encryption status is set.
+	 */
+	if (subsystem->regions_baseptr == 0 ||
+	    le32_to_cpu(subsystem->status) != 1 ||
+	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
+	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE)
+		return NULL;
+
+	*seg_cnt = le32_to_cpu(subsystem->region_count);
+
+	return ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
+			*seg_cnt * sizeof(struct minidump_region));
+}
+EXPORT_SYMBOL_GPL(qcom_ss_md_mapped_base);
+
+/**
+ * qcom_ss_valid_segment_info() - Checks segment sanity and gets it's details
+ *
+ * @ptr:  Segment IO-mapped base address.
+ * @i:	  Segment index.
+ * @name: Segment name.
+ * @da:	  Segment physical address.
+ * @size: Segment size.
+ *
+ * Return: It returns 0 on success and 1 if the segment is invalid and negative
+ *	   value on error.
+ */
+int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, size_t *size)
+{
+	struct minidump_region __iomem *tmp;
+	struct minidump_region region;
+
+	if (!ptr)
+		return -EINVAL;
+
+	tmp = ptr;
+	memcpy_fromio(&region, tmp + i, sizeof(region));
+
+	/* If it is not valid region, skip it */
+	if (le32_to_cpu(region.valid) != MINIDUMP_REGION_VALID)
+		return 1;
+
+	*name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
+	if (!*name)
+		return -ENOMEM;
+
+	*da = le64_to_cpu(region.address);
+	*size = le64_to_cpu(region.size);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info);
+
+MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver");
+MODULE_LICENSE("GPL");
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
new file mode 100644
index 000000000000..d7747c27fd45
--- /dev/null
+++ b/include/soc/qcom/qcom_minidump.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _QCOM_MINIDUMP_H_
+#define _QCOM_MINIDUMP_H_
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
+void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt);
+int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
+			       dma_addr_t *da, size_t *size);
+#else
+static inline void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt)
+{
+	return NULL;
+}
+static inline int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
+					     dma_addr_t *da, size_t *size)
+{
+	return -EINVAL;
+}
+#endif /* CONFIG_QCOM_MINIDUMP_SMEM */
+#endif /* _QCOM_MINIDUMP_H_ */
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add qcom_minidump_smem module in a preparation to remove smem
based minidump specific code from driver/remoteproc/qcom_common.c
and provide needed exported API, this abstract minidump specific
data layout from qualcomm's remoteproc driver.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig              |   8 ++
 drivers/soc/qcom/qcom_minidump_smem.c | 147 ++++++++++++++++++++++++++++++++++
 include/soc/qcom/qcom_minidump.h      |  24 ++++++
 3 files changed, 179 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
 create mode 100644 include/soc/qcom/qcom_minidump.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index a491718f8064..982310b5a1cb 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -279,4 +279,12 @@ config QCOM_INLINE_CRYPTO_ENGINE
 	tristate
 	select QCOM_SCM
 
+config QCOM_MINIDUMP_SMEM
+	tristate "QCOM Minidump SMEM (as backend) Support"
+	depends on ARCH_QCOM
+	depends on QCOM_SMEM
+	help
+	  Enablement of core minidump feature is controlled from boot firmware
+	  side, and this config allow linux to query minidump segments associated
+	  with the remote processor and check its validity.
 endmenu
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
new file mode 100644
index 000000000000..b588833ea26e
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -0,0 +1,147 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/io.h>
+#include <linux/soc/qcom/smem.h>
+#include <soc/qcom/qcom_minidump.h>
+
+#define MAX_NUM_OF_SS           10
+#define MAX_REGION_NAME_LENGTH  16
+#define SBL_MINIDUMP_SMEM_ID	602
+#define MINIDUMP_REGION_VALID	('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_SS_ENCR_DONE	('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED	('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+/**
+ * struct minidump_region - Minidump region
+ * @name		: Name of the region to be dumped
+ * @seq_num:		: Use to differentiate regions with same name.
+ * @valid		: This entry to be dumped (if set to 1)
+ * @address		: Physical address of region to be dumped
+ * @size		: Size of the region
+ */
+struct minidump_region {
+	char	name[MAX_REGION_NAME_LENGTH];
+	__le32	seq_num;
+	__le32	valid;
+	__le64	address;
+	__le64	size;
+};
+
+/**
+ * struct minidump_subsystem - Subsystem's SMEM Table of content
+ * @status : Subsystem toc init status
+ * @enabled : if set to 1, this region would be copied during coredump
+ * @encryption_status: Encryption status for this subsystem
+ * @encryption_required : Decides to encrypt the subsystem regions or not
+ * @region_count : Number of regions added in this subsystem toc
+ * @regions_baseptr : regions base pointer of the subsystem
+ */
+struct minidump_subsystem {
+	__le32	status;
+	__le32	enabled;
+	__le32	encryption_status;
+	__le32	encryption_required;
+	__le32	region_count;
+	__le64	regions_baseptr;
+};
+
+/**
+ * struct minidump_global_toc - Global Table of Content
+ * @status : Global Minidump init status
+ * @md_revision : Minidump revision
+ * @enabled : Minidump enable status
+ * @subsystems : Array of subsystems toc
+ */
+struct minidump_global_toc {
+	__le32				status;
+	__le32				md_revision;
+	__le32				enabled;
+	struct minidump_subsystem	subsystems[MAX_NUM_OF_SS];
+};
+
+/**
+ * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address
+ * for given minidump index.
+ *
+ * @minidump_id: Subsystem minidump index.
+ * @seg_cnt:	 Segment count for a given minidump index
+ *
+ * Return: On success, it returns iomapped base segment address, otherwise NULL on error.
+ */
+void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt)
+{
+	struct minidump_global_toc *toc;
+	struct minidump_subsystem *subsystem;
+
+	/*
+	 * Get global minidump ToC and check if global table
+	 * pointer exists and init is set.
+	 */
+	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
+	if (IS_ERR(toc) || !toc->status)
+		return NULL;
+
+	/* Get subsystem table of contents using the minidump id */
+	subsystem = &toc->subsystems[minidump_id];
+
+	/**
+	 * Collect minidump if SS ToC is valid and segment table
+	 * is initialized in memory and encryption status is set.
+	 */
+	if (subsystem->regions_baseptr == 0 ||
+	    le32_to_cpu(subsystem->status) != 1 ||
+	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
+	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE)
+		return NULL;
+
+	*seg_cnt = le32_to_cpu(subsystem->region_count);
+
+	return ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
+			*seg_cnt * sizeof(struct minidump_region));
+}
+EXPORT_SYMBOL_GPL(qcom_ss_md_mapped_base);
+
+/**
+ * qcom_ss_valid_segment_info() - Checks segment sanity and gets it's details
+ *
+ * @ptr:  Segment IO-mapped base address.
+ * @i:	  Segment index.
+ * @name: Segment name.
+ * @da:	  Segment physical address.
+ * @size: Segment size.
+ *
+ * Return: It returns 0 on success and 1 if the segment is invalid and negative
+ *	   value on error.
+ */
+int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, size_t *size)
+{
+	struct minidump_region __iomem *tmp;
+	struct minidump_region region;
+
+	if (!ptr)
+		return -EINVAL;
+
+	tmp = ptr;
+	memcpy_fromio(&region, tmp + i, sizeof(region));
+
+	/* If it is not valid region, skip it */
+	if (le32_to_cpu(region.valid) != MINIDUMP_REGION_VALID)
+		return 1;
+
+	*name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
+	if (!*name)
+		return -ENOMEM;
+
+	*da = le64_to_cpu(region.address);
+	*size = le64_to_cpu(region.size);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info);
+
+MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver");
+MODULE_LICENSE("GPL");
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
new file mode 100644
index 000000000000..d7747c27fd45
--- /dev/null
+++ b/include/soc/qcom/qcom_minidump.h
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _QCOM_MINIDUMP_H_
+#define _QCOM_MINIDUMP_H_
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
+void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt);
+int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
+			       dma_addr_t *da, size_t *size);
+#else
+static inline void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt)
+{
+	return NULL;
+}
+static inline int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
+					     dma_addr_t *da, size_t *size)
+{
+	return -EINVAL;
+}
+#endif /* CONFIG_QCOM_MINIDUMP_SMEM */
+#endif /* _QCOM_MINIDUMP_H_ */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig                  |  15 +
 drivers/soc/qcom/Makefile                 |   2 +
 drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
 include/soc/qcom/qcom_minidump.h          |  35 +++
 5 files changed, 583 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_minidump.c
 create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 982310b5a1cb..874ee8c3efe0 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
 	tristate
 	select QCOM_SCM
 
+config QCOM_MINIDUMP
+	tristate "QCOM Minidump APSS Core Infrastructure"
+	depends on ARCH_QCOM
+	help
+	  This config allow linux core infrastructure for APSS minidump for
+	  underlying backend(smem etc.) which can hook themselves to this and
+	  work as one unit. So, this config should be selected in combination
+	  with its backend.
+
+	  After this Linux clients driver can register their internal data
+	  structures and debug messages as part of the apss minidump region
+	  and when the SoC is crashed, and these selective regions will be
+	  dumped instead of the entire DDR. This saves significant amount
+	  of time and/or storage space.
+
 config QCOM_MINIDUMP_SMEM
 	tristate "QCOM Minidump SMEM (as backend) Support"
 	depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 89b775512bef..737d868757ac 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
 obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
 qcom_ice-objs			+= ice.o
 obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
+obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
+obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
new file mode 100644
index 000000000000..7744e57843ab
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -0,0 +1,456 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/device.h>
+#include <linux/export.h>
+#include <linux/kallsyms.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/string.h>
+
+#include "qcom_minidump_internal.h"
+
+/*
+ * In some of the Old Qualcomm devices, boot firmware statically allocates 300
+ * as total number of supported region (including all co-processors) in
+ * 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
+ * Linux to 201.
+ */
+#define MAX_NUM_ENTRIES	  201
+#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
+
+/*
+ * md_lock protects "md" during calls to qcom_minidump_backend_register(),
+ * qcom_minidump_backend_unregister().
+ */
+static DEFINE_MUTEX(md_lock);
+
+/* Only one front end will be attached to one back-end */
+static struct minidump *md;
+static char *md_backend;
+
+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);
+
+	return &eshdr[idx];
+}
+
+static struct elf_phdr *elf_phdr_entry_addr(struct elfhdr *ehdr, int idx)
+{
+	struct elf_phdr *ephdr = (struct elf_phdr *)((size_t)ehdr + ehdr->e_phoff);
+
+	return &ephdr[idx];
+}
+
+static char *elf_str_table_start(struct elfhdr *ehdr)
+{
+	struct elf_shdr *eshdr;
+
+	if (ehdr->e_shstrndx == SHN_UNDEF)
+		return NULL;
+
+	eshdr = elf_shdr_entry_addr(ehdr, ehdr->e_shstrndx);
+	return (char *)ehdr + eshdr->sh_offset;
+}
+
+static char *elf_lookup_string(struct elfhdr *ehdr, int offset)
+{
+	char *strtab = elf_str_table_start(ehdr);
+
+	if (!strtab || (md->elf.strtable_idx < offset))
+		return NULL;
+
+	return strtab + offset;
+}
+
+static unsigned int append_str_to_strtable(struct minidump *md, const char *name)
+{
+	char *strtab = elf_str_table_start(md->elf.ehdr);
+	unsigned int old_idx = md->elf.strtable_idx;
+	unsigned int ret;
+
+	if (!strtab || !name)
+		return 0;
+
+	ret = old_idx;
+	old_idx += strscpy((strtab + old_idx), name, MAX_REGION_NAME_LENGTH);
+	md->elf.strtable_idx = old_idx + 1;
+
+	return ret;
+}
+
+static int qcom_minidump_clear_header(const struct qcom_minidump_region *region)
+{
+	struct elfhdr *ehdr = md->elf.ehdr;
+	struct elf_shdr *shdr;
+	struct elf_shdr *tmp_shdr;
+	struct elf_phdr *phdr;
+	struct elf_phdr *tmp_phdr;
+	unsigned int phidx;
+	unsigned int shidx;
+	unsigned int len;
+	unsigned int i;
+	char *shname;
+
+	for (i = 0; i < ehdr->e_phnum; i++) {
+		phdr = elf_phdr_entry_addr(ehdr, i);
+		if (phdr->p_paddr == region->phys_addr &&
+		    phdr->p_memsz == region->size)
+			break;
+	}
+
+	if (i == ehdr->e_phnum) {
+		dev_err(md->dev, "Cannot find program header entry in elf\n");
+		return -EINVAL;
+	}
+
+	phidx = i;
+	for (i = 0; i < ehdr->e_shnum; i++) {
+		shdr = elf_shdr_entry_addr(ehdr, i);
+		shname = elf_lookup_string(ehdr, shdr->sh_name);
+		if (shname && !strcmp(shname, region->name) &&
+		    shdr->sh_addr == (elf_addr_t)region->virt_addr &&
+		    shdr->sh_size == region->size)
+			break;
+	}
+
+	if (i == ehdr->e_shnum) {
+		dev_err(md->dev, "Cannot find section header entry in elf\n");
+		return -EINVAL;
+	}
+
+	shidx = i;
+	if (shdr->sh_offset != phdr->p_offset) {
+		dev_err(md->dev, "Invalid entry details for region: %s\n", region->name);
+		return -EINVAL;
+	}
+
+	/* Clear name in string table */
+	len = strlen(shname) + 1;
+	memmove(shname, shname + len, md->elf.strtable_idx - shdr->sh_name - len);
+	md->elf.strtable_idx -= len;
+
+	/* Clear program header */
+	tmp_phdr = elf_phdr_entry_addr(ehdr, phidx);
+	for (i = phidx; i < ehdr->e_phnum - 1; i++) {
+		tmp_phdr = elf_phdr_entry_addr(ehdr, i + 1);
+		phdr = elf_phdr_entry_addr(ehdr, i);
+		memcpy(phdr, tmp_phdr, sizeof(struct elf_phdr));
+		phdr->p_offset = phdr->p_offset - region->size;
+	}
+	memset(tmp_phdr, 0, sizeof(struct elf_phdr));
+	ehdr->e_phnum--;
+
+	/* Clear section header */
+	tmp_shdr = elf_shdr_entry_addr(ehdr, shidx);
+	for (i = shidx; i < ehdr->e_shnum - 1; i++) {
+		tmp_shdr = elf_shdr_entry_addr(ehdr, i + 1);
+		shdr = elf_shdr_entry_addr(ehdr, i);
+		memcpy(shdr, tmp_shdr, sizeof(struct elf_shdr));
+		shdr->sh_offset -= region->size;
+		shdr->sh_name -= len;
+	}
+
+	memset(tmp_shdr, 0, sizeof(struct elf_shdr));
+	ehdr->e_shnum--;
+	md->elf.elf_offset -= region->size;
+
+	return 0;
+}
+
+static void qcom_md_update_elf_header(const struct qcom_minidump_region *region)
+{
+	struct elfhdr *ehdr = md->elf.ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+
+	shdr = elf_shdr_entry_addr(ehdr, ehdr->e_shnum++);
+	phdr = elf_phdr_entry_addr(ehdr, ehdr->e_phnum++);
+
+	shdr->sh_type = SHT_PROGBITS;
+	shdr->sh_name = append_str_to_strtable(md, region->name);
+	shdr->sh_addr = (elf_addr_t)region->virt_addr;
+	shdr->sh_size = region->size;
+	shdr->sh_flags = SHF_WRITE;
+	shdr->sh_offset = md->elf.elf_offset;
+	shdr->sh_entsize = 0;
+
+	phdr->p_type = PT_LOAD;
+	phdr->p_offset = md->elf.elf_offset;
+	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
+	phdr->p_paddr = region->phys_addr;
+	phdr->p_filesz = phdr->p_memsz = region->size;
+	phdr->p_flags = PF_R | PF_W;
+	md->elf.elf_offset += shdr->sh_size;
+}
+
+static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region)
+{
+	return region &&
+		strnlen(region->name, MAX_NAME_LENGTH) < MAX_NAME_LENGTH &&
+		region->virt_addr &&
+		region->size &&
+		IS_ALIGNED(region->size, 4);
+}
+
+/**
+ * qcom_minidump_region_register() - Register region in APSS Minidump table.
+ * @region: minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_region_register(const struct qcom_minidump_region *region)
+{
+	int ret;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		mutex_unlock(&md_lock);
+		pr_err("No backend registered yet, try again..");
+		return -EPROBE_DEFER;
+	}
+
+	ret = md->ops->md_region_register(md, region);
+	if (ret)
+		goto unlock;
+
+	qcom_md_update_elf_header(region);
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
+
+/**
+ * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
+ * @region: minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
+{
+	int ret;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		mutex_unlock(&md_lock);
+		pr_err("No backend registered yet, try again..");
+		return -EPROBE_DEFER;
+	}
+
+	ret = md->ops->md_region_unregister(md, region);
+	if (ret)
+		goto unlock;
+
+	ret = qcom_minidump_clear_header(region);
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
+
+static int qcom_minidump_add_elf_header(struct minidump *md_data)
+{
+	struct qcom_minidump_region elfregion;
+	struct elfhdr *ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+	unsigned int  elfh_size;
+	unsigned int strtbl_off;
+	unsigned int phdr_off;
+	char *linux_banner;
+	unsigned int banner_len;
+	char *banner;
+
+	linux_banner = (char *)kallsyms_lookup_name("linux_banner");
+	banner_len = strlen(linux_banner);
+	/*
+	 * Header buffer contains:
+	 * ELF header, (MAX_NUM_ENTRIES + 4) of Section and Program ELF headers,
+	 * where, 4 additional entries, one for empty header, one for string table
+	 * one for minidump table and one for linux banner.
+	 *
+	 * Linux banner is stored in minidump to aid post mortem tools to determine
+	 * the kernel version.
+	 */
+	elfh_size = sizeof(*ehdr);
+	elfh_size += MAX_STRTBL_SIZE;
+	elfh_size += banner_len + 1;
+	elfh_size += ((sizeof(*shdr) + sizeof(*phdr)) * (MAX_NUM_ENTRIES + 4));
+	elfh_size = ALIGN(elfh_size, 4);
+
+	md_data->elf.ehdr = devm_kzalloc(md_data->dev, elfh_size, GFP_KERNEL);
+	if (!md_data->elf.ehdr)
+		return -ENOMEM;
+
+	ehdr = md_data->elf.ehdr;
+	/* Assign Section/Program headers offset */
+	md_data->elf.shdr = shdr = (struct elf_shdr *)(ehdr + 1);
+	md_data->elf.phdr = phdr = (struct elf_phdr *)(shdr + MAX_NUM_ENTRIES);
+	phdr_off = sizeof(*ehdr) + (sizeof(*shdr) * MAX_NUM_ENTRIES);
+
+	memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
+	ehdr->e_ident[EI_CLASS] = ELF_CLASS;
+	ehdr->e_ident[EI_DATA] = ELF_DATA;
+	ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+	ehdr->e_ident[EI_OSABI] = ELF_OSABI;
+	ehdr->e_type = ET_CORE;
+	ehdr->e_machine  = ELF_ARCH;
+	ehdr->e_version = EV_CURRENT;
+	ehdr->e_ehsize = sizeof(*ehdr);
+	ehdr->e_phoff = phdr_off;
+	ehdr->e_phentsize = sizeof(*phdr);
+	ehdr->e_shoff = sizeof(*ehdr);
+	ehdr->e_shentsize = sizeof(*shdr);
+	ehdr->e_shstrndx = 1;
+
+	md_data->elf.elf_offset = elfh_size;
+	/*
+	 * The zeroth index of the section header is reserved and is rarely used.
+	 * Set the section header as null (SHN_UNDEF) and move to the next one.
+	 * 2nd Section is String table.
+	 */
+	md_data->elf.strtable_idx = 1;
+	strtbl_off = sizeof(*ehdr) + ((sizeof(*phdr) + sizeof(*shdr)) * MAX_NUM_ENTRIES);
+	shdr++;
+	shdr->sh_type = SHT_STRTAB;
+	shdr->sh_offset = (elf_addr_t)strtbl_off;
+	shdr->sh_size = MAX_STRTBL_SIZE;
+	shdr->sh_entsize = 0;
+	shdr->sh_flags = 0;
+	shdr->sh_name = append_str_to_strtable(md_data, "STR_TBL");
+	shdr++;
+
+	/* 3rd Section is Linux banner */
+	banner = (char *)ehdr + strtbl_off + MAX_STRTBL_SIZE;
+	memcpy(banner, linux_banner, banner_len);
+
+	shdr->sh_type = SHT_PROGBITS;
+	shdr->sh_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE);
+	shdr->sh_size = banner_len + 1;
+	shdr->sh_addr = (elf_addr_t)linux_banner;
+	shdr->sh_entsize = 0;
+	shdr->sh_flags = SHF_WRITE;
+	shdr->sh_name = append_str_to_strtable(md_data, "linux_banner");
+
+	phdr->p_type = PT_LOAD;
+	phdr->p_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE);
+	phdr->p_vaddr = (elf_addr_t)linux_banner;
+	phdr->p_paddr = virt_to_phys(linux_banner);
+	phdr->p_filesz = phdr->p_memsz = banner_len + 1;
+	phdr->p_flags = PF_R | PF_W;
+
+	/*
+	 * Above are some prdefined sections/program header used
+	 * for debug, update their count here.
+	 */
+	ehdr->e_phnum = 1;
+	ehdr->e_shnum = 3;
+
+	/* Register ELF header as first region */
+	strscpy(elfregion.name, "KELF_HEADER", sizeof(elfregion.name));
+	elfregion.virt_addr = md_data->elf.ehdr;
+	elfregion.phys_addr = virt_to_phys(md_data->elf.ehdr);
+	elfregion.size = elfh_size;
+
+	return md_data->ops->md_region_register(md_data, &elfregion);
+}
+
+/**
+ * qcom_minidump_backend_register() - Register backend minidump device.
+ * @md_data: minidump backend driver data
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_backend_register(struct minidump *md_data)
+{
+	int ret;
+
+	if (!md_data->name || !md_data->dev ||
+	    !md_data->ops ||
+	    !md_data->ops->md_table_init ||
+	    !md_data->ops->md_region_register ||
+	    !md_data->ops->md_region_unregister ||
+	    !md_data->ops->md_table_exit) {
+		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
+		return -EINVAL;
+	}
+
+	if (md_backend && strcmp(md_backend, md_data->name)) {
+		pr_warn("backend '%s' already in use: ignoring '%s'\n",
+			 md_backend, md_data->name);
+		return -EBUSY;
+	}
+
+	mutex_lock(&md_lock);
+	if (md) {
+		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
+			 md->name, md_data->name);
+		ret = -EBUSY;
+		goto unlock;
+	}
+
+	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
+		md_data->max_region_limit = MAX_NUM_ENTRIES;
+
+	ret = md_data->ops->md_table_init(md_data);
+	if (ret) {
+		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
+		goto unlock;
+	}
+
+	/* First entry would be ELF header */
+	ret = qcom_minidump_add_elf_header(md_data);
+	if (ret) {
+		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
+		md_data->ops->md_table_exit(md_data);
+		goto unlock;
+	}
+
+	md = md_data;
+	md_backend = kstrdup(md->name, GFP_KERNEL);
+	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
+
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);
+
+/**
+ * qcom_minidump_backend_unregister() - Unregister backend minidump device.
+ * @md_data: minidump backend driver data
+ */
+void qcom_minidump_backend_unregister(struct minidump *md_data)
+{
+	mutex_lock(&md_lock);
+	/* Only one backend can be registered at a time. */
+	if (WARN_ON(md_data != md))
+		goto unlock;
+
+	dev_info(md_data->dev, "Unregistered %s as minidump backend\n", md_data->name);
+	md_data->ops->md_table_exit(md_data);
+	kfree(md_backend);
+	md_backend = NULL;
+	md = NULL;
+unlock:
+	mutex_unlock(&md_lock);
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_backend_unregister);
+
+MODULE_DESCRIPTION("Qualcomm minidump core");
+MODULE_LICENSE("GPL");
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
new file mode 100644
index 000000000000..9031b1b0a046
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _QCOM_MINIDUMP_INTERNAL_H_
+#define _QCOM_MINIDUMP_INTERNAL_H_
+
+#include <linux/elf.h>
+#include <soc/qcom/qcom_minidump.h>
+
+#define MAX_REGION_NAME_LENGTH  16
+
+struct minidump;
+/**
+ * struct minidump_ops - APSS Minidump operation structure, each underlying
+ *			 backend need to add their hooks to it.
+ *
+ * @md_table_init:	  Get the hold of APSS minidump table for the backend
+ *			  and initialize it with details.
+ * @md_table_exit:	  Clean up the stuff populated while md_table_init()
+ * @md_region_register:	  Callback to register the region at the backend.
+ * @md_region_unregister: Callback to unregister the region at the backend.
+ */
+struct minidump_ops {
+	int (*md_table_init)(struct minidump *md);
+	int (*md_table_exit)(struct minidump *md);
+	int (*md_region_register)(struct minidump *md,
+				 const struct qcom_minidump_region *region);
+	int (*md_region_unregister)(struct minidump *md,
+				 const struct qcom_minidump_region *region);
+};
+
+/**
+ * struct minidump_elfhdr - Minidump table elf header
+ * @ehdr: elf main header
+ * @shdr: Section header
+ * @phdr: Program header
+ * @elf_offset: Section offset in elf
+ * @strtable_idx: String table current index position
+ */
+struct minidump_elfhdr {
+	struct elfhdr		*ehdr;
+	struct elf_shdr		*shdr;
+	struct elf_phdr		*phdr;
+	size_t			elf_offset;
+	size_t			strtable_idx;
+};
+
+/**
+ * struct minidump - Qualcomm minidump core information
+ * @name	  : Minidump backend name
+ * @ops		  : set of callback need to be implemented
+ * @elf		  : Minidump elf header
+ * @dev		  : Minidump backend device
+ * @max_num_limit : Maximum number of region limit
+ * @apss_data	  : Backend driver's private data pointer
+ */
+struct minidump {
+	const char			*name;
+	struct minidump_ops		*ops;
+	struct minidump_elfhdr		elf;
+	struct device			*dev;
+	unsigned int			max_region_limit;
+	void				*apss_data;
+};
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+int qcom_minidump_backend_register(struct minidump *md);
+void qcom_minidump_backend_unregister(struct minidump *md);
+#else
+int qcom_minidump_backend_register(struct minidump *md) { return 0; }
+void qcom_minidump_backend_unregister(struct minidump *md) {}
+#endif /* CONFIG_QCOM_MINIDUMP */
+#endif /* _QCOM_MINIDUMP_INTERNAL_H_ */
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
index d7747c27fd45..d0bebc3daac5 100644
--- a/include/soc/qcom/qcom_minidump.h
+++ b/include/soc/qcom/qcom_minidump.h
@@ -1,11 +1,46 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
+ * This file contains data structure which should be used by the
+ * APSS minidump clients.
+ *
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _QCOM_MINIDUMP_H_
 #define _QCOM_MINIDUMP_H_
 
+#define MAX_NAME_LENGTH		12
+/**
+ * struct qcom_minidump_region - APSS Minidump region information
+ *
+ * @name:	Entry name, Minidump will dump binary with this name.
+ * @virt_addr:  Virtual address of the entry.
+ * @phys_addr:	Physical address of the entry to dump.
+ * @size:	Number of byte to dump from @address location,
+ *		and it should be 4 byte aligned.
+ */
+struct qcom_minidump_region {
+	char		name[MAX_NAME_LENGTH];
+	void		*virt_addr;
+	phys_addr_t	phys_addr;
+	size_t		size;
+};
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+int qcom_minidump_region_register(const struct qcom_minidump_region *region);
+int qcom_minidump_region_unregister(const struct qcom_minidump_region *region);
+#else
+static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region)
+{
+	/* Return quietly, if minidump is not enabled */
+	return 0;
+}
+static inline int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
+{
+	return 0;
+}
+#endif /* CONFIG_QCOM_MINIDUMP */
+
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
 void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt);
 int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

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

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig                  |  15 +
 drivers/soc/qcom/Makefile                 |   2 +
 drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
 include/soc/qcom/qcom_minidump.h          |  35 +++
 5 files changed, 583 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_minidump.c
 create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 982310b5a1cb..874ee8c3efe0 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
 	tristate
 	select QCOM_SCM
 
+config QCOM_MINIDUMP
+	tristate "QCOM Minidump APSS Core Infrastructure"
+	depends on ARCH_QCOM
+	help
+	  This config allow linux core infrastructure for APSS minidump for
+	  underlying backend(smem etc.) which can hook themselves to this and
+	  work as one unit. So, this config should be selected in combination
+	  with its backend.
+
+	  After this Linux clients driver can register their internal data
+	  structures and debug messages as part of the apss minidump region
+	  and when the SoC is crashed, and these selective regions will be
+	  dumped instead of the entire DDR. This saves significant amount
+	  of time and/or storage space.
+
 config QCOM_MINIDUMP_SMEM
 	tristate "QCOM Minidump SMEM (as backend) Support"
 	depends on ARCH_QCOM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 89b775512bef..737d868757ac 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
 obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
 qcom_ice-objs			+= ice.o
 obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
+obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
+obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
new file mode 100644
index 000000000000..7744e57843ab
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -0,0 +1,456 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/device.h>
+#include <linux/export.h>
+#include <linux/kallsyms.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/printk.h>
+#include <linux/string.h>
+
+#include "qcom_minidump_internal.h"
+
+/*
+ * In some of the Old Qualcomm devices, boot firmware statically allocates 300
+ * as total number of supported region (including all co-processors) in
+ * 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
+ * Linux to 201.
+ */
+#define MAX_NUM_ENTRIES	  201
+#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
+
+/*
+ * md_lock protects "md" during calls to qcom_minidump_backend_register(),
+ * qcom_minidump_backend_unregister().
+ */
+static DEFINE_MUTEX(md_lock);
+
+/* Only one front end will be attached to one back-end */
+static struct minidump *md;
+static char *md_backend;
+
+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);
+
+	return &eshdr[idx];
+}
+
+static struct elf_phdr *elf_phdr_entry_addr(struct elfhdr *ehdr, int idx)
+{
+	struct elf_phdr *ephdr = (struct elf_phdr *)((size_t)ehdr + ehdr->e_phoff);
+
+	return &ephdr[idx];
+}
+
+static char *elf_str_table_start(struct elfhdr *ehdr)
+{
+	struct elf_shdr *eshdr;
+
+	if (ehdr->e_shstrndx == SHN_UNDEF)
+		return NULL;
+
+	eshdr = elf_shdr_entry_addr(ehdr, ehdr->e_shstrndx);
+	return (char *)ehdr + eshdr->sh_offset;
+}
+
+static char *elf_lookup_string(struct elfhdr *ehdr, int offset)
+{
+	char *strtab = elf_str_table_start(ehdr);
+
+	if (!strtab || (md->elf.strtable_idx < offset))
+		return NULL;
+
+	return strtab + offset;
+}
+
+static unsigned int append_str_to_strtable(struct minidump *md, const char *name)
+{
+	char *strtab = elf_str_table_start(md->elf.ehdr);
+	unsigned int old_idx = md->elf.strtable_idx;
+	unsigned int ret;
+
+	if (!strtab || !name)
+		return 0;
+
+	ret = old_idx;
+	old_idx += strscpy((strtab + old_idx), name, MAX_REGION_NAME_LENGTH);
+	md->elf.strtable_idx = old_idx + 1;
+
+	return ret;
+}
+
+static int qcom_minidump_clear_header(const struct qcom_minidump_region *region)
+{
+	struct elfhdr *ehdr = md->elf.ehdr;
+	struct elf_shdr *shdr;
+	struct elf_shdr *tmp_shdr;
+	struct elf_phdr *phdr;
+	struct elf_phdr *tmp_phdr;
+	unsigned int phidx;
+	unsigned int shidx;
+	unsigned int len;
+	unsigned int i;
+	char *shname;
+
+	for (i = 0; i < ehdr->e_phnum; i++) {
+		phdr = elf_phdr_entry_addr(ehdr, i);
+		if (phdr->p_paddr == region->phys_addr &&
+		    phdr->p_memsz == region->size)
+			break;
+	}
+
+	if (i == ehdr->e_phnum) {
+		dev_err(md->dev, "Cannot find program header entry in elf\n");
+		return -EINVAL;
+	}
+
+	phidx = i;
+	for (i = 0; i < ehdr->e_shnum; i++) {
+		shdr = elf_shdr_entry_addr(ehdr, i);
+		shname = elf_lookup_string(ehdr, shdr->sh_name);
+		if (shname && !strcmp(shname, region->name) &&
+		    shdr->sh_addr == (elf_addr_t)region->virt_addr &&
+		    shdr->sh_size == region->size)
+			break;
+	}
+
+	if (i == ehdr->e_shnum) {
+		dev_err(md->dev, "Cannot find section header entry in elf\n");
+		return -EINVAL;
+	}
+
+	shidx = i;
+	if (shdr->sh_offset != phdr->p_offset) {
+		dev_err(md->dev, "Invalid entry details for region: %s\n", region->name);
+		return -EINVAL;
+	}
+
+	/* Clear name in string table */
+	len = strlen(shname) + 1;
+	memmove(shname, shname + len, md->elf.strtable_idx - shdr->sh_name - len);
+	md->elf.strtable_idx -= len;
+
+	/* Clear program header */
+	tmp_phdr = elf_phdr_entry_addr(ehdr, phidx);
+	for (i = phidx; i < ehdr->e_phnum - 1; i++) {
+		tmp_phdr = elf_phdr_entry_addr(ehdr, i + 1);
+		phdr = elf_phdr_entry_addr(ehdr, i);
+		memcpy(phdr, tmp_phdr, sizeof(struct elf_phdr));
+		phdr->p_offset = phdr->p_offset - region->size;
+	}
+	memset(tmp_phdr, 0, sizeof(struct elf_phdr));
+	ehdr->e_phnum--;
+
+	/* Clear section header */
+	tmp_shdr = elf_shdr_entry_addr(ehdr, shidx);
+	for (i = shidx; i < ehdr->e_shnum - 1; i++) {
+		tmp_shdr = elf_shdr_entry_addr(ehdr, i + 1);
+		shdr = elf_shdr_entry_addr(ehdr, i);
+		memcpy(shdr, tmp_shdr, sizeof(struct elf_shdr));
+		shdr->sh_offset -= region->size;
+		shdr->sh_name -= len;
+	}
+
+	memset(tmp_shdr, 0, sizeof(struct elf_shdr));
+	ehdr->e_shnum--;
+	md->elf.elf_offset -= region->size;
+
+	return 0;
+}
+
+static void qcom_md_update_elf_header(const struct qcom_minidump_region *region)
+{
+	struct elfhdr *ehdr = md->elf.ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+
+	shdr = elf_shdr_entry_addr(ehdr, ehdr->e_shnum++);
+	phdr = elf_phdr_entry_addr(ehdr, ehdr->e_phnum++);
+
+	shdr->sh_type = SHT_PROGBITS;
+	shdr->sh_name = append_str_to_strtable(md, region->name);
+	shdr->sh_addr = (elf_addr_t)region->virt_addr;
+	shdr->sh_size = region->size;
+	shdr->sh_flags = SHF_WRITE;
+	shdr->sh_offset = md->elf.elf_offset;
+	shdr->sh_entsize = 0;
+
+	phdr->p_type = PT_LOAD;
+	phdr->p_offset = md->elf.elf_offset;
+	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
+	phdr->p_paddr = region->phys_addr;
+	phdr->p_filesz = phdr->p_memsz = region->size;
+	phdr->p_flags = PF_R | PF_W;
+	md->elf.elf_offset += shdr->sh_size;
+}
+
+static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region)
+{
+	return region &&
+		strnlen(region->name, MAX_NAME_LENGTH) < MAX_NAME_LENGTH &&
+		region->virt_addr &&
+		region->size &&
+		IS_ALIGNED(region->size, 4);
+}
+
+/**
+ * qcom_minidump_region_register() - Register region in APSS Minidump table.
+ * @region: minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_region_register(const struct qcom_minidump_region *region)
+{
+	int ret;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		mutex_unlock(&md_lock);
+		pr_err("No backend registered yet, try again..");
+		return -EPROBE_DEFER;
+	}
+
+	ret = md->ops->md_region_register(md, region);
+	if (ret)
+		goto unlock;
+
+	qcom_md_update_elf_header(region);
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
+
+/**
+ * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
+ * @region: minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
+{
+	int ret;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		mutex_unlock(&md_lock);
+		pr_err("No backend registered yet, try again..");
+		return -EPROBE_DEFER;
+	}
+
+	ret = md->ops->md_region_unregister(md, region);
+	if (ret)
+		goto unlock;
+
+	ret = qcom_minidump_clear_header(region);
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
+
+static int qcom_minidump_add_elf_header(struct minidump *md_data)
+{
+	struct qcom_minidump_region elfregion;
+	struct elfhdr *ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+	unsigned int  elfh_size;
+	unsigned int strtbl_off;
+	unsigned int phdr_off;
+	char *linux_banner;
+	unsigned int banner_len;
+	char *banner;
+
+	linux_banner = (char *)kallsyms_lookup_name("linux_banner");
+	banner_len = strlen(linux_banner);
+	/*
+	 * Header buffer contains:
+	 * ELF header, (MAX_NUM_ENTRIES + 4) of Section and Program ELF headers,
+	 * where, 4 additional entries, one for empty header, one for string table
+	 * one for minidump table and one for linux banner.
+	 *
+	 * Linux banner is stored in minidump to aid post mortem tools to determine
+	 * the kernel version.
+	 */
+	elfh_size = sizeof(*ehdr);
+	elfh_size += MAX_STRTBL_SIZE;
+	elfh_size += banner_len + 1;
+	elfh_size += ((sizeof(*shdr) + sizeof(*phdr)) * (MAX_NUM_ENTRIES + 4));
+	elfh_size = ALIGN(elfh_size, 4);
+
+	md_data->elf.ehdr = devm_kzalloc(md_data->dev, elfh_size, GFP_KERNEL);
+	if (!md_data->elf.ehdr)
+		return -ENOMEM;
+
+	ehdr = md_data->elf.ehdr;
+	/* Assign Section/Program headers offset */
+	md_data->elf.shdr = shdr = (struct elf_shdr *)(ehdr + 1);
+	md_data->elf.phdr = phdr = (struct elf_phdr *)(shdr + MAX_NUM_ENTRIES);
+	phdr_off = sizeof(*ehdr) + (sizeof(*shdr) * MAX_NUM_ENTRIES);
+
+	memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
+	ehdr->e_ident[EI_CLASS] = ELF_CLASS;
+	ehdr->e_ident[EI_DATA] = ELF_DATA;
+	ehdr->e_ident[EI_VERSION] = EV_CURRENT;
+	ehdr->e_ident[EI_OSABI] = ELF_OSABI;
+	ehdr->e_type = ET_CORE;
+	ehdr->e_machine  = ELF_ARCH;
+	ehdr->e_version = EV_CURRENT;
+	ehdr->e_ehsize = sizeof(*ehdr);
+	ehdr->e_phoff = phdr_off;
+	ehdr->e_phentsize = sizeof(*phdr);
+	ehdr->e_shoff = sizeof(*ehdr);
+	ehdr->e_shentsize = sizeof(*shdr);
+	ehdr->e_shstrndx = 1;
+
+	md_data->elf.elf_offset = elfh_size;
+	/*
+	 * The zeroth index of the section header is reserved and is rarely used.
+	 * Set the section header as null (SHN_UNDEF) and move to the next one.
+	 * 2nd Section is String table.
+	 */
+	md_data->elf.strtable_idx = 1;
+	strtbl_off = sizeof(*ehdr) + ((sizeof(*phdr) + sizeof(*shdr)) * MAX_NUM_ENTRIES);
+	shdr++;
+	shdr->sh_type = SHT_STRTAB;
+	shdr->sh_offset = (elf_addr_t)strtbl_off;
+	shdr->sh_size = MAX_STRTBL_SIZE;
+	shdr->sh_entsize = 0;
+	shdr->sh_flags = 0;
+	shdr->sh_name = append_str_to_strtable(md_data, "STR_TBL");
+	shdr++;
+
+	/* 3rd Section is Linux banner */
+	banner = (char *)ehdr + strtbl_off + MAX_STRTBL_SIZE;
+	memcpy(banner, linux_banner, banner_len);
+
+	shdr->sh_type = SHT_PROGBITS;
+	shdr->sh_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE);
+	shdr->sh_size = banner_len + 1;
+	shdr->sh_addr = (elf_addr_t)linux_banner;
+	shdr->sh_entsize = 0;
+	shdr->sh_flags = SHF_WRITE;
+	shdr->sh_name = append_str_to_strtable(md_data, "linux_banner");
+
+	phdr->p_type = PT_LOAD;
+	phdr->p_offset = (elf_addr_t)(strtbl_off + MAX_STRTBL_SIZE);
+	phdr->p_vaddr = (elf_addr_t)linux_banner;
+	phdr->p_paddr = virt_to_phys(linux_banner);
+	phdr->p_filesz = phdr->p_memsz = banner_len + 1;
+	phdr->p_flags = PF_R | PF_W;
+
+	/*
+	 * Above are some prdefined sections/program header used
+	 * for debug, update their count here.
+	 */
+	ehdr->e_phnum = 1;
+	ehdr->e_shnum = 3;
+
+	/* Register ELF header as first region */
+	strscpy(elfregion.name, "KELF_HEADER", sizeof(elfregion.name));
+	elfregion.virt_addr = md_data->elf.ehdr;
+	elfregion.phys_addr = virt_to_phys(md_data->elf.ehdr);
+	elfregion.size = elfh_size;
+
+	return md_data->ops->md_region_register(md_data, &elfregion);
+}
+
+/**
+ * qcom_minidump_backend_register() - Register backend minidump device.
+ * @md_data: minidump backend driver data
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_backend_register(struct minidump *md_data)
+{
+	int ret;
+
+	if (!md_data->name || !md_data->dev ||
+	    !md_data->ops ||
+	    !md_data->ops->md_table_init ||
+	    !md_data->ops->md_region_register ||
+	    !md_data->ops->md_region_unregister ||
+	    !md_data->ops->md_table_exit) {
+		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
+		return -EINVAL;
+	}
+
+	if (md_backend && strcmp(md_backend, md_data->name)) {
+		pr_warn("backend '%s' already in use: ignoring '%s'\n",
+			 md_backend, md_data->name);
+		return -EBUSY;
+	}
+
+	mutex_lock(&md_lock);
+	if (md) {
+		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
+			 md->name, md_data->name);
+		ret = -EBUSY;
+		goto unlock;
+	}
+
+	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
+		md_data->max_region_limit = MAX_NUM_ENTRIES;
+
+	ret = md_data->ops->md_table_init(md_data);
+	if (ret) {
+		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
+		goto unlock;
+	}
+
+	/* First entry would be ELF header */
+	ret = qcom_minidump_add_elf_header(md_data);
+	if (ret) {
+		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
+		md_data->ops->md_table_exit(md_data);
+		goto unlock;
+	}
+
+	md = md_data;
+	md_backend = kstrdup(md->name, GFP_KERNEL);
+	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
+
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);
+
+/**
+ * qcom_minidump_backend_unregister() - Unregister backend minidump device.
+ * @md_data: minidump backend driver data
+ */
+void qcom_minidump_backend_unregister(struct minidump *md_data)
+{
+	mutex_lock(&md_lock);
+	/* Only one backend can be registered at a time. */
+	if (WARN_ON(md_data != md))
+		goto unlock;
+
+	dev_info(md_data->dev, "Unregistered %s as minidump backend\n", md_data->name);
+	md_data->ops->md_table_exit(md_data);
+	kfree(md_backend);
+	md_backend = NULL;
+	md = NULL;
+unlock:
+	mutex_unlock(&md_lock);
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_backend_unregister);
+
+MODULE_DESCRIPTION("Qualcomm minidump core");
+MODULE_LICENSE("GPL");
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
new file mode 100644
index 000000000000..9031b1b0a046
--- /dev/null
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _QCOM_MINIDUMP_INTERNAL_H_
+#define _QCOM_MINIDUMP_INTERNAL_H_
+
+#include <linux/elf.h>
+#include <soc/qcom/qcom_minidump.h>
+
+#define MAX_REGION_NAME_LENGTH  16
+
+struct minidump;
+/**
+ * struct minidump_ops - APSS Minidump operation structure, each underlying
+ *			 backend need to add their hooks to it.
+ *
+ * @md_table_init:	  Get the hold of APSS minidump table for the backend
+ *			  and initialize it with details.
+ * @md_table_exit:	  Clean up the stuff populated while md_table_init()
+ * @md_region_register:	  Callback to register the region at the backend.
+ * @md_region_unregister: Callback to unregister the region at the backend.
+ */
+struct minidump_ops {
+	int (*md_table_init)(struct minidump *md);
+	int (*md_table_exit)(struct minidump *md);
+	int (*md_region_register)(struct minidump *md,
+				 const struct qcom_minidump_region *region);
+	int (*md_region_unregister)(struct minidump *md,
+				 const struct qcom_minidump_region *region);
+};
+
+/**
+ * struct minidump_elfhdr - Minidump table elf header
+ * @ehdr: elf main header
+ * @shdr: Section header
+ * @phdr: Program header
+ * @elf_offset: Section offset in elf
+ * @strtable_idx: String table current index position
+ */
+struct minidump_elfhdr {
+	struct elfhdr		*ehdr;
+	struct elf_shdr		*shdr;
+	struct elf_phdr		*phdr;
+	size_t			elf_offset;
+	size_t			strtable_idx;
+};
+
+/**
+ * struct minidump - Qualcomm minidump core information
+ * @name	  : Minidump backend name
+ * @ops		  : set of callback need to be implemented
+ * @elf		  : Minidump elf header
+ * @dev		  : Minidump backend device
+ * @max_num_limit : Maximum number of region limit
+ * @apss_data	  : Backend driver's private data pointer
+ */
+struct minidump {
+	const char			*name;
+	struct minidump_ops		*ops;
+	struct minidump_elfhdr		elf;
+	struct device			*dev;
+	unsigned int			max_region_limit;
+	void				*apss_data;
+};
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+int qcom_minidump_backend_register(struct minidump *md);
+void qcom_minidump_backend_unregister(struct minidump *md);
+#else
+int qcom_minidump_backend_register(struct minidump *md) { return 0; }
+void qcom_minidump_backend_unregister(struct minidump *md) {}
+#endif /* CONFIG_QCOM_MINIDUMP */
+#endif /* _QCOM_MINIDUMP_INTERNAL_H_ */
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
index d7747c27fd45..d0bebc3daac5 100644
--- a/include/soc/qcom/qcom_minidump.h
+++ b/include/soc/qcom/qcom_minidump.h
@@ -1,11 +1,46 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
+ * This file contains data structure which should be used by the
+ * APSS minidump clients.
+ *
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _QCOM_MINIDUMP_H_
 #define _QCOM_MINIDUMP_H_
 
+#define MAX_NAME_LENGTH		12
+/**
+ * struct qcom_minidump_region - APSS Minidump region information
+ *
+ * @name:	Entry name, Minidump will dump binary with this name.
+ * @virt_addr:  Virtual address of the entry.
+ * @phys_addr:	Physical address of the entry to dump.
+ * @size:	Number of byte to dump from @address location,
+ *		and it should be 4 byte aligned.
+ */
+struct qcom_minidump_region {
+	char		name[MAX_NAME_LENGTH];
+	void		*virt_addr;
+	phys_addr_t	phys_addr;
+	size_t		size;
+};
+
+#if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
+int qcom_minidump_region_register(const struct qcom_minidump_region *region);
+int qcom_minidump_region_unregister(const struct qcom_minidump_region *region);
+#else
+static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region)
+{
+	/* Return quietly, if minidump is not enabled */
+	return 0;
+}
+static inline int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
+{
+	return 0;
+}
+#endif /* CONFIG_QCOM_MINIDUMP */
+
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
 void *qcom_ss_md_mapped_base(unsigned int minidump_id, int *seg_cnt);
 int qcom_ss_valid_segment_info(void *ptr, int i, char **name,
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add shared memory based minidump backend driver and hook it
with minidump core (qcom_minidump) by registering SMEM as
backend device.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig              |   8 +-
 drivers/soc/qcom/qcom_minidump_smem.c | 231 +++++++++++++++++++++++++++++++++-
 drivers/soc/qcom/smem.c               |   9 ++
 3 files changed, 240 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 874ee8c3efe0..1834213fd652 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -298,8 +298,12 @@ config QCOM_MINIDUMP_SMEM
 	tristate "QCOM Minidump SMEM (as backend) Support"
 	depends on ARCH_QCOM
 	depends on QCOM_SMEM
+	select QCOM_MINIDUMP
 	help
 	  Enablement of core minidump feature is controlled from boot firmware
-	  side, and this config allow linux to query minidump segments associated
-	  with the remote processor and check its validity.
+	  side, and this config allow linux to query and manages minidump
+	  table for remote processors as well as APSS.
+
+	  This config should be enabled if the low level minidump is implemented
+	  as part of SMEM.
 endmenu
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
index b588833ea26e..bdc75aa2f518 100644
--- a/drivers/soc/qcom/qcom_minidump_smem.c
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -2,18 +2,34 @@
 /*
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
 #include <linux/soc/qcom/smem.h>
-#include <soc/qcom/qcom_minidump.h>
+
+#include "qcom_minidump_internal.h"
 
 #define MAX_NUM_OF_SS           10
-#define MAX_REGION_NAME_LENGTH  16
 #define SBL_MINIDUMP_SMEM_ID	602
-#define MINIDUMP_REGION_VALID	('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MINIDUMP_SS_ENCR_DONE	('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MINIDUMP_SS_ENABLED	('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+#define MINIDUMP_REGION_VALID	   ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_REGION_INVALID	   ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0)
+#define MINIDUMP_REGION_INIT	   ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0)
+#define MINIDUMP_REGION_NOINIT	   0
+
+#define MINIDUMP_SS_ENCR_REQ	   (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0)
+#define MINIDUMP_SS_ENCR_NOTREQ	   (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0)
+#define MINIDUMP_SS_ENCR_START	   ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0)
+#define MINIDUMP_SS_ENCR_DONE	   ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED	   ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+#define MINIDUMP_APSS_DESC	   0
 
 /**
  * struct minidump_region - Minidump region
@@ -64,6 +80,16 @@ struct minidump_global_toc {
 };
 
 /**
+ * struct minidump_ss_data - Minidump subsystem private data
+ * @md_ss_toc	: Application Subsystem TOC pointer
+ * @md_regions	: Application Subsystem region base pointer
+ */
+struct minidump_ss_data {
+	struct minidump_subsystem	*md_ss_toc;
+	struct minidump_region		*md_regions;
+};
+
+/**
  * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address
  * for given minidump index.
  *
@@ -143,5 +169,198 @@ int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, si
 }
 EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info);
 
+static int smem_md_get_region_index(struct minidump_ss_data *mdss_data,
+				    const struct qcom_minidump_region *region)
+{
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int i;
+	unsigned int count;
+
+	count = le32_to_cpu(mdss_toc->region_count);
+	for (i = 0; i < count; i++) {
+		mdr = &mdss_data->md_regions[i];
+		if (!strcmp(mdr->name, region->name))
+			return i;
+	}
+
+	return -ENOENT;
+}
+
+static void smem_md_add_region(struct minidump_ss_data *mdss_data,
+			       const struct qcom_minidump_region *region)
+{
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int region_cnt;
+
+	region_cnt = le32_to_cpu(mdss_toc->region_count);
+	mdr = &mdss_data->md_regions[region_cnt];
+	strscpy(mdr->name, region->name, sizeof(mdr->name));
+	mdr->address = cpu_to_le64(region->phys_addr);
+	mdr->size = cpu_to_le64(region->size);
+	mdr->valid = cpu_to_le32(MINIDUMP_REGION_VALID);
+	region_cnt++;
+	mdss_toc->region_count = cpu_to_le32(region_cnt);
+}
+
+static int smem_md_region_register(struct minidump *md,
+				   const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	unsigned int num_region;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret >= 0) {
+		dev_info(md->dev, "%s region is already registered\n", region->name);
+		return -EEXIST;
+	}
+
+	/* Check if there is a room for a new entry */
+	num_region = le32_to_cpu(mdss_toc->region_count);
+	if (num_region >= md->max_region_limit) {
+		dev_err(md->dev, "maximum region limit %u reached\n", num_region);
+		return -ENOSPC;
+	}
+
+	smem_md_add_region(mdss_data, region);
+
+	return 0;
+}
+
+static int smem_md_region_unregister(struct minidump *md,
+				     const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int region_cnt;
+	unsigned int idx;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret < 0) {
+		dev_err(md->dev, "%s region is not present\n", region->name);
+		return ret;
+	}
+
+	idx = ret;
+	mdr = &mdss_data->md_regions[0];
+	region_cnt = le32_to_cpu(mdss_toc->region_count);
+	/*
+	 * Left shift all the regions exist after this removed region
+	 * index by 1 to fill the gap and zero out the last region
+	 * present at the end.
+	 */
+	memmove(&mdr[idx], &mdr[idx + 1],
+		(region_cnt - idx - 1) * sizeof(struct minidump_region));
+	memset(&mdr[region_cnt - 1], 0, sizeof(struct minidump_region));
+	region_cnt--;
+	mdss_toc->region_count = cpu_to_le32(region_cnt);
+
+	return 0;
+}
+
+static int smem_md_table_init(struct minidump *md)
+{
+	struct minidump_global_toc *mdgtoc;
+	struct minidump_ss_data *mdss_data;
+	struct minidump_subsystem *mdss_toc;
+	size_t size;
+	int ret;
+
+	mdgtoc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size);
+	if (IS_ERR(mdgtoc)) {
+		ret = PTR_ERR(mdgtoc);
+		dev_err(md->dev, "Couldn't find minidump smem item: %d\n", ret);
+		return ret;
+	}
+
+	if (size < sizeof(mdgtoc) || !mdgtoc->status) {
+		ret = -EINVAL;
+		dev_err(md->dev, "minidump table is not initialized: %d\n", ret);
+		return ret;
+	}
+
+	mdss_data = devm_kzalloc(md->dev, sizeof(*mdss_data), GFP_KERNEL);
+	if (!mdss_data)
+		return -ENOMEM;
+
+	mdss_data->md_ss_toc = &mdgtoc->subsystems[MINIDUMP_APSS_DESC];
+	mdss_data->md_regions = devm_kcalloc(md->dev, md->max_region_limit,
+					     sizeof(struct minidump_region), GFP_KERNEL);
+	if (!mdss_data->md_regions)
+		return -ENOMEM;
+
+	mdss_toc = mdss_data->md_ss_toc;
+	mdss_toc->regions_baseptr = cpu_to_le64(virt_to_phys(mdss_data->md_regions));
+	mdss_toc->enabled = cpu_to_le32(MINIDUMP_SS_ENABLED);
+	mdss_toc->status = cpu_to_le32(1);
+	mdss_toc->region_count = cpu_to_le32(0);
+
+	/* Tell bootloader not to encrypt the regions of this subsystem */
+	mdss_toc->encryption_status = cpu_to_le32(MINIDUMP_SS_ENCR_DONE);
+	mdss_toc->encryption_required = cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ);
+	md->apss_data = mdss_data;
+
+	return 0;
+}
+
+static int smem_md_table_exit(struct minidump *md)
+{
+	struct minidump_ss_data *mdss_data;
+
+	mdss_data = md->apss_data;
+	memset(mdss_data->md_ss_toc,
+	       cpu_to_le32(0), sizeof(struct minidump_subsystem));
+
+	return 0;
+}
+
+static struct minidump_ops smem_md_ops = {
+	.md_table_init		= smem_md_table_init,
+	.md_table_exit		= smem_md_table_exit,
+	.md_region_register	= smem_md_region_register,
+	.md_region_unregister	= smem_md_region_unregister,
+};
+
+static int qcom_minidump_smem_probe(struct platform_device *pdev)
+{
+	struct minidump *md;
+
+	md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL);
+	if (!md)
+		return -ENOMEM;
+
+	md->dev = &pdev->dev;
+	md->ops = &smem_md_ops;
+	md->name = "smem";
+	platform_set_drvdata(pdev, md);
+
+	return qcom_minidump_backend_register(md);
+}
+
+static int qcom_minidump_smem_remove(struct platform_device *pdev)
+{
+	struct minidump *md = platform_get_drvdata(pdev);
+
+	qcom_minidump_backend_unregister(md);
+
+	return 0;
+}
+
+static struct platform_driver qcom_minidump_smem_driver = {
+	.probe = qcom_minidump_smem_probe,
+	.remove = qcom_minidump_smem_remove,
+	.driver  = {
+		.name = "qcom-minidump-smem",
+	},
+};
+
+module_platform_driver(qcom_minidump_smem_driver);
+
 MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:qcom-minidump-smem");
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 6be7ea93c78c..af582aa7f9a3 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -269,6 +269,7 @@ struct smem_region {
  * @partitions: list of partitions of current processor/host
  * @item_count: max accepted item number
  * @socinfo:	platform device pointer
+ * @minidump:	minidump platform device pointer
  * @num_regions: number of @regions
  * @regions:	list of the memory regions defining the shared memory
  */
@@ -279,6 +280,7 @@ struct qcom_smem {
 
 	u32 item_count;
 	struct platform_device *socinfo;
+	struct platform_device *minidump;
 	struct smem_ptable *ptable;
 	struct smem_partition global_partition;
 	struct smem_partition partitions[SMEM_HOST_COUNT];
@@ -1151,11 +1153,18 @@ static int qcom_smem_probe(struct platform_device *pdev)
 	if (IS_ERR(smem->socinfo))
 		dev_dbg(&pdev->dev, "failed to register socinfo device\n");
 
+	smem->minidump = platform_device_register_data(&pdev->dev, "qcom-minidump-smem",
+						      PLATFORM_DEVID_NONE, NULL,
+						      0);
+	if (IS_ERR(smem->minidump))
+		dev_dbg(&pdev->dev, "failed to register minidump device\n");
+
 	return 0;
 }
 
 static int qcom_smem_remove(struct platform_device *pdev)
 {
+	platform_device_unregister(__smem->minidump);
 	platform_device_unregister(__smem->socinfo);
 
 	hwspin_lock_free(__smem->hwlock);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add shared memory based minidump backend driver and hook it
with minidump core (qcom_minidump) by registering SMEM as
backend device.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig              |   8 +-
 drivers/soc/qcom/qcom_minidump_smem.c | 231 +++++++++++++++++++++++++++++++++-
 drivers/soc/qcom/smem.c               |   9 ++
 3 files changed, 240 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 874ee8c3efe0..1834213fd652 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -298,8 +298,12 @@ config QCOM_MINIDUMP_SMEM
 	tristate "QCOM Minidump SMEM (as backend) Support"
 	depends on ARCH_QCOM
 	depends on QCOM_SMEM
+	select QCOM_MINIDUMP
 	help
 	  Enablement of core minidump feature is controlled from boot firmware
-	  side, and this config allow linux to query minidump segments associated
-	  with the remote processor and check its validity.
+	  side, and this config allow linux to query and manages minidump
+	  table for remote processors as well as APSS.
+
+	  This config should be enabled if the low level minidump is implemented
+	  as part of SMEM.
 endmenu
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
index b588833ea26e..bdc75aa2f518 100644
--- a/drivers/soc/qcom/qcom_minidump_smem.c
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -2,18 +2,34 @@
 /*
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/export.h>
+#include <linux/init.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
 #include <linux/soc/qcom/smem.h>
-#include <soc/qcom/qcom_minidump.h>
+
+#include "qcom_minidump_internal.h"
 
 #define MAX_NUM_OF_SS           10
-#define MAX_REGION_NAME_LENGTH  16
 #define SBL_MINIDUMP_SMEM_ID	602
-#define MINIDUMP_REGION_VALID	('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MINIDUMP_SS_ENCR_DONE	('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MINIDUMP_SS_ENABLED	('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+#define MINIDUMP_REGION_VALID	   ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_REGION_INVALID	   ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0)
+#define MINIDUMP_REGION_INIT	   ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0)
+#define MINIDUMP_REGION_NOINIT	   0
+
+#define MINIDUMP_SS_ENCR_REQ	   (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0)
+#define MINIDUMP_SS_ENCR_NOTREQ	   (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0)
+#define MINIDUMP_SS_ENCR_START	   ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0)
+#define MINIDUMP_SS_ENCR_DONE	   ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED	   ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+
+#define MINIDUMP_APSS_DESC	   0
 
 /**
  * struct minidump_region - Minidump region
@@ -64,6 +80,16 @@ struct minidump_global_toc {
 };
 
 /**
+ * struct minidump_ss_data - Minidump subsystem private data
+ * @md_ss_toc	: Application Subsystem TOC pointer
+ * @md_regions	: Application Subsystem region base pointer
+ */
+struct minidump_ss_data {
+	struct minidump_subsystem	*md_ss_toc;
+	struct minidump_region		*md_regions;
+};
+
+/**
  * qcom_ss_md_mapped_base() - For getting subsystem iomapped base segment address
  * for given minidump index.
  *
@@ -143,5 +169,198 @@ int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t *da, si
 }
 EXPORT_SYMBOL_GPL(qcom_ss_valid_segment_info);
 
+static int smem_md_get_region_index(struct minidump_ss_data *mdss_data,
+				    const struct qcom_minidump_region *region)
+{
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int i;
+	unsigned int count;
+
+	count = le32_to_cpu(mdss_toc->region_count);
+	for (i = 0; i < count; i++) {
+		mdr = &mdss_data->md_regions[i];
+		if (!strcmp(mdr->name, region->name))
+			return i;
+	}
+
+	return -ENOENT;
+}
+
+static void smem_md_add_region(struct minidump_ss_data *mdss_data,
+			       const struct qcom_minidump_region *region)
+{
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int region_cnt;
+
+	region_cnt = le32_to_cpu(mdss_toc->region_count);
+	mdr = &mdss_data->md_regions[region_cnt];
+	strscpy(mdr->name, region->name, sizeof(mdr->name));
+	mdr->address = cpu_to_le64(region->phys_addr);
+	mdr->size = cpu_to_le64(region->size);
+	mdr->valid = cpu_to_le32(MINIDUMP_REGION_VALID);
+	region_cnt++;
+	mdss_toc->region_count = cpu_to_le32(region_cnt);
+}
+
+static int smem_md_region_register(struct minidump *md,
+				   const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	unsigned int num_region;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret >= 0) {
+		dev_info(md->dev, "%s region is already registered\n", region->name);
+		return -EEXIST;
+	}
+
+	/* Check if there is a room for a new entry */
+	num_region = le32_to_cpu(mdss_toc->region_count);
+	if (num_region >= md->max_region_limit) {
+		dev_err(md->dev, "maximum region limit %u reached\n", num_region);
+		return -ENOSPC;
+	}
+
+	smem_md_add_region(mdss_data, region);
+
+	return 0;
+}
+
+static int smem_md_region_unregister(struct minidump *md,
+				     const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_subsystem *mdss_toc = mdss_data->md_ss_toc;
+	struct minidump_region *mdr;
+	unsigned int region_cnt;
+	unsigned int idx;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret < 0) {
+		dev_err(md->dev, "%s region is not present\n", region->name);
+		return ret;
+	}
+
+	idx = ret;
+	mdr = &mdss_data->md_regions[0];
+	region_cnt = le32_to_cpu(mdss_toc->region_count);
+	/*
+	 * Left shift all the regions exist after this removed region
+	 * index by 1 to fill the gap and zero out the last region
+	 * present at the end.
+	 */
+	memmove(&mdr[idx], &mdr[idx + 1],
+		(region_cnt - idx - 1) * sizeof(struct minidump_region));
+	memset(&mdr[region_cnt - 1], 0, sizeof(struct minidump_region));
+	region_cnt--;
+	mdss_toc->region_count = cpu_to_le32(region_cnt);
+
+	return 0;
+}
+
+static int smem_md_table_init(struct minidump *md)
+{
+	struct minidump_global_toc *mdgtoc;
+	struct minidump_ss_data *mdss_data;
+	struct minidump_subsystem *mdss_toc;
+	size_t size;
+	int ret;
+
+	mdgtoc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, &size);
+	if (IS_ERR(mdgtoc)) {
+		ret = PTR_ERR(mdgtoc);
+		dev_err(md->dev, "Couldn't find minidump smem item: %d\n", ret);
+		return ret;
+	}
+
+	if (size < sizeof(mdgtoc) || !mdgtoc->status) {
+		ret = -EINVAL;
+		dev_err(md->dev, "minidump table is not initialized: %d\n", ret);
+		return ret;
+	}
+
+	mdss_data = devm_kzalloc(md->dev, sizeof(*mdss_data), GFP_KERNEL);
+	if (!mdss_data)
+		return -ENOMEM;
+
+	mdss_data->md_ss_toc = &mdgtoc->subsystems[MINIDUMP_APSS_DESC];
+	mdss_data->md_regions = devm_kcalloc(md->dev, md->max_region_limit,
+					     sizeof(struct minidump_region), GFP_KERNEL);
+	if (!mdss_data->md_regions)
+		return -ENOMEM;
+
+	mdss_toc = mdss_data->md_ss_toc;
+	mdss_toc->regions_baseptr = cpu_to_le64(virt_to_phys(mdss_data->md_regions));
+	mdss_toc->enabled = cpu_to_le32(MINIDUMP_SS_ENABLED);
+	mdss_toc->status = cpu_to_le32(1);
+	mdss_toc->region_count = cpu_to_le32(0);
+
+	/* Tell bootloader not to encrypt the regions of this subsystem */
+	mdss_toc->encryption_status = cpu_to_le32(MINIDUMP_SS_ENCR_DONE);
+	mdss_toc->encryption_required = cpu_to_le32(MINIDUMP_SS_ENCR_NOTREQ);
+	md->apss_data = mdss_data;
+
+	return 0;
+}
+
+static int smem_md_table_exit(struct minidump *md)
+{
+	struct minidump_ss_data *mdss_data;
+
+	mdss_data = md->apss_data;
+	memset(mdss_data->md_ss_toc,
+	       cpu_to_le32(0), sizeof(struct minidump_subsystem));
+
+	return 0;
+}
+
+static struct minidump_ops smem_md_ops = {
+	.md_table_init		= smem_md_table_init,
+	.md_table_exit		= smem_md_table_exit,
+	.md_region_register	= smem_md_region_register,
+	.md_region_unregister	= smem_md_region_unregister,
+};
+
+static int qcom_minidump_smem_probe(struct platform_device *pdev)
+{
+	struct minidump *md;
+
+	md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL);
+	if (!md)
+		return -ENOMEM;
+
+	md->dev = &pdev->dev;
+	md->ops = &smem_md_ops;
+	md->name = "smem";
+	platform_set_drvdata(pdev, md);
+
+	return qcom_minidump_backend_register(md);
+}
+
+static int qcom_minidump_smem_remove(struct platform_device *pdev)
+{
+	struct minidump *md = platform_get_drvdata(pdev);
+
+	qcom_minidump_backend_unregister(md);
+
+	return 0;
+}
+
+static struct platform_driver qcom_minidump_smem_driver = {
+	.probe = qcom_minidump_smem_probe,
+	.remove = qcom_minidump_smem_remove,
+	.driver  = {
+		.name = "qcom-minidump-smem",
+	},
+};
+
+module_platform_driver(qcom_minidump_smem_driver);
+
 MODULE_DESCRIPTION("Qualcomm Minidump SMEM as backend driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:qcom-minidump-smem");
diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c
index 6be7ea93c78c..af582aa7f9a3 100644
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -269,6 +269,7 @@ struct smem_region {
  * @partitions: list of partitions of current processor/host
  * @item_count: max accepted item number
  * @socinfo:	platform device pointer
+ * @minidump:	minidump platform device pointer
  * @num_regions: number of @regions
  * @regions:	list of the memory regions defining the shared memory
  */
@@ -279,6 +280,7 @@ struct qcom_smem {
 
 	u32 item_count;
 	struct platform_device *socinfo;
+	struct platform_device *minidump;
 	struct smem_ptable *ptable;
 	struct smem_partition global_partition;
 	struct smem_partition partitions[SMEM_HOST_COUNT];
@@ -1151,11 +1153,18 @@ static int qcom_smem_probe(struct platform_device *pdev)
 	if (IS_ERR(smem->socinfo))
 		dev_dbg(&pdev->dev, "failed to register socinfo device\n");
 
+	smem->minidump = platform_device_register_data(&pdev->dev, "qcom-minidump-smem",
+						      PLATFORM_DEVID_NONE, NULL,
+						      0);
+	if (IS_ERR(smem->minidump))
+		dev_dbg(&pdev->dev, "failed to register minidump device\n");
+
 	return 0;
 }
 
 static int qcom_smem_remove(struct platform_device *pdev)
 {
+	platform_device_unregister(__smem->minidump);
 	platform_device_unregister(__smem->socinfo);
 
 	hwspin_lock_free(__smem->hwlock);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 06/21] soc: qcom: minidump: Add pending region registration support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Pending regions are those apss minidump regions which came for
registration before minidump was initialized or ready to do
register the region.

We can add regions to pending region list and register them from
apss minidump driver probe in one go.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_minidump.c          | 87 ++++++++++++++++++++++++++++---
 drivers/soc/qcom/qcom_minidump_internal.h | 20 +++++++
 2 files changed, 99 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
index 7744e57843ab..cfdb63cc29d6 100644
--- a/drivers/soc/qcom/qcom_minidump.c
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -9,6 +9,7 @@
 #include <linux/export.h>
 #include <linux/kallsyms.h>
 #include <linux/kernel.h>
+#include <linux/list.h>
 #include <linux/module.h>
 #include <linux/printk.h>
 #include <linux/string.h>
@@ -35,6 +36,10 @@ static DEFINE_MUTEX(md_lock);
 /* Only one front end will be attached to one back-end */
 static struct minidump *md;
 static char *md_backend;
+static struct minidump_plist md_plist = {
+	.plist = LIST_HEAD_INIT(md_plist.plist),
+	.pregion_cnt = 0,
+};
 
 static struct elf_shdr *elf_shdr_entry_addr(struct elfhdr *ehdr, int idx)
 {
@@ -201,6 +206,26 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region
 		IS_ALIGNED(region->size, 4);
 }
 
+static struct minidump_pregion *
+check_if_pending_region_exist(const struct qcom_minidump_region *region)
+{
+	struct minidump_pregion *md_pregion;
+	struct minidump_pregion *tmp;
+	bool found = false;
+
+	list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) {
+		struct qcom_minidump_region *md_region;
+
+		md_region = &md_pregion->region;
+		if (!strcmp(md_region->name, region->name)) {
+			found = true;
+			break;
+		}
+	}
+
+	return found ? md_pregion : NULL;
+}
+
 /**
  * qcom_minidump_region_register() - Register region in APSS Minidump table.
  * @region: minidump region.
@@ -209,16 +234,40 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region
  */
 int qcom_minidump_region_register(const struct qcom_minidump_region *region)
 {
-	int ret;
+	struct minidump_pregion *md_pregion;
+	int ret = 0;
 
 	if (!qcom_minidump_valid_region(region))
 		return -EINVAL;
 
 	mutex_lock(&md_lock);
 	if (!md) {
-		mutex_unlock(&md_lock);
-		pr_err("No backend registered yet, try again..");
-		return -EPROBE_DEFER;
+		if (md_plist.pregion_cnt >= MAX_NUM_ENTRIES - 1) {
+			pr_err("maximum region limit %u reached\n", md_plist.pregion_cnt);
+			ret = -ENOSPC;
+			goto unlock;
+		}
+
+		md_pregion = check_if_pending_region_exist(region);
+		if (md_pregion) {
+			pr_info("%s region is already exist\n", region->name);
+			ret = -EEXIST;
+			goto unlock;
+		}
+		/*
+		 * Maintain a list of client regions which came before
+		 * minidump driver was ready and once it is ready,
+		 * register them in one go from minidump probe function.
+		 */
+		md_pregion = kzalloc(sizeof(*md_pregion), GFP_KERNEL);
+		if (!md_pregion) {
+			ret = -ENOMEM;
+			goto unlock;
+		}
+		md_pregion->region = *region;
+		list_add_tail(&md_pregion->list, &md_plist.plist);
+		md_plist.pregion_cnt++;
+		goto unlock;
 	}
 
 	ret = md->ops->md_region_register(md, region);
@@ -240,16 +289,22 @@ EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
  */
 int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
 {
-	int ret;
+	struct minidump_pregion *md_pregion;
+	int ret = 0;
 
 	if (!qcom_minidump_valid_region(region))
 		return -EINVAL;
 
 	mutex_lock(&md_lock);
 	if (!md) {
-		mutex_unlock(&md_lock);
-		pr_err("No backend registered yet, try again..");
-		return -EPROBE_DEFER;
+		md_pregion = check_if_pending_region_exist(region);
+		if (!md_pregion)
+			goto unlock;
+
+		list_del(&md_pregion->list);
+		kfree(md_pregion);
+		md_plist.pregion_cnt--;
+		goto unlock;
 	}
 
 	ret = md->ops->md_region_unregister(md, region);
@@ -378,6 +433,8 @@ static int qcom_minidump_add_elf_header(struct minidump *md_data)
  */
 int qcom_minidump_backend_register(struct minidump *md_data)
 {
+	struct minidump_pregion *md_pregion;
+	struct minidump_pregion *tmp;
 	int ret;
 
 	if (!md_data->name || !md_data->dev ||
@@ -425,6 +482,20 @@ int qcom_minidump_backend_register(struct minidump *md_data)
 	md_backend = kstrdup(md->name, GFP_KERNEL);
 	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
 
+	list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) {
+		struct qcom_minidump_region *region;
+
+		region = &md_pregion->region;
+		ret = md->ops->md_region_register(md, region);
+		if (ret)
+			goto unlock;
+
+		qcom_md_update_elf_header(region);
+		list_del(&md_pregion->list);
+		kfree(md_pregion);
+		md_plist.pregion_cnt--;
+	}
+
 unlock:
 	mutex_unlock(&md_lock);
 	return ret;
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
index 9031b1b0a046..6993e3be10c2 100644
--- a/drivers/soc/qcom/qcom_minidump_internal.h
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -65,6 +65,26 @@ struct minidump {
 	void				*apss_data;
 };
 
+/**
+ * struct minidump_pregion - Minidump pending region
+ * @list       : Pending region list pointer
+ * @region     : APSS minidump client region
+ */
+struct minidump_pregion {
+	struct list_head	     list;
+	struct qcom_minidump_region  region;
+};
+
+/**
+ * struct minidump_plist - Minidump pending region list
+ * @plist	: List of pending region to be registered
+ * @pregion_cnt	: Count of the pending region to be registered
+ */
+struct minidump_plist {
+	struct list_head  plist;
+	int		  pregion_cnt;
+};
+
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
 int qcom_minidump_backend_register(struct minidump *md);
 void qcom_minidump_backend_unregister(struct minidump *md);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 06/21] soc: qcom: minidump: Add pending region registration support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Pending regions are those apss minidump regions which came for
registration before minidump was initialized or ready to do
register the region.

We can add regions to pending region list and register them from
apss minidump driver probe in one go.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_minidump.c          | 87 ++++++++++++++++++++++++++++---
 drivers/soc/qcom/qcom_minidump_internal.h | 20 +++++++
 2 files changed, 99 insertions(+), 8 deletions(-)

diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
index 7744e57843ab..cfdb63cc29d6 100644
--- a/drivers/soc/qcom/qcom_minidump.c
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -9,6 +9,7 @@
 #include <linux/export.h>
 #include <linux/kallsyms.h>
 #include <linux/kernel.h>
+#include <linux/list.h>
 #include <linux/module.h>
 #include <linux/printk.h>
 #include <linux/string.h>
@@ -35,6 +36,10 @@ static DEFINE_MUTEX(md_lock);
 /* Only one front end will be attached to one back-end */
 static struct minidump *md;
 static char *md_backend;
+static struct minidump_plist md_plist = {
+	.plist = LIST_HEAD_INIT(md_plist.plist),
+	.pregion_cnt = 0,
+};
 
 static struct elf_shdr *elf_shdr_entry_addr(struct elfhdr *ehdr, int idx)
 {
@@ -201,6 +206,26 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region
 		IS_ALIGNED(region->size, 4);
 }
 
+static struct minidump_pregion *
+check_if_pending_region_exist(const struct qcom_minidump_region *region)
+{
+	struct minidump_pregion *md_pregion;
+	struct minidump_pregion *tmp;
+	bool found = false;
+
+	list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) {
+		struct qcom_minidump_region *md_region;
+
+		md_region = &md_pregion->region;
+		if (!strcmp(md_region->name, region->name)) {
+			found = true;
+			break;
+		}
+	}
+
+	return found ? md_pregion : NULL;
+}
+
 /**
  * qcom_minidump_region_register() - Register region in APSS Minidump table.
  * @region: minidump region.
@@ -209,16 +234,40 @@ static bool qcom_minidump_valid_region(const struct qcom_minidump_region *region
  */
 int qcom_minidump_region_register(const struct qcom_minidump_region *region)
 {
-	int ret;
+	struct minidump_pregion *md_pregion;
+	int ret = 0;
 
 	if (!qcom_minidump_valid_region(region))
 		return -EINVAL;
 
 	mutex_lock(&md_lock);
 	if (!md) {
-		mutex_unlock(&md_lock);
-		pr_err("No backend registered yet, try again..");
-		return -EPROBE_DEFER;
+		if (md_plist.pregion_cnt >= MAX_NUM_ENTRIES - 1) {
+			pr_err("maximum region limit %u reached\n", md_plist.pregion_cnt);
+			ret = -ENOSPC;
+			goto unlock;
+		}
+
+		md_pregion = check_if_pending_region_exist(region);
+		if (md_pregion) {
+			pr_info("%s region is already exist\n", region->name);
+			ret = -EEXIST;
+			goto unlock;
+		}
+		/*
+		 * Maintain a list of client regions which came before
+		 * minidump driver was ready and once it is ready,
+		 * register them in one go from minidump probe function.
+		 */
+		md_pregion = kzalloc(sizeof(*md_pregion), GFP_KERNEL);
+		if (!md_pregion) {
+			ret = -ENOMEM;
+			goto unlock;
+		}
+		md_pregion->region = *region;
+		list_add_tail(&md_pregion->list, &md_plist.plist);
+		md_plist.pregion_cnt++;
+		goto unlock;
 	}
 
 	ret = md->ops->md_region_register(md, region);
@@ -240,16 +289,22 @@ EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
  */
 int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
 {
-	int ret;
+	struct minidump_pregion *md_pregion;
+	int ret = 0;
 
 	if (!qcom_minidump_valid_region(region))
 		return -EINVAL;
 
 	mutex_lock(&md_lock);
 	if (!md) {
-		mutex_unlock(&md_lock);
-		pr_err("No backend registered yet, try again..");
-		return -EPROBE_DEFER;
+		md_pregion = check_if_pending_region_exist(region);
+		if (!md_pregion)
+			goto unlock;
+
+		list_del(&md_pregion->list);
+		kfree(md_pregion);
+		md_plist.pregion_cnt--;
+		goto unlock;
 	}
 
 	ret = md->ops->md_region_unregister(md, region);
@@ -378,6 +433,8 @@ static int qcom_minidump_add_elf_header(struct minidump *md_data)
  */
 int qcom_minidump_backend_register(struct minidump *md_data)
 {
+	struct minidump_pregion *md_pregion;
+	struct minidump_pregion *tmp;
 	int ret;
 
 	if (!md_data->name || !md_data->dev ||
@@ -425,6 +482,20 @@ int qcom_minidump_backend_register(struct minidump *md_data)
 	md_backend = kstrdup(md->name, GFP_KERNEL);
 	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
 
+	list_for_each_entry_safe(md_pregion, tmp, &md_plist.plist, list) {
+		struct qcom_minidump_region *region;
+
+		region = &md_pregion->region;
+		ret = md->ops->md_region_register(md, region);
+		if (ret)
+			goto unlock;
+
+		qcom_md_update_elf_header(region);
+		list_del(&md_pregion->list);
+		kfree(md_pregion);
+		md_plist.pregion_cnt--;
+	}
+
 unlock:
 	mutex_unlock(&md_lock);
 	return ret;
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
index 9031b1b0a046..6993e3be10c2 100644
--- a/drivers/soc/qcom/qcom_minidump_internal.h
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -65,6 +65,26 @@ struct minidump {
 	void				*apss_data;
 };
 
+/**
+ * struct minidump_pregion - Minidump pending region
+ * @list       : Pending region list pointer
+ * @region     : APSS minidump client region
+ */
+struct minidump_pregion {
+	struct list_head	     list;
+	struct qcom_minidump_region  region;
+};
+
+/**
+ * struct minidump_plist - Minidump pending region list
+ * @plist	: List of pending region to be registered
+ * @pregion_cnt	: Count of the pending region to be registered
+ */
+struct minidump_plist {
+	struct list_head  plist;
+	int		  pregion_cnt;
+};
+
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
 int qcom_minidump_backend_register(struct minidump *md);
 void qcom_minidump_backend_unregister(struct minidump *md);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 07/21] soc: qcom: minidump: Add update region support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add support to update client's region physical/virtual addresses,
which is useful for dynamic loadable modules, dynamic address
changing clients like if we want to collect current stack
information for each core and the current stack is changing on
each sched_switch event, So here virtual/physical address of
the current stack is changing. So, to cover such use cases
add the update region support in minidump driver and the
corresponding smem backend support.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_minidump.c          | 55 +++++++++++++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h |  3 ++
 drivers/soc/qcom/qcom_minidump_smem.c     | 21 ++++++++++++
 include/soc/qcom/qcom_minidump.h          |  5 +++
 4 files changed, 84 insertions(+)

diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
index cfdb63cc29d6..37d6ceb4d85c 100644
--- a/drivers/soc/qcom/qcom_minidump.c
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -318,6 +318,61 @@ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
 }
 EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
 
+/**
+ * qcom_minidump_update_region() - Update region information with new physical
+ * address and virtual address for already registered region e.g, current task
+ * stack for a core keeps on changing on each context switch, there it needs to
+ * change registered region with new updated addresses.
+ *
+ * @region: Should be already registered minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_update_region(const struct qcom_minidump_region *region)
+{
+	struct minidump_pregion *md_pregion;
+	struct qcom_minidump_region *tmp;
+	struct elfhdr *ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+	int idx;
+	int ret = 0;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		md_pregion = check_if_pending_region_exist(region);
+		if (!md_pregion) {
+			ret = -ENOENT;
+			goto unlock;
+		}
+		tmp = &md_pregion->region;
+		tmp->phys_addr = region->phys_addr;
+		tmp->virt_addr = region->virt_addr;
+		goto unlock;
+	}
+
+	ret = md->ops->md_update_region(md, &idx, region);
+	if (ret)
+		goto unlock;
+
+	/* Skip predefined shdr/phdr header entry at the start */
+	ehdr = md->elf.ehdr;
+	shdr = elf_shdr_entry_addr(ehdr, idx + 4);
+	phdr = elf_phdr_entry_addr(ehdr, idx + 1);
+
+	shdr->sh_addr = (elf_addr_t)region->virt_addr;
+	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
+	phdr->p_paddr = region->phys_addr;
+
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_update_region);
+
 static int qcom_minidump_add_elf_header(struct minidump *md_data)
 {
 	struct qcom_minidump_region elfregion;
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
index 6993e3be10c2..dc1e76c1f063 100644
--- a/drivers/soc/qcom/qcom_minidump_internal.h
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -21,6 +21,7 @@ struct minidump;
  * @md_table_exit:	  Clean up the stuff populated while md_table_init()
  * @md_region_register:	  Callback to register the region at the backend.
  * @md_region_unregister: Callback to unregister the region at the backend.
+ * @md_update_region:	  Callback to update address of already registered regions.
  */
 struct minidump_ops {
 	int (*md_table_init)(struct minidump *md);
@@ -29,6 +30,8 @@ struct minidump_ops {
 				 const struct qcom_minidump_region *region);
 	int (*md_region_unregister)(struct minidump *md,
 				 const struct qcom_minidump_region *region);
+	int (*md_update_region)(struct minidump *md, int *idx,
+                                 const struct qcom_minidump_region *region);
 };
 
 /**
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
index bdc75aa2f518..9d4021a5e4c8 100644
--- a/drivers/soc/qcom/qcom_minidump_smem.c
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -263,6 +263,26 @@ static int smem_md_region_unregister(struct minidump *md,
 	return 0;
 }
 
+static int smem_md_update_region(struct minidump *md, int *idx,
+				 const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_region *mdr;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret < 0) {
+		dev_err(md->dev, "%s region is not present\n", region->name);
+		return ret;
+	}
+
+	*idx = ret;
+	mdr = &mdss_data->md_regions[*idx];
+	mdr->address = cpu_to_le64(region->phys_addr);
+
+	return 0;
+}
+
 static int smem_md_table_init(struct minidump *md)
 {
 	struct minidump_global_toc *mdgtoc;
@@ -324,6 +344,7 @@ static struct minidump_ops smem_md_ops = {
 	.md_table_exit		= smem_md_table_exit,
 	.md_region_register	= smem_md_region_register,
 	.md_region_unregister	= smem_md_region_unregister,
+	.md_update_region	= smem_md_update_region,
 };
 
 static int qcom_minidump_smem_probe(struct platform_device *pdev)
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
index d0bebc3daac5..a86b0313698f 100644
--- a/include/soc/qcom/qcom_minidump.h
+++ b/include/soc/qcom/qcom_minidump.h
@@ -29,6 +29,7 @@ struct qcom_minidump_region {
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
 int qcom_minidump_region_register(const struct qcom_minidump_region *region);
 int qcom_minidump_region_unregister(const struct qcom_minidump_region *region);
+int qcom_minidump_update_region(const struct qcom_minidump_region *region);
 #else
 static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region)
 {
@@ -39,6 +40,10 @@ static inline int qcom_minidump_region_unregister(const struct qcom_minidump_reg
 {
 	return 0;
 }
+static inline int qcom_minidump_update_region(const struct qcom_minidump_region *region)
+{
+	return 0;
+}
 #endif /* CONFIG_QCOM_MINIDUMP */
 
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 07/21] soc: qcom: minidump: Add update region support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add support to update client's region physical/virtual addresses,
which is useful for dynamic loadable modules, dynamic address
changing clients like if we want to collect current stack
information for each core and the current stack is changing on
each sched_switch event, So here virtual/physical address of
the current stack is changing. So, to cover such use cases
add the update region support in minidump driver and the
corresponding smem backend support.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_minidump.c          | 55 +++++++++++++++++++++++++++++++
 drivers/soc/qcom/qcom_minidump_internal.h |  3 ++
 drivers/soc/qcom/qcom_minidump_smem.c     | 21 ++++++++++++
 include/soc/qcom/qcom_minidump.h          |  5 +++
 4 files changed, 84 insertions(+)

diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
index cfdb63cc29d6..37d6ceb4d85c 100644
--- a/drivers/soc/qcom/qcom_minidump.c
+++ b/drivers/soc/qcom/qcom_minidump.c
@@ -318,6 +318,61 @@ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
 }
 EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
 
+/**
+ * qcom_minidump_update_region() - Update region information with new physical
+ * address and virtual address for already registered region e.g, current task
+ * stack for a core keeps on changing on each context switch, there it needs to
+ * change registered region with new updated addresses.
+ *
+ * @region: Should be already registered minidump region.
+ *
+ * Return: On success, it returns 0 and negative error value on failure.
+ */
+int qcom_minidump_update_region(const struct qcom_minidump_region *region)
+{
+	struct minidump_pregion *md_pregion;
+	struct qcom_minidump_region *tmp;
+	struct elfhdr *ehdr;
+	struct elf_shdr *shdr;
+	struct elf_phdr *phdr;
+	int idx;
+	int ret = 0;
+
+	if (!qcom_minidump_valid_region(region))
+		return -EINVAL;
+
+	mutex_lock(&md_lock);
+	if (!md) {
+		md_pregion = check_if_pending_region_exist(region);
+		if (!md_pregion) {
+			ret = -ENOENT;
+			goto unlock;
+		}
+		tmp = &md_pregion->region;
+		tmp->phys_addr = region->phys_addr;
+		tmp->virt_addr = region->virt_addr;
+		goto unlock;
+	}
+
+	ret = md->ops->md_update_region(md, &idx, region);
+	if (ret)
+		goto unlock;
+
+	/* Skip predefined shdr/phdr header entry at the start */
+	ehdr = md->elf.ehdr;
+	shdr = elf_shdr_entry_addr(ehdr, idx + 4);
+	phdr = elf_phdr_entry_addr(ehdr, idx + 1);
+
+	shdr->sh_addr = (elf_addr_t)region->virt_addr;
+	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
+	phdr->p_paddr = region->phys_addr;
+
+unlock:
+	mutex_unlock(&md_lock);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(qcom_minidump_update_region);
+
 static int qcom_minidump_add_elf_header(struct minidump *md_data)
 {
 	struct qcom_minidump_region elfregion;
diff --git a/drivers/soc/qcom/qcom_minidump_internal.h b/drivers/soc/qcom/qcom_minidump_internal.h
index 6993e3be10c2..dc1e76c1f063 100644
--- a/drivers/soc/qcom/qcom_minidump_internal.h
+++ b/drivers/soc/qcom/qcom_minidump_internal.h
@@ -21,6 +21,7 @@ struct minidump;
  * @md_table_exit:	  Clean up the stuff populated while md_table_init()
  * @md_region_register:	  Callback to register the region at the backend.
  * @md_region_unregister: Callback to unregister the region at the backend.
+ * @md_update_region:	  Callback to update address of already registered regions.
  */
 struct minidump_ops {
 	int (*md_table_init)(struct minidump *md);
@@ -29,6 +30,8 @@ struct minidump_ops {
 				 const struct qcom_minidump_region *region);
 	int (*md_region_unregister)(struct minidump *md,
 				 const struct qcom_minidump_region *region);
+	int (*md_update_region)(struct minidump *md, int *idx,
+                                 const struct qcom_minidump_region *region);
 };
 
 /**
diff --git a/drivers/soc/qcom/qcom_minidump_smem.c b/drivers/soc/qcom/qcom_minidump_smem.c
index bdc75aa2f518..9d4021a5e4c8 100644
--- a/drivers/soc/qcom/qcom_minidump_smem.c
+++ b/drivers/soc/qcom/qcom_minidump_smem.c
@@ -263,6 +263,26 @@ static int smem_md_region_unregister(struct minidump *md,
 	return 0;
 }
 
+static int smem_md_update_region(struct minidump *md, int *idx,
+				 const struct qcom_minidump_region *region)
+{
+	struct minidump_ss_data *mdss_data = md->apss_data;
+	struct minidump_region *mdr;
+	int ret;
+
+	ret = smem_md_get_region_index(mdss_data, region);
+	if (ret < 0) {
+		dev_err(md->dev, "%s region is not present\n", region->name);
+		return ret;
+	}
+
+	*idx = ret;
+	mdr = &mdss_data->md_regions[*idx];
+	mdr->address = cpu_to_le64(region->phys_addr);
+
+	return 0;
+}
+
 static int smem_md_table_init(struct minidump *md)
 {
 	struct minidump_global_toc *mdgtoc;
@@ -324,6 +344,7 @@ static struct minidump_ops smem_md_ops = {
 	.md_table_exit		= smem_md_table_exit,
 	.md_region_register	= smem_md_region_register,
 	.md_region_unregister	= smem_md_region_unregister,
+	.md_update_region	= smem_md_update_region,
 };
 
 static int qcom_minidump_smem_probe(struct platform_device *pdev)
diff --git a/include/soc/qcom/qcom_minidump.h b/include/soc/qcom/qcom_minidump.h
index d0bebc3daac5..a86b0313698f 100644
--- a/include/soc/qcom/qcom_minidump.h
+++ b/include/soc/qcom/qcom_minidump.h
@@ -29,6 +29,7 @@ struct qcom_minidump_region {
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP)
 int qcom_minidump_region_register(const struct qcom_minidump_region *region);
 int qcom_minidump_region_unregister(const struct qcom_minidump_region *region);
+int qcom_minidump_update_region(const struct qcom_minidump_region *region);
 #else
 static inline int qcom_minidump_region_register(const struct qcom_minidump_region *region)
 {
@@ -39,6 +40,10 @@ static inline int qcom_minidump_region_unregister(const struct qcom_minidump_reg
 {
 	return 0;
 }
+static inline int qcom_minidump_update_region(const struct qcom_minidump_region *region)
+{
+	return 0;
+}
 #endif /* CONFIG_QCOM_MINIDUMP */
 
 #if IS_ENABLED(CONFIG_QCOM_MINIDUMP_SMEM)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Qualcomm ramoops minidump logger provide a means of storing
the ramoops data to some dynamically reserved memory instead
of traditionally implemented ramoops where the region should
be statically fixed ram region. Its device tree binding
would be exactly same as ramoops device tree binding and is
going to contain traditional ramoops frontend data and this
content will be collected via Qualcomm minidump infrastructure
provided from the boot firmware.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
new file mode 100644
index 000000000000..b1fdcf3f8ad4
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm Ramoops minidump logger
+
+description: |
+  Qualcomm ramoops minidump logger provide a means of storing the ramoops
+  data to some dynamically reserved memory instead of traditionally
+  implemented ramoops where the region should be statically fixed ram
+  region. Because of its similarity with ramoops it will also have same
+  set of property what ramoops have it in its schema and is going to
+  contain traditional ramoops frontend data and this region will be
+  collected via Qualcomm minidump infrastructure provided from the
+  boot firmware.
+
+maintainers:
+  - Mukesh Ojha <quic_mojha@quicinc.com>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - qcom,sm8450-ramoops
+      - const: qcom,ramoops
+
+  memory-region:
+    maxItems: 1
+    description: handle to memory reservation for qcom,ramoops region.
+
+  ecc-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: enables ECC support and specifies ECC buffer size in bytes
+    default: 0 # no ECC
+
+  record-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: maximum size in bytes of each kmsg dump
+    default: 0
+
+  console-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for kernel messages
+    default: 0
+
+  ftrace-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for function tracing and profiling
+    default: 0
+
+  pmsg-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for userspace messages
+    default: 0
+
+  mem-type:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: if present, sets the type of mapping is to be used to map the reserved region.
+    default: 0
+    oneOf:
+      - const: 0
+        description: write-combined
+      - const: 1
+        description: unbuffered
+      - const: 2
+        description: cached
+
+  max-reason:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 2 # log oopses and panics
+    maximum: 0x7fffffff
+    description: |
+      If present, sets maximum type of kmsg dump reasons to store.
+      This can be set to INT_MAX to store all kmsg dumps.
+      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
+      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
+      controlled by the printk.always_kmsg_dump boot param.
+      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
+
+  flags:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+    description: |
+      If present, pass ramoops behavioral flags
+      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
+
+  no-dump-oops:
+    deprecated: true
+    type: boolean
+    description: |
+      Use max_reason instead. If present, and max_reason is not specified,
+      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
+
+  unbuffered:
+    deprecated: true
+    type: boolean
+    description: |
+      Use mem_type instead. If present, and mem_type is not specified,
+      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
+      the reserved region (defaults to buffered mappings mem_type = 0).
+      If both are specified -- "mem_type" overrides "unbuffered".
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - memory-region
+
+anyOf:
+  - required: [record-size]
+  - required: [console-size]
+  - required: [ftrace-size]
+  - required: [pmsg-size]
+
+examples:
+  - |
+
+    qcom_ramoops {
+        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
+        memory-region = <&qcom_ramoops_region>;
+        console-size = <0x8000>;    /* 32kB */
+        record-size = <0x400>;      /*  1kB */
+        ecc-size = <16>;
+    };
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Qualcomm ramoops minidump logger provide a means of storing
the ramoops data to some dynamically reserved memory instead
of traditionally implemented ramoops where the region should
be statically fixed ram region. Its device tree binding
would be exactly same as ramoops device tree binding and is
going to contain traditional ramoops frontend data and this
content will be collected via Qualcomm minidump infrastructure
provided from the boot firmware.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
 1 file changed, 126 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
new file mode 100644
index 000000000000..b1fdcf3f8ad4
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
@@ -0,0 +1,126 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Qualcomm Ramoops minidump logger
+
+description: |
+  Qualcomm ramoops minidump logger provide a means of storing the ramoops
+  data to some dynamically reserved memory instead of traditionally
+  implemented ramoops where the region should be statically fixed ram
+  region. Because of its similarity with ramoops it will also have same
+  set of property what ramoops have it in its schema and is going to
+  contain traditional ramoops frontend data and this region will be
+  collected via Qualcomm minidump infrastructure provided from the
+  boot firmware.
+
+maintainers:
+  - Mukesh Ojha <quic_mojha@quicinc.com>
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - qcom,sm8450-ramoops
+      - const: qcom,ramoops
+
+  memory-region:
+    maxItems: 1
+    description: handle to memory reservation for qcom,ramoops region.
+
+  ecc-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: enables ECC support and specifies ECC buffer size in bytes
+    default: 0 # no ECC
+
+  record-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: maximum size in bytes of each kmsg dump
+    default: 0
+
+  console-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for kernel messages
+    default: 0
+
+  ftrace-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for function tracing and profiling
+    default: 0
+
+  pmsg-size:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: size in bytes of log buffer reserved for userspace messages
+    default: 0
+
+  mem-type:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: if present, sets the type of mapping is to be used to map the reserved region.
+    default: 0
+    oneOf:
+      - const: 0
+        description: write-combined
+      - const: 1
+        description: unbuffered
+      - const: 2
+        description: cached
+
+  max-reason:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 2 # log oopses and panics
+    maximum: 0x7fffffff
+    description: |
+      If present, sets maximum type of kmsg dump reasons to store.
+      This can be set to INT_MAX to store all kmsg dumps.
+      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
+      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
+      controlled by the printk.always_kmsg_dump boot param.
+      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
+
+  flags:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    default: 0
+    description: |
+      If present, pass ramoops behavioral flags
+      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
+
+  no-dump-oops:
+    deprecated: true
+    type: boolean
+    description: |
+      Use max_reason instead. If present, and max_reason is not specified,
+      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
+
+  unbuffered:
+    deprecated: true
+    type: boolean
+    description: |
+      Use mem_type instead. If present, and mem_type is not specified,
+      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
+      the reserved region (defaults to buffered mappings mem_type = 0).
+      If both are specified -- "mem_type" overrides "unbuffered".
+
+unevaluatedProperties: false
+
+required:
+  - compatible
+  - memory-region
+
+anyOf:
+  - required: [record-size]
+  - required: [console-size]
+  - required: [ftrace-size]
+  - required: [pmsg-size]
+
+examples:
+  - |
+
+    qcom_ramoops {
+        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
+        memory-region = <&qcom_ramoops_region>;
+        console-size = <0x8000>;    /* 32kB */
+        record-size = <0x400>;      /*  1kB */
+        ecc-size = <16>;
+    };
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 09/21] pstore/ram : Export ramoops_parse_dt() symbol
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

It is possible if some driver do not want ramoops region to
be static instead it sets up the mem_address and mem_size
and use everything what this driver has to offer. To offer
this convenience export ramoops_parse_dt() function.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 fs/pstore/ram.c            | 26 ++++++++++++++++++--------
 include/linux/pstore_ram.h |  2 ++
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ade66dbe5f39..6bb66d044bef 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -638,7 +638,7 @@ static int ramoops_parse_dt_u32(struct platform_device *pdev,
 	return 0;
 }
 
-static int ramoops_parse_dt(struct platform_device *pdev,
+int ramoops_parse_dt(struct platform_device *pdev,
 			    struct ramoops_platform_data *pdata)
 {
 	struct device_node *of_node = pdev->dev.of_node;
@@ -649,15 +649,24 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 
 	dev_dbg(&pdev->dev, "using Device Tree\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev,
-			"failed to locate DT /reserved-memory resource\n");
-		return -EINVAL;
+	/*
+	 * It is possible if some driver do not want ramoops
+	 * region to be static instead it sets up the mem_address
+	 * and mem_size and use everything what this driver has
+	 * to offer.
+	 */
+	if (!pdata->mem_address && !pdata->mem_size) {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res) {
+			dev_err(&pdev->dev,
+				"failed to locate DT /reserved-memory resource\n");
+			return -EINVAL;
+		}
+
+		pdata->mem_size = resource_size(res);
+		pdata->mem_address = res->start;
 	}
 
-	pdata->mem_size = resource_size(res);
-	pdata->mem_address = res->start;
 	/*
 	 * Setting "unbuffered" is deprecated and will be ignored if
 	 * "mem_type" is also specified.
@@ -713,6 +722,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ramoops_parse_dt);
 
 static int ramoops_probe(struct platform_device *pdev)
 {
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 9d65ff94e216..55df4e631a25 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -8,6 +8,7 @@
 #ifndef __LINUX_PSTORE_RAM_H__
 #define __LINUX_PSTORE_RAM_H__
 
+#include <linux/platform_device.h>
 #include <linux/pstore.h>
 
 struct persistent_ram_ecc_info {
@@ -39,4 +40,5 @@ struct ramoops_platform_data {
 	struct persistent_ram_ecc_info ecc_info;
 };
 
+int ramoops_parse_dt(struct platform_device *, struct ramoops_platform_data *);
 #endif
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 09/21] pstore/ram : Export ramoops_parse_dt() symbol
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

It is possible if some driver do not want ramoops region to
be static instead it sets up the mem_address and mem_size
and use everything what this driver has to offer. To offer
this convenience export ramoops_parse_dt() function.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 fs/pstore/ram.c            | 26 ++++++++++++++++++--------
 include/linux/pstore_ram.h |  2 ++
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index ade66dbe5f39..6bb66d044bef 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -638,7 +638,7 @@ static int ramoops_parse_dt_u32(struct platform_device *pdev,
 	return 0;
 }
 
-static int ramoops_parse_dt(struct platform_device *pdev,
+int ramoops_parse_dt(struct platform_device *pdev,
 			    struct ramoops_platform_data *pdata)
 {
 	struct device_node *of_node = pdev->dev.of_node;
@@ -649,15 +649,24 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 
 	dev_dbg(&pdev->dev, "using Device Tree\n");
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev,
-			"failed to locate DT /reserved-memory resource\n");
-		return -EINVAL;
+	/*
+	 * It is possible if some driver do not want ramoops
+	 * region to be static instead it sets up the mem_address
+	 * and mem_size and use everything what this driver has
+	 * to offer.
+	 */
+	if (!pdata->mem_address && !pdata->mem_size) {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if (!res) {
+			dev_err(&pdev->dev,
+				"failed to locate DT /reserved-memory resource\n");
+			return -EINVAL;
+		}
+
+		pdata->mem_size = resource_size(res);
+		pdata->mem_address = res->start;
 	}
 
-	pdata->mem_size = resource_size(res);
-	pdata->mem_address = res->start;
 	/*
 	 * Setting "unbuffered" is deprecated and will be ignored if
 	 * "mem_type" is also specified.
@@ -713,6 +722,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(ramoops_parse_dt);
 
 static int ramoops_probe(struct platform_device *pdev)
 {
diff --git a/include/linux/pstore_ram.h b/include/linux/pstore_ram.h
index 9d65ff94e216..55df4e631a25 100644
--- a/include/linux/pstore_ram.h
+++ b/include/linux/pstore_ram.h
@@ -8,6 +8,7 @@
 #ifndef __LINUX_PSTORE_RAM_H__
 #define __LINUX_PSTORE_RAM_H__
 
+#include <linux/platform_device.h>
 #include <linux/pstore.h>
 
 struct persistent_ram_ecc_info {
@@ -39,4 +40,5 @@ struct ramoops_platform_data {
 	struct persistent_ram_ecc_info ecc_info;
 };
 
+int ramoops_parse_dt(struct platform_device *, struct ramoops_platform_data *);
 #endif
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

This driver was inspired from the fact pstore ram region should be
fixed and boot firmware need to have awarness about this region,
so that it will be persistent across boot. But, there are many
QCOM SoC which does not support warm boot from hardware but they
have minidump support from the software, and for them, there is
no need of this pstore ram region to be fixed, but at the same
time have interest in the pstore frontends data. So, this driver
get the dynamic reserved region from the ram and register the
ramoops platform device.

 +---------+     +---------+   +--------+     +---------+
 | console |     | pmsg    |   | ftrace |     | dmesg   |
 +---------+     +---------+   +--------+     +---------+
       |             |             |              |
       |             |             |              |
       +------------------------------------------+
                          |
                         \ /
                  +----------------+
            (1)   |pstore frontends|
                  +----------------+
                          |
                         \ /
                 +------------------- +
            (2)  | pstore backend(ram)|
                 +--------------------+
                          |
                         \ /
                 +--------------------+
            (3)  |qcom_pstore_minidump|
                 +--------------------+
                          |
                         \ /
                   +---------------+
            (4)    | qcom_minidump |
                   +---------------+

This driver will route all the pstore front data to the stored
in qcom pstore reserved region and the reason of showing an
arrow from (3) to (4) as qcom_pstore_minidump driver will register
all the available frontends region with qcom minidump driver
in upcoming patch.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig                | 12 +++++
 drivers/soc/qcom/Makefile               |  1 +
 drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 1834213fd652..fbf08e30feda 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
 
 	  This config should be enabled if the low level minidump is implemented
 	  as part of SMEM.
+
+config QCOM_PSTORE_MINIDUMP
+	tristate "Pstore support for QCOM Minidump"
+	depends on ARCH_QCOM
+	depends on PSTORE_RAM
+	depends on QCOM_MINIDUMP
+	help
+	  Enablement of this driver ensures that ramoops region can be anywhere
+	  reserved in ram instead of being fixed address which needs boot firmware
+	  awareness. So, this driver creates plaform device and registers available
+	  frontend region with the Qualcomm's minidump driver.
+
 endmenu
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 737d868757ac..1ab59c1b364d 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -36,3 +36,4 @@ qcom_ice-objs			+= ice.o
 obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
 obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
 obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
+obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
new file mode 100644
index 000000000000..b07cd10340df
--- /dev/null
+++ b/drivers/soc/qcom/qcom_pstore_minidump.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/platform_device.h>
+#include <linux/pstore_ram.h>
+
+struct qcom_ramoops_dd {
+	struct ramoops_platform_data qcom_ramoops_pdata;
+	struct platform_device *ramoops_pdev;
+};
+
+static int qcom_ramoops_probe(struct platform_device *pdev)
+{
+	struct device_node *of_node = pdev->dev.of_node;
+	struct qcom_ramoops_dd *qcom_rdd;
+	struct ramoops_platform_data *pdata;
+	struct reserved_mem *rmem;
+	struct device_node *node;
+	long ret;
+
+	node = of_parse_phandle(of_node, "memory-region", 0);
+	if (!node)
+		return -ENODEV;
+
+	rmem = of_reserved_mem_lookup(node);
+	of_node_put(node);
+	if (!rmem) {
+		dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
+		return -EINVAL;
+	}
+
+	qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
+	if (!qcom_rdd)
+		return -ENOMEM;
+
+	pdata = &qcom_rdd->qcom_ramoops_pdata;
+	pdata->mem_size = rmem->size;
+	pdata->mem_address = rmem->base;
+	ramoops_parse_dt(pdev, pdata);
+
+	qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
+							       pdata, sizeof(*pdata));
+	if (IS_ERR(qcom_rdd->ramoops_pdev)) {
+		ret = PTR_ERR(qcom_rdd->ramoops_pdev);
+		dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
+		qcom_rdd->ramoops_pdev = NULL;
+	}
+	platform_set_drvdata(pdev, qcom_rdd);
+
+	return ret;
+}
+
+static void qcom_ramoops_remove(struct platform_device *pdev)
+{
+	struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
+
+	platform_device_unregister(qcom_rdd->ramoops_pdev);
+	qcom_rdd->ramoops_pdev = NULL;
+}
+
+static const struct of_device_id qcom_ramoops_of_match[] = {
+	{ .compatible = "qcom,ramoops"},
+	{}
+};
+MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
+
+static struct platform_driver qcom_ramoops_drv = {
+	.driver		= {
+		.name	= "qcom,ramoops",
+		.of_match_table = qcom_ramoops_of_match,
+	},
+	.probe = qcom_ramoops_probe,
+	.remove_new = qcom_ramoops_remove,
+};
+
+module_platform_driver(qcom_ramoops_drv);
+
+MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
+MODULE_LICENSE("GPL");
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

This driver was inspired from the fact pstore ram region should be
fixed and boot firmware need to have awarness about this region,
so that it will be persistent across boot. But, there are many
QCOM SoC which does not support warm boot from hardware but they
have minidump support from the software, and for them, there is
no need of this pstore ram region to be fixed, but at the same
time have interest in the pstore frontends data. So, this driver
get the dynamic reserved region from the ram and register the
ramoops platform device.

 +---------+     +---------+   +--------+     +---------+
 | console |     | pmsg    |   | ftrace |     | dmesg   |
 +---------+     +---------+   +--------+     +---------+
       |             |             |              |
       |             |             |              |
       +------------------------------------------+
                          |
                         \ /
                  +----------------+
            (1)   |pstore frontends|
                  +----------------+
                          |
                         \ /
                 +------------------- +
            (2)  | pstore backend(ram)|
                 +--------------------+
                          |
                         \ /
                 +--------------------+
            (3)  |qcom_pstore_minidump|
                 +--------------------+
                          |
                         \ /
                   +---------------+
            (4)    | qcom_minidump |
                   +---------------+

This driver will route all the pstore front data to the stored
in qcom pstore reserved region and the reason of showing an
arrow from (3) to (4) as qcom_pstore_minidump driver will register
all the available frontends region with qcom minidump driver
in upcoming patch.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/Kconfig                | 12 +++++
 drivers/soc/qcom/Makefile               |  1 +
 drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index 1834213fd652..fbf08e30feda 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
 
 	  This config should be enabled if the low level minidump is implemented
 	  as part of SMEM.
+
+config QCOM_PSTORE_MINIDUMP
+	tristate "Pstore support for QCOM Minidump"
+	depends on ARCH_QCOM
+	depends on PSTORE_RAM
+	depends on QCOM_MINIDUMP
+	help
+	  Enablement of this driver ensures that ramoops region can be anywhere
+	  reserved in ram instead of being fixed address which needs boot firmware
+	  awareness. So, this driver creates plaform device and registers available
+	  frontend region with the Qualcomm's minidump driver.
+
 endmenu
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index 737d868757ac..1ab59c1b364d 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -36,3 +36,4 @@ qcom_ice-objs			+= ice.o
 obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
 obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
 obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
+obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
new file mode 100644
index 000000000000..b07cd10340df
--- /dev/null
+++ b/drivers/soc/qcom/qcom_pstore_minidump.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+/*
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/platform_device.h>
+#include <linux/pstore_ram.h>
+
+struct qcom_ramoops_dd {
+	struct ramoops_platform_data qcom_ramoops_pdata;
+	struct platform_device *ramoops_pdev;
+};
+
+static int qcom_ramoops_probe(struct platform_device *pdev)
+{
+	struct device_node *of_node = pdev->dev.of_node;
+	struct qcom_ramoops_dd *qcom_rdd;
+	struct ramoops_platform_data *pdata;
+	struct reserved_mem *rmem;
+	struct device_node *node;
+	long ret;
+
+	node = of_parse_phandle(of_node, "memory-region", 0);
+	if (!node)
+		return -ENODEV;
+
+	rmem = of_reserved_mem_lookup(node);
+	of_node_put(node);
+	if (!rmem) {
+		dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
+		return -EINVAL;
+	}
+
+	qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
+	if (!qcom_rdd)
+		return -ENOMEM;
+
+	pdata = &qcom_rdd->qcom_ramoops_pdata;
+	pdata->mem_size = rmem->size;
+	pdata->mem_address = rmem->base;
+	ramoops_parse_dt(pdev, pdata);
+
+	qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
+							       pdata, sizeof(*pdata));
+	if (IS_ERR(qcom_rdd->ramoops_pdev)) {
+		ret = PTR_ERR(qcom_rdd->ramoops_pdev);
+		dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
+		qcom_rdd->ramoops_pdev = NULL;
+	}
+	platform_set_drvdata(pdev, qcom_rdd);
+
+	return ret;
+}
+
+static void qcom_ramoops_remove(struct platform_device *pdev)
+{
+	struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
+
+	platform_device_unregister(qcom_rdd->ramoops_pdev);
+	qcom_rdd->ramoops_pdev = NULL;
+}
+
+static const struct of_device_id qcom_ramoops_of_match[] = {
+	{ .compatible = "qcom,ramoops"},
+	{}
+};
+MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
+
+static struct platform_driver qcom_ramoops_drv = {
+	.driver		= {
+		.name	= "qcom,ramoops",
+		.of_match_table = qcom_ramoops_of_match,
+	},
+	.probe = qcom_ramoops_probe,
+	.remove_new = qcom_ramoops_remove,
+};
+
+module_platform_driver(qcom_ramoops_drv);
+
+MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
+MODULE_LICENSE("GPL");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Since qcom_pstore_minidump driver creates platform device for
qualcomm devices, so it knows the physical addresses of the
frontend region now. Let's register the regions with
qcom_minidump driver.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_pstore_minidump.c | 131 +++++++++++++++++++++++++++++++-
 1 file changed, 128 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
index b07cd10340df..f17384dd2d72 100644
--- a/drivers/soc/qcom/qcom_pstore_minidump.c
+++ b/drivers/soc/qcom/qcom_pstore_minidump.c
@@ -9,12 +9,120 @@
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 #include <linux/pstore_ram.h>
+#include <soc/qcom/qcom_minidump.h>
 
 struct qcom_ramoops_dd {
 	struct ramoops_platform_data qcom_ramoops_pdata;
 	struct platform_device *ramoops_pdev;
+	struct device *dev;
+	struct qcom_minidump_region **dmesg_region;
+	struct qcom_minidump_region *console_region;
+	struct qcom_minidump_region *pmsg_region;
+	struct qcom_minidump_region **ftrace_region;
+	unsigned int max_dump_cnt;
+	unsigned int max_ftrace_cnt;
 };
 
+static int qcom_ramoops_md_region_register(struct device *dev, struct qcom_minidump_region **zone,
+					   const char *name, phys_addr_t phys_addr,
+					   unsigned long size)
+{
+	struct qcom_minidump_region *md_region;
+	int ret;
+
+	if (!size)
+		return 0;
+
+	md_region = devm_kzalloc(dev, sizeof(*md_region), GFP_KERNEL);
+	if (!md_region)
+		return -ENOMEM;
+
+	strscpy(md_region->name, name, sizeof(md_region->name));
+	md_region->phys_addr = phys_addr;
+	md_region->virt_addr = phys_to_virt(phys_addr);
+	md_region->size = size;
+	*zone = md_region;
+	ret = qcom_minidump_region_register(md_region);
+	if (ret)
+		dev_err(dev, "failed to add %s in minidump: err: %d\n", name, ret);
+
+	return ret;
+}
+
+static int qcom_ramoops_minidump_register(struct qcom_ramoops_dd *qcom_rdd)
+{
+	struct ramoops_platform_data *pdata = &qcom_rdd->qcom_ramoops_pdata;
+	char name[MAX_NAME_LENGTH];
+	size_t zone_sz;
+	phys_addr_t phys_addr;
+	int ret = 0;
+	int i;
+
+	phys_addr = pdata->mem_address;
+	for (i = 0; i < qcom_rdd->max_dump_cnt; i++) {
+		scnprintf(name, sizeof(name), "KDMSG%d", i);
+		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->dmesg_region[i], name, phys_addr,
+			pdata->record_size);
+		if (ret)
+			return ret;
+
+		phys_addr += pdata->record_size;
+	}
+
+	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->console_region, "KCONSOLE", phys_addr,
+			pdata->console_size);
+	if (ret)
+		return ret;
+
+	phys_addr += pdata->console_size;
+
+	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->pmsg_region, "KPMSG", phys_addr,
+			pdata->pmsg_size);
+	if (ret)
+		return ret;
+
+	phys_addr += pdata->pmsg_size;
+
+	zone_sz =  pdata->ftrace_size / qcom_rdd->max_ftrace_cnt;
+	for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) {
+		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->ftrace_region[i], "KFTRACE", phys_addr,
+			zone_sz);
+		if (ret)
+			return ret;
+
+		phys_addr += zone_sz;
+	}
+
+	return ret;
+}
+
+static void qcom_ramoops_minidump_unregister(struct qcom_ramoops_dd *qcom_rdd)
+{
+	struct ramoops_platform_data *pdata;
+	int i;
+
+	pdata = &qcom_rdd->qcom_ramoops_pdata;
+	if (pdata->record_size) {
+		for (i = 0; i < qcom_rdd->max_dump_cnt; i++)
+			qcom_minidump_region_unregister(qcom_rdd->dmesg_region[i]);
+	}
+
+	if (pdata->console_size)
+		qcom_minidump_region_unregister(qcom_rdd->console_region);
+
+	if (pdata->pmsg_size)
+		qcom_minidump_region_unregister(qcom_rdd->pmsg_region);
+
+	if (pdata->ftrace_size) {
+		for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++)
+			qcom_minidump_region_unregister(qcom_rdd->ftrace_region[i]);
+	}
+}
+
 static int qcom_ramoops_probe(struct platform_device *pdev)
 {
 	struct device_node *of_node = pdev->dev.of_node;
@@ -22,6 +130,7 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
 	struct ramoops_platform_data *pdata;
 	struct reserved_mem *rmem;
 	struct device_node *node;
+	size_t dump_mem_sz;
 	long ret;
 
 	node = of_parse_phandle(of_node, "memory-region", 0);
@@ -39,27 +148,43 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
 	if (!qcom_rdd)
 		return -ENOMEM;
 
+	qcom_rdd->dev = &pdev->dev;
 	pdata = &qcom_rdd->qcom_ramoops_pdata;
 	pdata->mem_size = rmem->size;
 	pdata->mem_address = rmem->base;
-	ramoops_parse_dt(pdev, pdata);
-
+	ret = ramoops_parse_dt(pdev, pdata);
+	if (ret < 0)
+		return ret;
+
+	dump_mem_sz = pdata->mem_size - pdata->console_size - pdata->ftrace_size
+		      - pdata->pmsg_size;
+	if (!dump_mem_sz || !pdata->record_size)
+		qcom_rdd->max_dump_cnt = 0;
+	else
+		qcom_rdd->max_dump_cnt = dump_mem_sz / pdata->record_size;
+
+	qcom_rdd->max_ftrace_cnt = (pdata->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)
+				? nr_cpu_ids
+				: 1;
 	qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
 							       pdata, sizeof(*pdata));
 	if (IS_ERR(qcom_rdd->ramoops_pdev)) {
 		ret = PTR_ERR(qcom_rdd->ramoops_pdev);
 		dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
 		qcom_rdd->ramoops_pdev = NULL;
+		return ret;
 	}
+
 	platform_set_drvdata(pdev, qcom_rdd);
 
-	return ret;
+	return qcom_ramoops_minidump_register(qcom_rdd);
 }
 
 static void qcom_ramoops_remove(struct platform_device *pdev)
 {
 	struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
 
+	qcom_ramoops_minidump_unregister(qcom_rdd);
 	platform_device_unregister(qcom_rdd->ramoops_pdev);
 	qcom_rdd->ramoops_pdev = NULL;
 }
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Since qcom_pstore_minidump driver creates platform device for
qualcomm devices, so it knows the physical addresses of the
frontend region now. Let's register the regions with
qcom_minidump driver.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/soc/qcom/qcom_pstore_minidump.c | 131 +++++++++++++++++++++++++++++++-
 1 file changed, 128 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
index b07cd10340df..f17384dd2d72 100644
--- a/drivers/soc/qcom/qcom_pstore_minidump.c
+++ b/drivers/soc/qcom/qcom_pstore_minidump.c
@@ -9,12 +9,120 @@
 #include <linux/of_reserved_mem.h>
 #include <linux/platform_device.h>
 #include <linux/pstore_ram.h>
+#include <soc/qcom/qcom_minidump.h>
 
 struct qcom_ramoops_dd {
 	struct ramoops_platform_data qcom_ramoops_pdata;
 	struct platform_device *ramoops_pdev;
+	struct device *dev;
+	struct qcom_minidump_region **dmesg_region;
+	struct qcom_minidump_region *console_region;
+	struct qcom_minidump_region *pmsg_region;
+	struct qcom_minidump_region **ftrace_region;
+	unsigned int max_dump_cnt;
+	unsigned int max_ftrace_cnt;
 };
 
+static int qcom_ramoops_md_region_register(struct device *dev, struct qcom_minidump_region **zone,
+					   const char *name, phys_addr_t phys_addr,
+					   unsigned long size)
+{
+	struct qcom_minidump_region *md_region;
+	int ret;
+
+	if (!size)
+		return 0;
+
+	md_region = devm_kzalloc(dev, sizeof(*md_region), GFP_KERNEL);
+	if (!md_region)
+		return -ENOMEM;
+
+	strscpy(md_region->name, name, sizeof(md_region->name));
+	md_region->phys_addr = phys_addr;
+	md_region->virt_addr = phys_to_virt(phys_addr);
+	md_region->size = size;
+	*zone = md_region;
+	ret = qcom_minidump_region_register(md_region);
+	if (ret)
+		dev_err(dev, "failed to add %s in minidump: err: %d\n", name, ret);
+
+	return ret;
+}
+
+static int qcom_ramoops_minidump_register(struct qcom_ramoops_dd *qcom_rdd)
+{
+	struct ramoops_platform_data *pdata = &qcom_rdd->qcom_ramoops_pdata;
+	char name[MAX_NAME_LENGTH];
+	size_t zone_sz;
+	phys_addr_t phys_addr;
+	int ret = 0;
+	int i;
+
+	phys_addr = pdata->mem_address;
+	for (i = 0; i < qcom_rdd->max_dump_cnt; i++) {
+		scnprintf(name, sizeof(name), "KDMSG%d", i);
+		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->dmesg_region[i], name, phys_addr,
+			pdata->record_size);
+		if (ret)
+			return ret;
+
+		phys_addr += pdata->record_size;
+	}
+
+	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->console_region, "KCONSOLE", phys_addr,
+			pdata->console_size);
+	if (ret)
+		return ret;
+
+	phys_addr += pdata->console_size;
+
+	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->pmsg_region, "KPMSG", phys_addr,
+			pdata->pmsg_size);
+	if (ret)
+		return ret;
+
+	phys_addr += pdata->pmsg_size;
+
+	zone_sz =  pdata->ftrace_size / qcom_rdd->max_ftrace_cnt;
+	for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) {
+		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
+			&qcom_rdd->ftrace_region[i], "KFTRACE", phys_addr,
+			zone_sz);
+		if (ret)
+			return ret;
+
+		phys_addr += zone_sz;
+	}
+
+	return ret;
+}
+
+static void qcom_ramoops_minidump_unregister(struct qcom_ramoops_dd *qcom_rdd)
+{
+	struct ramoops_platform_data *pdata;
+	int i;
+
+	pdata = &qcom_rdd->qcom_ramoops_pdata;
+	if (pdata->record_size) {
+		for (i = 0; i < qcom_rdd->max_dump_cnt; i++)
+			qcom_minidump_region_unregister(qcom_rdd->dmesg_region[i]);
+	}
+
+	if (pdata->console_size)
+		qcom_minidump_region_unregister(qcom_rdd->console_region);
+
+	if (pdata->pmsg_size)
+		qcom_minidump_region_unregister(qcom_rdd->pmsg_region);
+
+	if (pdata->ftrace_size) {
+		for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++)
+			qcom_minidump_region_unregister(qcom_rdd->ftrace_region[i]);
+	}
+}
+
 static int qcom_ramoops_probe(struct platform_device *pdev)
 {
 	struct device_node *of_node = pdev->dev.of_node;
@@ -22,6 +130,7 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
 	struct ramoops_platform_data *pdata;
 	struct reserved_mem *rmem;
 	struct device_node *node;
+	size_t dump_mem_sz;
 	long ret;
 
 	node = of_parse_phandle(of_node, "memory-region", 0);
@@ -39,27 +148,43 @@ static int qcom_ramoops_probe(struct platform_device *pdev)
 	if (!qcom_rdd)
 		return -ENOMEM;
 
+	qcom_rdd->dev = &pdev->dev;
 	pdata = &qcom_rdd->qcom_ramoops_pdata;
 	pdata->mem_size = rmem->size;
 	pdata->mem_address = rmem->base;
-	ramoops_parse_dt(pdev, pdata);
-
+	ret = ramoops_parse_dt(pdev, pdata);
+	if (ret < 0)
+		return ret;
+
+	dump_mem_sz = pdata->mem_size - pdata->console_size - pdata->ftrace_size
+		      - pdata->pmsg_size;
+	if (!dump_mem_sz || !pdata->record_size)
+		qcom_rdd->max_dump_cnt = 0;
+	else
+		qcom_rdd->max_dump_cnt = dump_mem_sz / pdata->record_size;
+
+	qcom_rdd->max_ftrace_cnt = (pdata->flags & RAMOOPS_FLAG_FTRACE_PER_CPU)
+				? nr_cpu_ids
+				: 1;
 	qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
 							       pdata, sizeof(*pdata));
 	if (IS_ERR(qcom_rdd->ramoops_pdev)) {
 		ret = PTR_ERR(qcom_rdd->ramoops_pdev);
 		dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
 		qcom_rdd->ramoops_pdev = NULL;
+		return ret;
 	}
+
 	platform_set_drvdata(pdev, qcom_rdd);
 
-	return ret;
+	return qcom_ramoops_minidump_register(qcom_rdd);
 }
 
 static void qcom_ramoops_remove(struct platform_device *pdev)
 {
 	struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
 
+	qcom_ramoops_minidump_unregister(qcom_rdd);
 	platform_device_unregister(qcom_rdd->ramoops_pdev);
 	qcom_rdd->ramoops_pdev = NULL;
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 12/21] remoteproc: qcom: Expand MD_* as MINIDUMP_*
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Expand MD_* as MINIDUMP_* which makes more sense than the
abbreviation.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index a0d4238492e9..805e525df3b5 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -29,9 +29,9 @@
 #define MAX_NUM_OF_SS           10
 #define MAX_REGION_NAME_LENGTH  16
 #define SBL_MINIDUMP_SMEM_ID	602
-#define MD_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MD_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MD_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+#define MINIDUMP_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
 
 /**
  * struct minidump_region - Minidump region
@@ -125,7 +125,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
 
 	for (i = 0; i < seg_cnt; i++) {
 		memcpy_fromio(&region, ptr + i, sizeof(region));
-		if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
+		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
 			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
 			if (!name) {
 				iounmap(ptr);
@@ -168,8 +168,8 @@ void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
 	 */
 	if (subsystem->regions_baseptr == 0 ||
 	    le32_to_cpu(subsystem->status) != 1 ||
-	    le32_to_cpu(subsystem->enabled) != MD_SS_ENABLED ||
-	    le32_to_cpu(subsystem->encryption_status) != MD_SS_ENCR_DONE) {
+	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
+	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
 		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
 		return;
 	}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 12/21] remoteproc: qcom: Expand MD_* as MINIDUMP_*
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Expand MD_* as MINIDUMP_* which makes more sense than the
abbreviation.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index a0d4238492e9..805e525df3b5 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -29,9 +29,9 @@
 #define MAX_NUM_OF_SS           10
 #define MAX_REGION_NAME_LENGTH  16
 #define SBL_MINIDUMP_SMEM_ID	602
-#define MD_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MD_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MD_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
+#define MINIDUMP_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
+#define MINIDUMP_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
+#define MINIDUMP_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
 
 /**
  * struct minidump_region - Minidump region
@@ -125,7 +125,7 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
 
 	for (i = 0; i < seg_cnt; i++) {
 		memcpy_fromio(&region, ptr + i, sizeof(region));
-		if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
+		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
 			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
 			if (!name) {
 				iounmap(ptr);
@@ -168,8 +168,8 @@ void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
 	 */
 	if (subsystem->regions_baseptr == 0 ||
 	    le32_to_cpu(subsystem->status) != 1 ||
-	    le32_to_cpu(subsystem->enabled) != MD_SS_ENABLED ||
-	    le32_to_cpu(subsystem->encryption_status) != MD_SS_ENCR_DONE) {
+	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
+	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
 		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
 		return;
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

There is no need remoteproc code(driver/remoteproc/qcom_common.c)
to know about minidump data structure layout instead it should
better use the minidump exported symbol to get the required
information.

Refactor the qcom_minidump() function and remove the minidump
related data structure from driver/remoteproc/qcom_common.c .

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 142 +++++++--------------------------------
 1 file changed, 25 insertions(+), 117 deletions(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 805e525df3b5..24e8b692cd2c 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/soc/qcom/mdt_loader.h>
 #include <linux/soc/qcom/smem.h>
+#include <soc/qcom/qcom_minidump.h>
 
 #include "remoteproc_internal.h"
 #include "qcom_common.h"
@@ -26,61 +27,6 @@
 #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
 #define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
 
-#define MAX_NUM_OF_SS           10
-#define MAX_REGION_NAME_LENGTH  16
-#define SBL_MINIDUMP_SMEM_ID	602
-#define MINIDUMP_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MINIDUMP_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MINIDUMP_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
-
-/**
- * struct minidump_region - Minidump region
- * @name		: Name of the region to be dumped
- * @seq_num:		: Use to differentiate regions with same name.
- * @valid		: This entry to be dumped (if set to 1)
- * @address		: Physical address of region to be dumped
- * @size		: Size of the region
- */
-struct minidump_region {
-	char	name[MAX_REGION_NAME_LENGTH];
-	__le32	seq_num;
-	__le32	valid;
-	__le64	address;
-	__le64	size;
-};
-
-/**
- * struct minidump_subsystem - Subsystem's SMEM Table of content
- * @status : Subsystem toc init status
- * @enabled : if set to 1, this region would be copied during coredump
- * @encryption_status: Encryption status for this subsystem
- * @encryption_required : Decides to encrypt the subsystem regions or not
- * @region_count : Number of regions added in this subsystem toc
- * @regions_baseptr : regions base pointer of the subsystem
- */
-struct minidump_subsystem {
-	__le32	status;
-	__le32	enabled;
-	__le32	encryption_status;
-	__le32	encryption_required;
-	__le32	region_count;
-	__le64	regions_baseptr;
-};
-
-/**
- * struct minidump_global_toc - Global Table of Content
- * @status : Global Minidump init status
- * @md_revision : Minidump revision
- * @enabled : Minidump enable status
- * @subsystems : Array of subsystems toc
- */
-struct minidump_global_toc {
-	__le32				status;
-	__le32				md_revision;
-	__le32				enabled;
-	struct minidump_subsystem	subsystems[MAX_NUM_OF_SS];
-};
-
 struct qcom_ssr_subsystem {
 	const char *name;
 	struct srcu_notifier_head notifier_list;
@@ -101,85 +47,47 @@ static void qcom_minidump_cleanup(struct rproc *rproc)
 	}
 }
 
-static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
-			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
-				void *dest, size_t offset, size_t size))
+void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
+		void (*rproc_dumpfn_t)(struct rproc *rproc,
+		struct rproc_dump_segment *segment, void *dest, size_t offset,
+		size_t size))
 {
-	struct minidump_region __iomem *ptr;
-	struct minidump_region region;
-	int seg_cnt, i;
 	dma_addr_t da;
 	size_t size;
+	int seg_cnt;
 	char *name;
+	void *ptr;
+	int ret;
+	int i;
 
 	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
 		dev_err(&rproc->dev, "dump segment list already populated\n");
-		return -EUCLEAN;
+		return;
 	}
 
-	seg_cnt = le32_to_cpu(subsystem->region_count);
-	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
-		      seg_cnt * sizeof(struct minidump_region));
+	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
 	if (!ptr)
-		return -EFAULT;
+		return;
 
 	for (i = 0; i < seg_cnt; i++) {
-		memcpy_fromio(&region, ptr + i, sizeof(region));
-		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
-			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
-			if (!name) {
-				iounmap(ptr);
-				return -ENOMEM;
-			}
-			da = le64_to_cpu(region.address);
-			size = le64_to_cpu(region.size);
-			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
+		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
+		if (ret < 0) {
+			iounmap(ptr);
+			dev_err(&rproc->dev,
+				"Failed with error: %d while adding minidump entries\n",
+				ret);
+			goto clean_minidump;
 		}
-	}
-
-	iounmap(ptr);
-	return 0;
-}
-
-void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
-		void (*rproc_dumpfn_t)(struct rproc *rproc,
-		struct rproc_dump_segment *segment, void *dest, size_t offset,
-		size_t size))
-{
-	int ret;
-	struct minidump_subsystem *subsystem;
-	struct minidump_global_toc *toc;
-
-	/* Get Global minidump ToC*/
-	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
-
-	/* check if global table pointer exists and init is set */
-	if (IS_ERR(toc) || !toc->status) {
-		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
-		return;
-	}
 
-	/* Get subsystem table of contents using the minidump id */
-	subsystem = &toc->subsystems[minidump_id];
-
-	/**
-	 * Collect minidump if SS ToC is valid and segment table
-	 * is initialized in memory and encryption status is set.
-	 */
-	if (subsystem->regions_baseptr == 0 ||
-	    le32_to_cpu(subsystem->status) != 1 ||
-	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
-	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
-		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
-		return;
+		/* if it is a valid segment */
+		if (!ret)
+			rproc_coredump_add_custom_segment(rproc, da, size,
+							  rproc_dumpfn_t, name);
 	}
 
-	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
-		goto clean_minidump;
-	}
+	iounmap(ptr);
 	rproc_coredump_using_sections(rproc);
+
 clean_minidump:
 	qcom_minidump_cleanup(rproc);
 }
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

There is no need remoteproc code(driver/remoteproc/qcom_common.c)
to know about minidump data structure layout instead it should
better use the minidump exported symbol to get the required
information.

Refactor the qcom_minidump() function and remove the minidump
related data structure from driver/remoteproc/qcom_common.c .

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 142 +++++++--------------------------------
 1 file changed, 25 insertions(+), 117 deletions(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 805e525df3b5..24e8b692cd2c 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/soc/qcom/mdt_loader.h>
 #include <linux/soc/qcom/smem.h>
+#include <soc/qcom/qcom_minidump.h>
 
 #include "remoteproc_internal.h"
 #include "qcom_common.h"
@@ -26,61 +27,6 @@
 #define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
 #define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
 
-#define MAX_NUM_OF_SS           10
-#define MAX_REGION_NAME_LENGTH  16
-#define SBL_MINIDUMP_SMEM_ID	602
-#define MINIDUMP_REGION_VALID		('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
-#define MINIDUMP_SS_ENCR_DONE		('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
-#define MINIDUMP_SS_ENABLED		('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
-
-/**
- * struct minidump_region - Minidump region
- * @name		: Name of the region to be dumped
- * @seq_num:		: Use to differentiate regions with same name.
- * @valid		: This entry to be dumped (if set to 1)
- * @address		: Physical address of region to be dumped
- * @size		: Size of the region
- */
-struct minidump_region {
-	char	name[MAX_REGION_NAME_LENGTH];
-	__le32	seq_num;
-	__le32	valid;
-	__le64	address;
-	__le64	size;
-};
-
-/**
- * struct minidump_subsystem - Subsystem's SMEM Table of content
- * @status : Subsystem toc init status
- * @enabled : if set to 1, this region would be copied during coredump
- * @encryption_status: Encryption status for this subsystem
- * @encryption_required : Decides to encrypt the subsystem regions or not
- * @region_count : Number of regions added in this subsystem toc
- * @regions_baseptr : regions base pointer of the subsystem
- */
-struct minidump_subsystem {
-	__le32	status;
-	__le32	enabled;
-	__le32	encryption_status;
-	__le32	encryption_required;
-	__le32	region_count;
-	__le64	regions_baseptr;
-};
-
-/**
- * struct minidump_global_toc - Global Table of Content
- * @status : Global Minidump init status
- * @md_revision : Minidump revision
- * @enabled : Minidump enable status
- * @subsystems : Array of subsystems toc
- */
-struct minidump_global_toc {
-	__le32				status;
-	__le32				md_revision;
-	__le32				enabled;
-	struct minidump_subsystem	subsystems[MAX_NUM_OF_SS];
-};
-
 struct qcom_ssr_subsystem {
 	const char *name;
 	struct srcu_notifier_head notifier_list;
@@ -101,85 +47,47 @@ static void qcom_minidump_cleanup(struct rproc *rproc)
 	}
 }
 
-static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
-			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
-				void *dest, size_t offset, size_t size))
+void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
+		void (*rproc_dumpfn_t)(struct rproc *rproc,
+		struct rproc_dump_segment *segment, void *dest, size_t offset,
+		size_t size))
 {
-	struct minidump_region __iomem *ptr;
-	struct minidump_region region;
-	int seg_cnt, i;
 	dma_addr_t da;
 	size_t size;
+	int seg_cnt;
 	char *name;
+	void *ptr;
+	int ret;
+	int i;
 
 	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
 		dev_err(&rproc->dev, "dump segment list already populated\n");
-		return -EUCLEAN;
+		return;
 	}
 
-	seg_cnt = le32_to_cpu(subsystem->region_count);
-	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
-		      seg_cnt * sizeof(struct minidump_region));
+	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
 	if (!ptr)
-		return -EFAULT;
+		return;
 
 	for (i = 0; i < seg_cnt; i++) {
-		memcpy_fromio(&region, ptr + i, sizeof(region));
-		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
-			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
-			if (!name) {
-				iounmap(ptr);
-				return -ENOMEM;
-			}
-			da = le64_to_cpu(region.address);
-			size = le64_to_cpu(region.size);
-			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
+		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
+		if (ret < 0) {
+			iounmap(ptr);
+			dev_err(&rproc->dev,
+				"Failed with error: %d while adding minidump entries\n",
+				ret);
+			goto clean_minidump;
 		}
-	}
-
-	iounmap(ptr);
-	return 0;
-}
-
-void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
-		void (*rproc_dumpfn_t)(struct rproc *rproc,
-		struct rproc_dump_segment *segment, void *dest, size_t offset,
-		size_t size))
-{
-	int ret;
-	struct minidump_subsystem *subsystem;
-	struct minidump_global_toc *toc;
-
-	/* Get Global minidump ToC*/
-	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
-
-	/* check if global table pointer exists and init is set */
-	if (IS_ERR(toc) || !toc->status) {
-		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
-		return;
-	}
 
-	/* Get subsystem table of contents using the minidump id */
-	subsystem = &toc->subsystems[minidump_id];
-
-	/**
-	 * Collect minidump if SS ToC is valid and segment table
-	 * is initialized in memory and encryption status is set.
-	 */
-	if (subsystem->regions_baseptr == 0 ||
-	    le32_to_cpu(subsystem->status) != 1 ||
-	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
-	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
-		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
-		return;
+		/* if it is a valid segment */
+		if (!ret)
+			rproc_coredump_add_custom_segment(rproc, da, size,
+							  rproc_dumpfn_t, name);
 	}
 
-	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
-	if (ret) {
-		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
-		goto clean_minidump;
-	}
+	iounmap(ptr);
 	rproc_coredump_using_sections(rproc);
+
 clean_minidump:
 	qcom_minidump_cleanup(rproc);
 }
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 14/21] MAINTAINERS: Add entry for minidump driver related support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add the entries for all the files added as a part qualcomm
minidump driver support.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 MAINTAINERS | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a82795114ad4..8cbbe3e662e5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17551,6 +17551,14 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/regulator/vqmmc-ipq4019-regulator.yaml
 F:	drivers/regulator/vqmmc-ipq4019-regulator.c
 
+QUALCOMM MINIDUMP DRIVER
+M:	Mukesh Ojha <quic_mojha@quicinc.com>
+L:	linux-arm-msm@vger.kernel.org
+S:	Maintained
+F:	Documentation/admin-guide/qcom_minidump.rst
+F:	drivers/soc/qcom/qcom_minidump.c
+F:	drivers/soc/qcom/qcom_minidump_smem.c
+
 QUALCOMM NAND CONTROLLER DRIVER
 M:	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
 L:	linux-mtd@lists.infradead.org
@@ -17559,6 +17567,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
 F:	drivers/mtd/nand/raw/qcom_nandc.c
 
+QUALCOMM PSTORE MINIDUMP DRIVER
+M:	Mukesh Ojha <quic_mojha@quicinc.com>
+L:	linux-arm-msm@vger.kernel.org
+S:	Maintained
+F:	drivers/soc/qcom/qcom_pstore_minidump.c
+F:	Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
+
 QUALCOMM RMNET DRIVER
 M:	Subash Abhinov Kasiviswanathan <quic_subashab@quicinc.com>
 M:	Sean Tranchetti <quic_stranche@quicinc.com>
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 14/21] MAINTAINERS: Add entry for minidump driver related support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Add the entries for all the files added as a part qualcomm
minidump driver support.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 MAINTAINERS | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a82795114ad4..8cbbe3e662e5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -17551,6 +17551,14 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/regulator/vqmmc-ipq4019-regulator.yaml
 F:	drivers/regulator/vqmmc-ipq4019-regulator.c
 
+QUALCOMM MINIDUMP DRIVER
+M:	Mukesh Ojha <quic_mojha@quicinc.com>
+L:	linux-arm-msm@vger.kernel.org
+S:	Maintained
+F:	Documentation/admin-guide/qcom_minidump.rst
+F:	drivers/soc/qcom/qcom_minidump.c
+F:	drivers/soc/qcom/qcom_minidump_smem.c
+
 QUALCOMM NAND CONTROLLER DRIVER
 M:	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
 L:	linux-mtd@lists.infradead.org
@@ -17559,6 +17567,13 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
 F:	drivers/mtd/nand/raw/qcom_nandc.c
 
+QUALCOMM PSTORE MINIDUMP DRIVER
+M:	Mukesh Ojha <quic_mojha@quicinc.com>
+L:	linux-arm-msm@vger.kernel.org
+S:	Maintained
+F:	drivers/soc/qcom/qcom_pstore_minidump.c
+F:	Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
+
 QUALCOMM RMNET DRIVER
 M:	Subash Abhinov Kasiviswanathan <quic_subashab@quicinc.com>
 M:	Sean Tranchetti <quic_stranche@quicinc.com>
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 15/21] arm64: defconfig: Enable Qualcomm Minidump related drivers
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Enable QCOM_MINIDUMP_SMEM backend driver which automatically
selects QCOM_MINIDUMP core for its functionality to work.

While at it, also enable clients of minidump driver which
is QCOM_PSTORE_MINIDUMP that uses PSTORE_RAM and
PSTORE_CONSOLE to capture console logs into minidump.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 arch/arm64/configs/defconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index a24609e14d50..9a47c9ec0391 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1250,6 +1250,8 @@ CONFIG_QCOM_STATS=m
 CONFIG_QCOM_WCNSS_CTRL=m
 CONFIG_QCOM_APR=m
 CONFIG_QCOM_ICC_BWMON=m
+CONFIG_QCOM_MINIDUMP_SMEM=m
+CONFIG_QCOM_PSTORE_MINIDUMP=m
 CONFIG_ARCH_R8A77995=y
 CONFIG_ARCH_R8A77990=y
 CONFIG_ARCH_R8A77951=y
@@ -1445,6 +1447,8 @@ CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_EFIVAR_FS=y
 CONFIG_SQUASHFS=y
+CONFIG_PSTORE_CONSOLE=y
+CONFIG_PSTORE_RAM=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V4=y
 CONFIG_NFS_V4_1=y
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 15/21] arm64: defconfig: Enable Qualcomm Minidump related drivers
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Enable QCOM_MINIDUMP_SMEM backend driver which automatically
selects QCOM_MINIDUMP core for its functionality to work.

While at it, also enable clients of minidump driver which
is QCOM_PSTORE_MINIDUMP that uses PSTORE_RAM and
PSTORE_CONSOLE to capture console logs into minidump.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 arch/arm64/configs/defconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index a24609e14d50..9a47c9ec0391 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -1250,6 +1250,8 @@ CONFIG_QCOM_STATS=m
 CONFIG_QCOM_WCNSS_CTRL=m
 CONFIG_QCOM_APR=m
 CONFIG_QCOM_ICC_BWMON=m
+CONFIG_QCOM_MINIDUMP_SMEM=m
+CONFIG_QCOM_PSTORE_MINIDUMP=m
 CONFIG_ARCH_R8A77995=y
 CONFIG_ARCH_R8A77990=y
 CONFIG_ARCH_R8A77951=y
@@ -1445,6 +1447,8 @@ CONFIG_HUGETLBFS=y
 CONFIG_CONFIGFS_FS=y
 CONFIG_EFIVAR_FS=y
 CONFIG_SQUASHFS=y
+CONFIG_PSTORE_CONSOLE=y
+CONFIG_PSTORE_RAM=y
 CONFIG_NFS_FS=y
 CONFIG_NFS_V4=y
 CONFIG_NFS_V4_1=y
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 16/21] arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

This enable dynamic reserve memory for Qualcomm ramoops device,
which will be used to save ramoops frontend data and this region
gets dumped on crash via Qualcomm's minidump infrastructure.
qcom_pstore_minidump is the associated driver for this node.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 arch/arm64/boot/dts/qcom/sm8450.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi
index d59ea8ee7111..0b1dedee606b 100644
--- a/arch/arm64/boot/dts/qcom/sm8450.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi
@@ -390,6 +390,12 @@
 		};
 	};
 
+	ramoops-minidump {
+		compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
+		console-size = <0x200000>;
+		memory-region = <&qcom_ramoops>;
+	};
+
 	reserved_memory: reserved-memory {
 		#address-cells = <2>;
 		#size-cells = <2>;
@@ -623,6 +629,12 @@
 			reg = <0x0 0xed900000 0x0 0x3b00000>;
 			no-map;
 		};
+
+		qcom_ramoops: ramoops {
+			alloc-ranges = <0x0 0x00000000 0xffffffff 0xffffffff>;
+			size = <0x0 0x200000>;
+			no-map;
+		};
 	};
 
 	smp2p-adsp {
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 16/21] arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

This enable dynamic reserve memory for Qualcomm ramoops device,
which will be used to save ramoops frontend data and this region
gets dumped on crash via Qualcomm's minidump infrastructure.
qcom_pstore_minidump is the associated driver for this node.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 arch/arm64/boot/dts/qcom/sm8450.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sm8450.dtsi b/arch/arm64/boot/dts/qcom/sm8450.dtsi
index d59ea8ee7111..0b1dedee606b 100644
--- a/arch/arm64/boot/dts/qcom/sm8450.dtsi
+++ b/arch/arm64/boot/dts/qcom/sm8450.dtsi
@@ -390,6 +390,12 @@
 		};
 	};
 
+	ramoops-minidump {
+		compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
+		console-size = <0x200000>;
+		memory-region = <&qcom_ramoops>;
+	};
+
 	reserved_memory: reserved-memory {
 		#address-cells = <2>;
 		#size-cells = <2>;
@@ -623,6 +629,12 @@
 			reg = <0x0 0xed900000 0x0 0x3b00000>;
 			no-map;
 		};
+
+		qcom_ramoops: ramoops {
+			alloc-ranges = <0x0 0x00000000 0xffffffff 0xffffffff>;
+			size = <0x0 0x200000>;
+			no-map;
+		};
 	};
 
 	smp2p-adsp {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

It was realized by Srinivas K. that there is a need of
read-modify-write scm exported function so that it can
be used by multiple clients.

Let's introduce qcom_scm_io_update_field() which masks
out the bits and write the passed value to that
bit-offset. Subsequent patch will use this function.

Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c            | 15 +++++++++++++++
 include/linux/firmware/qcom/qcom_scm.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index fde33acd46b7..104d86e49b97 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id)
 }
 EXPORT_SYMBOL(qcom_scm_set_remote_state);
 
+int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val)
+{
+	unsigned int old, new;
+	int ret;
+
+	ret = qcom_scm_io_readl(addr, &old);
+	if (ret)
+		return ret;
+
+	new = (old & ~mask) | (val & mask);
+
+	return qcom_scm_io_writel(addr, new);
+}
+EXPORT_SYMBOL(qcom_scm_io_update_field);
+
 static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 {
 	struct qcom_scm_desc desc = {
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index 250ea4efb7cb..ca41e4eb33ad 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -84,6 +84,8 @@ extern bool qcom_scm_pas_supported(u32 peripheral);
 
 extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
 extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
+extern int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask,
+				    unsigned int val);
 
 extern bool qcom_scm_restore_sec_cfg_available(void);
 extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

It was realized by Srinivas K. that there is a need of
read-modify-write scm exported function so that it can
be used by multiple clients.

Let's introduce qcom_scm_io_update_field() which masks
out the bits and write the passed value to that
bit-offset. Subsequent patch will use this function.

Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c            | 15 +++++++++++++++
 include/linux/firmware/qcom/qcom_scm.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index fde33acd46b7..104d86e49b97 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id)
 }
 EXPORT_SYMBOL(qcom_scm_set_remote_state);
 
+int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val)
+{
+	unsigned int old, new;
+	int ret;
+
+	ret = qcom_scm_io_readl(addr, &old);
+	if (ret)
+		return ret;
+
+	new = (old & ~mask) | (val & mask);
+
+	return qcom_scm_io_writel(addr, new);
+}
+EXPORT_SYMBOL(qcom_scm_io_update_field);
+
 static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 {
 	struct qcom_scm_desc desc = {
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index 250ea4efb7cb..ca41e4eb33ad 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -84,6 +84,8 @@ extern bool qcom_scm_pas_supported(u32 peripheral);
 
 extern int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val);
 extern int qcom_scm_io_writel(phys_addr_t addr, unsigned int val);
+extern int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask,
+				    unsigned int val);
 
 extern bool qcom_scm_restore_sec_cfg_available(void);
 extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Use qcom_scm_io_update_field() exported function introduced
in last commit.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index c5f52d4f7781..f31b54bf98e4 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -1041,6 +1041,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	const struct msm_pingroup *g;
 	unsigned long flags;
 	bool was_enabled;
+	u32 mask;
 	u32 val;
 
 	if (msm_gpio_needs_dual_edge_parent_workaround(d, type)) {
@@ -1075,23 +1076,20 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	 * With intr_target_use_scm interrupts are routed to
 	 * application cpu using scm calls.
 	 */
+	mask = (GENMASK(2, 0) << g->intr_target_bit);
 	if (pctrl->intr_target_use_scm) {
 		u32 addr = pctrl->phys_base[0] + g->intr_target_reg;
 		int ret;
 
-		qcom_scm_io_readl(addr, &val);
-
-		val &= ~(7 << g->intr_target_bit);
-		val |= g->intr_target_kpss_val << g->intr_target_bit;
-
-		ret = qcom_scm_io_writel(addr, val);
+		val = g->intr_target_kpss_val << g->intr_target_bit;
+		ret = qcom_scm_io_update_field(addr, mask, val);
 		if (ret)
 			dev_err(pctrl->dev,
 				"Failed routing %lu interrupt to Apps proc",
 				d->hwirq);
 	} else {
 		val = msm_readl_intr_target(pctrl, g);
-		val &= ~(7 << g->intr_target_bit);
+		val &= ~mask;
 		val |= g->intr_target_kpss_val << g->intr_target_bit;
 		msm_writel_intr_target(val, pctrl, g);
 	}
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Use qcom_scm_io_update_field() exported function introduced
in last commit.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index c5f52d4f7781..f31b54bf98e4 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -1041,6 +1041,7 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	const struct msm_pingroup *g;
 	unsigned long flags;
 	bool was_enabled;
+	u32 mask;
 	u32 val;
 
 	if (msm_gpio_needs_dual_edge_parent_workaround(d, type)) {
@@ -1075,23 +1076,20 @@ static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	 * With intr_target_use_scm interrupts are routed to
 	 * application cpu using scm calls.
 	 */
+	mask = (GENMASK(2, 0) << g->intr_target_bit);
 	if (pctrl->intr_target_use_scm) {
 		u32 addr = pctrl->phys_base[0] + g->intr_target_reg;
 		int ret;
 
-		qcom_scm_io_readl(addr, &val);
-
-		val &= ~(7 << g->intr_target_bit);
-		val |= g->intr_target_kpss_val << g->intr_target_bit;
-
-		ret = qcom_scm_io_writel(addr, val);
+		val = g->intr_target_kpss_val << g->intr_target_bit;
+		ret = qcom_scm_io_update_field(addr, mask, val);
 		if (ret)
 			dev_err(pctrl->dev,
 				"Failed routing %lu interrupt to Apps proc",
 				d->hwirq);
 	} else {
 		val = msm_readl_intr_target(pctrl, g);
-		val &= ~(7 << g->intr_target_bit);
+		val &= ~mask;
 		val |= g->intr_target_kpss_val << g->intr_target_bit;
 		msm_writel_intr_target(val, pctrl, g);
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

CrashDump collection is based on the DLOAD bit of TCSR register.
To retain other bits, we read the register and modify only the
DLOAD bit as the other bits have their own significance.

Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 104d86e49b97..a9ff77d16c42 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
 #define SCM_HAS_IFACE_CLK	BIT(1)
 #define SCM_HAS_BUS_CLK		BIT(2)
 
+#define QCOM_DOWNLOAD_FULLDUMP		 0x1
+#define QCOM_DOWNLOAD_NODUMP		 0x0
+#define QCOM_DOWNLOAD_MODE_SHIFT	   4
+#define QCOM_DOWNLOAD_MODE_MASK		0x30
+
 struct qcom_scm {
 	struct device *dev;
 	struct clk *core_clk;
@@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 static void qcom_scm_set_download_mode(bool enable)
 {
 	bool avail;
+	int val;
 	int ret = 0;
 
 	avail = __qcom_scm_is_call_available(__scm->dev,
@@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
 	if (avail) {
 		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
 	} else if (__scm->dload_mode_addr) {
-		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
-				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
+		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
+		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
+		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
+				QCOM_DOWNLOAD_MODE_MASK, val);
 	} else {
 		dev_err(__scm->dev,
 			"No available mechanism for setting download mode\n");
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

CrashDump collection is based on the DLOAD bit of TCSR register.
To retain other bits, we read the register and modify only the
DLOAD bit as the other bits have their own significance.

Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 104d86e49b97..a9ff77d16c42 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
 #define SCM_HAS_IFACE_CLK	BIT(1)
 #define SCM_HAS_BUS_CLK		BIT(2)
 
+#define QCOM_DOWNLOAD_FULLDUMP		 0x1
+#define QCOM_DOWNLOAD_NODUMP		 0x0
+#define QCOM_DOWNLOAD_MODE_SHIFT	   4
+#define QCOM_DOWNLOAD_MODE_MASK		0x30
+
 struct qcom_scm {
 	struct device *dev;
 	struct clk *core_clk;
@@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 static void qcom_scm_set_download_mode(bool enable)
 {
 	bool avail;
+	int val;
 	int ret = 0;
 
 	avail = __qcom_scm_is_call_available(__scm->dev,
@@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
 	if (avail) {
 		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
 	} else if (__scm->dload_mode_addr) {
-		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
-				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
+		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
+		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
+		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
+				QCOM_DOWNLOAD_MODE_MASK, val);
 	} else {
 		dev_err(__scm->dev,
 			"No available mechanism for setting download mode\n");
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Currently on Qualcomm SoC, download_mode is enabled if
CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected.

Refactor the code such that it supports multiple download
modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config
instead, give interface to set the download mode from
module parameter.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/Kconfig    | 11 ---------
 drivers/firmware/qcom_scm.c | 56 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index b59e3041fd62..ff7e9f330559 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -215,17 +215,6 @@ config MTK_ADSP_IPC
 config QCOM_SCM
 	tristate
 
-config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
-	bool "Qualcomm download mode enabled by default"
-	depends on QCOM_SCM
-	help
-	  A device with "download mode" enabled will upon an unexpected
-	  warm-restart enter a special debug mode that allows the user to
-	  "download" memory content over USB for offline postmortem analysis.
-	  The feature can be enabled/disabled on the kernel command line.
-
-	  Say Y here to enable "download mode" by default.
-
 config SYSFB
 	bool
 	select BOOT_VESA_SUPPORT
diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index a9ff77d16c42..946cb0f76a17 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -18,13 +18,13 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/clk.h>
+#include <linux/kstrtox.h>
 #include <linux/reset-controller.h>
 #include <linux/arm-smccc.h>
 
 #include "qcom_scm.h"
 
-static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
-module_param(download_mode, bool, 0);
+static u32 download_mode;
 
 #define SCM_HAS_CORE_CLK	BIT(0)
 #define SCM_HAS_IFACE_CLK	BIT(1)
@@ -82,6 +82,11 @@ static const char * const qcom_scm_convention_names[] = {
 	[SMC_CONVENTION_LEGACY] = "smc legacy",
 };
 
+static const char * const download_mode_name[] = {
+	[QCOM_DOWNLOAD_NODUMP]	 = "off",
+	[QCOM_DOWNLOAD_FULLDUMP] = "full",
+};
+
 static struct qcom_scm *__scm;
 
 static int qcom_scm_clk_enable(void)
@@ -442,8 +447,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 	return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
 }
 
-static void qcom_scm_set_download_mode(bool enable)
+static void qcom_scm_set_download_mode(u32 download_mode)
 {
+	bool enable = !!download_mode;
 	bool avail;
 	int val;
 	int ret = 0;
@@ -454,7 +460,7 @@ static void qcom_scm_set_download_mode(bool enable)
 	if (avail) {
 		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
 	} else if (__scm->dload_mode_addr) {
-		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
+		val = download_mode;
 		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
 		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
 				QCOM_DOWNLOAD_MODE_MASK, val);
@@ -1425,6 +1431,42 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static int get_download_mode(char *buffer, const struct kernel_param *kp)
+{
+	if (download_mode >= ARRAY_SIZE(download_mode_name))
+		return sysfs_emit(buffer, "unknown mode\n");
+
+	return sysfs_emit(buffer, "%s\n", download_mode_name[download_mode]);
+}
+
+static int set_download_mode(const char *val, const struct kernel_param *kp)
+{
+	u32 old = download_mode;
+	int ret;
+
+	ret = sysfs_match_string(download_mode_name, val);
+	if (ret < 0) {
+		download_mode = old;
+		pr_err("qcom_scm: unknown download mode: %s\n", val);
+		return -EINVAL;
+	}
+
+	download_mode = ret;
+	if (__scm)
+		qcom_scm_set_download_mode(download_mode);
+
+	return 0;
+}
+
+static const struct kernel_param_ops download_mode_param_ops = {
+	.get = get_download_mode,
+	.set = set_download_mode,
+};
+
+module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
+MODULE_PARM_DESC(download_mode,
+		"download mode: off/full are acceptable values");
+
 static int qcom_scm_probe(struct platform_device *pdev)
 {
 	struct qcom_scm *scm;
@@ -1518,12 +1560,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
 	__get_convention();
 
 	/*
-	 * If requested enable "download mode", from this point on warmboot
+	 * If "download mode" is requested, from this point on warmboot
 	 * will cause the boot stages to enter download mode, unless
 	 * disabled below by a clean shutdown/reboot.
 	 */
 	if (download_mode)
-		qcom_scm_set_download_mode(true);
+		qcom_scm_set_download_mode(download_mode);
 
 	return 0;
 }
@@ -1531,7 +1573,7 @@ static int qcom_scm_probe(struct platform_device *pdev)
 static void qcom_scm_shutdown(struct platform_device *pdev)
 {
 	/* Clean shutdown, disable download mode to allow normal restart */
-	qcom_scm_set_download_mode(false);
+	qcom_scm_set_download_mode(QCOM_DOWNLOAD_NODUMP);
 }
 
 static const struct of_device_id qcom_scm_dt_match[] = {
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Currently on Qualcomm SoC, download_mode is enabled if
CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected.

Refactor the code such that it supports multiple download
modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config
instead, give interface to set the download mode from
module parameter.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/Kconfig    | 11 ---------
 drivers/firmware/qcom_scm.c | 56 +++++++++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index b59e3041fd62..ff7e9f330559 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -215,17 +215,6 @@ config MTK_ADSP_IPC
 config QCOM_SCM
 	tristate
 
-config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
-	bool "Qualcomm download mode enabled by default"
-	depends on QCOM_SCM
-	help
-	  A device with "download mode" enabled will upon an unexpected
-	  warm-restart enter a special debug mode that allows the user to
-	  "download" memory content over USB for offline postmortem analysis.
-	  The feature can be enabled/disabled on the kernel command line.
-
-	  Say Y here to enable "download mode" by default.
-
 config SYSFB
 	bool
 	select BOOT_VESA_SUPPORT
diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index a9ff77d16c42..946cb0f76a17 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -18,13 +18,13 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/clk.h>
+#include <linux/kstrtox.h>
 #include <linux/reset-controller.h>
 #include <linux/arm-smccc.h>
 
 #include "qcom_scm.h"
 
-static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
-module_param(download_mode, bool, 0);
+static u32 download_mode;
 
 #define SCM_HAS_CORE_CLK	BIT(0)
 #define SCM_HAS_IFACE_CLK	BIT(1)
@@ -82,6 +82,11 @@ static const char * const qcom_scm_convention_names[] = {
 	[SMC_CONVENTION_LEGACY] = "smc legacy",
 };
 
+static const char * const download_mode_name[] = {
+	[QCOM_DOWNLOAD_NODUMP]	 = "off",
+	[QCOM_DOWNLOAD_FULLDUMP] = "full",
+};
+
 static struct qcom_scm *__scm;
 
 static int qcom_scm_clk_enable(void)
@@ -442,8 +447,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
 	return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
 }
 
-static void qcom_scm_set_download_mode(bool enable)
+static void qcom_scm_set_download_mode(u32 download_mode)
 {
+	bool enable = !!download_mode;
 	bool avail;
 	int val;
 	int ret = 0;
@@ -454,7 +460,7 @@ static void qcom_scm_set_download_mode(bool enable)
 	if (avail) {
 		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
 	} else if (__scm->dload_mode_addr) {
-		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
+		val = download_mode;
 		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
 		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
 				QCOM_DOWNLOAD_MODE_MASK, val);
@@ -1425,6 +1431,42 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+static int get_download_mode(char *buffer, const struct kernel_param *kp)
+{
+	if (download_mode >= ARRAY_SIZE(download_mode_name))
+		return sysfs_emit(buffer, "unknown mode\n");
+
+	return sysfs_emit(buffer, "%s\n", download_mode_name[download_mode]);
+}
+
+static int set_download_mode(const char *val, const struct kernel_param *kp)
+{
+	u32 old = download_mode;
+	int ret;
+
+	ret = sysfs_match_string(download_mode_name, val);
+	if (ret < 0) {
+		download_mode = old;
+		pr_err("qcom_scm: unknown download mode: %s\n", val);
+		return -EINVAL;
+	}
+
+	download_mode = ret;
+	if (__scm)
+		qcom_scm_set_download_mode(download_mode);
+
+	return 0;
+}
+
+static const struct kernel_param_ops download_mode_param_ops = {
+	.get = get_download_mode,
+	.set = set_download_mode,
+};
+
+module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
+MODULE_PARM_DESC(download_mode,
+		"download mode: off/full are acceptable values");
+
 static int qcom_scm_probe(struct platform_device *pdev)
 {
 	struct qcom_scm *scm;
@@ -1518,12 +1560,12 @@ static int qcom_scm_probe(struct platform_device *pdev)
 	__get_convention();
 
 	/*
-	 * If requested enable "download mode", from this point on warmboot
+	 * If "download mode" is requested, from this point on warmboot
 	 * will cause the boot stages to enter download mode, unless
 	 * disabled below by a clean shutdown/reboot.
 	 */
 	if (download_mode)
-		qcom_scm_set_download_mode(true);
+		qcom_scm_set_download_mode(download_mode);
 
 	return 0;
 }
@@ -1531,7 +1573,7 @@ static int qcom_scm_probe(struct platform_device *pdev)
 static void qcom_scm_shutdown(struct platform_device *pdev)
 {
 	/* Clean shutdown, disable download mode to allow normal restart */
-	qcom_scm_set_download_mode(false);
+	qcom_scm_set_download_mode(QCOM_DOWNLOAD_NODUMP);
 }
 
 static const struct of_device_id qcom_scm_dt_match[] = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 21/21] firmware: qcom_scm: Add multiple download mode support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 12:34   ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Currently, scm driver only supports full dump when download
mode is selected. Add support to enable minidump as well as
enable it along with fulldump.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 946cb0f76a17..52e3b613a1af 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -31,6 +31,8 @@ static u32 download_mode;
 #define SCM_HAS_BUS_CLK		BIT(2)
 
 #define QCOM_DOWNLOAD_FULLDUMP		 0x1
+#define QCOM_DOWNLOAD_MINIDUMP		 0x2
+#define QCOM_DOWNLOAD_BOTHDUMP		 (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
 #define QCOM_DOWNLOAD_NODUMP		 0x0
 #define QCOM_DOWNLOAD_MODE_SHIFT	   4
 #define QCOM_DOWNLOAD_MODE_MASK		0x30
@@ -85,6 +87,8 @@ static const char * const qcom_scm_convention_names[] = {
 static const char * const download_mode_name[] = {
 	[QCOM_DOWNLOAD_NODUMP]	 = "off",
 	[QCOM_DOWNLOAD_FULLDUMP] = "full",
+	[QCOM_DOWNLOAD_MINIDUMP] = "mini",
+	[QCOM_DOWNLOAD_BOTHDUMP] = "full,mini",
 };
 
 static struct qcom_scm *__scm;
@@ -1465,7 +1469,7 @@ static const struct kernel_param_ops download_mode_param_ops = {
 
 module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
 MODULE_PARM_DESC(download_mode,
-		"download mode: off/full are acceptable values");
+		"download mode: off/full/mini/full,mini are acceptable values");
 
 static int qcom_scm_probe(struct platform_device *pdev)
 {
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 176+ messages in thread

* [PATCH v4 21/21] firmware: qcom_scm: Add multiple download mode support
@ 2023-06-28 12:34   ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 12:34 UTC (permalink / raw)
  To: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Mukesh Ojha

Currently, scm driver only supports full dump when download
mode is selected. Add support to enable minidump as well as
enable it along with fulldump.

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/firmware/qcom_scm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 946cb0f76a17..52e3b613a1af 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -31,6 +31,8 @@ static u32 download_mode;
 #define SCM_HAS_BUS_CLK		BIT(2)
 
 #define QCOM_DOWNLOAD_FULLDUMP		 0x1
+#define QCOM_DOWNLOAD_MINIDUMP		 0x2
+#define QCOM_DOWNLOAD_BOTHDUMP		 (QCOM_DOWNLOAD_FULLDUMP | QCOM_DOWNLOAD_MINIDUMP)
 #define QCOM_DOWNLOAD_NODUMP		 0x0
 #define QCOM_DOWNLOAD_MODE_SHIFT	   4
 #define QCOM_DOWNLOAD_MODE_MASK		0x30
@@ -85,6 +87,8 @@ static const char * const qcom_scm_convention_names[] = {
 static const char * const download_mode_name[] = {
 	[QCOM_DOWNLOAD_NODUMP]	 = "off",
 	[QCOM_DOWNLOAD_FULLDUMP] = "full",
+	[QCOM_DOWNLOAD_MINIDUMP] = "mini",
+	[QCOM_DOWNLOAD_BOTHDUMP] = "full,mini",
 };
 
 static struct qcom_scm *__scm;
@@ -1465,7 +1469,7 @@ static const struct kernel_param_ops download_mode_param_ops = {
 
 module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
 MODULE_PARM_DESC(download_mode,
-		"download mode: off/full are acceptable values");
+		"download mode: off/full/mini/full,mini are acceptable values");
 
 static int qcom_scm_probe(struct platform_device *pdev)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:24     ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:24 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Module like minidump providing debugging support will need to
> get the symbol information from the core kernel e.g to get
> the linux_banner, kernel section addresses bss, data, ro etc.
>
> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()

Commit

>  and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
> due to lack of in-tree user of the symbol. Now, that minidump
> will one of its user, export it.

users

...

Is it a direct revert? Then make it visible by leaving pieces from `git revert`.

...

> -

If not, drop this stray change.

> +EXPORT_SYMBOL_GPL(kallsyms_lookup_name);


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 13:24     ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:24 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Module like minidump providing debugging support will need to
> get the symbol information from the core kernel e.g to get
> the linux_banner, kernel section addresses bss, data, ro etc.
>
> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()

Commit

>  and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
> due to lack of in-tree user of the symbol. Now, that minidump
> will one of its user, export it.

users

...

Is it a direct revert? Then make it visible by leaving pieces from `git revert`.

...

> -

If not, drop this stray change.

> +EXPORT_SYMBOL_GPL(kallsyms_lookup_name);


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:31     ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:31 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Add qcom_minidump_smem module in a preparation to remove smem
> based minidump specific code from driver/remoteproc/qcom_common.c
> and provide needed exported API, this abstract minidump specific
> data layout from qualcomm's remoteproc driver.

...

> +#include <linux/kernel.h>

Why?

Missing headers:
err.h
export.h
string.h
types.h

byteorder/generic.h

> +#include <linux/module.h>
> +#include <linux/io.h>

Can you have them ordered?

...

> + * Return: On success, it returns iomapped base segment address, otherwise NULL on error.

IO mapped (or MMIO?)

...

> +       return ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),

Why casting?

> +                       *seg_cnt * sizeof(struct minidump_region));

Something from overflow.h?

...

> +       /* If it is not valid region, skip it */

if region is not valid, skip it

...

> +#ifndef _QCOM_MINIDUMP_H_
> +#define _QCOM_MINIDUMP_H_

This header uses EINVAL, IS_ENABLED() and (to some extent) dma_addr_t.
So do you need respective headers to be included?

> +#endif /* _QCOM_MINIDUMP_H_ */

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
@ 2023-06-28 13:31     ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:31 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Add qcom_minidump_smem module in a preparation to remove smem
> based minidump specific code from driver/remoteproc/qcom_common.c
> and provide needed exported API, this abstract minidump specific
> data layout from qualcomm's remoteproc driver.

...

> +#include <linux/kernel.h>

Why?

Missing headers:
err.h
export.h
string.h
types.h

byteorder/generic.h

> +#include <linux/module.h>
> +#include <linux/io.h>

Can you have them ordered?

...

> + * Return: On success, it returns iomapped base segment address, otherwise NULL on error.

IO mapped (or MMIO?)

...

> +       return ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),

Why casting?

> +                       *seg_cnt * sizeof(struct minidump_region));

Something from overflow.h?

...

> +       /* If it is not valid region, skip it */

if region is not valid, skip it

...

> +#ifndef _QCOM_MINIDUMP_H_
> +#define _QCOM_MINIDUMP_H_

This header uses EINVAL, IS_ENABLED() and (to some extent) dma_addr_t.
So do you need respective headers to be included?

> +#endif /* _QCOM_MINIDUMP_H_ */

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:43     ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:43 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

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

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
@ 2023-06-28 13:43     ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:43 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:44     ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:44 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:37 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Use qcom_scm_io_update_field() exported function introduced
> in last commit.

the last

But what is that? Be more specific.

...

> +       mask = (GENMASK(2, 0) << g->intr_target_bit);

Outer parentheses are not needed.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
@ 2023-06-28 13:44     ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:44 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:37 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Use qcom_scm_io_update_field() exported function introduced
> in last commit.

the last

But what is that? Be more specific.

...

> +       mask = (GENMASK(2, 0) << g->intr_target_bit);

Outer parentheses are not needed.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:51     ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:51 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Add shared memory based minidump backend driver and hook it
> with minidump core (qcom_minidump) by registering SMEM as
> backend device.

...

>         help
>           Enablement of core minidump feature is controlled from boot firmware
> -         side, and this config allow linux to query minidump segments associated
> -         with the remote processor and check its validity.
> +         side, and this config allow linux to query and manages minidump

allows
Linux

> +         table for remote processors as well as APSS.
> +
> +         This config should be enabled if the low level minidump is implemented
> +         as part of SMEM.

...

> +#include <linux/io.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> -#include <linux/io.h>

Yeah, the result of wrong order in the initial commit. Can you fix it there?

...

> -#define MINIDUMP_SS_ENCR_DONE  ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
> -#define MINIDUMP_SS_ENABLED    ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
> +
> +#define MINIDUMP_REGION_VALID     ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
> +#define MINIDUMP_REGION_INVALID           ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0)
> +#define MINIDUMP_REGION_INIT      ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0)
> +#define MINIDUMP_REGION_NOINIT    0
> +
> +#define MINIDUMP_SS_ENCR_REQ      (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0)
> +#define MINIDUMP_SS_ENCR_NOTREQ           (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0)
> +#define MINIDUMP_SS_ENCR_START    ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0)
> +#define MINIDUMP_SS_ENCR_DONE     ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
> +#define MINIDUMP_SS_ENABLED       ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)

For all these, please use format like

#define MINIDUMP_SS_ENCR_START    0x.... // STRT

...

> +static int smem_md_table_exit(struct minidump *md)
> +{
> +       struct minidump_ss_data *mdss_data;
> +
> +       mdss_data = md->apss_data;
> +       memset(mdss_data->md_ss_toc,
> +              cpu_to_le32(0), sizeof(struct minidump_subsystem));

Do you need cpu_to_le32() here?
Can this be on one line?

> +       return 0;
> +}

...

> +

Unnecessary blank line.

> +module_platform_driver(qcom_minidump_smem_driver);

...

> +       smem->minidump = platform_device_register_data(&pdev->dev, "qcom-minidump-smem",
> +                                                     PLATFORM_DEVID_NONE, NULL,
> +                                                     0);

Why can't room on the previous line be used?

> +       if (IS_ERR(smem->minidump))
> +               dev_dbg(&pdev->dev, "failed to register minidump device\n");

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 05/21] soc: qcom: Add linux minidump smem backend driver support
@ 2023-06-28 13:51     ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-28 13:51 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Add shared memory based minidump backend driver and hook it
> with minidump core (qcom_minidump) by registering SMEM as
> backend device.

...

>         help
>           Enablement of core minidump feature is controlled from boot firmware
> -         side, and this config allow linux to query minidump segments associated
> -         with the remote processor and check its validity.
> +         side, and this config allow linux to query and manages minidump

allows
Linux

> +         table for remote processors as well as APSS.
> +
> +         This config should be enabled if the low level minidump is implemented
> +         as part of SMEM.

...

> +#include <linux/io.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> -#include <linux/io.h>

Yeah, the result of wrong order in the initial commit. Can you fix it there?

...

> -#define MINIDUMP_SS_ENCR_DONE  ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
> -#define MINIDUMP_SS_ENABLED    ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)
> +
> +#define MINIDUMP_REGION_VALID     ('V' << 24 | 'A' << 16 | 'L' << 8 | 'I' << 0)
> +#define MINIDUMP_REGION_INVALID           ('I' << 24 | 'N' << 16 | 'V' << 8 | 'A' << 0)
> +#define MINIDUMP_REGION_INIT      ('I' << 24 | 'N' << 16 | 'I' << 8 | 'T' << 0)
> +#define MINIDUMP_REGION_NOINIT    0
> +
> +#define MINIDUMP_SS_ENCR_REQ      (0 << 24 | 'Y' << 16 | 'E' << 8 | 'S' << 0)
> +#define MINIDUMP_SS_ENCR_NOTREQ           (0 << 24 | 0 << 16 | 'N' << 8 | 'R' << 0)
> +#define MINIDUMP_SS_ENCR_START    ('S' << 24 | 'T' << 16 | 'R' << 8 | 'T' << 0)
> +#define MINIDUMP_SS_ENCR_DONE     ('D' << 24 | 'O' << 16 | 'N' << 8 | 'E' << 0)
> +#define MINIDUMP_SS_ENABLED       ('E' << 24 | 'N' << 16 | 'B' << 8 | 'L' << 0)

For all these, please use format like

#define MINIDUMP_SS_ENCR_START    0x.... // STRT

...

> +static int smem_md_table_exit(struct minidump *md)
> +{
> +       struct minidump_ss_data *mdss_data;
> +
> +       mdss_data = md->apss_data;
> +       memset(mdss_data->md_ss_toc,
> +              cpu_to_le32(0), sizeof(struct minidump_subsystem));

Do you need cpu_to_le32() here?
Can this be on one line?

> +       return 0;
> +}

...

> +

Unnecessary blank line.

> +module_platform_driver(qcom_minidump_smem_driver);

...

> +       smem->minidump = platform_device_register_data(&pdev->dev, "qcom-minidump-smem",
> +                                                     PLATFORM_DEVID_NONE, NULL,
> +                                                     0);

Why can't room on the previous line be used?

> +       if (IS_ERR(smem->minidump))
> +               dev_dbg(&pdev->dev, "failed to register minidump device\n");

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 13:53     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 13:53 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> Module like minidump providing debugging support will need to
> get the symbol information from the core kernel e.g to get
> the linux_banner, kernel section addresses bss, data, ro etc.
> 
One might ask why we would need such a debug driver to
be compiled as module? What would you do if we need to capture more
kernel data structures later? Do you plan to continue use
kallsyms_lookup_name() to query all the symbols?

I have seen v3 discussion where you are asked to compile this driver
as module but that time there was no reason why your driver needs to
be compiled as statically, now you have a reason (linux_banner) for
it.

> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
>  and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
> due to lack of in-tree user of the symbol. Now, that minidump
> will one of its user, export it.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 13:53     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 13:53 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> Module like minidump providing debugging support will need to
> get the symbol information from the core kernel e.g to get
> the linux_banner, kernel section addresses bss, data, ro etc.
> 
One might ask why we would need such a debug driver to
be compiled as module? What would you do if we need to capture more
kernel data structures later? Do you plan to continue use
kallsyms_lookup_name() to query all the symbols?

I have seen v3 discussion where you are asked to compile this driver
as module but that time there was no reason why your driver needs to
be compiled as statically, now you have a reason (linux_banner) for
it.

> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
>  and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
> due to lack of in-tree user of the symbol. Now, that minidump
> will one of its user, export it.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 14:10     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 14:10 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> Qualcomm ramoops minidump logger provide a means of storing
> the ramoops data to some dynamically reserved memory instead
> of traditionally implemented ramoops where the region should
> be statically fixed ram region. Its device tree binding
> would be exactly same as ramoops device tree binding and is
> going to contain traditional ramoops frontend data and this
> content will be collected via Qualcomm minidump infrastructure
> provided from the boot firmware.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>  1 file changed, 126 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> 
> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> new file mode 100644
> index 000000000000..b1fdcf3f8ad4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm Ramoops minidump logger
> +
> +description: |
> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> +  data to some dynamically reserved memory instead of traditionally
> +  implemented ramoops where the region should be statically fixed ram
> +  region. Because of its similarity with ramoops it will also have same
> +  set of property what ramoops have it in its schema and is going to
> +  contain traditional ramoops frontend data and this region will be
> +  collected via Qualcomm minidump infrastructure provided from the
> +  boot firmware.
> +
> +maintainers:
> +  - Mukesh Ojha <quic_mojha@quicinc.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - qcom,sm8450-ramoops
> +      - const: qcom,ramoops
> +
> +  memory-region:
> +    maxItems: 1
> +    description: handle to memory reservation for qcom,ramoops region.
> +
> +  ecc-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: enables ECC support and specifies ECC buffer size in bytes
> +    default: 0 # no ECC
> +
> +  record-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum size in bytes of each kmsg dump
> +    default: 0
> +
> +  console-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for kernel messages
> +    default: 0
> +
> +  ftrace-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for function tracing and profiling
> +    default: 0
> +
> +  pmsg-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for userspace messages
> +    default: 0
> +
> +  mem-type:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: if present, sets the type of mapping is to be used to map the reserved region.
> +    default: 0
> +    oneOf:
> +      - const: 0
> +        description: write-combined
> +      - const: 1
> +        description: unbuffered
> +      - const: 2
> +        description: cached
> +
> +  max-reason:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 2 # log oopses and panics
> +    maximum: 0x7fffffff
> +    description: |
> +      If present, sets maximum type of kmsg dump reasons to store.
> +      This can be set to INT_MAX to store all kmsg dumps.
> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> +      controlled by the printk.always_kmsg_dump boot param.
> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> +
> +  flags:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +    description: |
> +      If present, pass ramoops behavioral flags
> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> +
> +  no-dump-oops:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use max_reason instead. If present, and max_reason is not specified,
> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> +
> +  unbuffered:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use mem_type instead. If present, and mem_type is not specified,
> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> +      the reserved region (defaults to buffered mappings mem_type = 0).
> +      If both are specified -- "mem_type" overrides "unbuffered".
> +

Most of the properties you added here are already documented at
Documentation/devicetree/bindings/reserved-memory/ramoops.yaml 

Can't we just reference them here? would something like work?

max-reason:
  $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason

> +unevaluatedProperties: false
> +

will there be any additional properties be added dynamically? if not,
should not we use "additionalProperties: false" here?

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-28 14:10     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 14:10 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> Qualcomm ramoops minidump logger provide a means of storing
> the ramoops data to some dynamically reserved memory instead
> of traditionally implemented ramoops where the region should
> be statically fixed ram region. Its device tree binding
> would be exactly same as ramoops device tree binding and is
> going to contain traditional ramoops frontend data and this
> content will be collected via Qualcomm minidump infrastructure
> provided from the boot firmware.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>  1 file changed, 126 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> 
> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> new file mode 100644
> index 000000000000..b1fdcf3f8ad4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm Ramoops minidump logger
> +
> +description: |
> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> +  data to some dynamically reserved memory instead of traditionally
> +  implemented ramoops where the region should be statically fixed ram
> +  region. Because of its similarity with ramoops it will also have same
> +  set of property what ramoops have it in its schema and is going to
> +  contain traditional ramoops frontend data and this region will be
> +  collected via Qualcomm minidump infrastructure provided from the
> +  boot firmware.
> +
> +maintainers:
> +  - Mukesh Ojha <quic_mojha@quicinc.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - qcom,sm8450-ramoops
> +      - const: qcom,ramoops
> +
> +  memory-region:
> +    maxItems: 1
> +    description: handle to memory reservation for qcom,ramoops region.
> +
> +  ecc-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: enables ECC support and specifies ECC buffer size in bytes
> +    default: 0 # no ECC
> +
> +  record-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum size in bytes of each kmsg dump
> +    default: 0
> +
> +  console-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for kernel messages
> +    default: 0
> +
> +  ftrace-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for function tracing and profiling
> +    default: 0
> +
> +  pmsg-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for userspace messages
> +    default: 0
> +
> +  mem-type:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: if present, sets the type of mapping is to be used to map the reserved region.
> +    default: 0
> +    oneOf:
> +      - const: 0
> +        description: write-combined
> +      - const: 1
> +        description: unbuffered
> +      - const: 2
> +        description: cached
> +
> +  max-reason:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 2 # log oopses and panics
> +    maximum: 0x7fffffff
> +    description: |
> +      If present, sets maximum type of kmsg dump reasons to store.
> +      This can be set to INT_MAX to store all kmsg dumps.
> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> +      controlled by the printk.always_kmsg_dump boot param.
> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> +
> +  flags:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +    description: |
> +      If present, pass ramoops behavioral flags
> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> +
> +  no-dump-oops:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use max_reason instead. If present, and max_reason is not specified,
> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> +
> +  unbuffered:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use mem_type instead. If present, and mem_type is not specified,
> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> +      the reserved region (defaults to buffered mappings mem_type = 0).
> +      If both are specified -- "mem_type" overrides "unbuffered".
> +

Most of the properties you added here are already documented at
Documentation/devicetree/bindings/reserved-memory/ramoops.yaml 

Can't we just reference them here? would something like work?

max-reason:
  $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason

> +unevaluatedProperties: false
> +

will there be any additional properties be added dynamically? if not,
should not we use "additionalProperties: false" here?

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 14:47     ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 14:47 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Qualcomm ramoops minidump logger provide a means of storing
> the ramoops data to some dynamically reserved memory instead
> of traditionally implemented ramoops where the region should
> be statically fixed ram region. Its device tree binding
> would be exactly same as ramoops device tree binding and is
> going to contain traditional ramoops frontend data and this
> content will be collected via Qualcomm minidump infrastructure
> provided from the boot firmware.

The big difference is if firmware is not deciding where this log
lives, then it doesn't need to be in DT. How does anything except the
kernel that allocates the log find the logs?

I'm pretty sure I already said all this before.

>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>  1 file changed, 126 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>
> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> new file mode 100644
> index 000000000000..b1fdcf3f8ad4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm Ramoops minidump logger
> +
> +description: |
> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> +  data to some dynamically reserved memory instead of traditionally
> +  implemented ramoops where the region should be statically fixed ram
> +  region. Because of its similarity with ramoops it will also have same
> +  set of property what ramoops have it in its schema and is going to
> +  contain traditional ramoops frontend data and this region will be
> +  collected via Qualcomm minidump infrastructure provided from the
> +  boot firmware.
> +
> +maintainers:
> +  - Mukesh Ojha <quic_mojha@quicinc.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - qcom,sm8450-ramoops
> +      - const: qcom,ramoops
> +
> +  memory-region:
> +    maxItems: 1
> +    description: handle to memory reservation for qcom,ramoops region.
> +
> +  ecc-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: enables ECC support and specifies ECC buffer size in bytes
> +    default: 0 # no ECC
> +
> +  record-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum size in bytes of each kmsg dump
> +    default: 0
> +
> +  console-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for kernel messages
> +    default: 0
> +
> +  ftrace-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for function tracing and profiling
> +    default: 0
> +
> +  pmsg-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for userspace messages
> +    default: 0
> +
> +  mem-type:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: if present, sets the type of mapping is to be used to map the reserved region.
> +    default: 0
> +    oneOf:
> +      - const: 0
> +        description: write-combined
> +      - const: 1
> +        description: unbuffered
> +      - const: 2
> +        description: cached
> +
> +  max-reason:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 2 # log oopses and panics
> +    maximum: 0x7fffffff
> +    description: |
> +      If present, sets maximum type of kmsg dump reasons to store.
> +      This can be set to INT_MAX to store all kmsg dumps.
> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> +      controlled by the printk.always_kmsg_dump boot param.
> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> +
> +  flags:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +    description: |
> +      If present, pass ramoops behavioral flags
> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> +
> +  no-dump-oops:
> +    deprecated: true

Why would you define deprecated properties in a *new* binding?

> +    type: boolean
> +    description: |
> +      Use max_reason instead. If present, and max_reason is not specified,
> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> +
> +  unbuffered:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use mem_type instead. If present, and mem_type is not specified,
> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> +      the reserved region (defaults to buffered mappings mem_type = 0).
> +      If both are specified -- "mem_type" overrides "unbuffered".
> +
> +unevaluatedProperties: false
> +
> +required:
> +  - compatible
> +  - memory-region
> +
> +anyOf:
> +  - required: [record-size]
> +  - required: [console-size]
> +  - required: [ftrace-size]
> +  - required: [pmsg-size]
> +
> +examples:
> +  - |
> +
> +    qcom_ramoops {
> +        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
> +        memory-region = <&qcom_ramoops_region>;
> +        console-size = <0x8000>;    /* 32kB */
> +        record-size = <0x400>;      /*  1kB */
> +        ecc-size = <16>;
> +    };
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-28 14:47     ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 14:47 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> Qualcomm ramoops minidump logger provide a means of storing
> the ramoops data to some dynamically reserved memory instead
> of traditionally implemented ramoops where the region should
> be statically fixed ram region. Its device tree binding
> would be exactly same as ramoops device tree binding and is
> going to contain traditional ramoops frontend data and this
> content will be collected via Qualcomm minidump infrastructure
> provided from the boot firmware.

The big difference is if firmware is not deciding where this log
lives, then it doesn't need to be in DT. How does anything except the
kernel that allocates the log find the logs?

I'm pretty sure I already said all this before.

>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>  1 file changed, 126 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>
> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> new file mode 100644
> index 000000000000..b1fdcf3f8ad4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> @@ -0,0 +1,126 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Qualcomm Ramoops minidump logger
> +
> +description: |
> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> +  data to some dynamically reserved memory instead of traditionally
> +  implemented ramoops where the region should be statically fixed ram
> +  region. Because of its similarity with ramoops it will also have same
> +  set of property what ramoops have it in its schema and is going to
> +  contain traditional ramoops frontend data and this region will be
> +  collected via Qualcomm minidump infrastructure provided from the
> +  boot firmware.
> +
> +maintainers:
> +  - Mukesh Ojha <quic_mojha@quicinc.com>
> +
> +properties:
> +  compatible:
> +    items:
> +      - enum:
> +          - qcom,sm8450-ramoops
> +      - const: qcom,ramoops
> +
> +  memory-region:
> +    maxItems: 1
> +    description: handle to memory reservation for qcom,ramoops region.
> +
> +  ecc-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: enables ECC support and specifies ECC buffer size in bytes
> +    default: 0 # no ECC
> +
> +  record-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: maximum size in bytes of each kmsg dump
> +    default: 0
> +
> +  console-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for kernel messages
> +    default: 0
> +
> +  ftrace-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for function tracing and profiling
> +    default: 0
> +
> +  pmsg-size:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: size in bytes of log buffer reserved for userspace messages
> +    default: 0
> +
> +  mem-type:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: if present, sets the type of mapping is to be used to map the reserved region.
> +    default: 0
> +    oneOf:
> +      - const: 0
> +        description: write-combined
> +      - const: 1
> +        description: unbuffered
> +      - const: 2
> +        description: cached
> +
> +  max-reason:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 2 # log oopses and panics
> +    maximum: 0x7fffffff
> +    description: |
> +      If present, sets maximum type of kmsg dump reasons to store.
> +      This can be set to INT_MAX to store all kmsg dumps.
> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> +      controlled by the printk.always_kmsg_dump boot param.
> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> +
> +  flags:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    default: 0
> +    description: |
> +      If present, pass ramoops behavioral flags
> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> +
> +  no-dump-oops:
> +    deprecated: true

Why would you define deprecated properties in a *new* binding?

> +    type: boolean
> +    description: |
> +      Use max_reason instead. If present, and max_reason is not specified,
> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> +
> +  unbuffered:
> +    deprecated: true
> +    type: boolean
> +    description: |
> +      Use mem_type instead. If present, and mem_type is not specified,
> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> +      the reserved region (defaults to buffered mappings mem_type = 0).
> +      If both are specified -- "mem_type" overrides "unbuffered".
> +
> +unevaluatedProperties: false
> +
> +required:
> +  - compatible
> +  - memory-region
> +
> +anyOf:
> +  - required: [record-size]
> +  - required: [console-size]
> +  - required: [ftrace-size]
> +  - required: [pmsg-size]
> +
> +examples:
> +  - |
> +
> +    qcom_ramoops {
> +        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
> +        memory-region = <&qcom_ramoops_region>;
> +        console-size = <0x8000>;    /* 32kB */
> +        record-size = <0x400>;      /*  1kB */
> +        ecc-size = <16>;
> +    };
> --
> 2.7.4
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 14:47     ` Rob Herring
@ 2023-06-28 15:01       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 8:17 PM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Qualcomm ramoops minidump logger provide a means of storing
>> the ramoops data to some dynamically reserved memory instead
>> of traditionally implemented ramoops where the region should
>> be statically fixed ram region. Its device tree binding
>> would be exactly same as ramoops device tree binding and is
>> going to contain traditional ramoops frontend data and this
>> content will be collected via Qualcomm minidump infrastructure
>> provided from the boot firmware.
> 
> The big difference is if firmware is not deciding where this log
> lives, then it doesn't need to be in DT. How does anything except the
> kernel that allocates the log find the logs?

Yes, you are correct, firmware is not deciding where the logs lives
instead here, Kernel has reserved the region where the ramoops region
lives and later with the minidump registration where, physical
address/size/virtual address(for parsing) are passed and that is how
firmware is able to know and dump those region before triggering system
reset.

A part of this registration code you can find in 11/21

> I'm pretty sure I already said all this before.

Yes, you said this before but that's the reason i came up with vendor
ramoops instead of changing traditional ramoops binding.

> 
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>>   1 file changed, 126 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>> new file mode 100644
>> index 000000000000..b1fdcf3f8ad4
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>> @@ -0,0 +1,126 @@
>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
>> +
>> +title: Qualcomm Ramoops minidump logger
>> +
>> +description: |
>> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
>> +  data to some dynamically reserved memory instead of traditionally
>> +  implemented ramoops where the region should be statically fixed ram
>> +  region. Because of its similarity with ramoops it will also have same
>> +  set of property what ramoops have it in its schema and is going to
>> +  contain traditional ramoops frontend data and this region will be
>> +  collected via Qualcomm minidump infrastructure provided from the
>> +  boot firmware.
>> +
>> +maintainers:
>> +  - Mukesh Ojha <quic_mojha@quicinc.com>
>> +
>> +properties:
>> +  compatible:
>> +    items:
>> +      - enum:
>> +          - qcom,sm8450-ramoops
>> +      - const: qcom,ramoops
>> +
>> +  memory-region:
>> +    maxItems: 1
>> +    description: handle to memory reservation for qcom,ramoops region.
>> +
>> +  ecc-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: enables ECC support and specifies ECC buffer size in bytes
>> +    default: 0 # no ECC
>> +
>> +  record-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: maximum size in bytes of each kmsg dump
>> +    default: 0
>> +
>> +  console-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for kernel messages
>> +    default: 0
>> +
>> +  ftrace-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for function tracing and profiling
>> +    default: 0
>> +
>> +  pmsg-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for userspace messages
>> +    default: 0
>> +
>> +  mem-type:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: if present, sets the type of mapping is to be used to map the reserved region.
>> +    default: 0
>> +    oneOf:
>> +      - const: 0
>> +        description: write-combined
>> +      - const: 1
>> +        description: unbuffered
>> +      - const: 2
>> +        description: cached
>> +
>> +  max-reason:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    default: 2 # log oopses and panics
>> +    maximum: 0x7fffffff
>> +    description: |
>> +      If present, sets maximum type of kmsg dump reasons to store.
>> +      This can be set to INT_MAX to store all kmsg dumps.
>> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
>> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
>> +      controlled by the printk.always_kmsg_dump boot param.
>> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
>> +
>> +  flags:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    default: 0
>> +    description: |
>> +      If present, pass ramoops behavioral flags
>> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
>> +
>> +  no-dump-oops:
>> +    deprecated: true
> 
> Why would you define deprecated properties in a *new* binding?

Since, it is exact copy of ramoops binding, that's the reason of mention.

Will remove it.

-Mukesh
> 
>> +    type: boolean
>> +    description: |
>> +      Use max_reason instead. If present, and max_reason is not specified,
>> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
>> +
>> +  unbuffered:
>> +    deprecated: true
>> +    type: boolean
>> +    description: |
>> +      Use mem_type instead. If present, and mem_type is not specified,
>> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
>> +      the reserved region (defaults to buffered mappings mem_type = 0).
>> +      If both are specified -- "mem_type" overrides "unbuffered".
>> +
>> +unevaluatedProperties: false
>> +
>> +required:
>> +  - compatible
>> +  - memory-region
>> +
>> +anyOf:
>> +  - required: [record-size]
>> +  - required: [console-size]
>> +  - required: [ftrace-size]
>> +  - required: [pmsg-size]
>> +
>> +examples:
>> +  - |
>> +
>> +    qcom_ramoops {
>> +        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
>> +        memory-region = <&qcom_ramoops_region>;
>> +        console-size = <0x8000>;    /* 32kB */
>> +        record-size = <0x400>;      /*  1kB */
>> +        ecc-size = <16>;
>> +    };
>> --
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-28 15:01       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:01 UTC (permalink / raw)
  To: Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 8:17 PM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Qualcomm ramoops minidump logger provide a means of storing
>> the ramoops data to some dynamically reserved memory instead
>> of traditionally implemented ramoops where the region should
>> be statically fixed ram region. Its device tree binding
>> would be exactly same as ramoops device tree binding and is
>> going to contain traditional ramoops frontend data and this
>> content will be collected via Qualcomm minidump infrastructure
>> provided from the boot firmware.
> 
> The big difference is if firmware is not deciding where this log
> lives, then it doesn't need to be in DT. How does anything except the
> kernel that allocates the log find the logs?

Yes, you are correct, firmware is not deciding where the logs lives
instead here, Kernel has reserved the region where the ramoops region
lives and later with the minidump registration where, physical
address/size/virtual address(for parsing) are passed and that is how
firmware is able to know and dump those region before triggering system
reset.

A part of this registration code you can find in 11/21

> I'm pretty sure I already said all this before.

Yes, you said this before but that's the reason i came up with vendor
ramoops instead of changing traditional ramoops binding.

> 
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
>>   1 file changed, 126 insertions(+)
>>   create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>> new file mode 100644
>> index 000000000000..b1fdcf3f8ad4
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>> @@ -0,0 +1,126 @@
>> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
>> +%YAML 1.2
>> +---
>> +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
>> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
>> +
>> +title: Qualcomm Ramoops minidump logger
>> +
>> +description: |
>> +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
>> +  data to some dynamically reserved memory instead of traditionally
>> +  implemented ramoops where the region should be statically fixed ram
>> +  region. Because of its similarity with ramoops it will also have same
>> +  set of property what ramoops have it in its schema and is going to
>> +  contain traditional ramoops frontend data and this region will be
>> +  collected via Qualcomm minidump infrastructure provided from the
>> +  boot firmware.
>> +
>> +maintainers:
>> +  - Mukesh Ojha <quic_mojha@quicinc.com>
>> +
>> +properties:
>> +  compatible:
>> +    items:
>> +      - enum:
>> +          - qcom,sm8450-ramoops
>> +      - const: qcom,ramoops
>> +
>> +  memory-region:
>> +    maxItems: 1
>> +    description: handle to memory reservation for qcom,ramoops region.
>> +
>> +  ecc-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: enables ECC support and specifies ECC buffer size in bytes
>> +    default: 0 # no ECC
>> +
>> +  record-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: maximum size in bytes of each kmsg dump
>> +    default: 0
>> +
>> +  console-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for kernel messages
>> +    default: 0
>> +
>> +  ftrace-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for function tracing and profiling
>> +    default: 0
>> +
>> +  pmsg-size:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: size in bytes of log buffer reserved for userspace messages
>> +    default: 0
>> +
>> +  mem-type:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    description: if present, sets the type of mapping is to be used to map the reserved region.
>> +    default: 0
>> +    oneOf:
>> +      - const: 0
>> +        description: write-combined
>> +      - const: 1
>> +        description: unbuffered
>> +      - const: 2
>> +        description: cached
>> +
>> +  max-reason:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    default: 2 # log oopses and panics
>> +    maximum: 0x7fffffff
>> +    description: |
>> +      If present, sets maximum type of kmsg dump reasons to store.
>> +      This can be set to INT_MAX to store all kmsg dumps.
>> +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
>> +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
>> +      controlled by the printk.always_kmsg_dump boot param.
>> +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
>> +
>> +  flags:
>> +    $ref: /schemas/types.yaml#/definitions/uint32
>> +    default: 0
>> +    description: |
>> +      If present, pass ramoops behavioral flags
>> +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
>> +
>> +  no-dump-oops:
>> +    deprecated: true
> 
> Why would you define deprecated properties in a *new* binding?

Since, it is exact copy of ramoops binding, that's the reason of mention.

Will remove it.

-Mukesh
> 
>> +    type: boolean
>> +    description: |
>> +      Use max_reason instead. If present, and max_reason is not specified,
>> +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
>> +
>> +  unbuffered:
>> +    deprecated: true
>> +    type: boolean
>> +    description: |
>> +      Use mem_type instead. If present, and mem_type is not specified,
>> +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
>> +      the reserved region (defaults to buffered mappings mem_type = 0).
>> +      If both are specified -- "mem_type" overrides "unbuffered".
>> +
>> +unevaluatedProperties: false
>> +
>> +required:
>> +  - compatible
>> +  - memory-region
>> +
>> +anyOf:
>> +  - required: [record-size]
>> +  - required: [console-size]
>> +  - required: [ftrace-size]
>> +  - required: [pmsg-size]
>> +
>> +examples:
>> +  - |
>> +
>> +    qcom_ramoops {
>> +        compatible = "qcom,sm8450-ramoops", "qcom,ramoops";
>> +        memory-region = <&qcom_ramoops_region>;
>> +        console-size = <0x8000>;    /* 32kB */
>> +        record-size = <0x400>;      /*  1kB */
>> +        ecc-size = <16>;
>> +    };
>> --
>> 2.7.4
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 13:24     ` Andy Shevchenko
@ 2023-06-28 15:04       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 6:54 PM, Andy Shevchenko wrote:
> On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Module like minidump providing debugging support will need to
>> get the symbol information from the core kernel e.g to get
>> the linux_banner, kernel section addresses bss, data, ro etc.
>>
>> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
> 
> Commit
> 
>>   and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
>> due to lack of in-tree user of the symbol. Now, that minidump
>> will one of its user, export it.
> 
> users
> 
> ...
> 
> Is it a direct revert? Then make it visible by leaving pieces from `git revert`.
> 

No, it is not direct revert..

> ...
> 
>> -
> 
> If not, drop this stray change.

ok

- Mukesh
> 
>> +EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
> 
> 

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 15:04       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:04 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 6:54 PM, Andy Shevchenko wrote:
> On Wed, Jun 28, 2023 at 3:35 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Module like minidump providing debugging support will need to
>> get the symbol information from the core kernel e.g to get
>> the linux_banner, kernel section addresses bss, data, ro etc.
>>
>> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
> 
> Commit
> 
>>   and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
>> due to lack of in-tree user of the symbol. Now, that minidump
>> will one of its user, export it.
> 
> users
> 
> ...
> 
> Is it a direct revert? Then make it visible by leaving pieces from `git revert`.
> 

No, it is not direct revert..

> ...
> 
>> -
> 
> If not, drop this stray change.

ok

- Mukesh
> 
>> +EXPORT_SYMBOL_GPL(kallsyms_lookup_name);
> 
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 15:20     ` Konrad Dybcio
  -1 siblings, 0 replies; 176+ messages in thread
From: Konrad Dybcio @ 2023-06-28 15:20 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On 28.06.2023 14:34, Mukesh Ojha wrote:
> CrashDump collection is based on the DLOAD bit of TCSR register.
> To retain other bits, we read the register and modify only the
> DLOAD bit as the other bits have their own significance.
> 
> Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index 104d86e49b97..a9ff77d16c42 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
>  #define SCM_HAS_IFACE_CLK	BIT(1)
>  #define SCM_HAS_BUS_CLK		BIT(2)
>  
> +#define QCOM_DOWNLOAD_FULLDUMP		 0x1
> +#define QCOM_DOWNLOAD_NODUMP		 0x0
> +#define QCOM_DOWNLOAD_MODE_SHIFT	   4
> +#define QCOM_DOWNLOAD_MODE_MASK		0x30
GENMASK and then FIELD_PREP below?

> +
>  struct qcom_scm {
>  	struct device *dev;
>  	struct clk *core_clk;
> @@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>  static void qcom_scm_set_download_mode(bool enable)
>  {
>  	bool avail;
> +	int val;
What's wrong with initializing it in the same line as ret?

>  	int ret = 0;
>  
>  	avail = __qcom_scm_is_call_available(__scm->dev,
> @@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
>  	if (avail) {
>  		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>  	} else if (__scm->dload_mode_addr) {
> -		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
> -				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
> +		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
unnecessary braces

Konrad
> +		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
> +		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
> +				QCOM_DOWNLOAD_MODE_MASK, val);
>  	} else {
>  		dev_err(__scm->dev,
>  			"No available mechanism for setting download mode\n");

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
@ 2023-06-28 15:20     ` Konrad Dybcio
  0 siblings, 0 replies; 176+ messages in thread
From: Konrad Dybcio @ 2023-06-28 15:20 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On 28.06.2023 14:34, Mukesh Ojha wrote:
> CrashDump collection is based on the DLOAD bit of TCSR register.
> To retain other bits, we read the register and modify only the
> DLOAD bit as the other bits have their own significance.
> 
> Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index 104d86e49b97..a9ff77d16c42 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
>  #define SCM_HAS_IFACE_CLK	BIT(1)
>  #define SCM_HAS_BUS_CLK		BIT(2)
>  
> +#define QCOM_DOWNLOAD_FULLDUMP		 0x1
> +#define QCOM_DOWNLOAD_NODUMP		 0x0
> +#define QCOM_DOWNLOAD_MODE_SHIFT	   4
> +#define QCOM_DOWNLOAD_MODE_MASK		0x30
GENMASK and then FIELD_PREP below?

> +
>  struct qcom_scm {
>  	struct device *dev;
>  	struct clk *core_clk;
> @@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>  static void qcom_scm_set_download_mode(bool enable)
>  {
>  	bool avail;
> +	int val;
What's wrong with initializing it in the same line as ret?

>  	int ret = 0;
>  
>  	avail = __qcom_scm_is_call_available(__scm->dev,
> @@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
>  	if (avail) {
>  		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>  	} else if (__scm->dload_mode_addr) {
> -		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
> -				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
> +		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
unnecessary braces

Konrad
> +		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
> +		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
> +				QCOM_DOWNLOAD_MODE_MASK, val);
>  	} else {
>  		dev_err(__scm->dev,
>  			"No available mechanism for setting download mode\n");

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 13:53     ` Pavan Kondeti
@ 2023-06-28 15:22       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:22 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
>> Module like minidump providing debugging support will need to
>> get the symbol information from the core kernel e.g to get
>> the linux_banner, kernel section addresses bss, data, ro etc.
>>
> One might ask why we would need such a debug driver to
> be compiled as module? What would you do if we need to capture more
> kernel data structures later? Do you plan to continue use
> kallsyms_lookup_name() to query all the symbols?

You are on point, i needed this driver to be static but i don't have
any example at present to collect more than just _linux_banner_ from
my existing set of patches..

Agree, it will be easier to make this driver as static instead of
opening up the doors for modules to abuse via exporting
kallsyms_lookup_name() and also it will be very slow for production
kernel uses.

> 
> I have seen v3 discussion where you are asked to compile this driver
> as module but that time there was no reason why your driver needs to
> be compiled as statically, now you have a reason (linux_banner) for
> it.

Yes, at present minidump driver will not be able to compile without
exporting kallsyms_lookup_name()

-Mukesh

> 
>> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
>>   and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
>> due to lack of in-tree user of the symbol. Now, that minidump
>> will one of its user, export it.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> 
> Thanks,
> Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 15:22       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 15:22 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
>> Module like minidump providing debugging support will need to
>> get the symbol information from the core kernel e.g to get
>> the linux_banner, kernel section addresses bss, data, ro etc.
>>
> One might ask why we would need such a debug driver to
> be compiled as module? What would you do if we need to capture more
> kernel data structures later? Do you plan to continue use
> kallsyms_lookup_name() to query all the symbols?

You are on point, i needed this driver to be static but i don't have
any example at present to collect more than just _linux_banner_ from
my existing set of patches..

Agree, it will be easier to make this driver as static instead of
opening up the doors for modules to abuse via exporting
kallsyms_lookup_name() and also it will be very slow for production
kernel uses.

> 
> I have seen v3 discussion where you are asked to compile this driver
> as module but that time there was no reason why your driver needs to
> be compiled as statically, now you have a reason (linux_banner) for
> it.

Yes, at present minidump driver will not be able to compile without
exporting kallsyms_lookup_name()

-Mukesh

> 
>> commit 0bd476e6c671 ("kallsyms: unexport kallsyms_lookup_name()
>>   and kallsyms_on_each_symbol()") unexports kallsyms_lookup_name
>> due to lack of in-tree user of the symbol. Now, that minidump
>> will one of its user, export it.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> 
> Thanks,
> Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 15:22       ` Mukesh Ojha
@ 2023-06-28 15:32         ` Will Deacon
  -1 siblings, 0 replies; 176+ messages in thread
From: Will Deacon @ 2023-06-28 15:32 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, linus.walleij, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 08:52:57PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> > On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> > > Module like minidump providing debugging support will need to
> > > get the symbol information from the core kernel e.g to get
> > > the linux_banner, kernel section addresses bss, data, ro etc.
> > > 
> > One might ask why we would need such a debug driver to
> > be compiled as module? What would you do if we need to capture more
> > kernel data structures later? Do you plan to continue use
> > kallsyms_lookup_name() to query all the symbols?
> 
> You are on point, i needed this driver to be static but i don't have
> any example at present to collect more than just _linux_banner_ from
> my existing set of patches..
> 
> Agree, it will be easier to make this driver as static instead of
> opening up the doors for modules to abuse via exporting
> kallsyms_lookup_name() and also it will be very slow for production
> kernel uses.

Right, I unexported that symbol deliberately in 0bd476e6c671 ("kallsyms:
unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()") and I
don't think we should add it back for this driver.

Will

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 15:32         ` Will Deacon
  0 siblings, 0 replies; 176+ messages in thread
From: Will Deacon @ 2023-06-28 15:32 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, linus.walleij, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 08:52:57PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> > On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> > > Module like minidump providing debugging support will need to
> > > get the symbol information from the core kernel e.g to get
> > > the linux_banner, kernel section addresses bss, data, ro etc.
> > > 
> > One might ask why we would need such a debug driver to
> > be compiled as module? What would you do if we need to capture more
> > kernel data structures later? Do you plan to continue use
> > kallsyms_lookup_name() to query all the symbols?
> 
> You are on point, i needed this driver to be static but i don't have
> any example at present to collect more than just _linux_banner_ from
> my existing set of patches..
> 
> Agree, it will be easier to make this driver as static instead of
> opening up the doors for modules to abuse via exporting
> kallsyms_lookup_name() and also it will be very slow for production
> kernel uses.

Right, I unexported that symbol deliberately in 0bd476e6c671 ("kallsyms:
unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()") and I
don't think we should add it back for this driver.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
  2023-06-28 15:32         ` Will Deacon
@ 2023-06-28 15:43           ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:43 UTC (permalink / raw)
  To: Will Deacon
  Cc: Mukesh Ojha, Pavan Kondeti, corbet, agross, andersson,
	konrad.dybcio, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 04:32:47PM +0100, Will Deacon wrote:
> On Wed, Jun 28, 2023 at 08:52:57PM +0530, Mukesh Ojha wrote:
> > 
> > 
> > On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> > > On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> > > > Module like minidump providing debugging support will need to
> > > > get the symbol information from the core kernel e.g to get
> > > > the linux_banner, kernel section addresses bss, data, ro etc.
> > > > 
> > > One might ask why we would need such a debug driver to
> > > be compiled as module? What would you do if we need to capture more
> > > kernel data structures later? Do you plan to continue use
> > > kallsyms_lookup_name() to query all the symbols?
> > 
> > You are on point, i needed this driver to be static but i don't have
> > any example at present to collect more than just _linux_banner_ from
> > my existing set of patches..
> > 
> > Agree, it will be easier to make this driver as static instead of
> > opening up the doors for modules to abuse via exporting
> > kallsyms_lookup_name() and also it will be very slow for production
> > kernel uses.
> 
> Right, I unexported that symbol deliberately in 0bd476e6c671 ("kallsyms:
> unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()") and I
> don't think we should add it back for this driver.

I agree, it shouldn't be needed by any in-kernel module/driver.  If you
really want the name, look it up afterward in userspace :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 02/21] kallsyms: Export kallsyms_lookup_name
@ 2023-06-28 15:43           ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:43 UTC (permalink / raw)
  To: Will Deacon
  Cc: Mukesh Ojha, Pavan Kondeti, corbet, agross, andersson,
	konrad.dybcio, robh+dt, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 04:32:47PM +0100, Will Deacon wrote:
> On Wed, Jun 28, 2023 at 08:52:57PM +0530, Mukesh Ojha wrote:
> > 
> > 
> > On 6/28/2023 7:23 PM, Pavan Kondeti wrote:
> > > On Wed, Jun 28, 2023 at 06:04:29PM +0530, Mukesh Ojha wrote:
> > > > Module like minidump providing debugging support will need to
> > > > get the symbol information from the core kernel e.g to get
> > > > the linux_banner, kernel section addresses bss, data, ro etc.
> > > > 
> > > One might ask why we would need such a debug driver to
> > > be compiled as module? What would you do if we need to capture more
> > > kernel data structures later? Do you plan to continue use
> > > kallsyms_lookup_name() to query all the symbols?
> > 
> > You are on point, i needed this driver to be static but i don't have
> > any example at present to collect more than just _linux_banner_ from
> > my existing set of patches..
> > 
> > Agree, it will be easier to make this driver as static instead of
> > opening up the doors for modules to abuse via exporting
> > kallsyms_lookup_name() and also it will be very slow for production
> > kernel uses.
> 
> Right, I unexported that symbol deliberately in 0bd476e6c671 ("kallsyms:
> unexport kallsyms_lookup_name() and kallsyms_on_each_symbol()") and I
> don't think we should add it back for this driver.

I agree, it shouldn't be needed by any in-kernel module/driver.  If you
really want the name, look it up afterward in userspace :)

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-06-28 15:45   ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:45 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> included in the ramdump.
> 
> 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(gunyah) 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.

If you only have one "backend" then you don't need the extra compexity
here at all, just remove that whole middle layer please and make this
much simpler and smaller and easier to review and possibly accept.

We don't add layers when they are not needed, and never when there is no
actual user.  If you need the extra "complexity" later, then add it
later when it is needed as who knows when that will ever be.

Please redo this series based on that, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 15:45   ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:45 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> included in the ramdump.
> 
> 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(gunyah) 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.

If you only have one "backend" then you don't need the extra compexity
here at all, just remove that whole middle layer please and make this
much simpler and smaller and easier to review and possibly accept.

We don't add layers when they are not needed, and never when there is no
actual user.  If you need the extra "complexity" later, then add it
later when it is needed as who knows when that will ever be.

Please redo this series based on that, thanks.

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 15:47     ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:47 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:30PM +0530, Mukesh Ojha wrote:
> Add qcom_minidump_smem module in a preparation to remove smem
> based minidump specific code from driver/remoteproc/qcom_common.c
> and provide needed exported API, this abstract minidump specific
> data layout from qualcomm's remoteproc driver.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig              |   8 ++
>  drivers/soc/qcom/qcom_minidump_smem.c | 147 ++++++++++++++++++++++++++++++++++
>  include/soc/qcom/qcom_minidump.h      |  24 ++++++
>  3 files changed, 179 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>  create mode 100644 include/soc/qcom/qcom_minidump.h
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index a491718f8064..982310b5a1cb 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -279,4 +279,12 @@ config QCOM_INLINE_CRYPTO_ENGINE
>  	tristate
>  	select QCOM_SCM
>  
> +config QCOM_MINIDUMP_SMEM
> +	tristate "QCOM Minidump SMEM (as backend) Support"
> +	depends on ARCH_QCOM
> +	depends on QCOM_SMEM
> +	help
> +	  Enablement of core minidump feature is controlled from boot firmware
> +	  side, and this config allow linux to query minidump segments associated
> +	  with the remote processor and check its validity.

I can not understand this help text, sorry.  Also, what is the module
name?

And why is this only with ARCH_QCOM?  Why are we doing ARCH_PLATFORM
symbols still?  why is that a thing for a generic cpu type?

And don't you want build coverage?  Why not allow that?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 03/21] soc: qcom: Add qcom_minidump_smem module
@ 2023-06-28 15:47     ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 15:47 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:30PM +0530, Mukesh Ojha wrote:
> Add qcom_minidump_smem module in a preparation to remove smem
> based minidump specific code from driver/remoteproc/qcom_common.c
> and provide needed exported API, this abstract minidump specific
> data layout from qualcomm's remoteproc driver.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig              |   8 ++
>  drivers/soc/qcom/qcom_minidump_smem.c | 147 ++++++++++++++++++++++++++++++++++
>  include/soc/qcom/qcom_minidump.h      |  24 ++++++
>  3 files changed, 179 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>  create mode 100644 include/soc/qcom/qcom_minidump.h
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index a491718f8064..982310b5a1cb 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -279,4 +279,12 @@ config QCOM_INLINE_CRYPTO_ENGINE
>  	tristate
>  	select QCOM_SCM
>  
> +config QCOM_MINIDUMP_SMEM
> +	tristate "QCOM Minidump SMEM (as backend) Support"
> +	depends on ARCH_QCOM
> +	depends on QCOM_SMEM
> +	help
> +	  Enablement of core minidump feature is controlled from boot firmware
> +	  side, and this config allow linux to query minidump segments associated
> +	  with the remote processor and check its validity.

I can not understand this help text, sorry.  Also, what is the module
name?

And why is this only with ARCH_QCOM?  Why are we doing ARCH_PLATFORM
symbols still?  why is that a thing for a generic cpu type?

And don't you want build coverage?  Why not allow that?

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 15:51     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 15:51 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
> -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
> -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
> -				void *dest, size_t offset, size_t size))
> +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> +		void (*rproc_dumpfn_t)(struct rproc *rproc,
> +		struct rproc_dump_segment *segment, void *dest, size_t offset,
> +		size_t size))
>  {
> -	struct minidump_region __iomem *ptr;
> -	struct minidump_region region;
> -	int seg_cnt, i;
>  	dma_addr_t da;
>  	size_t size;
> +	int seg_cnt;
>  	char *name;
> +	void *ptr;
> +	int ret;
> +	int i;
>  
>  	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
>  		dev_err(&rproc->dev, "dump segment list already populated\n");
> -		return -EUCLEAN;
> +		return;
>  	}
>  
> -	seg_cnt = le32_to_cpu(subsystem->region_count);
> -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
> -		      seg_cnt * sizeof(struct minidump_region));
> +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
>  	if (!ptr)
> -		return -EFAULT;
> +		return;
>  
>  	for (i = 0; i < seg_cnt; i++) {
> -		memcpy_fromio(&region, ptr + i, sizeof(region));
> -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
> -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
> -			if (!name) {
> -				iounmap(ptr);
> -				return -ENOMEM;
> -			}
> -			da = le64_to_cpu(region.address);
> -			size = le64_to_cpu(region.size);
> -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
> +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
> +		if (ret < 0) {
> +			iounmap(ptr);
> +			dev_err(&rproc->dev,
> +				"Failed with error: %d while adding minidump entries\n",
> +				ret);
> +			goto clean_minidump;
>  		}
> -	}
> -
> -	iounmap(ptr);
> -	return 0;
> -}
> -
> -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> -		void (*rproc_dumpfn_t)(struct rproc *rproc,
> -		struct rproc_dump_segment *segment, void *dest, size_t offset,
> -		size_t size))
> -{
> -	int ret;
> -	struct minidump_subsystem *subsystem;
> -	struct minidump_global_toc *toc;
> -
> -	/* Get Global minidump ToC*/
> -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
> -
> -	/* check if global table pointer exists and init is set */
> -	if (IS_ERR(toc) || !toc->status) {
> -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
> -		return;
> -	}
>  
> -	/* Get subsystem table of contents using the minidump id */
> -	subsystem = &toc->subsystems[minidump_id];
> -
> -	/**
> -	 * Collect minidump if SS ToC is valid and segment table
> -	 * is initialized in memory and encryption status is set.
> -	 */
> -	if (subsystem->regions_baseptr == 0 ||
> -	    le32_to_cpu(subsystem->status) != 1 ||
> -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
> -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
> -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
> -		return;
> +		/* if it is a valid segment */
> +		if (!ret)
> +			rproc_coredump_add_custom_segment(rproc, da, size,
> +							  rproc_dumpfn_t, name);
>  	}
>  
> -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
> -	if (ret) {
> -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
> -		goto clean_minidump;
> -	}
> +	iounmap(ptr);
>  	rproc_coredump_using_sections(rproc);
> +
>  clean_minidump:
>  	qcom_minidump_cleanup(rproc);
>  }

I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.

Is it possible to accept one function callback from remoteproc and do
all of this in one function exported by minidump? 

qcom_ss_valid_segment_info() seems a low level function to be exported..

Thanks,
Pavan


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
@ 2023-06-28 15:51     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-28 15:51 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
> -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
> -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
> -				void *dest, size_t offset, size_t size))
> +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> +		void (*rproc_dumpfn_t)(struct rproc *rproc,
> +		struct rproc_dump_segment *segment, void *dest, size_t offset,
> +		size_t size))
>  {
> -	struct minidump_region __iomem *ptr;
> -	struct minidump_region region;
> -	int seg_cnt, i;
>  	dma_addr_t da;
>  	size_t size;
> +	int seg_cnt;
>  	char *name;
> +	void *ptr;
> +	int ret;
> +	int i;
>  
>  	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
>  		dev_err(&rproc->dev, "dump segment list already populated\n");
> -		return -EUCLEAN;
> +		return;
>  	}
>  
> -	seg_cnt = le32_to_cpu(subsystem->region_count);
> -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
> -		      seg_cnt * sizeof(struct minidump_region));
> +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
>  	if (!ptr)
> -		return -EFAULT;
> +		return;
>  
>  	for (i = 0; i < seg_cnt; i++) {
> -		memcpy_fromio(&region, ptr + i, sizeof(region));
> -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
> -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
> -			if (!name) {
> -				iounmap(ptr);
> -				return -ENOMEM;
> -			}
> -			da = le64_to_cpu(region.address);
> -			size = le64_to_cpu(region.size);
> -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
> +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
> +		if (ret < 0) {
> +			iounmap(ptr);
> +			dev_err(&rproc->dev,
> +				"Failed with error: %d while adding minidump entries\n",
> +				ret);
> +			goto clean_minidump;
>  		}
> -	}
> -
> -	iounmap(ptr);
> -	return 0;
> -}
> -
> -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> -		void (*rproc_dumpfn_t)(struct rproc *rproc,
> -		struct rproc_dump_segment *segment, void *dest, size_t offset,
> -		size_t size))
> -{
> -	int ret;
> -	struct minidump_subsystem *subsystem;
> -	struct minidump_global_toc *toc;
> -
> -	/* Get Global minidump ToC*/
> -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
> -
> -	/* check if global table pointer exists and init is set */
> -	if (IS_ERR(toc) || !toc->status) {
> -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
> -		return;
> -	}
>  
> -	/* Get subsystem table of contents using the minidump id */
> -	subsystem = &toc->subsystems[minidump_id];
> -
> -	/**
> -	 * Collect minidump if SS ToC is valid and segment table
> -	 * is initialized in memory and encryption status is set.
> -	 */
> -	if (subsystem->regions_baseptr == 0 ||
> -	    le32_to_cpu(subsystem->status) != 1 ||
> -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
> -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
> -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
> -		return;
> +		/* if it is a valid segment */
> +		if (!ret)
> +			rproc_coredump_add_custom_segment(rproc, da, size,
> +							  rproc_dumpfn_t, name);
>  	}
>  
> -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
> -	if (ret) {
> -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
> -		goto clean_minidump;
> -	}
> +	iounmap(ptr);
>  	rproc_coredump_using_sections(rproc);
> +
>  clean_minidump:
>  	qcom_minidump_cleanup(rproc);
>  }

I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.

Is it possible to accept one function callback from remoteproc and do
all of this in one function exported by minidump? 

qcom_ss_valid_segment_info() seems a low level function to be exported..

Thanks,
Pavan


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 15:45   ` Greg KH
@ 2023-06-28 16:20     ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 16:20 UTC (permalink / raw)
  To: Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 9:15 PM, Greg KH wrote:
> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
>> included in the ramdump.
>>
>> 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(gunyah) 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.
> 
> If you only have one "backend" then you don't need the extra compexity
> here at all, just remove that whole middle layer please and make this
> much simpler and smaller and easier to review and possibly accept.
> 
> We don't add layers when they are not needed, and never when there is no
> actual user.  If you need the extra "complexity" later, then add it
> later when it is needed as who knows when that will ever be.
> 
> Please redo this series based on that, thanks.

I already followed without this middle layer till v3 since without
the middle layer it will be end up with lot of code duplication if there
is another backend.

We already have other backend implementation in the downstream, if you
want to see them, i will try to post them in upcoming series..

-Mukesh

> 
> greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 16:20     ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-28 16:20 UTC (permalink / raw)
  To: Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 9:15 PM, Greg KH wrote:
> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
>> included in the ramdump.
>>
>> 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(gunyah) 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.
> 
> If you only have one "backend" then you don't need the extra compexity
> here at all, just remove that whole middle layer please and make this
> much simpler and smaller and easier to review and possibly accept.
> 
> We don't add layers when they are not needed, and never when there is no
> actual user.  If you need the extra "complexity" later, then add it
> later when it is needed as who knows when that will ever be.
> 
> Please redo this series based on that, thanks.

I already followed without this middle layer till v3 since without
the middle layer it will be end up with lot of code duplication if there
is another backend.

We already have other backend implementation in the downstream, if you
want to see them, i will try to post them in upcoming series..

-Mukesh

> 
> greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 16:20     ` Mukesh Ojha
@ 2023-06-28 16:53       ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 16:53 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 09:50:00PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 9:15 PM, Greg KH wrote:
> > On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> > > included in the ramdump.
> > > 
> > > 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(gunyah) 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.
> > 
> > If you only have one "backend" then you don't need the extra compexity
> > here at all, just remove that whole middle layer please and make this
> > much simpler and smaller and easier to review and possibly accept.
> > 
> > We don't add layers when they are not needed, and never when there is no
> > actual user.  If you need the extra "complexity" later, then add it
> > later when it is needed as who knows when that will ever be.
> > 
> > Please redo this series based on that, thanks.
> 
> I already followed without this middle layer till v3 since without
> the middle layer it will be end up with lot of code duplication if there
> is another backend.

But as this series does not have such a thing, only add it when needed
please.  Don't make us review a whole bunch of stuff that is not
actually used here.

Would you want to review such a thing?

> We already have other backend implementation in the downstream, if you
> want to see them, i will try to post them in upcoming series..

Ok, so if you already have it, yes, post it as part of the series,
otherwise such a layer makes no sense.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 16:53       ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-06-28 16:53 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 09:50:00PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 9:15 PM, Greg KH wrote:
> > On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> > > included in the ramdump.
> > > 
> > > 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(gunyah) 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.
> > 
> > If you only have one "backend" then you don't need the extra compexity
> > here at all, just remove that whole middle layer please and make this
> > much simpler and smaller and easier to review and possibly accept.
> > 
> > We don't add layers when they are not needed, and never when there is no
> > actual user.  If you need the extra "complexity" later, then add it
> > later when it is needed as who knows when that will ever be.
> > 
> > Please redo this series based on that, thanks.
> 
> I already followed without this middle layer till v3 since without
> the middle layer it will be end up with lot of code duplication if there
> is another backend.

But as this series does not have such a thing, only add it when needed
please.  Don't make us review a whole bunch of stuff that is not
actually used here.

Would you want to review such a thing?

> We already have other backend implementation in the downstream, if you
> want to see them, i will try to post them in upcoming series..

Ok, so if you already have it, yes, post it as part of the series,
otherwise such a layer makes no sense.

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 22:57     ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 22:57 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> This driver was inspired from the fact pstore ram region should be
> fixed and boot firmware need to have awarness about this region,
> so that it will be persistent across boot. But, there are many
> QCOM SoC which does not support warm boot from hardware but they
> have minidump support from the software, and for them, there is
> no need of this pstore ram region to be fixed, but at the same
> time have interest in the pstore frontends data. So, this driver
> get the dynamic reserved region from the ram and register the
> ramoops platform device.
>
>  +---------+     +---------+   +--------+     +---------+
>  | console |     | pmsg    |   | ftrace |     | dmesg   |
>  +---------+     +---------+   +--------+     +---------+
>        |             |             |              |
>        |             |             |              |
>        +------------------------------------------+
>                           |
>                          \ /
>                   +----------------+
>             (1)   |pstore frontends|
>                   +----------------+
>                           |
>                          \ /
>                  +------------------- +
>             (2)  | pstore backend(ram)|
>                  +--------------------+
>                           |
>                          \ /
>                  +--------------------+
>             (3)  |qcom_pstore_minidump|
>                  +--------------------+
>                           |
>                          \ /
>                    +---------------+
>             (4)    | qcom_minidump |
>                    +---------------+
>
> This driver will route all the pstore front data to the stored
> in qcom pstore reserved region and the reason of showing an
> arrow from (3) to (4) as qcom_pstore_minidump driver will register
> all the available frontends region with qcom minidump driver
> in upcoming patch.
>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig                | 12 +++++
>  drivers/soc/qcom/Makefile               |  1 +
>  drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++

drivers/soc/ is the dumping ground for things with no other place. As
this is a pstore driver, it belongs with pstore.

>  3 files changed, 98 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 1834213fd652..fbf08e30feda 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
>
>           This config should be enabled if the low level minidump is implemented
>           as part of SMEM.
> +
> +config QCOM_PSTORE_MINIDUMP
> +       tristate "Pstore support for QCOM Minidump"
> +       depends on ARCH_QCOM
> +       depends on PSTORE_RAM
> +       depends on QCOM_MINIDUMP
> +       help
> +         Enablement of this driver ensures that ramoops region can be anywhere
> +         reserved in ram instead of being fixed address which needs boot firmware
> +         awareness. So, this driver creates plaform device and registers available
> +         frontend region with the Qualcomm's minidump driver.
> +
>  endmenu
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 737d868757ac..1ab59c1b364d 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -36,3 +36,4 @@ qcom_ice-objs                 += ice.o
>  obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)        += qcom_ice.o
>  obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>  obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
> +obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
> diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
> new file mode 100644
> index 000000000000..b07cd10340df
> --- /dev/null
> +++ b/drivers/soc/qcom/qcom_pstore_minidump.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +/*
> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/of_device.h>

You probably don't need this include. Use the actual includes you need
and don't rely on implicit includes (because I'm trying to remove
those).

> +#include <linux/of_reserved_mem.h>
> +#include <linux/platform_device.h>
> +#include <linux/pstore_ram.h>
> +
> +struct qcom_ramoops_dd {
> +       struct ramoops_platform_data qcom_ramoops_pdata;
> +       struct platform_device *ramoops_pdev;
> +};
> +
> +static int qcom_ramoops_probe(struct platform_device *pdev)
> +{
> +       struct device_node *of_node = pdev->dev.of_node;
> +       struct qcom_ramoops_dd *qcom_rdd;
> +       struct ramoops_platform_data *pdata;
> +       struct reserved_mem *rmem;
> +       struct device_node *node;
> +       long ret;
> +
> +       node = of_parse_phandle(of_node, "memory-region", 0);
> +       if (!node)
> +               return -ENODEV;
> +
> +       rmem = of_reserved_mem_lookup(node);
> +       of_node_put(node);
> +       if (!rmem) {
> +               dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
> +               return -EINVAL;
> +       }
> +
> +       qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
> +       if (!qcom_rdd)
> +               return -ENOMEM;
> +
> +       pdata = &qcom_rdd->qcom_ramoops_pdata;
> +       pdata->mem_size = rmem->size;
> +       pdata->mem_address = rmem->base;
> +       ramoops_parse_dt(pdev, pdata);
> +
> +       qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
> +                                                              pdata, sizeof(*pdata));
> +       if (IS_ERR(qcom_rdd->ramoops_pdev)) {
> +               ret = PTR_ERR(qcom_rdd->ramoops_pdev);
> +               dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
> +               qcom_rdd->ramoops_pdev = NULL;
> +       }
> +       platform_set_drvdata(pdev, qcom_rdd);
> +
> +       return ret;
> +}
> +
> +static void qcom_ramoops_remove(struct platform_device *pdev)
> +{
> +       struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
> +
> +       platform_device_unregister(qcom_rdd->ramoops_pdev);
> +       qcom_rdd->ramoops_pdev = NULL;
> +}
> +
> +static const struct of_device_id qcom_ramoops_of_match[] = {
> +       { .compatible = "qcom,ramoops"},
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
> +
> +static struct platform_driver qcom_ramoops_drv = {
> +       .driver         = {
> +               .name   = "qcom,ramoops",
> +               .of_match_table = qcom_ramoops_of_match,
> +       },
> +       .probe = qcom_ramoops_probe,
> +       .remove_new = qcom_ramoops_remove,
> +};
> +
> +module_platform_driver(qcom_ramoops_drv);
> +
> +MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
> +MODULE_LICENSE("GPL");
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
@ 2023-06-28 22:57     ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 22:57 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> This driver was inspired from the fact pstore ram region should be
> fixed and boot firmware need to have awarness about this region,
> so that it will be persistent across boot. But, there are many
> QCOM SoC which does not support warm boot from hardware but they
> have minidump support from the software, and for them, there is
> no need of this pstore ram region to be fixed, but at the same
> time have interest in the pstore frontends data. So, this driver
> get the dynamic reserved region from the ram and register the
> ramoops platform device.
>
>  +---------+     +---------+   +--------+     +---------+
>  | console |     | pmsg    |   | ftrace |     | dmesg   |
>  +---------+     +---------+   +--------+     +---------+
>        |             |             |              |
>        |             |             |              |
>        +------------------------------------------+
>                           |
>                          \ /
>                   +----------------+
>             (1)   |pstore frontends|
>                   +----------------+
>                           |
>                          \ /
>                  +------------------- +
>             (2)  | pstore backend(ram)|
>                  +--------------------+
>                           |
>                          \ /
>                  +--------------------+
>             (3)  |qcom_pstore_minidump|
>                  +--------------------+
>                           |
>                          \ /
>                    +---------------+
>             (4)    | qcom_minidump |
>                    +---------------+
>
> This driver will route all the pstore front data to the stored
> in qcom pstore reserved region and the reason of showing an
> arrow from (3) to (4) as qcom_pstore_minidump driver will register
> all the available frontends region with qcom minidump driver
> in upcoming patch.
>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig                | 12 +++++
>  drivers/soc/qcom/Makefile               |  1 +
>  drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++

drivers/soc/ is the dumping ground for things with no other place. As
this is a pstore driver, it belongs with pstore.

>  3 files changed, 98 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 1834213fd652..fbf08e30feda 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
>
>           This config should be enabled if the low level minidump is implemented
>           as part of SMEM.
> +
> +config QCOM_PSTORE_MINIDUMP
> +       tristate "Pstore support for QCOM Minidump"
> +       depends on ARCH_QCOM
> +       depends on PSTORE_RAM
> +       depends on QCOM_MINIDUMP
> +       help
> +         Enablement of this driver ensures that ramoops region can be anywhere
> +         reserved in ram instead of being fixed address which needs boot firmware
> +         awareness. So, this driver creates plaform device and registers available
> +         frontend region with the Qualcomm's minidump driver.
> +
>  endmenu
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 737d868757ac..1ab59c1b364d 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -36,3 +36,4 @@ qcom_ice-objs                 += ice.o
>  obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)        += qcom_ice.o
>  obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>  obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
> +obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
> diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
> new file mode 100644
> index 000000000000..b07cd10340df
> --- /dev/null
> +++ b/drivers/soc/qcom/qcom_pstore_minidump.c
> @@ -0,0 +1,85 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +/*
> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/of_device.h>

You probably don't need this include. Use the actual includes you need
and don't rely on implicit includes (because I'm trying to remove
those).

> +#include <linux/of_reserved_mem.h>
> +#include <linux/platform_device.h>
> +#include <linux/pstore_ram.h>
> +
> +struct qcom_ramoops_dd {
> +       struct ramoops_platform_data qcom_ramoops_pdata;
> +       struct platform_device *ramoops_pdev;
> +};
> +
> +static int qcom_ramoops_probe(struct platform_device *pdev)
> +{
> +       struct device_node *of_node = pdev->dev.of_node;
> +       struct qcom_ramoops_dd *qcom_rdd;
> +       struct ramoops_platform_data *pdata;
> +       struct reserved_mem *rmem;
> +       struct device_node *node;
> +       long ret;
> +
> +       node = of_parse_phandle(of_node, "memory-region", 0);
> +       if (!node)
> +               return -ENODEV;
> +
> +       rmem = of_reserved_mem_lookup(node);
> +       of_node_put(node);
> +       if (!rmem) {
> +               dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
> +               return -EINVAL;
> +       }
> +
> +       qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
> +       if (!qcom_rdd)
> +               return -ENOMEM;
> +
> +       pdata = &qcom_rdd->qcom_ramoops_pdata;
> +       pdata->mem_size = rmem->size;
> +       pdata->mem_address = rmem->base;
> +       ramoops_parse_dt(pdev, pdata);
> +
> +       qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
> +                                                              pdata, sizeof(*pdata));
> +       if (IS_ERR(qcom_rdd->ramoops_pdev)) {
> +               ret = PTR_ERR(qcom_rdd->ramoops_pdev);
> +               dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
> +               qcom_rdd->ramoops_pdev = NULL;
> +       }
> +       platform_set_drvdata(pdev, qcom_rdd);
> +
> +       return ret;
> +}
> +
> +static void qcom_ramoops_remove(struct platform_device *pdev)
> +{
> +       struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
> +
> +       platform_device_unregister(qcom_rdd->ramoops_pdev);
> +       qcom_rdd->ramoops_pdev = NULL;
> +}
> +
> +static const struct of_device_id qcom_ramoops_of_match[] = {
> +       { .compatible = "qcom,ramoops"},
> +       {}
> +};
> +MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
> +
> +static struct platform_driver qcom_ramoops_drv = {
> +       .driver         = {
> +               .name   = "qcom,ramoops",
> +               .of_match_table = qcom_ramoops_of_match,
> +       },
> +       .probe = qcom_ramoops_probe,
> +       .remove_new = qcom_ramoops_remove,
> +};
> +
> +module_platform_driver(qcom_ramoops_drv);
> +
> +MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
> +MODULE_LICENSE("GPL");
> --
> 2.7.4
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 15:45   ` Greg KH
@ 2023-06-28 23:12     ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:12 UTC (permalink / raw)
  To: Greg KH, Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 9:45 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> > included in the ramdump.
> >
> > 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(gunyah) 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.
>
> If you only have one "backend" then you don't need the extra compexity
> here at all, just remove that whole middle layer please and make this
> much simpler and smaller and easier to review and possibly accept.

pstore already supports backends. Why aren't the above backends just
pstore backends rather than having an intermediate pstore backend in
RAM which then somehow gets moved into these minidump backends.

> We don't add layers when they are not needed, and never when there is no
> actual user.  If you need the extra "complexity" later, then add it
> later when it is needed as who knows when that will ever be.
>
> Please redo this series based on that, thanks.

My bigger issue with this whole series is what would this all look
like if every SoC vendor upstreamed their own custom dumping
mechanism. That would be a mess. (I have similar opinions on the
$soc-vendor hypervisors.)

Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-28 23:12     ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:12 UTC (permalink / raw)
  To: Greg KH, Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 9:45 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
> > included in the ramdump.
> >
> > 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(gunyah) 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.
>
> If you only have one "backend" then you don't need the extra compexity
> here at all, just remove that whole middle layer please and make this
> much simpler and smaller and easier to review and possibly accept.

pstore already supports backends. Why aren't the above backends just
pstore backends rather than having an intermediate pstore backend in
RAM which then somehow gets moved into these minidump backends.

> We don't add layers when they are not needed, and never when there is no
> actual user.  If you need the extra "complexity" later, then add it
> later when it is needed as who knows when that will ever be.
>
> Please redo this series based on that, thanks.

My bigger issue with this whole series is what would this all look
like if every SoC vendor upstreamed their own custom dumping
mechanism. That would be a mess. (I have similar opinions on the
$soc-vendor hypervisors.)

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 14:10     ` Pavan Kondeti
@ 2023-06-28 23:17       ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:17 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 8:11 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
>
> On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> > Qualcomm ramoops minidump logger provide a means of storing
> > the ramoops data to some dynamically reserved memory instead
> > of traditionally implemented ramoops where the region should
> > be statically fixed ram region. Its device tree binding
> > would be exactly same as ramoops device tree binding and is
> > going to contain traditional ramoops frontend data and this
> > content will be collected via Qualcomm minidump infrastructure
> > provided from the boot firmware.
> >
> > Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> > ---
> >  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
> >  1 file changed, 126 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > new file mode 100644
> > index 000000000000..b1fdcf3f8ad4
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > @@ -0,0 +1,126 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> > +
> > +title: Qualcomm Ramoops minidump logger
> > +
> > +description: |
> > +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> > +  data to some dynamically reserved memory instead of traditionally
> > +  implemented ramoops where the region should be statically fixed ram
> > +  region. Because of its similarity with ramoops it will also have same
> > +  set of property what ramoops have it in its schema and is going to
> > +  contain traditional ramoops frontend data and this region will be
> > +  collected via Qualcomm minidump infrastructure provided from the
> > +  boot firmware.
> > +
> > +maintainers:
> > +  - Mukesh Ojha <quic_mojha@quicinc.com>
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - qcom,sm8450-ramoops
> > +      - const: qcom,ramoops
> > +
> > +  memory-region:
> > +    maxItems: 1
> > +    description: handle to memory reservation for qcom,ramoops region.
> > +
> > +  ecc-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: enables ECC support and specifies ECC buffer size in bytes
> > +    default: 0 # no ECC
> > +
> > +  record-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: maximum size in bytes of each kmsg dump
> > +    default: 0
> > +
> > +  console-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for kernel messages
> > +    default: 0
> > +
> > +  ftrace-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for function tracing and profiling
> > +    default: 0
> > +
> > +  pmsg-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for userspace messages
> > +    default: 0
> > +
> > +  mem-type:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: if present, sets the type of mapping is to be used to map the reserved region.
> > +    default: 0
> > +    oneOf:
> > +      - const: 0
> > +        description: write-combined
> > +      - const: 1
> > +        description: unbuffered
> > +      - const: 2
> > +        description: cached
> > +
> > +  max-reason:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    default: 2 # log oopses and panics
> > +    maximum: 0x7fffffff
> > +    description: |
> > +      If present, sets maximum type of kmsg dump reasons to store.
> > +      This can be set to INT_MAX to store all kmsg dumps.
> > +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> > +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> > +      controlled by the printk.always_kmsg_dump boot param.
> > +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> > +
> > +  flags:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    default: 0
> > +    description: |
> > +      If present, pass ramoops behavioral flags
> > +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> > +
> > +  no-dump-oops:
> > +    deprecated: true
> > +    type: boolean
> > +    description: |
> > +      Use max_reason instead. If present, and max_reason is not specified,
> > +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> > +
> > +  unbuffered:
> > +    deprecated: true
> > +    type: boolean
> > +    description: |
> > +      Use mem_type instead. If present, and mem_type is not specified,
> > +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> > +      the reserved region (defaults to buffered mappings mem_type = 0).
> > +      If both are specified -- "mem_type" overrides "unbuffered".
> > +
>
> Most of the properties you added here are already documented at
> Documentation/devicetree/bindings/reserved-memory/ramoops.yaml

That is certainly a problem. Don't define the same property more than
once. Not yet checked and enforced by the tools, but it will be.

> Can't we just reference them here? would something like work?
>
> max-reason:
>   $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason

Can work, but no. Common properties need to go into a schema of common
properties which the device specific schemas reference.

>
> > +unevaluatedProperties: false
> > +
>
> will there be any additional properties be added dynamically? if not,
> should not we use "additionalProperties: false" here?

I don't know what you mean by dynamically, but that's not the criteria
for which to use.

Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-28 23:17       ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:17 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 8:11 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
>
> On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> > Qualcomm ramoops minidump logger provide a means of storing
> > the ramoops data to some dynamically reserved memory instead
> > of traditionally implemented ramoops where the region should
> > be statically fixed ram region. Its device tree binding
> > would be exactly same as ramoops device tree binding and is
> > going to contain traditional ramoops frontend data and this
> > content will be collected via Qualcomm minidump infrastructure
> > provided from the boot firmware.
> >
> > Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> > ---
> >  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
> >  1 file changed, 126 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > new file mode 100644
> > index 000000000000..b1fdcf3f8ad4
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > @@ -0,0 +1,126 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> > +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> > +
> > +title: Qualcomm Ramoops minidump logger
> > +
> > +description: |
> > +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> > +  data to some dynamically reserved memory instead of traditionally
> > +  implemented ramoops where the region should be statically fixed ram
> > +  region. Because of its similarity with ramoops it will also have same
> > +  set of property what ramoops have it in its schema and is going to
> > +  contain traditional ramoops frontend data and this region will be
> > +  collected via Qualcomm minidump infrastructure provided from the
> > +  boot firmware.
> > +
> > +maintainers:
> > +  - Mukesh Ojha <quic_mojha@quicinc.com>
> > +
> > +properties:
> > +  compatible:
> > +    items:
> > +      - enum:
> > +          - qcom,sm8450-ramoops
> > +      - const: qcom,ramoops
> > +
> > +  memory-region:
> > +    maxItems: 1
> > +    description: handle to memory reservation for qcom,ramoops region.
> > +
> > +  ecc-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: enables ECC support and specifies ECC buffer size in bytes
> > +    default: 0 # no ECC
> > +
> > +  record-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: maximum size in bytes of each kmsg dump
> > +    default: 0
> > +
> > +  console-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for kernel messages
> > +    default: 0
> > +
> > +  ftrace-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for function tracing and profiling
> > +    default: 0
> > +
> > +  pmsg-size:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: size in bytes of log buffer reserved for userspace messages
> > +    default: 0
> > +
> > +  mem-type:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: if present, sets the type of mapping is to be used to map the reserved region.
> > +    default: 0
> > +    oneOf:
> > +      - const: 0
> > +        description: write-combined
> > +      - const: 1
> > +        description: unbuffered
> > +      - const: 2
> > +        description: cached
> > +
> > +  max-reason:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    default: 2 # log oopses and panics
> > +    maximum: 0x7fffffff
> > +    description: |
> > +      If present, sets maximum type of kmsg dump reasons to store.
> > +      This can be set to INT_MAX to store all kmsg dumps.
> > +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> > +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> > +      controlled by the printk.always_kmsg_dump boot param.
> > +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> > +
> > +  flags:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    default: 0
> > +    description: |
> > +      If present, pass ramoops behavioral flags
> > +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> > +
> > +  no-dump-oops:
> > +    deprecated: true
> > +    type: boolean
> > +    description: |
> > +      Use max_reason instead. If present, and max_reason is not specified,
> > +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> > +
> > +  unbuffered:
> > +    deprecated: true
> > +    type: boolean
> > +    description: |
> > +      Use mem_type instead. If present, and mem_type is not specified,
> > +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> > +      the reserved region (defaults to buffered mappings mem_type = 0).
> > +      If both are specified -- "mem_type" overrides "unbuffered".
> > +
>
> Most of the properties you added here are already documented at
> Documentation/devicetree/bindings/reserved-memory/ramoops.yaml

That is certainly a problem. Don't define the same property more than
once. Not yet checked and enforced by the tools, but it will be.

> Can't we just reference them here? would something like work?
>
> max-reason:
>   $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason

Can work, but no. Common properties need to go into a schema of common
properties which the device specific schemas reference.

>
> > +unevaluatedProperties: false
> > +
>
> will there be any additional properties be added dynamically? if not,
> should not we use "additionalProperties: false" here?

I don't know what you mean by dynamically, but that's not the criteria
for which to use.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-28 23:21     ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:21 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> 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(&region);
> +  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

So I can't use my QCom laptop or M1 MacBook? This text won't age well,
so perhaps reword it.

Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide
@ 2023-06-28 23:21     ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-06-28 23:21 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
> 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(&region);
> +  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

So I can't use my QCom laptop or M1 MacBook? This text won't age well,
so perhaps reword it.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 23:17       ` Rob Herring
@ 2023-06-29  1:45         ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  1:45 UTC (permalink / raw)
  To: Rob Herring
  Cc: Pavan Kondeti, Mukesh Ojha, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, mathieu.poirier, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 05:17:13PM -0600, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 8:11 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> >
> > On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> > > Qualcomm ramoops minidump logger provide a means of storing
> > > the ramoops data to some dynamically reserved memory instead
> > > of traditionally implemented ramoops where the region should
> > > be statically fixed ram region. Its device tree binding
> > > would be exactly same as ramoops device tree binding and is
> > > going to contain traditional ramoops frontend data and this
> > > content will be collected via Qualcomm minidump infrastructure
> > > provided from the boot firmware.
> > >
> > > Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> > > ---
> > >  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
> > >  1 file changed, 126 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > > new file mode 100644
> > > index 000000000000..b1fdcf3f8ad4
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > > @@ -0,0 +1,126 @@
> > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> > > +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> > > +
> > > +title: Qualcomm Ramoops minidump logger
> > > +
> > > +description: |
> > > +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> > > +  data to some dynamically reserved memory instead of traditionally
> > > +  implemented ramoops where the region should be statically fixed ram
> > > +  region. Because of its similarity with ramoops it will also have same
> > > +  set of property what ramoops have it in its schema and is going to
> > > +  contain traditional ramoops frontend data and this region will be
> > > +  collected via Qualcomm minidump infrastructure provided from the
> > > +  boot firmware.
> > > +
> > > +maintainers:
> > > +  - Mukesh Ojha <quic_mojha@quicinc.com>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - qcom,sm8450-ramoops
> > > +      - const: qcom,ramoops
> > > +
> > > +  memory-region:
> > > +    maxItems: 1
> > > +    description: handle to memory reservation for qcom,ramoops region.
> > > +
> > > +  ecc-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: enables ECC support and specifies ECC buffer size in bytes
> > > +    default: 0 # no ECC
> > > +
> > > +  record-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: maximum size in bytes of each kmsg dump
> > > +    default: 0
> > > +
> > > +  console-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for kernel messages
> > > +    default: 0
> > > +
> > > +  ftrace-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for function tracing and profiling
> > > +    default: 0
> > > +
> > > +  pmsg-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for userspace messages
> > > +    default: 0
> > > +
> > > +  mem-type:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: if present, sets the type of mapping is to be used to map the reserved region.
> > > +    default: 0
> > > +    oneOf:
> > > +      - const: 0
> > > +        description: write-combined
> > > +      - const: 1
> > > +        description: unbuffered
> > > +      - const: 2
> > > +        description: cached
> > > +
> > > +  max-reason:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    default: 2 # log oopses and panics
> > > +    maximum: 0x7fffffff
> > > +    description: |
> > > +      If present, sets maximum type of kmsg dump reasons to store.
> > > +      This can be set to INT_MAX to store all kmsg dumps.
> > > +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> > > +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> > > +      controlled by the printk.always_kmsg_dump boot param.
> > > +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> > > +
> > > +  flags:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    default: 0
> > > +    description: |
> > > +      If present, pass ramoops behavioral flags
> > > +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> > > +
> > > +  no-dump-oops:
> > > +    deprecated: true
> > > +    type: boolean
> > > +    description: |
> > > +      Use max_reason instead. If present, and max_reason is not specified,
> > > +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> > > +
> > > +  unbuffered:
> > > +    deprecated: true
> > > +    type: boolean
> > > +    description: |
> > > +      Use mem_type instead. If present, and mem_type is not specified,
> > > +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> > > +      the reserved region (defaults to buffered mappings mem_type = 0).
> > > +      If both are specified -- "mem_type" overrides "unbuffered".
> > > +
> >
> > Most of the properties you added here are already documented at
> > Documentation/devicetree/bindings/reserved-memory/ramoops.yaml
> 
> That is certainly a problem. Don't define the same property more than
> once. Not yet checked and enforced by the tools, but it will be.
> 
> > Can't we just reference them here? would something like work?
> >
> > max-reason:
> >   $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason
> 
> Can work, but no. Common properties need to go into a schema of common
> properties which the device specific schemas reference.
> 

Thanks for the clarification. We need to define the common properties
and make it available under /schemas/<>.yaml and add a reference to it
in these bindings. Is my understanding correct?

> >
> > > +unevaluatedProperties: false
> > > +
> >
> > will there be any additional properties be added dynamically? if not,
> > should not we use "additionalProperties: false" here?
> 
> I don't know what you mean by dynamically, but that's not the criteria
> for which to use.
> 
ok, I was wrong in saying dynamically. I should say "are there any other
properties that will be included that are not documented here".

is below my understanding correct?

additionalProperties needs to be set to false if at all this binding
defines all the possible properties (including child nodes) and not
referring to any other schemas.

If that is not the case and this binding references to other schemas,
then unevaluatedProperties could be used since additionalProperties
can't support combining schemas.

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-06-29  1:45         ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  1:45 UTC (permalink / raw)
  To: Rob Herring
  Cc: Pavan Kondeti, Mukesh Ojha, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, mathieu.poirier, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Wed, Jun 28, 2023 at 05:17:13PM -0600, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 8:11 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> >
> > On Wed, Jun 28, 2023 at 06:04:35PM +0530, Mukesh Ojha wrote:
> > > Qualcomm ramoops minidump logger provide a means of storing
> > > the ramoops data to some dynamically reserved memory instead
> > > of traditionally implemented ramoops where the region should
> > > be statically fixed ram region. Its device tree binding
> > > would be exactly same as ramoops device tree binding and is
> > > going to contain traditional ramoops frontend data and this
> > > content will be collected via Qualcomm minidump infrastructure
> > > provided from the boot firmware.
> > >
> > > Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> > > ---
> > >  .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++++++++++++++++++
> > >  1 file changed, 126 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > > new file mode 100644
> > > index 000000000000..b1fdcf3f8ad4
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
> > > @@ -0,0 +1,126 @@
> > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: "http://devicetree.org/schemas/soc/qcom/qcom,ramoops.yaml#"
> > > +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> > > +
> > > +title: Qualcomm Ramoops minidump logger
> > > +
> > > +description: |
> > > +  Qualcomm ramoops minidump logger provide a means of storing the ramoops
> > > +  data to some dynamically reserved memory instead of traditionally
> > > +  implemented ramoops where the region should be statically fixed ram
> > > +  region. Because of its similarity with ramoops it will also have same
> > > +  set of property what ramoops have it in its schema and is going to
> > > +  contain traditional ramoops frontend data and this region will be
> > > +  collected via Qualcomm minidump infrastructure provided from the
> > > +  boot firmware.
> > > +
> > > +maintainers:
> > > +  - Mukesh Ojha <quic_mojha@quicinc.com>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    items:
> > > +      - enum:
> > > +          - qcom,sm8450-ramoops
> > > +      - const: qcom,ramoops
> > > +
> > > +  memory-region:
> > > +    maxItems: 1
> > > +    description: handle to memory reservation for qcom,ramoops region.
> > > +
> > > +  ecc-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: enables ECC support and specifies ECC buffer size in bytes
> > > +    default: 0 # no ECC
> > > +
> > > +  record-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: maximum size in bytes of each kmsg dump
> > > +    default: 0
> > > +
> > > +  console-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for kernel messages
> > > +    default: 0
> > > +
> > > +  ftrace-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for function tracing and profiling
> > > +    default: 0
> > > +
> > > +  pmsg-size:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: size in bytes of log buffer reserved for userspace messages
> > > +    default: 0
> > > +
> > > +  mem-type:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: if present, sets the type of mapping is to be used to map the reserved region.
> > > +    default: 0
> > > +    oneOf:
> > > +      - const: 0
> > > +        description: write-combined
> > > +      - const: 1
> > > +        description: unbuffered
> > > +      - const: 2
> > > +        description: cached
> > > +
> > > +  max-reason:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    default: 2 # log oopses and panics
> > > +    maximum: 0x7fffffff
> > > +    description: |
> > > +      If present, sets maximum type of kmsg dump reasons to store.
> > > +      This can be set to INT_MAX to store all kmsg dumps.
> > > +      See include/linux/kmsg_dump.h KMSG_DUMP_* for other kmsg dump reason values.
> > > +      Setting this to 0 (KMSG_DUMP_UNDEF), means the reason filtering will be
> > > +      controlled by the printk.always_kmsg_dump boot param.
> > > +      If unset, it will be 2 (KMSG_DUMP_OOPS), otherwise 5 (KMSG_DUMP_MAX).
> > > +
> > > +  flags:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    default: 0
> > > +    description: |
> > > +      If present, pass ramoops behavioral flags
> > > +      (see include/linux/pstore_ram.h RAMOOPS_FLAG_* for flag values).
> > > +
> > > +  no-dump-oops:
> > > +    deprecated: true
> > > +    type: boolean
> > > +    description: |
> > > +      Use max_reason instead. If present, and max_reason is not specified,
> > > +      it is equivalent to max_reason = 1 (KMSG_DUMP_PANIC).
> > > +
> > > +  unbuffered:
> > > +    deprecated: true
> > > +    type: boolean
> > > +    description: |
> > > +      Use mem_type instead. If present, and mem_type is not specified,
> > > +      it is equivalent to mem_type = 1 and uses unbuffered mappings to map
> > > +      the reserved region (defaults to buffered mappings mem_type = 0).
> > > +      If both are specified -- "mem_type" overrides "unbuffered".
> > > +
> >
> > Most of the properties you added here are already documented at
> > Documentation/devicetree/bindings/reserved-memory/ramoops.yaml
> 
> That is certainly a problem. Don't define the same property more than
> once. Not yet checked and enforced by the tools, but it will be.
> 
> > Can't we just reference them here? would something like work?
> >
> > max-reason:
> >   $ref: "../../reserved-memory/ramoops.yaml#/properties/max-reason
> 
> Can work, but no. Common properties need to go into a schema of common
> properties which the device specific schemas reference.
> 

Thanks for the clarification. We need to define the common properties
and make it available under /schemas/<>.yaml and add a reference to it
in these bindings. Is my understanding correct?

> >
> > > +unevaluatedProperties: false
> > > +
> >
> > will there be any additional properties be added dynamically? if not,
> > should not we use "additionalProperties: false" here?
> 
> I don't know what you mean by dynamically, but that's not the criteria
> for which to use.
> 
ok, I was wrong in saying dynamically. I should say "are there any other
properties that will be included that are not documented here".

is below my understanding correct?

additionalProperties needs to be set to false if at all this binding
defines all the possible properties (including child nodes) and not
referring to any other schemas.

If that is not the case and this binding references to other schemas,
then unevaluatedProperties could be used since additionalProperties
can't support combining schemas.

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-29  2:33     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  2:33 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:31PM +0530, Mukesh Ojha 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 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 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.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig                  |  15 +
>  drivers/soc/qcom/Makefile                 |   2 +
>  drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
>  drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
>  include/soc/qcom/qcom_minidump.h          |  35 +++
>  5 files changed, 583 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_minidump.c
>  create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 982310b5a1cb..874ee8c3efe0 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
>  	tristate
>  	select QCOM_SCM
>  
> +config QCOM_MINIDUMP
> +	tristate "QCOM Minidump APSS Core Infrastructure"
> +	depends on ARCH_QCOM
> +	help
> +	  This config allow linux core infrastructure for APSS minidump for
> +	  underlying backend(smem etc.) which can hook themselves to this and
> +	  work as one unit. So, this config should be selected in combination
> +	  with its backend.
> +
> +	  After this Linux clients driver can register their internal data
> +	  structures and debug messages as part of the apss minidump region
> +	  and when the SoC is crashed, and these selective regions will be
> +	  dumped instead of the entire DDR. This saves significant amount
> +	  of time and/or storage space.
> +
>  config QCOM_MINIDUMP_SMEM
>  	tristate "QCOM Minidump SMEM (as backend) Support"
>  	depends on ARCH_QCOM
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 89b775512bef..737d868757ac 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
>  obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
>  qcom_ice-objs			+= ice.o
>  obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
> +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
> +obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
> new file mode 100644
> index 000000000000..7744e57843ab
> --- /dev/null
> +++ b/drivers/soc/qcom/qcom_minidump.c
> @@ -0,0 +1,456 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/device.h>
> +#include <linux/export.h>
> +#include <linux/kallsyms.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/printk.h>
> +#include <linux/string.h>
> +
> +#include "qcom_minidump_internal.h"
> +
> +/*
> + * In some of the Old Qualcomm devices, boot firmware statically allocates 300
> + * as total number of supported region (including all co-processors) in
> + * 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
> + * Linux to 201.
> + */
> +#define MAX_NUM_ENTRIES	  201
> +#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
> +

Should not we receive these constraints from backend?

> +/*
> + * md_lock protects "md" during calls to qcom_minidump_backend_register(),
> + * qcom_minidump_backend_unregister().
> + */
> +static DEFINE_MUTEX(md_lock);
> +
> +/* Only one front end will be attached to one back-end */
> +static struct minidump *md;
> +static char *md_backend;
> +

Can you explain this a bit more? There is just one fronend, correct?
Multiple possibilites of backend.

Is it a limitation at the moment that we support only one backend or
plan to support more backends later for the same frontend. Pls clarify.

> +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);
> +
> +	return &eshdr[idx];
> +}
> +

[...]

> +/**
> + * qcom_minidump_region_register() - Register region in APSS Minidump table.
> + * @region: minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */

Are we not going to return any cookie upon success which can be passed
to us during unregistration?

> +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
> +{
> +	int ret;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		mutex_unlock(&md_lock);
> +		pr_err("No backend registered yet, try again..");
> +		return -EPROBE_DEFER;
> +	}
> +
> +	ret = md->ops->md_region_register(md, region);
> +	if (ret)
> +		goto unlock;
> +

The md_lock description in the beginning does not seems to be correct.
It is not limited to backend registration. It has much wider usage.

You are holding the lock while calling into backend. Basically the
synchronization is done in the front end.

> +	qcom_md_update_elf_header(region);
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
> +
> +/**
> + * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
> + * @region: minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
> +{
> +	int ret;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		mutex_unlock(&md_lock);
> +		pr_err("No backend registered yet, try again..");
> +		return -EPROBE_DEFER;
> +	}
> +
> +	ret = md->ops->md_region_unregister(md, region);
> +	if (ret)
> +		goto unlock;
> +

The frontend is not validing that it is actually a registered client, it
is left to backend. Seems that is more duplication in the backend(s).

> +	ret = qcom_minidump_clear_header(region);
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);

can we create a namespace for exporting these symbols?

> +
> +static int qcom_minidump_add_elf_header(struct minidump *md_data)
> +{

[...]

> +
> +/**
> + * qcom_minidump_backend_register() - Register backend minidump device.
> + * @md_data: minidump backend driver data
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_backend_register(struct minidump *md_data)
> +{
> +	int ret;
> +
> +	if (!md_data->name || !md_data->dev ||
> +	    !md_data->ops ||
> +	    !md_data->ops->md_table_init ||
> +	    !md_data->ops->md_region_register ||
> +	    !md_data->ops->md_region_unregister ||
> +	    !md_data->ops->md_table_exit) {
> +		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
> +		return -EINVAL;
> +	}
> +
> +	if (md_backend && strcmp(md_backend, md_data->name)) {
> +		pr_warn("backend '%s' already in use: ignoring '%s'\n",
> +			 md_backend, md_data->name);
> +		return -EBUSY;
> +	}
> +
> +	mutex_lock(&md_lock);
> +	if (md) {
> +		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
> +			 md->name, md_data->name);
> +		ret = -EBUSY;
> +		goto unlock;
> +	}
> +
> +	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
> +		md_data->max_region_limit = MAX_NUM_ENTRIES;
> +
> +	ret = md_data->ops->md_table_init(md_data);
> +	if (ret) {
> +		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
> +		goto unlock;
> +	}
> +
> +	/* First entry would be ELF header */
> +	ret = qcom_minidump_add_elf_header(md_data);
> +	if (ret) {
> +		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
> +		md_data->ops->md_table_exit(md_data);
> +		goto unlock;
> +	}
> +
> +	md = md_data;
> +	md_backend = kstrdup(md->name, GFP_KERNEL);
> +	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
> +

What is the need for keeping md_backend separately? md::name is already
present.

Also, how do we prevent backend module unloading while it is inuse? or
we don't need that constraint?

> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
@ 2023-06-29  2:33     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  2:33 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:31PM +0530, Mukesh Ojha 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 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 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.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/Kconfig                  |  15 +
>  drivers/soc/qcom/Makefile                 |   2 +
>  drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
>  drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
>  include/soc/qcom/qcom_minidump.h          |  35 +++
>  5 files changed, 583 insertions(+)
>  create mode 100644 drivers/soc/qcom/qcom_minidump.c
>  create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index 982310b5a1cb..874ee8c3efe0 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
>  	tristate
>  	select QCOM_SCM
>  
> +config QCOM_MINIDUMP
> +	tristate "QCOM Minidump APSS Core Infrastructure"
> +	depends on ARCH_QCOM
> +	help
> +	  This config allow linux core infrastructure for APSS minidump for
> +	  underlying backend(smem etc.) which can hook themselves to this and
> +	  work as one unit. So, this config should be selected in combination
> +	  with its backend.
> +
> +	  After this Linux clients driver can register their internal data
> +	  structures and debug messages as part of the apss minidump region
> +	  and when the SoC is crashed, and these selective regions will be
> +	  dumped instead of the entire DDR. This saves significant amount
> +	  of time and/or storage space.
> +
>  config QCOM_MINIDUMP_SMEM
>  	tristate "QCOM Minidump SMEM (as backend) Support"
>  	depends on ARCH_QCOM
> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
> index 89b775512bef..737d868757ac 100644
> --- a/drivers/soc/qcom/Makefile
> +++ b/drivers/soc/qcom/Makefile
> @@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
>  obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
>  qcom_ice-objs			+= ice.o
>  obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
> +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
> +obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
> new file mode 100644
> index 000000000000..7744e57843ab
> --- /dev/null
> +++ b/drivers/soc/qcom/qcom_minidump.c
> @@ -0,0 +1,456 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/device.h>
> +#include <linux/export.h>
> +#include <linux/kallsyms.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/printk.h>
> +#include <linux/string.h>
> +
> +#include "qcom_minidump_internal.h"
> +
> +/*
> + * In some of the Old Qualcomm devices, boot firmware statically allocates 300
> + * as total number of supported region (including all co-processors) in
> + * 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
> + * Linux to 201.
> + */
> +#define MAX_NUM_ENTRIES	  201
> +#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
> +

Should not we receive these constraints from backend?

> +/*
> + * md_lock protects "md" during calls to qcom_minidump_backend_register(),
> + * qcom_minidump_backend_unregister().
> + */
> +static DEFINE_MUTEX(md_lock);
> +
> +/* Only one front end will be attached to one back-end */
> +static struct minidump *md;
> +static char *md_backend;
> +

Can you explain this a bit more? There is just one fronend, correct?
Multiple possibilites of backend.

Is it a limitation at the moment that we support only one backend or
plan to support more backends later for the same frontend. Pls clarify.

> +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);
> +
> +	return &eshdr[idx];
> +}
> +

[...]

> +/**
> + * qcom_minidump_region_register() - Register region in APSS Minidump table.
> + * @region: minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */

Are we not going to return any cookie upon success which can be passed
to us during unregistration?

> +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
> +{
> +	int ret;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		mutex_unlock(&md_lock);
> +		pr_err("No backend registered yet, try again..");
> +		return -EPROBE_DEFER;
> +	}
> +
> +	ret = md->ops->md_region_register(md, region);
> +	if (ret)
> +		goto unlock;
> +

The md_lock description in the beginning does not seems to be correct.
It is not limited to backend registration. It has much wider usage.

You are holding the lock while calling into backend. Basically the
synchronization is done in the front end.

> +	qcom_md_update_elf_header(region);
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
> +
> +/**
> + * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
> + * @region: minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
> +{
> +	int ret;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		mutex_unlock(&md_lock);
> +		pr_err("No backend registered yet, try again..");
> +		return -EPROBE_DEFER;
> +	}
> +
> +	ret = md->ops->md_region_unregister(md, region);
> +	if (ret)
> +		goto unlock;
> +

The frontend is not validing that it is actually a registered client, it
is left to backend. Seems that is more duplication in the backend(s).

> +	ret = qcom_minidump_clear_header(region);
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);

can we create a namespace for exporting these symbols?

> +
> +static int qcom_minidump_add_elf_header(struct minidump *md_data)
> +{

[...]

> +
> +/**
> + * qcom_minidump_backend_register() - Register backend minidump device.
> + * @md_data: minidump backend driver data
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_backend_register(struct minidump *md_data)
> +{
> +	int ret;
> +
> +	if (!md_data->name || !md_data->dev ||
> +	    !md_data->ops ||
> +	    !md_data->ops->md_table_init ||
> +	    !md_data->ops->md_region_register ||
> +	    !md_data->ops->md_region_unregister ||
> +	    !md_data->ops->md_table_exit) {
> +		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
> +		return -EINVAL;
> +	}
> +
> +	if (md_backend && strcmp(md_backend, md_data->name)) {
> +		pr_warn("backend '%s' already in use: ignoring '%s'\n",
> +			 md_backend, md_data->name);
> +		return -EBUSY;
> +	}
> +
> +	mutex_lock(&md_lock);
> +	if (md) {
> +		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
> +			 md->name, md_data->name);
> +		ret = -EBUSY;
> +		goto unlock;
> +	}
> +
> +	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
> +		md_data->max_region_limit = MAX_NUM_ENTRIES;
> +
> +	ret = md_data->ops->md_table_init(md_data);
> +	if (ret) {
> +		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
> +		goto unlock;
> +	}
> +
> +	/* First entry would be ELF header */
> +	ret = qcom_minidump_add_elf_header(md_data);
> +	if (ret) {
> +		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
> +		md_data->ops->md_table_exit(md_data);
> +		goto unlock;
> +	}
> +
> +	md = md_data;
> +	md_backend = kstrdup(md->name, GFP_KERNEL);
> +	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
> +

What is the need for keeping md_backend separately? md::name is already
present.

Also, how do we prevent backend module unloading while it is inuse? or
we don't need that constraint?

> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 07/21] soc: qcom: minidump: Add update region support
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-29  2:49     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  2:49 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:34PM +0530, Mukesh Ojha wrote:
> Add support to update client's region physical/virtual addresses,
> which is useful for dynamic loadable modules, dynamic address
> changing clients like if we want to collect current stack
> information for each core and the current stack is changing on
> each sched_switch event, So here virtual/physical address of
> the current stack is changing. So, to cover such use cases
> add the update region support in minidump driver and the
> corresponding smem backend support.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/qcom_minidump.c          | 55 +++++++++++++++++++++++++++++++
>  drivers/soc/qcom/qcom_minidump_internal.h |  3 ++
>  drivers/soc/qcom/qcom_minidump_smem.c     | 21 ++++++++++++
>  include/soc/qcom/qcom_minidump.h          |  5 +++
>  4 files changed, 84 insertions(+)
> 
> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
> index cfdb63cc29d6..37d6ceb4d85c 100644
> --- a/drivers/soc/qcom/qcom_minidump.c
> +++ b/drivers/soc/qcom/qcom_minidump.c
> @@ -318,6 +318,61 @@ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
>  }
>  EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
>  
> +/**
> + * qcom_minidump_update_region() - Update region information with new physical
> + * address and virtual address for already registered region e.g, current task
> + * stack for a core keeps on changing on each context switch, there it needs to
> + * change registered region with new updated addresses.
> + *
> + * @region: Should be already registered minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_update_region(const struct qcom_minidump_region *region)
> +{
> +	struct minidump_pregion *md_pregion;
> +	struct qcom_minidump_region *tmp;
> +	struct elfhdr *ehdr;
> +	struct elf_shdr *shdr;
> +	struct elf_phdr *phdr;
> +	int idx;
> +	int ret = 0;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		md_pregion = check_if_pending_region_exist(region);
> +		if (!md_pregion) {
> +			ret = -ENOENT;
> +			goto unlock;
> +		}
> +		tmp = &md_pregion->region;
> +		tmp->phys_addr = region->phys_addr;
> +		tmp->virt_addr = region->virt_addr;
> +		goto unlock;
> +	}
> +
> +	ret = md->ops->md_update_region(md, &idx, region);
> +	if (ret)
> +		goto unlock;
> +
> +	/* Skip predefined shdr/phdr header entry at the start */
> +	ehdr = md->elf.ehdr;
> +	shdr = elf_shdr_entry_addr(ehdr, idx + 4);
> +	phdr = elf_phdr_entry_addr(ehdr, idx + 1);
> +
> +	shdr->sh_addr = (elf_addr_t)region->virt_addr;
> +	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
> +	phdr->p_paddr = region->phys_addr;
> +
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_update_region);
> +

I don't see any use of this API in the series. Do you plan to add one in
the next version?

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 07/21] soc: qcom: minidump: Add update region support
@ 2023-06-29  2:49     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-29  2:49 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:34PM +0530, Mukesh Ojha wrote:
> Add support to update client's region physical/virtual addresses,
> which is useful for dynamic loadable modules, dynamic address
> changing clients like if we want to collect current stack
> information for each core and the current stack is changing on
> each sched_switch event, So here virtual/physical address of
> the current stack is changing. So, to cover such use cases
> add the update region support in minidump driver and the
> corresponding smem backend support.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/soc/qcom/qcom_minidump.c          | 55 +++++++++++++++++++++++++++++++
>  drivers/soc/qcom/qcom_minidump_internal.h |  3 ++
>  drivers/soc/qcom/qcom_minidump_smem.c     | 21 ++++++++++++
>  include/soc/qcom/qcom_minidump.h          |  5 +++
>  4 files changed, 84 insertions(+)
> 
> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
> index cfdb63cc29d6..37d6ceb4d85c 100644
> --- a/drivers/soc/qcom/qcom_minidump.c
> +++ b/drivers/soc/qcom/qcom_minidump.c
> @@ -318,6 +318,61 @@ int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
>  }
>  EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
>  
> +/**
> + * qcom_minidump_update_region() - Update region information with new physical
> + * address and virtual address for already registered region e.g, current task
> + * stack for a core keeps on changing on each context switch, there it needs to
> + * change registered region with new updated addresses.
> + *
> + * @region: Should be already registered minidump region.
> + *
> + * Return: On success, it returns 0 and negative error value on failure.
> + */
> +int qcom_minidump_update_region(const struct qcom_minidump_region *region)
> +{
> +	struct minidump_pregion *md_pregion;
> +	struct qcom_minidump_region *tmp;
> +	struct elfhdr *ehdr;
> +	struct elf_shdr *shdr;
> +	struct elf_phdr *phdr;
> +	int idx;
> +	int ret = 0;
> +
> +	if (!qcom_minidump_valid_region(region))
> +		return -EINVAL;
> +
> +	mutex_lock(&md_lock);
> +	if (!md) {
> +		md_pregion = check_if_pending_region_exist(region);
> +		if (!md_pregion) {
> +			ret = -ENOENT;
> +			goto unlock;
> +		}
> +		tmp = &md_pregion->region;
> +		tmp->phys_addr = region->phys_addr;
> +		tmp->virt_addr = region->virt_addr;
> +		goto unlock;
> +	}
> +
> +	ret = md->ops->md_update_region(md, &idx, region);
> +	if (ret)
> +		goto unlock;
> +
> +	/* Skip predefined shdr/phdr header entry at the start */
> +	ehdr = md->elf.ehdr;
> +	shdr = elf_shdr_entry_addr(ehdr, idx + 4);
> +	phdr = elf_phdr_entry_addr(ehdr, idx + 1);
> +
> +	shdr->sh_addr = (elf_addr_t)region->virt_addr;
> +	phdr->p_vaddr = (elf_addr_t)region->virt_addr;
> +	phdr->p_paddr = region->phys_addr;
> +
> +unlock:
> +	mutex_unlock(&md_lock);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(qcom_minidump_update_region);
> +

I don't see any use of this API in the series. Do you plan to add one in
the next version?

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
  2023-06-28 22:57     ` Rob Herring
@ 2023-06-29  9:16       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-29  9:16 UTC (permalink / raw)
  To: Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/29/2023 4:27 AM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> This driver was inspired from the fact pstore ram region should be
>> fixed and boot firmware need to have awarness about this region,
>> so that it will be persistent across boot. But, there are many
>> QCOM SoC which does not support warm boot from hardware but they
>> have minidump support from the software, and for them, there is
>> no need of this pstore ram region to be fixed, but at the same
>> time have interest in the pstore frontends data. So, this driver
>> get the dynamic reserved region from the ram and register the
>> ramoops platform device.
>>
>>   +---------+     +---------+   +--------+     +---------+
>>   | console |     | pmsg    |   | ftrace |     | dmesg   |
>>   +---------+     +---------+   +--------+     +---------+
>>         |             |             |              |
>>         |             |             |              |
>>         +------------------------------------------+
>>                            |
>>                           \ /
>>                    +----------------+
>>              (1)   |pstore frontends|
>>                    +----------------+
>>                            |
>>                           \ /
>>                   +------------------- +
>>              (2)  | pstore backend(ram)|
>>                   +--------------------+
>>                            |
>>                           \ /
>>                   +--------------------+
>>              (3)  |qcom_pstore_minidump|
>>                   +--------------------+
>>                            |
>>                           \ /
>>                     +---------------+
>>              (4)    | qcom_minidump |
>>                     +---------------+
>>
>> This driver will route all the pstore front data to the stored
>> in qcom pstore reserved region and the reason of showing an
>> arrow from (3) to (4) as qcom_pstore_minidump driver will register
>> all the available frontends region with qcom minidump driver
>> in upcoming patch.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/soc/qcom/Kconfig                | 12 +++++
>>   drivers/soc/qcom/Makefile               |  1 +
>>   drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
> 
> drivers/soc/ is the dumping ground for things with no other place. As
> this is a pstore driver, it belongs with pstore.

The inspiration of this driver was taken from 
drivers/platform/chrome/chromeos_pstore.c, do you think that is misplaced ?

> 
>>   3 files changed, 98 insertions(+)
>>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>>
>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
>> index 1834213fd652..fbf08e30feda 100644
>> --- a/drivers/soc/qcom/Kconfig
>> +++ b/drivers/soc/qcom/Kconfig
>> @@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
>>
>>            This config should be enabled if the low level minidump is implemented
>>            as part of SMEM.
>> +
>> +config QCOM_PSTORE_MINIDUMP
>> +       tristate "Pstore support for QCOM Minidump"
>> +       depends on ARCH_QCOM
>> +       depends on PSTORE_RAM
>> +       depends on QCOM_MINIDUMP
>> +       help
>> +         Enablement of this driver ensures that ramoops region can be anywhere
>> +         reserved in ram instead of being fixed address which needs boot firmware
>> +         awareness. So, this driver creates plaform device and registers available
>> +         frontend region with the Qualcomm's minidump driver.
>> +
>>   endmenu
>> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
>> index 737d868757ac..1ab59c1b364d 100644
>> --- a/drivers/soc/qcom/Makefile
>> +++ b/drivers/soc/qcom/Makefile
>> @@ -36,3 +36,4 @@ qcom_ice-objs                 += ice.o
>>   obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)        += qcom_ice.o
>>   obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>>   obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
>> +obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
>> diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
>> new file mode 100644
>> index 000000000000..b07cd10340df
>> --- /dev/null
>> +++ b/drivers/soc/qcom/qcom_pstore_minidump.c
>> @@ -0,0 +1,85 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +
>> +/*
>> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
> 
> You probably don't need this include. Use the actual includes you need
> and don't rely on implicit includes (because I'm trying to remove
> those).

Ok, will try to check..

- Mukesh

> 
>> +#include <linux/of_reserved_mem.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pstore_ram.h>
>> +
>> +struct qcom_ramoops_dd {
>> +       struct ramoops_platform_data qcom_ramoops_pdata;
>> +       struct platform_device *ramoops_pdev;
>> +};
>> +
>> +static int qcom_ramoops_probe(struct platform_device *pdev)
>> +{
>> +       struct device_node *of_node = pdev->dev.of_node;
>> +       struct qcom_ramoops_dd *qcom_rdd;
>> +       struct ramoops_platform_data *pdata;
>> +       struct reserved_mem *rmem;
>> +       struct device_node *node;
>> +       long ret;
>> +
>> +       node = of_parse_phandle(of_node, "memory-region", 0);
>> +       if (!node)
>> +               return -ENODEV;
>> +
>> +       rmem = of_reserved_mem_lookup(node);
>> +       of_node_put(node);
>> +       if (!rmem) {
>> +               dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
>> +       if (!qcom_rdd)
>> +               return -ENOMEM;
>> +
>> +       pdata = &qcom_rdd->qcom_ramoops_pdata;
>> +       pdata->mem_size = rmem->size;
>> +       pdata->mem_address = rmem->base;
>> +       ramoops_parse_dt(pdev, pdata);
>> +
>> +       qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
>> +                                                              pdata, sizeof(*pdata));
>> +       if (IS_ERR(qcom_rdd->ramoops_pdev)) {
>> +               ret = PTR_ERR(qcom_rdd->ramoops_pdev);
>> +               dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
>> +               qcom_rdd->ramoops_pdev = NULL;
>> +       }
>> +       platform_set_drvdata(pdev, qcom_rdd);
>> +
>> +       return ret;
>> +}
>> +
>> +static void qcom_ramoops_remove(struct platform_device *pdev)
>> +{
>> +       struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
>> +
>> +       platform_device_unregister(qcom_rdd->ramoops_pdev);
>> +       qcom_rdd->ramoops_pdev = NULL;
>> +}
>> +
>> +static const struct of_device_id qcom_ramoops_of_match[] = {
>> +       { .compatible = "qcom,ramoops"},
>> +       {}
>> +};
>> +MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
>> +
>> +static struct platform_driver qcom_ramoops_drv = {
>> +       .driver         = {
>> +               .name   = "qcom,ramoops",
>> +               .of_match_table = qcom_ramoops_of_match,
>> +       },
>> +       .probe = qcom_ramoops_probe,
>> +       .remove_new = qcom_ramoops_remove,
>> +};
>> +
>> +module_platform_driver(qcom_ramoops_drv);
>> +
>> +MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
>> +MODULE_LICENSE("GPL");
>> --
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
@ 2023-06-29  9:16       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-29  9:16 UTC (permalink / raw)
  To: Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/29/2023 4:27 AM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> This driver was inspired from the fact pstore ram region should be
>> fixed and boot firmware need to have awarness about this region,
>> so that it will be persistent across boot. But, there are many
>> QCOM SoC which does not support warm boot from hardware but they
>> have minidump support from the software, and for them, there is
>> no need of this pstore ram region to be fixed, but at the same
>> time have interest in the pstore frontends data. So, this driver
>> get the dynamic reserved region from the ram and register the
>> ramoops platform device.
>>
>>   +---------+     +---------+   +--------+     +---------+
>>   | console |     | pmsg    |   | ftrace |     | dmesg   |
>>   +---------+     +---------+   +--------+     +---------+
>>         |             |             |              |
>>         |             |             |              |
>>         +------------------------------------------+
>>                            |
>>                           \ /
>>                    +----------------+
>>              (1)   |pstore frontends|
>>                    +----------------+
>>                            |
>>                           \ /
>>                   +------------------- +
>>              (2)  | pstore backend(ram)|
>>                   +--------------------+
>>                            |
>>                           \ /
>>                   +--------------------+
>>              (3)  |qcom_pstore_minidump|
>>                   +--------------------+
>>                            |
>>                           \ /
>>                     +---------------+
>>              (4)    | qcom_minidump |
>>                     +---------------+
>>
>> This driver will route all the pstore front data to the stored
>> in qcom pstore reserved region and the reason of showing an
>> arrow from (3) to (4) as qcom_pstore_minidump driver will register
>> all the available frontends region with qcom minidump driver
>> in upcoming patch.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/soc/qcom/Kconfig                | 12 +++++
>>   drivers/soc/qcom/Makefile               |  1 +
>>   drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
> 
> drivers/soc/ is the dumping ground for things with no other place. As
> this is a pstore driver, it belongs with pstore.

The inspiration of this driver was taken from 
drivers/platform/chrome/chromeos_pstore.c, do you think that is misplaced ?

> 
>>   3 files changed, 98 insertions(+)
>>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>>
>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
>> index 1834213fd652..fbf08e30feda 100644
>> --- a/drivers/soc/qcom/Kconfig
>> +++ b/drivers/soc/qcom/Kconfig
>> @@ -306,4 +306,16 @@ config QCOM_MINIDUMP_SMEM
>>
>>            This config should be enabled if the low level minidump is implemented
>>            as part of SMEM.
>> +
>> +config QCOM_PSTORE_MINIDUMP
>> +       tristate "Pstore support for QCOM Minidump"
>> +       depends on ARCH_QCOM
>> +       depends on PSTORE_RAM
>> +       depends on QCOM_MINIDUMP
>> +       help
>> +         Enablement of this driver ensures that ramoops region can be anywhere
>> +         reserved in ram instead of being fixed address which needs boot firmware
>> +         awareness. So, this driver creates plaform device and registers available
>> +         frontend region with the Qualcomm's minidump driver.
>> +
>>   endmenu
>> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
>> index 737d868757ac..1ab59c1b364d 100644
>> --- a/drivers/soc/qcom/Makefile
>> +++ b/drivers/soc/qcom/Makefile
>> @@ -36,3 +36,4 @@ qcom_ice-objs                 += ice.o
>>   obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)        += qcom_ice.o
>>   obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>>   obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
>> +obj-$(CONFIG_QCOM_PSTORE_MINIDUMP) += qcom_pstore_minidump.o
>> diff --git a/drivers/soc/qcom/qcom_pstore_minidump.c b/drivers/soc/qcom/qcom_pstore_minidump.c
>> new file mode 100644
>> index 000000000000..b07cd10340df
>> --- /dev/null
>> +++ b/drivers/soc/qcom/qcom_pstore_minidump.c
>> @@ -0,0 +1,85 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +
>> +/*
>> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
> 
> You probably don't need this include. Use the actual includes you need
> and don't rely on implicit includes (because I'm trying to remove
> those).

Ok, will try to check..

- Mukesh

> 
>> +#include <linux/of_reserved_mem.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/pstore_ram.h>
>> +
>> +struct qcom_ramoops_dd {
>> +       struct ramoops_platform_data qcom_ramoops_pdata;
>> +       struct platform_device *ramoops_pdev;
>> +};
>> +
>> +static int qcom_ramoops_probe(struct platform_device *pdev)
>> +{
>> +       struct device_node *of_node = pdev->dev.of_node;
>> +       struct qcom_ramoops_dd *qcom_rdd;
>> +       struct ramoops_platform_data *pdata;
>> +       struct reserved_mem *rmem;
>> +       struct device_node *node;
>> +       long ret;
>> +
>> +       node = of_parse_phandle(of_node, "memory-region", 0);
>> +       if (!node)
>> +               return -ENODEV;
>> +
>> +       rmem = of_reserved_mem_lookup(node);
>> +       of_node_put(node);
>> +       if (!rmem) {
>> +               dev_err(&pdev->dev, "failed to locate DT /reserved-memory resource\n");
>> +               return -EINVAL;
>> +       }
>> +
>> +       qcom_rdd = devm_kzalloc(&pdev->dev, sizeof(*qcom_rdd), GFP_KERNEL);
>> +       if (!qcom_rdd)
>> +               return -ENOMEM;
>> +
>> +       pdata = &qcom_rdd->qcom_ramoops_pdata;
>> +       pdata->mem_size = rmem->size;
>> +       pdata->mem_address = rmem->base;
>> +       ramoops_parse_dt(pdev, pdata);
>> +
>> +       qcom_rdd->ramoops_pdev = platform_device_register_data(NULL, "ramoops", -1,
>> +                                                              pdata, sizeof(*pdata));
>> +       if (IS_ERR(qcom_rdd->ramoops_pdev)) {
>> +               ret = PTR_ERR(qcom_rdd->ramoops_pdev);
>> +               dev_err(&pdev->dev, "could not create platform device: %ld\n", ret);
>> +               qcom_rdd->ramoops_pdev = NULL;
>> +       }
>> +       platform_set_drvdata(pdev, qcom_rdd);
>> +
>> +       return ret;
>> +}
>> +
>> +static void qcom_ramoops_remove(struct platform_device *pdev)
>> +{
>> +       struct qcom_ramoops_dd *qcom_rdd = platform_get_drvdata(pdev);
>> +
>> +       platform_device_unregister(qcom_rdd->ramoops_pdev);
>> +       qcom_rdd->ramoops_pdev = NULL;
>> +}
>> +
>> +static const struct of_device_id qcom_ramoops_of_match[] = {
>> +       { .compatible = "qcom,ramoops"},
>> +       {}
>> +};
>> +MODULE_DEVICE_TABLE(of, qcom_ramoops_of_match);
>> +
>> +static struct platform_driver qcom_ramoops_drv = {
>> +       .driver         = {
>> +               .name   = "qcom,ramoops",
>> +               .of_match_table = qcom_ramoops_of_match,
>> +       },
>> +       .probe = qcom_ramoops_probe,
>> +       .remove_new = qcom_ramoops_remove,
>> +};
>> +
>> +module_platform_driver(qcom_ramoops_drv);
>> +
>> +MODULE_DESCRIPTION("Qualcomm ramoops minidump driver");
>> +MODULE_LICENSE("GPL");
>> --
>> 2.7.4
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
  2023-06-28 15:51     ` Pavan Kondeti
@ 2023-06-29  9:20       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-29  9:20 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 9:21 PM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
>> -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
>> -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
>> -				void *dest, size_t offset, size_t size))
>> +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
>> +		void (*rproc_dumpfn_t)(struct rproc *rproc,
>> +		struct rproc_dump_segment *segment, void *dest, size_t offset,
>> +		size_t size))
>>   {
>> -	struct minidump_region __iomem *ptr;
>> -	struct minidump_region region;
>> -	int seg_cnt, i;
>>   	dma_addr_t da;
>>   	size_t size;
>> +	int seg_cnt;
>>   	char *name;
>> +	void *ptr;
>> +	int ret;
>> +	int i;
>>   
>>   	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
>>   		dev_err(&rproc->dev, "dump segment list already populated\n");
>> -		return -EUCLEAN;
>> +		return;
>>   	}
>>   
>> -	seg_cnt = le32_to_cpu(subsystem->region_count);
>> -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
>> -		      seg_cnt * sizeof(struct minidump_region));
>> +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
>>   	if (!ptr)
>> -		return -EFAULT;
>> +		return;
>>   
>>   	for (i = 0; i < seg_cnt; i++) {
>> -		memcpy_fromio(&region, ptr + i, sizeof(region));
>> -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
>> -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
>> -			if (!name) {
>> -				iounmap(ptr);
>> -				return -ENOMEM;
>> -			}
>> -			da = le64_to_cpu(region.address);
>> -			size = le64_to_cpu(region.size);
>> -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
>> +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
>> +		if (ret < 0) {
>> +			iounmap(ptr);
>> +			dev_err(&rproc->dev,
>> +				"Failed with error: %d while adding minidump entries\n",
>> +				ret);
>> +			goto clean_minidump;
>>   		}
>> -	}
>> -
>> -	iounmap(ptr);
>> -	return 0;
>> -}
>> -
>> -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
>> -		void (*rproc_dumpfn_t)(struct rproc *rproc,
>> -		struct rproc_dump_segment *segment, void *dest, size_t offset,
>> -		size_t size))
>> -{
>> -	int ret;
>> -	struct minidump_subsystem *subsystem;
>> -	struct minidump_global_toc *toc;
>> -
>> -	/* Get Global minidump ToC*/
>> -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
>> -
>> -	/* check if global table pointer exists and init is set */
>> -	if (IS_ERR(toc) || !toc->status) {
>> -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
>> -		return;
>> -	}
>>   
>> -	/* Get subsystem table of contents using the minidump id */
>> -	subsystem = &toc->subsystems[minidump_id];
>> -
>> -	/**
>> -	 * Collect minidump if SS ToC is valid and segment table
>> -	 * is initialized in memory and encryption status is set.
>> -	 */
>> -	if (subsystem->regions_baseptr == 0 ||
>> -	    le32_to_cpu(subsystem->status) != 1 ||
>> -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
>> -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
>> -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
>> -		return;
>> +		/* if it is a valid segment */
>> +		if (!ret)
>> +			rproc_coredump_add_custom_segment(rproc, da, size,
>> +							  rproc_dumpfn_t, name);
>>   	}
>>   
>> -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
>> -	if (ret) {
>> -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
>> -		goto clean_minidump;
>> -	}
>> +	iounmap(ptr);
>>   	rproc_coredump_using_sections(rproc);
>> +
>>   clean_minidump:
>>   	qcom_minidump_cleanup(rproc);
>>   }
> 
> I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.
> 
> Is it possible to accept one function callback from remoteproc and do
> all of this in one function exported by minidump?
> 
> qcom_ss_valid_segment_info() seems a low level function to be exported..

It was ending up with circular dependency due to
rproc_coredump_add_custom_segment()


rproc_coredump => qcom_common => qcom_minidump_smem => rproc_coredump

-Mukesh

> 
> Thanks,
> Pavan
> 

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
@ 2023-06-29  9:20       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-29  9:20 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/28/2023 9:21 PM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
>> -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
>> -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
>> -				void *dest, size_t offset, size_t size))
>> +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
>> +		void (*rproc_dumpfn_t)(struct rproc *rproc,
>> +		struct rproc_dump_segment *segment, void *dest, size_t offset,
>> +		size_t size))
>>   {
>> -	struct minidump_region __iomem *ptr;
>> -	struct minidump_region region;
>> -	int seg_cnt, i;
>>   	dma_addr_t da;
>>   	size_t size;
>> +	int seg_cnt;
>>   	char *name;
>> +	void *ptr;
>> +	int ret;
>> +	int i;
>>   
>>   	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
>>   		dev_err(&rproc->dev, "dump segment list already populated\n");
>> -		return -EUCLEAN;
>> +		return;
>>   	}
>>   
>> -	seg_cnt = le32_to_cpu(subsystem->region_count);
>> -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
>> -		      seg_cnt * sizeof(struct minidump_region));
>> +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
>>   	if (!ptr)
>> -		return -EFAULT;
>> +		return;
>>   
>>   	for (i = 0; i < seg_cnt; i++) {
>> -		memcpy_fromio(&region, ptr + i, sizeof(region));
>> -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
>> -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
>> -			if (!name) {
>> -				iounmap(ptr);
>> -				return -ENOMEM;
>> -			}
>> -			da = le64_to_cpu(region.address);
>> -			size = le64_to_cpu(region.size);
>> -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
>> +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
>> +		if (ret < 0) {
>> +			iounmap(ptr);
>> +			dev_err(&rproc->dev,
>> +				"Failed with error: %d while adding minidump entries\n",
>> +				ret);
>> +			goto clean_minidump;
>>   		}
>> -	}
>> -
>> -	iounmap(ptr);
>> -	return 0;
>> -}
>> -
>> -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
>> -		void (*rproc_dumpfn_t)(struct rproc *rproc,
>> -		struct rproc_dump_segment *segment, void *dest, size_t offset,
>> -		size_t size))
>> -{
>> -	int ret;
>> -	struct minidump_subsystem *subsystem;
>> -	struct minidump_global_toc *toc;
>> -
>> -	/* Get Global minidump ToC*/
>> -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
>> -
>> -	/* check if global table pointer exists and init is set */
>> -	if (IS_ERR(toc) || !toc->status) {
>> -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
>> -		return;
>> -	}
>>   
>> -	/* Get subsystem table of contents using the minidump id */
>> -	subsystem = &toc->subsystems[minidump_id];
>> -
>> -	/**
>> -	 * Collect minidump if SS ToC is valid and segment table
>> -	 * is initialized in memory and encryption status is set.
>> -	 */
>> -	if (subsystem->regions_baseptr == 0 ||
>> -	    le32_to_cpu(subsystem->status) != 1 ||
>> -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
>> -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
>> -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
>> -		return;
>> +		/* if it is a valid segment */
>> +		if (!ret)
>> +			rproc_coredump_add_custom_segment(rproc, da, size,
>> +							  rproc_dumpfn_t, name);
>>   	}
>>   
>> -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
>> -	if (ret) {
>> -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
>> -		goto clean_minidump;
>> -	}
>> +	iounmap(ptr);
>>   	rproc_coredump_using_sections(rproc);
>> +
>>   clean_minidump:
>>   	qcom_minidump_cleanup(rproc);
>>   }
> 
> I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.
> 
> Is it possible to accept one function callback from remoteproc and do
> all of this in one function exported by minidump?
> 
> qcom_ss_valid_segment_info() seems a low level function to be exported..

It was ending up with circular dependency due to
rproc_coredump_add_custom_segment()


rproc_coredump => qcom_common => qcom_minidump_smem => rproc_coredump

-Mukesh

> 
> Thanks,
> Pavan
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
  2023-06-29  9:20       ` Mukesh Ojha
@ 2023-06-30  3:41         ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  3:41 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Thu, Jun 29, 2023 at 02:50:34PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 9:21 PM, Pavan Kondeti wrote:
> > On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
> > > -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
> > > -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
> > > -				void *dest, size_t offset, size_t size))
> > > +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> > > +		void (*rproc_dumpfn_t)(struct rproc *rproc,
> > > +		struct rproc_dump_segment *segment, void *dest, size_t offset,
> > > +		size_t size))
> > >   {
> > > -	struct minidump_region __iomem *ptr;
> > > -	struct minidump_region region;
> > > -	int seg_cnt, i;
> > >   	dma_addr_t da;
> > >   	size_t size;
> > > +	int seg_cnt;
> > >   	char *name;
> > > +	void *ptr;
> > > +	int ret;
> > > +	int i;
> > >   	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
> > >   		dev_err(&rproc->dev, "dump segment list already populated\n");
> > > -		return -EUCLEAN;
> > > +		return;
> > >   	}
> > > -	seg_cnt = le32_to_cpu(subsystem->region_count);
> > > -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
> > > -		      seg_cnt * sizeof(struct minidump_region));
> > > +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
> > >   	if (!ptr)
> > > -		return -EFAULT;
> > > +		return;
> > >   	for (i = 0; i < seg_cnt; i++) {
> > > -		memcpy_fromio(&region, ptr + i, sizeof(region));
> > > -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
> > > -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
> > > -			if (!name) {
> > > -				iounmap(ptr);
> > > -				return -ENOMEM;
> > > -			}
> > > -			da = le64_to_cpu(region.address);
> > > -			size = le64_to_cpu(region.size);
> > > -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
> > > +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
> > > +		if (ret < 0) {
> > > +			iounmap(ptr);
> > > +			dev_err(&rproc->dev,
> > > +				"Failed with error: %d while adding minidump entries\n",
> > > +				ret);
> > > +			goto clean_minidump;
> > >   		}
> > > -	}
> > > -
> > > -	iounmap(ptr);
> > > -	return 0;
> > > -}
> > > -
> > > -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> > > -		void (*rproc_dumpfn_t)(struct rproc *rproc,
> > > -		struct rproc_dump_segment *segment, void *dest, size_t offset,
> > > -		size_t size))
> > > -{
> > > -	int ret;
> > > -	struct minidump_subsystem *subsystem;
> > > -	struct minidump_global_toc *toc;
> > > -
> > > -	/* Get Global minidump ToC*/
> > > -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
> > > -
> > > -	/* check if global table pointer exists and init is set */
> > > -	if (IS_ERR(toc) || !toc->status) {
> > > -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
> > > -		return;
> > > -	}
> > > -	/* Get subsystem table of contents using the minidump id */
> > > -	subsystem = &toc->subsystems[minidump_id];
> > > -
> > > -	/**
> > > -	 * Collect minidump if SS ToC is valid and segment table
> > > -	 * is initialized in memory and encryption status is set.
> > > -	 */
> > > -	if (subsystem->regions_baseptr == 0 ||
> > > -	    le32_to_cpu(subsystem->status) != 1 ||
> > > -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
> > > -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
> > > -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
> > > -		return;
> > > +		/* if it is a valid segment */
> > > +		if (!ret)
> > > +			rproc_coredump_add_custom_segment(rproc, da, size,
> > > +							  rproc_dumpfn_t, name);
> > >   	}
> > > -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
> > > -	if (ret) {
> > > -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
> > > -		goto clean_minidump;
> > > -	}
> > > +	iounmap(ptr);
> > >   	rproc_coredump_using_sections(rproc);
> > > +
> > >   clean_minidump:
> > >   	qcom_minidump_cleanup(rproc);
> > >   }
> > 
> > I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.
> > 
> > Is it possible to accept one function callback from remoteproc and do
> > all of this in one function exported by minidump?
> > 
> > qcom_ss_valid_segment_info() seems a low level function to be exported..
> 
> It was ending up with circular dependency due to
> rproc_coredump_add_custom_segment()
> 
> 
> rproc_coredump => qcom_common => qcom_minidump_smem => rproc_coredump
> 

Where is the circular dependency here? Any API accepting callback would
end up like below

caller -> API(callback) -> (*callback) -> [in caller code ...]

May be I am missing something here.

AFAICS, the minidump could do everything except it does not know how to
create a segment and add it to rproc::dump_segments list. Is it not
possible to write a minidump API that accepts a callback and a list
head? we may not probably re-use rproc_coredump_add_custom_segment() as
is, but some refactoring allows/covers both cases..Pls give it a
thought.

This way we don't need to create an internal API like below

int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t
*da, size_t *size)

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol
@ 2023-06-30  3:41         ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  3:41 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Thu, Jun 29, 2023 at 02:50:34PM +0530, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 9:21 PM, Pavan Kondeti wrote:
> > On Wed, Jun 28, 2023 at 06:04:40PM +0530, Mukesh Ojha wrote:
> > > -static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsystem *subsystem,
> > > -			void (*rproc_dumpfn_t)(struct rproc *rproc, struct rproc_dump_segment *segment,
> > > -				void *dest, size_t offset, size_t size))
> > > +void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> > > +		void (*rproc_dumpfn_t)(struct rproc *rproc,
> > > +		struct rproc_dump_segment *segment, void *dest, size_t offset,
> > > +		size_t size))
> > >   {
> > > -	struct minidump_region __iomem *ptr;
> > > -	struct minidump_region region;
> > > -	int seg_cnt, i;
> > >   	dma_addr_t da;
> > >   	size_t size;
> > > +	int seg_cnt;
> > >   	char *name;
> > > +	void *ptr;
> > > +	int ret;
> > > +	int i;
> > >   	if (WARN_ON(!list_empty(&rproc->dump_segments))) {
> > >   		dev_err(&rproc->dev, "dump segment list already populated\n");
> > > -		return -EUCLEAN;
> > > +		return;
> > >   	}
> > > -	seg_cnt = le32_to_cpu(subsystem->region_count);
> > > -	ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr),
> > > -		      seg_cnt * sizeof(struct minidump_region));
> > > +	ptr = qcom_ss_md_mapped_base(minidump_id, &seg_cnt);
> > >   	if (!ptr)
> > > -		return -EFAULT;
> > > +		return;
> > >   	for (i = 0; i < seg_cnt; i++) {
> > > -		memcpy_fromio(&region, ptr + i, sizeof(region));
> > > -		if (le32_to_cpu(region.valid) == MINIDUMP_REGION_VALID) {
> > > -			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
> > > -			if (!name) {
> > > -				iounmap(ptr);
> > > -				return -ENOMEM;
> > > -			}
> > > -			da = le64_to_cpu(region.address);
> > > -			size = le64_to_cpu(region.size);
> > > -			rproc_coredump_add_custom_segment(rproc, da, size, rproc_dumpfn_t, name);
> > > +		ret = qcom_ss_valid_segment_info(ptr, i, &name, &da, &size);
> > > +		if (ret < 0) {
> > > +			iounmap(ptr);
> > > +			dev_err(&rproc->dev,
> > > +				"Failed with error: %d while adding minidump entries\n",
> > > +				ret);
> > > +			goto clean_minidump;
> > >   		}
> > > -	}
> > > -
> > > -	iounmap(ptr);
> > > -	return 0;
> > > -}
> > > -
> > > -void qcom_minidump(struct rproc *rproc, unsigned int minidump_id,
> > > -		void (*rproc_dumpfn_t)(struct rproc *rproc,
> > > -		struct rproc_dump_segment *segment, void *dest, size_t offset,
> > > -		size_t size))
> > > -{
> > > -	int ret;
> > > -	struct minidump_subsystem *subsystem;
> > > -	struct minidump_global_toc *toc;
> > > -
> > > -	/* Get Global minidump ToC*/
> > > -	toc = qcom_smem_get(QCOM_SMEM_HOST_ANY, SBL_MINIDUMP_SMEM_ID, NULL);
> > > -
> > > -	/* check if global table pointer exists and init is set */
> > > -	if (IS_ERR(toc) || !toc->status) {
> > > -		dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n");
> > > -		return;
> > > -	}
> > > -	/* Get subsystem table of contents using the minidump id */
> > > -	subsystem = &toc->subsystems[minidump_id];
> > > -
> > > -	/**
> > > -	 * Collect minidump if SS ToC is valid and segment table
> > > -	 * is initialized in memory and encryption status is set.
> > > -	 */
> > > -	if (subsystem->regions_baseptr == 0 ||
> > > -	    le32_to_cpu(subsystem->status) != 1 ||
> > > -	    le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED ||
> > > -	    le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) {
> > > -		dev_err(&rproc->dev, "Minidump not ready, skipping\n");
> > > -		return;
> > > +		/* if it is a valid segment */
> > > +		if (!ret)
> > > +			rproc_coredump_add_custom_segment(rproc, da, size,
> > > +							  rproc_dumpfn_t, name);
> > >   	}
> > > -	ret = qcom_add_minidump_segments(rproc, subsystem, rproc_dumpfn_t);
> > > -	if (ret) {
> > > -		dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret);
> > > -		goto clean_minidump;
> > > -	}
> > > +	iounmap(ptr);
> > >   	rproc_coredump_using_sections(rproc);
> > > +
> > >   clean_minidump:
> > >   	qcom_minidump_cleanup(rproc);
> > >   }
> > 
> > I like the idea of moving minidump pieces to drivers/soc/qcom/*minidump*.
> > 
> > Is it possible to accept one function callback from remoteproc and do
> > all of this in one function exported by minidump?
> > 
> > qcom_ss_valid_segment_info() seems a low level function to be exported..
> 
> It was ending up with circular dependency due to
> rproc_coredump_add_custom_segment()
> 
> 
> rproc_coredump => qcom_common => qcom_minidump_smem => rproc_coredump
> 

Where is the circular dependency here? Any API accepting callback would
end up like below

caller -> API(callback) -> (*callback) -> [in caller code ...]

May be I am missing something here.

AFAICS, the minidump could do everything except it does not know how to
create a segment and add it to rproc::dump_segments list. Is it not
possible to write a minidump API that accepts a callback and a list
head? we may not probably re-use rproc_coredump_add_custom_segment() as
is, but some refactoring allows/covers both cases..Pls give it a
thought.

This way we don't need to create an internal API like below

int qcom_ss_valid_segment_info(void *ptr, int i, char **name, dma_addr_t
*da, size_t *size)

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-30  4:55     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  4:55 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:38PM +0530, Mukesh Ojha wrote:
> +static int qcom_ramoops_md_region_register(struct device *dev, struct qcom_minidump_region **zone,
> +					   const char *name, phys_addr_t phys_addr,
> +					   unsigned long size)
> +{
> +	struct qcom_minidump_region *md_region;
> +	int ret;
> +
> +	if (!size)
> +		return 0;
> +
> +	md_region = devm_kzalloc(dev, sizeof(*md_region), GFP_KERNEL);
> +	if (!md_region)
> +		return -ENOMEM;
> +
> +	strscpy(md_region->name, name, sizeof(md_region->name));
> +	md_region->phys_addr = phys_addr;
> +	md_region->virt_addr = phys_to_virt(phys_addr);
> +	md_region->size = size;
> +	*zone = md_region;
> +	ret = qcom_minidump_region_register(md_region);
> +	if (ret)
> +		dev_err(dev, "failed to add %s in minidump: err: %d\n", name, ret);
> +
> +	return ret;
> +}
> +
> +static int qcom_ramoops_minidump_register(struct qcom_ramoops_dd *qcom_rdd)
> +{
> +	struct ramoops_platform_data *pdata = &qcom_rdd->qcom_ramoops_pdata;
> +	char name[MAX_NAME_LENGTH];
> +	size_t zone_sz;
> +	phys_addr_t phys_addr;
> +	int ret = 0;
> +	int i;
> +
> +	phys_addr = pdata->mem_address;
> +	for (i = 0; i < qcom_rdd->max_dump_cnt; i++) {
> +		scnprintf(name, sizeof(name), "KDMSG%d", i);
> +		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->dmesg_region[i], name, phys_addr,
> +			pdata->record_size);
> +		if (ret)
> +			return ret;
> +
> +		phys_addr += pdata->record_size;
> +	}
> +
> +	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->console_region, "KCONSOLE", phys_addr,
> +			pdata->console_size);
> +	if (ret)
> +		return ret;
> +
> +	phys_addr += pdata->console_size;
> +
> +	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->pmsg_region, "KPMSG", phys_addr,
> +			pdata->pmsg_size);
> +	if (ret)
> +		return ret;
> +
> +	phys_addr += pdata->pmsg_size;
> +
> +	zone_sz =  pdata->ftrace_size / qcom_rdd->max_ftrace_cnt;
> +	for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) {
> +		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->ftrace_region[i], "KFTRACE", phys_addr,
> +			zone_sz);
> +		if (ret)
> +			return ret;
> +
> +		phys_addr += zone_sz;
> +	}
> +
> +	return ret;
> +}

This may be the least of your worries, but plan to fix the error
handling in this function. The probe expects this function to self clean
when returning error.

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
@ 2023-06-30  4:55     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  4:55 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:38PM +0530, Mukesh Ojha wrote:
> +static int qcom_ramoops_md_region_register(struct device *dev, struct qcom_minidump_region **zone,
> +					   const char *name, phys_addr_t phys_addr,
> +					   unsigned long size)
> +{
> +	struct qcom_minidump_region *md_region;
> +	int ret;
> +
> +	if (!size)
> +		return 0;
> +
> +	md_region = devm_kzalloc(dev, sizeof(*md_region), GFP_KERNEL);
> +	if (!md_region)
> +		return -ENOMEM;
> +
> +	strscpy(md_region->name, name, sizeof(md_region->name));
> +	md_region->phys_addr = phys_addr;
> +	md_region->virt_addr = phys_to_virt(phys_addr);
> +	md_region->size = size;
> +	*zone = md_region;
> +	ret = qcom_minidump_region_register(md_region);
> +	if (ret)
> +		dev_err(dev, "failed to add %s in minidump: err: %d\n", name, ret);
> +
> +	return ret;
> +}
> +
> +static int qcom_ramoops_minidump_register(struct qcom_ramoops_dd *qcom_rdd)
> +{
> +	struct ramoops_platform_data *pdata = &qcom_rdd->qcom_ramoops_pdata;
> +	char name[MAX_NAME_LENGTH];
> +	size_t zone_sz;
> +	phys_addr_t phys_addr;
> +	int ret = 0;
> +	int i;
> +
> +	phys_addr = pdata->mem_address;
> +	for (i = 0; i < qcom_rdd->max_dump_cnt; i++) {
> +		scnprintf(name, sizeof(name), "KDMSG%d", i);
> +		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->dmesg_region[i], name, phys_addr,
> +			pdata->record_size);
> +		if (ret)
> +			return ret;
> +
> +		phys_addr += pdata->record_size;
> +	}
> +
> +	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->console_region, "KCONSOLE", phys_addr,
> +			pdata->console_size);
> +	if (ret)
> +		return ret;
> +
> +	phys_addr += pdata->console_size;
> +
> +	ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->pmsg_region, "KPMSG", phys_addr,
> +			pdata->pmsg_size);
> +	if (ret)
> +		return ret;
> +
> +	phys_addr += pdata->pmsg_size;
> +
> +	zone_sz =  pdata->ftrace_size / qcom_rdd->max_ftrace_cnt;
> +	for (i = 0; i < qcom_rdd->max_ftrace_cnt; i++) {
> +		ret = qcom_ramoops_md_region_register(qcom_rdd->dev,
> +			&qcom_rdd->ftrace_region[i], "KFTRACE", phys_addr,
> +			zone_sz);
> +		if (ret)
> +			return ret;
> +
> +		phys_addr += zone_sz;
> +	}
> +
> +	return ret;
> +}

This may be the least of your worries, but plan to fix the error
handling in this function. The probe expects this function to self clean
when returning error.

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-30  5:01     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  5:01 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:44PM +0530, Mukesh Ojha wrote:
> It was realized by Srinivas K. that there is a need of
> read-modify-write scm exported function so that it can
> be used by multiple clients.
> 
> Let's introduce qcom_scm_io_update_field() which masks
> out the bits and write the passed value to that
> bit-offset. Subsequent patch will use this function.
> 
> Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c            | 15 +++++++++++++++
>  include/linux/firmware/qcom/qcom_scm.h |  2 ++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index fde33acd46b7..104d86e49b97 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id)
>  }
>  EXPORT_SYMBOL(qcom_scm_set_remote_state);
>  
> +int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val)
> +{
> +	unsigned int old, new;
> +	int ret;
> +
> +	ret = qcom_scm_io_readl(addr, &old);
> +	if (ret)
> +		return ret;
> +
> +	new = (old & ~mask) | (val & mask);
> +
> +	return qcom_scm_io_writel(addr, new);
> +}

I believe this API leaves the atomicity part to the client. or how does
it work?

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function
@ 2023-06-30  5:01     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  5:01 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:44PM +0530, Mukesh Ojha wrote:
> It was realized by Srinivas K. that there is a need of
> read-modify-write scm exported function so that it can
> be used by multiple clients.
> 
> Let's introduce qcom_scm_io_update_field() which masks
> out the bits and write the passed value to that
> bit-offset. Subsequent patch will use this function.
> 
> Suggested-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom_scm.c            | 15 +++++++++++++++
>  include/linux/firmware/qcom/qcom_scm.h |  2 ++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index fde33acd46b7..104d86e49b97 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -407,6 +407,21 @@ int qcom_scm_set_remote_state(u32 state, u32 id)
>  }
>  EXPORT_SYMBOL(qcom_scm_set_remote_state);
>  
> +int qcom_scm_io_update_field(phys_addr_t addr, unsigned int mask, unsigned int val)
> +{
> +	unsigned int old, new;
> +	int ret;
> +
> +	ret = qcom_scm_io_readl(addr, &old);
> +	if (ret)
> +		return ret;
> +
> +	new = (old & ~mask) | (val & mask);
> +
> +	return qcom_scm_io_writel(addr, new);
> +}

I believe this API leaves the atomicity part to the client. or how does
it work?

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
  2023-06-28 12:34   ` Mukesh Ojha
@ 2023-06-30  5:25     ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  5:25 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:47PM +0530, Mukesh Ojha wrote:
> Currently on Qualcomm SoC, download_mode is enabled if
> CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected.
> 
> Refactor the code such that it supports multiple download
> modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config
> instead, give interface to set the download mode from
> module parameter.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/Kconfig    | 11 ---------
>  drivers/firmware/qcom_scm.c | 56 +++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 49 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
> index b59e3041fd62..ff7e9f330559 100644
> --- a/drivers/firmware/Kconfig
> +++ b/drivers/firmware/Kconfig
> @@ -215,17 +215,6 @@ config MTK_ADSP_IPC
>  config QCOM_SCM
>  	tristate
>  
> -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
> -	bool "Qualcomm download mode enabled by default"
> -	depends on QCOM_SCM
> -	help
> -	  A device with "download mode" enabled will upon an unexpected
> -	  warm-restart enter a special debug mode that allows the user to
> -	  "download" memory content over USB for offline postmortem analysis.
> -	  The feature can be enabled/disabled on the kernel command line.
> -
> -	  Say Y here to enable "download mode" by default.
> -
>  config SYSFB
>  	bool
>  	select BOOT_VESA_SUPPORT
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index a9ff77d16c42..946cb0f76a17 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -18,13 +18,13 @@
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
>  #include <linux/clk.h>
> +#include <linux/kstrtox.h>
>  #include <linux/reset-controller.h>
>  #include <linux/arm-smccc.h>
>  
>  #include "qcom_scm.h"
>  
> -static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
> -module_param(download_mode, bool, 0);
> +static u32 download_mode;
>  
>  #define SCM_HAS_CORE_CLK	BIT(0)
>  #define SCM_HAS_IFACE_CLK	BIT(1)
> @@ -82,6 +82,11 @@ static const char * const qcom_scm_convention_names[] = {
>  	[SMC_CONVENTION_LEGACY] = "smc legacy",
>  };
>  
> +static const char * const download_mode_name[] = {
> +	[QCOM_DOWNLOAD_NODUMP]	 = "off",
> +	[QCOM_DOWNLOAD_FULLDUMP] = "full",
> +};
> +
>  static struct qcom_scm *__scm;
>  
>  static int qcom_scm_clk_enable(void)
> @@ -442,8 +447,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>  	return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
>  }
>  
> -static void qcom_scm_set_download_mode(bool enable)
> +static void qcom_scm_set_download_mode(u32 download_mode)
>  {
> +	bool enable = !!download_mode;
>  	bool avail;
>  	int val;
>  	int ret = 0;
> @@ -454,7 +460,7 @@ static void qcom_scm_set_download_mode(bool enable)
>  	if (avail) {
>  		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>  	} else if (__scm->dload_mode_addr) {
> -		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
> +		val = download_mode;
>  		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
>  		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
>  				QCOM_DOWNLOAD_MODE_MASK, val);
> @@ -1425,6 +1431,42 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> +static int get_download_mode(char *buffer, const struct kernel_param *kp)
> +{
> +	if (download_mode >= ARRAY_SIZE(download_mode_name))
> +		return sysfs_emit(buffer, "unknown mode\n");
> +
> +	return sysfs_emit(buffer, "%s\n", download_mode_name[download_mode]);
> +}
> +
> +static int set_download_mode(const char *val, const struct kernel_param *kp)
> +{
> +	u32 old = download_mode;
> +	int ret;
> +
> +	ret = sysfs_match_string(download_mode_name, val);
> +	if (ret < 0) {
> +		download_mode = old;
> +		pr_err("qcom_scm: unknown download mode: %s\n", val);
> +		return -EINVAL;
> +	}

minor nit: %s/-EINVAL/ret 

> +
> +	download_mode = ret;
> +	if (__scm)
> +		qcom_scm_set_download_mode(download_mode);
> +
> +	return 0;
> +}
> +
> +static const struct kernel_param_ops download_mode_param_ops = {
> +	.get = get_download_mode,
> +	.set = set_download_mode,
> +};
> +
> +module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
> +MODULE_PARM_DESC(download_mode,
> +		"download mode: off/full are acceptable values");
> +

Since we are adding a sysfs file under /sys/module/qcom_scm/ , does it
need to be documented under ABI?

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
@ 2023-06-30  5:25     ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  5:25 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Wed, Jun 28, 2023 at 06:04:47PM +0530, Mukesh Ojha wrote:
> Currently on Qualcomm SoC, download_mode is enabled if
> CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT is selected.
> 
> Refactor the code such that it supports multiple download
> modes and drop CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT config
> instead, give interface to set the download mode from
> module parameter.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/Kconfig    | 11 ---------
>  drivers/firmware/qcom_scm.c | 56 +++++++++++++++++++++++++++++++++++++++------
>  2 files changed, 49 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
> index b59e3041fd62..ff7e9f330559 100644
> --- a/drivers/firmware/Kconfig
> +++ b/drivers/firmware/Kconfig
> @@ -215,17 +215,6 @@ config MTK_ADSP_IPC
>  config QCOM_SCM
>  	tristate
>  
> -config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
> -	bool "Qualcomm download mode enabled by default"
> -	depends on QCOM_SCM
> -	help
> -	  A device with "download mode" enabled will upon an unexpected
> -	  warm-restart enter a special debug mode that allows the user to
> -	  "download" memory content over USB for offline postmortem analysis.
> -	  The feature can be enabled/disabled on the kernel command line.
> -
> -	  Say Y here to enable "download mode" by default.
> -
>  config SYSFB
>  	bool
>  	select BOOT_VESA_SUPPORT
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index a9ff77d16c42..946cb0f76a17 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -18,13 +18,13 @@
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
>  #include <linux/clk.h>
> +#include <linux/kstrtox.h>
>  #include <linux/reset-controller.h>
>  #include <linux/arm-smccc.h>
>  
>  #include "qcom_scm.h"
>  
> -static bool download_mode = IS_ENABLED(CONFIG_QCOM_SCM_DOWNLOAD_MODE_DEFAULT);
> -module_param(download_mode, bool, 0);
> +static u32 download_mode;
>  
>  #define SCM_HAS_CORE_CLK	BIT(0)
>  #define SCM_HAS_IFACE_CLK	BIT(1)
> @@ -82,6 +82,11 @@ static const char * const qcom_scm_convention_names[] = {
>  	[SMC_CONVENTION_LEGACY] = "smc legacy",
>  };
>  
> +static const char * const download_mode_name[] = {
> +	[QCOM_DOWNLOAD_NODUMP]	 = "off",
> +	[QCOM_DOWNLOAD_FULLDUMP] = "full",
> +};
> +
>  static struct qcom_scm *__scm;
>  
>  static int qcom_scm_clk_enable(void)
> @@ -442,8 +447,9 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>  	return qcom_scm_call_atomic(__scm->dev, &desc, NULL);
>  }
>  
> -static void qcom_scm_set_download_mode(bool enable)
> +static void qcom_scm_set_download_mode(u32 download_mode)
>  {
> +	bool enable = !!download_mode;
>  	bool avail;
>  	int val;
>  	int ret = 0;
> @@ -454,7 +460,7 @@ static void qcom_scm_set_download_mode(bool enable)
>  	if (avail) {
>  		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>  	} else if (__scm->dload_mode_addr) {
> -		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
> +		val = download_mode;
>  		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
>  		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
>  				QCOM_DOWNLOAD_MODE_MASK, val);
> @@ -1425,6 +1431,42 @@ static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> +static int get_download_mode(char *buffer, const struct kernel_param *kp)
> +{
> +	if (download_mode >= ARRAY_SIZE(download_mode_name))
> +		return sysfs_emit(buffer, "unknown mode\n");
> +
> +	return sysfs_emit(buffer, "%s\n", download_mode_name[download_mode]);
> +}
> +
> +static int set_download_mode(const char *val, const struct kernel_param *kp)
> +{
> +	u32 old = download_mode;
> +	int ret;
> +
> +	ret = sysfs_match_string(download_mode_name, val);
> +	if (ret < 0) {
> +		download_mode = old;
> +		pr_err("qcom_scm: unknown download mode: %s\n", val);
> +		return -EINVAL;
> +	}

minor nit: %s/-EINVAL/ret 

> +
> +	download_mode = ret;
> +	if (__scm)
> +		qcom_scm_set_download_mode(download_mode);
> +
> +	return 0;
> +}
> +
> +static const struct kernel_param_ops download_mode_param_ops = {
> +	.get = get_download_mode,
> +	.set = set_download_mode,
> +};
> +
> +module_param_cb(download_mode, &download_mode_param_ops, NULL, 0644);
> +MODULE_PARM_DESC(download_mode,
> +		"download mode: off/full are acceptable values");
> +

Since we are adding a sysfs file under /sys/module/qcom_scm/ , does it
need to be documented under ABI?

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  2023-06-29  2:33     ` Pavan Kondeti
@ 2023-06-30  7:15       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30  7:15 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/29/2023 8:03 AM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:31PM +0530, Mukesh Ojha 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 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 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.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/soc/qcom/Kconfig                  |  15 +
>>   drivers/soc/qcom/Makefile                 |   2 +
>>   drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
>>   drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
>>   include/soc/qcom/qcom_minidump.h          |  35 +++
>>   5 files changed, 583 insertions(+)
>>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>>
>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
>> index 982310b5a1cb..874ee8c3efe0 100644
>> --- a/drivers/soc/qcom/Kconfig
>> +++ b/drivers/soc/qcom/Kconfig
>> @@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
>>   	tristate
>>   	select QCOM_SCM
>>   
>> +config QCOM_MINIDUMP
>> +	tristate "QCOM Minidump APSS Core Infrastructure"
>> +	depends on ARCH_QCOM
>> +	help
>> +	  This config allow linux core infrastructure for APSS minidump for
>> +	  underlying backend(smem etc.) which can hook themselves to this and
>> +	  work as one unit. So, this config should be selected in combination
>> +	  with its backend.
>> +
>> +	  After this Linux clients driver can register their internal data
>> +	  structures and debug messages as part of the apss minidump region
>> +	  and when the SoC is crashed, and these selective regions will be
>> +	  dumped instead of the entire DDR. This saves significant amount
>> +	  of time and/or storage space.
>> +
>>   config QCOM_MINIDUMP_SMEM
>>   	tristate "QCOM Minidump SMEM (as backend) Support"
>>   	depends on ARCH_QCOM
>> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
>> index 89b775512bef..737d868757ac 100644
>> --- a/drivers/soc/qcom/Makefile
>> +++ b/drivers/soc/qcom/Makefile
>> @@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
>>   obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
>>   qcom_ice-objs			+= ice.o
>>   obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
>> +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>> +obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
>> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
>> new file mode 100644
>> index 000000000000..7744e57843ab
>> --- /dev/null
>> +++ b/drivers/soc/qcom/qcom_minidump.c
>> @@ -0,0 +1,456 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>> +
>> +#include <linux/device.h>
>> +#include <linux/export.h>
>> +#include <linux/kallsyms.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/printk.h>
>> +#include <linux/string.h>
>> +
>> +#include "qcom_minidump_internal.h"
>> +
>> +/*
>> + * In some of the Old Qualcomm devices, boot firmware statically allocates 300
>> + * as total number of supported region (including all co-processors) in
>> + * 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
>> + * Linux to 201.
>> + */
>> +#define MAX_NUM_ENTRIES	  201
>> +#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
>> +
> 
> Should not we receive these constraints from backend?
> 
>> +/*
>> + * md_lock protects "md" during calls to qcom_minidump_backend_register(),
>> + * qcom_minidump_backend_unregister().
>> + */
>> +static DEFINE_MUTEX(md_lock);
>> +
>> +/* Only one front end will be attached to one back-end */
>> +static struct minidump *md;
>> +static char *md_backend;
>> +
> 
> Can you explain this a bit more? There is just one fronend, correct?
> Multiple possibilites of backend.

Sorry, for misleading with the comment.

Was trying to be explicit here that only one backend can be attached to
the front end ..

Will fix the confusion.

> 
> Is it a limitation at the moment that we support only one backend or
> plan to support more backends later for the same frontend. Pls clarify.
> 
>> +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);
>> +
>> +	return &eshdr[idx];
>> +}
>> +
> 
> [...]
> 
>> +/**
>> + * qcom_minidump_region_register() - Register region in APSS Minidump table.
>> + * @region: minidump region.
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
> 
> Are we not going to return any cookie upon success which can be passed
> to us during unregistration?

e.g, Let's just say if we return the region number as an cookies, the
problem i see that, we multiple unregistration is happening we will
be shifting the array upwards and that results in the index/cookies does
not retain the same for the shifted regions.

So, at the moment, client need to pass the same region for 
un-registration as they have passed for registration..

> 
>> +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
>> +{
>> +	int ret;
>> +
>> +	if (!qcom_minidump_valid_region(region))
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&md_lock);
>> +	if (!md) {
>> +		mutex_unlock(&md_lock);
>> +		pr_err("No backend registered yet, try again..");
>> +		return -EPROBE_DEFER;
>> +	}
>> +
>> +	ret = md->ops->md_region_register(md, region);
>> +	if (ret)
>> +		goto unlock;
>> +
> 
> The md_lock description in the beginning does not seems to be correct.
> It is not limited to backend registration. It has much wider usage.
> 
> You are holding the lock while calling into backend. Basically the
> synchronization is done in the front end.

Initially, the thought was to have the backend their own lock but that
is irrelevant as all the contention is there in the front end.

So, used the same lock for synchronization as i moved in developement
and the later that comment became obsolete.

Thanks for catching this.
will fix the comment.

> 
>> +	qcom_md_update_elf_header(region);
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
>> +
>> +/**
>> + * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
>> + * @region: minidump region.
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
>> +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
>> +{
>> +	int ret;
>> +
>> +	if (!qcom_minidump_valid_region(region))
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&md_lock);
>> +	if (!md) {
>> +		mutex_unlock(&md_lock);
>> +		pr_err("No backend registered yet, try again..");
>> +		return -EPROBE_DEFER;
>> +	}
>> +
>> +	ret = md->ops->md_region_unregister(md, region);
>> +	if (ret)
>> +		goto unlock;
>> +
> 
> The frontend is not validing that it is actually a registered client, it
> is left to backend. Seems that is more duplication in the backend(s).

For that front-end need to cache each registered entry and that is exact 
copy at the backend, will need extra memory for copied data, so, that's
the reason of this behavior.

> 
>> +	ret = qcom_minidump_clear_header(region);
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
> 
> can we create a namespace for exporting these symbols?

Any specific reason, you are suggesting this ?

> 
>> +
>> +static int qcom_minidump_add_elf_header(struct minidump *md_data)
>> +{
> 
> [...]
> 
>> +
>> +/**
>> + * qcom_minidump_backend_register() - Register backend minidump device.
>> + * @md_data: minidump backend driver data
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
>> +int qcom_minidump_backend_register(struct minidump *md_data)
>> +{
>> +	int ret;
>> +
>> +	if (!md_data->name || !md_data->dev ||
>> +	    !md_data->ops ||
>> +	    !md_data->ops->md_table_init ||
>> +	    !md_data->ops->md_region_register ||
>> +	    !md_data->ops->md_region_unregister ||
>> +	    !md_data->ops->md_table_exit) {
>> +		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (md_backend && strcmp(md_backend, md_data->name)) {
>> +		pr_warn("backend '%s' already in use: ignoring '%s'\n",
>> +			 md_backend, md_data->name);
>> +		return -EBUSY;
>> +	}
>> +
>> +	mutex_lock(&md_lock);
>> +	if (md) {
>> +		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
>> +			 md->name, md_data->name);
>> +		ret = -EBUSY;
>> +		goto unlock;
>> +	}
>> +
>> +	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
>> +		md_data->max_region_limit = MAX_NUM_ENTRIES;
>> +
>> +	ret = md_data->ops->md_table_init(md_data);
>> +	if (ret) {
>> +		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
>> +		goto unlock;
>> +	}
>> +
>> +	/* First entry would be ELF header */
>> +	ret = qcom_minidump_add_elf_header(md_data);
>> +	if (ret) {
>> +		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
>> +		md_data->ops->md_table_exit(md_data);
>> +		goto unlock;
>> +	}
>> +
>> +	md = md_data;
>> +	md_backend = kstrdup(md->name, GFP_KERNEL);
>> +	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
>> +
> 
> What is the need for keeping md_backend separately? md::name is already
> present.

It looks redundant, this is one of cleanup, missed, thanks..

> 
> Also, how do we prevent backend module unloading while it is inuse? or
> we don't need that constraint?

md_lock is there for that..

In next patch series, i am going to make all of this as static driver,
so that constraints will not be there ?

-Mukesh

> 
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);
> 
> Thanks,
> Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
@ 2023-06-30  7:15       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30  7:15 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio



On 6/29/2023 8:03 AM, Pavan Kondeti wrote:
> On Wed, Jun 28, 2023 at 06:04:31PM +0530, Mukesh Ojha 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 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 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.
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/soc/qcom/Kconfig                  |  15 +
>>   drivers/soc/qcom/Makefile                 |   2 +
>>   drivers/soc/qcom/qcom_minidump.c          | 456 ++++++++++++++++++++++++++++++
>>   drivers/soc/qcom/qcom_minidump_internal.h |  75 +++++
>>   include/soc/qcom/qcom_minidump.h          |  35 +++
>>   5 files changed, 583 insertions(+)
>>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>>
>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
>> index 982310b5a1cb..874ee8c3efe0 100644
>> --- a/drivers/soc/qcom/Kconfig
>> +++ b/drivers/soc/qcom/Kconfig
>> @@ -279,6 +279,21 @@ config QCOM_INLINE_CRYPTO_ENGINE
>>   	tristate
>>   	select QCOM_SCM
>>   
>> +config QCOM_MINIDUMP
>> +	tristate "QCOM Minidump APSS Core Infrastructure"
>> +	depends on ARCH_QCOM
>> +	help
>> +	  This config allow linux core infrastructure for APSS minidump for
>> +	  underlying backend(smem etc.) which can hook themselves to this and
>> +	  work as one unit. So, this config should be selected in combination
>> +	  with its backend.
>> +
>> +	  After this Linux clients driver can register their internal data
>> +	  structures and debug messages as part of the apss minidump region
>> +	  and when the SoC is crashed, and these selective regions will be
>> +	  dumped instead of the entire DDR. This saves significant amount
>> +	  of time and/or storage space.
>> +
>>   config QCOM_MINIDUMP_SMEM
>>   	tristate "QCOM Minidump SMEM (as backend) Support"
>>   	depends on ARCH_QCOM
>> diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
>> index 89b775512bef..737d868757ac 100644
>> --- a/drivers/soc/qcom/Makefile
>> +++ b/drivers/soc/qcom/Makefile
>> @@ -34,3 +34,5 @@ obj-$(CONFIG_QCOM_KRYO_L2_ACCESSORS) +=	kryo-l2-accessors.o
>>   obj-$(CONFIG_QCOM_ICC_BWMON)	+= icc-bwmon.o
>>   qcom_ice-objs			+= ice.o
>>   obj-$(CONFIG_QCOM_INLINE_CRYPTO_ENGINE)	+= qcom_ice.o
>> +obj-$(CONFIG_QCOM_MINIDUMP) += qcom_minidump.o
>> +obj-$(CONFIG_QCOM_MINIDUMP_SMEM) += qcom_minidump_smem.o
>> diff --git a/drivers/soc/qcom/qcom_minidump.c b/drivers/soc/qcom/qcom_minidump.c
>> new file mode 100644
>> index 000000000000..7744e57843ab
>> --- /dev/null
>> +++ b/drivers/soc/qcom/qcom_minidump.c
>> @@ -0,0 +1,456 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
>> + */
>> +
>> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>> +
>> +#include <linux/device.h>
>> +#include <linux/export.h>
>> +#include <linux/kallsyms.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/printk.h>
>> +#include <linux/string.h>
>> +
>> +#include "qcom_minidump_internal.h"
>> +
>> +/*
>> + * In some of the Old Qualcomm devices, boot firmware statically allocates 300
>> + * as total number of supported region (including all co-processors) in
>> + * 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
>> + * Linux to 201.
>> + */
>> +#define MAX_NUM_ENTRIES	  201
>> +#define MAX_STRTBL_SIZE	  (MAX_NUM_ENTRIES * MAX_REGION_NAME_LENGTH)
>> +
> 
> Should not we receive these constraints from backend?
> 
>> +/*
>> + * md_lock protects "md" during calls to qcom_minidump_backend_register(),
>> + * qcom_minidump_backend_unregister().
>> + */
>> +static DEFINE_MUTEX(md_lock);
>> +
>> +/* Only one front end will be attached to one back-end */
>> +static struct minidump *md;
>> +static char *md_backend;
>> +
> 
> Can you explain this a bit more? There is just one fronend, correct?
> Multiple possibilites of backend.

Sorry, for misleading with the comment.

Was trying to be explicit here that only one backend can be attached to
the front end ..

Will fix the confusion.

> 
> Is it a limitation at the moment that we support only one backend or
> plan to support more backends later for the same frontend. Pls clarify.
> 
>> +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);
>> +
>> +	return &eshdr[idx];
>> +}
>> +
> 
> [...]
> 
>> +/**
>> + * qcom_minidump_region_register() - Register region in APSS Minidump table.
>> + * @region: minidump region.
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
> 
> Are we not going to return any cookie upon success which can be passed
> to us during unregistration?

e.g, Let's just say if we return the region number as an cookies, the
problem i see that, we multiple unregistration is happening we will
be shifting the array upwards and that results in the index/cookies does
not retain the same for the shifted regions.

So, at the moment, client need to pass the same region for 
un-registration as they have passed for registration..

> 
>> +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
>> +{
>> +	int ret;
>> +
>> +	if (!qcom_minidump_valid_region(region))
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&md_lock);
>> +	if (!md) {
>> +		mutex_unlock(&md_lock);
>> +		pr_err("No backend registered yet, try again..");
>> +		return -EPROBE_DEFER;
>> +	}
>> +
>> +	ret = md->ops->md_region_register(md, region);
>> +	if (ret)
>> +		goto unlock;
>> +
> 
> The md_lock description in the beginning does not seems to be correct.
> It is not limited to backend registration. It has much wider usage.
> 
> You are holding the lock while calling into backend. Basically the
> synchronization is done in the front end.

Initially, the thought was to have the backend their own lock but that
is irrelevant as all the contention is there in the front end.

So, used the same lock for synchronization as i moved in developement
and the later that comment became obsolete.

Thanks for catching this.
will fix the comment.

> 
>> +	qcom_md_update_elf_header(region);
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
>> +
>> +/**
>> + * qcom_minidump_region_unregister() - Unregister region from APSS Minidump table.
>> + * @region: minidump region.
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
>> +int qcom_minidump_region_unregister(const struct qcom_minidump_region *region)
>> +{
>> +	int ret;
>> +
>> +	if (!qcom_minidump_valid_region(region))
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&md_lock);
>> +	if (!md) {
>> +		mutex_unlock(&md_lock);
>> +		pr_err("No backend registered yet, try again..");
>> +		return -EPROBE_DEFER;
>> +	}
>> +
>> +	ret = md->ops->md_region_unregister(md, region);
>> +	if (ret)
>> +		goto unlock;
>> +
> 
> The frontend is not validing that it is actually a registered client, it
> is left to backend. Seems that is more duplication in the backend(s).

For that front-end need to cache each registered entry and that is exact 
copy at the backend, will need extra memory for copied data, so, that's
the reason of this behavior.

> 
>> +	ret = qcom_minidump_clear_header(region);
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
> 
> can we create a namespace for exporting these symbols?

Any specific reason, you are suggesting this ?

> 
>> +
>> +static int qcom_minidump_add_elf_header(struct minidump *md_data)
>> +{
> 
> [...]
> 
>> +
>> +/**
>> + * qcom_minidump_backend_register() - Register backend minidump device.
>> + * @md_data: minidump backend driver data
>> + *
>> + * Return: On success, it returns 0 and negative error value on failure.
>> + */
>> +int qcom_minidump_backend_register(struct minidump *md_data)
>> +{
>> +	int ret;
>> +
>> +	if (!md_data->name || !md_data->dev ||
>> +	    !md_data->ops ||
>> +	    !md_data->ops->md_table_init ||
>> +	    !md_data->ops->md_region_register ||
>> +	    !md_data->ops->md_region_unregister ||
>> +	    !md_data->ops->md_table_exit) {
>> +		pr_warn("backend '%s' must fill/implement necessary fields\n", md->name);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (md_backend && strcmp(md_backend, md_data->name)) {
>> +		pr_warn("backend '%s' already in use: ignoring '%s'\n",
>> +			 md_backend, md_data->name);
>> +		return -EBUSY;
>> +	}
>> +
>> +	mutex_lock(&md_lock);
>> +	if (md) {
>> +		dev_warn(md->dev, "backend '%s' already loaded: ignoring '%s'\n",
>> +			 md->name, md_data->name);
>> +		ret = -EBUSY;
>> +		goto unlock;
>> +	}
>> +
>> +	if (!md_data->max_region_limit || md_data->max_region_limit > MAX_NUM_ENTRIES)
>> +		md_data->max_region_limit = MAX_NUM_ENTRIES;
>> +
>> +	ret = md_data->ops->md_table_init(md_data);
>> +	if (ret) {
>> +		dev_err(md_data->dev, "minidump backend initialization failed: %d\n", ret);
>> +		goto unlock;
>> +	}
>> +
>> +	/* First entry would be ELF header */
>> +	ret = qcom_minidump_add_elf_header(md_data);
>> +	if (ret) {
>> +		dev_err(md_data->dev, "Failed to add elf header: %d\n", ret);
>> +		md_data->ops->md_table_exit(md_data);
>> +		goto unlock;
>> +	}
>> +
>> +	md = md_data;
>> +	md_backend = kstrdup(md->name, GFP_KERNEL);
>> +	dev_info(md->dev, "Registered minidump backend : %s\n", md->name);
>> +
> 
> What is the need for keeping md_backend separately? md::name is already
> present.

It looks redundant, this is one of cleanup, missed, thanks..

> 
> Also, how do we prevent backend module unloading while it is inuse? or
> we don't need that constraint?

md_lock is there for that..

In next patch series, i am going to make all of this as static driver,
so that constraints will not be there ?

-Mukesh

> 
>> +unlock:
>> +	mutex_unlock(&md_lock);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(qcom_minidump_backend_register);
> 
> Thanks,
> Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
  2023-06-30  7:15       ` Mukesh Ojha
@ 2023-06-30  8:38         ` Pavan Kondeti
  -1 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  8:38 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Fri, Jun 30, 2023 at 12:45:13PM +0530, Mukesh Ojha wrote:
> > > +/**
> > > + * qcom_minidump_region_register() - Register region in APSS Minidump table.
> > > + * @region: minidump region.
> > > + *
> > > + * Return: On success, it returns 0 and negative error value on failure.
> > > + */
> > 
> > Are we not going to return any cookie upon success which can be passed
> > to us during unregistration?
> 
> e.g, Let's just say if we return the region number as an cookies, the
> problem i see that, we multiple unregistration is happening we will
> be shifting the array upwards and that results in the index/cookies does
> not retain the same for the shifted regions.
> 
> So, at the moment, client need to pass the same region for un-registration
> as they have passed for registration..
> 

From a driver user pov, there is no reason for keeping
qcom_minidump_region struct around after the registration, agree?
However, the unregistration API expects it again, so the driver needs to
cache it. The region is no way being used by the minidump core either..so it is
just there for no reason. Hence I asked this question.

Thanks for the explanation about why the region number can't be used as
cookie. Is it a limitation on the firmware that we need to left shift
all regions when a region is deleted? I ask this because
minidump_region::valid is avaialble for Linux to mark a lazy deletion.
Sure your look up would have to traverse the entire array in worst case,
but today also you are doing that for duplicate name check.
If this lazy deletion can be implemented, the region number can be used
a cookie, right?

> > 
> > > +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
> > > +{
> > > +	int ret;
> > > +
> > > +	if (!qcom_minidump_valid_region(region))
> > > +		return -EINVAL;
> > > +
> > > +	mutex_lock(&md_lock);
> > > +	if (!md) {
> > > +		mutex_unlock(&md_lock);
> > > +		pr_err("No backend registered yet, try again..");
> > > +		return -EPROBE_DEFER;
> > > +	}
> > > +
> > > +	ret = md->ops->md_region_register(md, region);
> > > +	if (ret)
> > > +		goto unlock;
> > > +
> > 
> > The md_lock description in the beginning does not seems to be correct.
> > It is not limited to backend registration. It has much wider usage.
> > 
> > You are holding the lock while calling into backend. Basically the
> > synchronization is done in the front end.
> 
> Initially, the thought was to have the backend their own lock but that
> is irrelevant as all the contention is there in the front end.
> 
> So, used the same lock for synchronization as i moved in developement
> and the later that comment became obsolete.
> 
> Thanks for catching this.
> will fix the comment.
> 

Sure

> > 
> > > +	qcom_md_update_elf_header(region);
> > > +unlock:
> > > +	mutex_unlock(&md_lock);
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
> 
> > 
> > > +	ret = qcom_minidump_clear_header(region);
> > > +unlock:
> > > +	mutex_unlock(&md_lock);
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
> > 
> > can we create a namespace for exporting these symbols?
> 
> Any specific reason, you are suggesting this ?
> 

My original intention was to mark qcom_minidump_backend_register()
and qcom_minidump_backend_unregister() under a namespace. Because these
are not meant for any drivers but only for minidump backend. That serves
as a clear documentation that minidump implementation is spanned across
this frontend and backend modules.

Thanks,
Pavan

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 04/21] soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
@ 2023-06-30  8:38         ` Pavan Kondeti
  0 siblings, 0 replies; 176+ messages in thread
From: Pavan Kondeti @ 2023-06-30  8:38 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Pavan Kondeti, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko, linux-doc, linux-kernel, linux-arm-msm,
	devicetree, linux-hardening, linux-remoteproc, linux-arm-kernel,
	linux-gpio

On Fri, Jun 30, 2023 at 12:45:13PM +0530, Mukesh Ojha wrote:
> > > +/**
> > > + * qcom_minidump_region_register() - Register region in APSS Minidump table.
> > > + * @region: minidump region.
> > > + *
> > > + * Return: On success, it returns 0 and negative error value on failure.
> > > + */
> > 
> > Are we not going to return any cookie upon success which can be passed
> > to us during unregistration?
> 
> e.g, Let's just say if we return the region number as an cookies, the
> problem i see that, we multiple unregistration is happening we will
> be shifting the array upwards and that results in the index/cookies does
> not retain the same for the shifted regions.
> 
> So, at the moment, client need to pass the same region for un-registration
> as they have passed for registration..
> 

From a driver user pov, there is no reason for keeping
qcom_minidump_region struct around after the registration, agree?
However, the unregistration API expects it again, so the driver needs to
cache it. The region is no way being used by the minidump core either..so it is
just there for no reason. Hence I asked this question.

Thanks for the explanation about why the region number can't be used as
cookie. Is it a limitation on the firmware that we need to left shift
all regions when a region is deleted? I ask this because
minidump_region::valid is avaialble for Linux to mark a lazy deletion.
Sure your look up would have to traverse the entire array in worst case,
but today also you are doing that for duplicate name check.
If this lazy deletion can be implemented, the region number can be used
a cookie, right?

> > 
> > > +int qcom_minidump_region_register(const struct qcom_minidump_region *region)
> > > +{
> > > +	int ret;
> > > +
> > > +	if (!qcom_minidump_valid_region(region))
> > > +		return -EINVAL;
> > > +
> > > +	mutex_lock(&md_lock);
> > > +	if (!md) {
> > > +		mutex_unlock(&md_lock);
> > > +		pr_err("No backend registered yet, try again..");
> > > +		return -EPROBE_DEFER;
> > > +	}
> > > +
> > > +	ret = md->ops->md_region_register(md, region);
> > > +	if (ret)
> > > +		goto unlock;
> > > +
> > 
> > The md_lock description in the beginning does not seems to be correct.
> > It is not limited to backend registration. It has much wider usage.
> > 
> > You are holding the lock while calling into backend. Basically the
> > synchronization is done in the front end.
> 
> Initially, the thought was to have the backend their own lock but that
> is irrelevant as all the contention is there in the front end.
> 
> So, used the same lock for synchronization as i moved in developement
> and the later that comment became obsolete.
> 
> Thanks for catching this.
> will fix the comment.
> 

Sure

> > 
> > > +	qcom_md_update_elf_header(region);
> > > +unlock:
> > > +	mutex_unlock(&md_lock);
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(qcom_minidump_region_register);
> 
> > 
> > > +	ret = qcom_minidump_clear_header(region);
> > > +unlock:
> > > +	mutex_unlock(&md_lock);
> > > +	return ret;
> > > +}
> > > +EXPORT_SYMBOL_GPL(qcom_minidump_region_unregister);
> > 
> > can we create a namespace for exporting these symbols?
> 
> Any specific reason, you are suggesting this ?
> 

My original intention was to mark qcom_minidump_backend_register()
and qcom_minidump_backend_unregister() under a namespace. Because these
are not meant for any drivers but only for minidump backend. That serves
as a clear documentation that minidump implementation is spanned across
this frontend and backend modules.

Thanks,
Pavan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
  2023-06-30  4:55     ` Pavan Kondeti
@ 2023-06-30  9:25       ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-30  9:25 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Fri, Jun 30, 2023 at 7:55 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> On Wed, Jun 28, 2023 at 06:04:38PM +0530, Mukesh Ojha wrote:

...

> > +             scnprintf(name, sizeof(name), "KDMSG%d", i);

Also a side note: here you use the 'c' variant of sprintf(),why bother
with it if you don't even check the returned value?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 11/21] soc: qcom: Register pstore frontend region with minidump
@ 2023-06-30  9:25       ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-30  9:25 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Fri, Jun 30, 2023 at 7:55 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> On Wed, Jun 28, 2023 at 06:04:38PM +0530, Mukesh Ojha wrote:

...

> > +             scnprintf(name, sizeof(name), "KDMSG%d", i);

Also a side note: here you use the 'c' variant of sprintf(),why bother
with it if you don't even check the returned value?

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
  2023-06-30  5:25     ` Pavan Kondeti
@ 2023-06-30  9:28       ` Andy Shevchenko
  -1 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-30  9:28 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Fri, Jun 30, 2023 at 8:25 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> On Wed, Jun 28, 2023 at 06:04:47PM +0530, Mukesh Ojha wrote:

...

> > +static int set_download_mode(const char *val, const struct kernel_param *kp)
> > +{
> > +     u32 old = download_mode;
> > +     int ret;
> > +
> > +     ret = sysfs_match_string(download_mode_name, val);
> > +     if (ret < 0) {

> > +             download_mode = old;

Why is this old variable needed at all?

> > +             pr_err("qcom_scm: unknown download mode: %s\n", val);
> > +             return -EINVAL;
> > +     }
>
> minor nit: %s/-EINVAL/ret
>
> > +     download_mode = ret;
> > +     if (__scm)
> > +             qcom_scm_set_download_mode(download_mode);
> > +
> > +     return 0;
> > +}


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 20/21] firmware: qcom_scm: Refactor code to support multiple download mode
@ 2023-06-30  9:28       ` Andy Shevchenko
  0 siblings, 0 replies; 176+ messages in thread
From: Andy Shevchenko @ 2023-06-30  9:28 UTC (permalink / raw)
  To: Pavan Kondeti
  Cc: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Fri, Jun 30, 2023 at 8:25 AM Pavan Kondeti <quic_pkondeti@quicinc.com> wrote:
> On Wed, Jun 28, 2023 at 06:04:47PM +0530, Mukesh Ojha wrote:

...

> > +static int set_download_mode(const char *val, const struct kernel_param *kp)
> > +{
> > +     u32 old = download_mode;
> > +     int ret;
> > +
> > +     ret = sysfs_match_string(download_mode_name, val);
> > +     if (ret < 0) {

> > +             download_mode = old;

Why is this old variable needed at all?

> > +             pr_err("qcom_scm: unknown download mode: %s\n", val);
> > +             return -EINVAL;
> > +     }
>
> minor nit: %s/-EINVAL/ret
>
> > +     download_mode = ret;
> > +     if (__scm)
> > +             qcom_scm_set_download_mode(download_mode);
> > +
> > +     return 0;
> > +}


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
  2023-06-28 15:20     ` Konrad Dybcio
@ 2023-06-30 14:57       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 14:57 UTC (permalink / raw)
  To: Konrad Dybcio, corbet, agross, andersson, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 8:50 PM, Konrad Dybcio wrote:
> On 28.06.2023 14:34, Mukesh Ojha wrote:
>> CrashDump collection is based on the DLOAD bit of TCSR register.
>> To retain other bits, we read the register and modify only the
>> DLOAD bit as the other bits have their own significance.
>>
>> Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/firmware/qcom_scm.c | 12 ++++++++++--
>>   1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
>> index 104d86e49b97..a9ff77d16c42 100644
>> --- a/drivers/firmware/qcom_scm.c
>> +++ b/drivers/firmware/qcom_scm.c
>> @@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
>>   #define SCM_HAS_IFACE_CLK	BIT(1)
>>   #define SCM_HAS_BUS_CLK		BIT(2)
>>   
>> +#define QCOM_DOWNLOAD_FULLDUMP		 0x1
>> +#define QCOM_DOWNLOAD_NODUMP		 0x0
>> +#define QCOM_DOWNLOAD_MODE_SHIFT	   4
>> +#define QCOM_DOWNLOAD_MODE_MASK		0x30
> GENMASK and then FIELD_PREP below?

Just checked about FIELD_PREP, it works, thanks.

FIELD_PREP(GENMASK(5, 4), QCOM_DOWNLOAD_FULLDUMP)
FIELD_PREP(GENMASK(5, 4), QCOM_DOWNLOAD_NODUMP)

-Mukesh

> 
>> +
>>   struct qcom_scm {
>>   	struct device *dev;
>>   	struct clk *core_clk;
>> @@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>>   static void qcom_scm_set_download_mode(bool enable)
>>   {
>>   	bool avail;
>> +	int val;
> What's wrong with initializing it in the same line as ret?
> 
>>   	int ret = 0;
>>   
>>   	avail = __qcom_scm_is_call_available(__scm->dev,
>> @@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
>>   	if (avail) {
>>   		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>>   	} else if (__scm->dload_mode_addr) {
>> -		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
>> -				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
>> +		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
> unnecessary braces
> 
> Konrad
>> +		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
>> +		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
>> +				QCOM_DOWNLOAD_MODE_MASK, val);
>>   	} else {
>>   		dev_err(__scm->dev,
>>   			"No available mechanism for setting download mode\n");

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 19/21] firmware: scm: Modify only the download bits in TCSR register
@ 2023-06-30 14:57       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 14:57 UTC (permalink / raw)
  To: Konrad Dybcio, corbet, agross, andersson, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/28/2023 8:50 PM, Konrad Dybcio wrote:
> On 28.06.2023 14:34, Mukesh Ojha wrote:
>> CrashDump collection is based on the DLOAD bit of TCSR register.
>> To retain other bits, we read the register and modify only the
>> DLOAD bit as the other bits have their own significance.
>>
>> Co-developed-by: Poovendhan Selvaraj <quic_poovendh@quicinc.com>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>> ---
>>   drivers/firmware/qcom_scm.c | 12 ++++++++++--
>>   1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
>> index 104d86e49b97..a9ff77d16c42 100644
>> --- a/drivers/firmware/qcom_scm.c
>> +++ b/drivers/firmware/qcom_scm.c
>> @@ -30,6 +30,11 @@ module_param(download_mode, bool, 0);
>>   #define SCM_HAS_IFACE_CLK	BIT(1)
>>   #define SCM_HAS_BUS_CLK		BIT(2)
>>   
>> +#define QCOM_DOWNLOAD_FULLDUMP		 0x1
>> +#define QCOM_DOWNLOAD_NODUMP		 0x0
>> +#define QCOM_DOWNLOAD_MODE_SHIFT	   4
>> +#define QCOM_DOWNLOAD_MODE_MASK		0x30
> GENMASK and then FIELD_PREP below?

Just checked about FIELD_PREP, it works, thanks.

FIELD_PREP(GENMASK(5, 4), QCOM_DOWNLOAD_FULLDUMP)
FIELD_PREP(GENMASK(5, 4), QCOM_DOWNLOAD_NODUMP)

-Mukesh

> 
>> +
>>   struct qcom_scm {
>>   	struct device *dev;
>>   	struct clk *core_clk;
>> @@ -440,6 +445,7 @@ static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
>>   static void qcom_scm_set_download_mode(bool enable)
>>   {
>>   	bool avail;
>> +	int val;
> What's wrong with initializing it in the same line as ret?
> 
>>   	int ret = 0;
>>   
>>   	avail = __qcom_scm_is_call_available(__scm->dev,
>> @@ -448,8 +454,10 @@ static void qcom_scm_set_download_mode(bool enable)
>>   	if (avail) {
>>   		ret = __qcom_scm_set_dload_mode(__scm->dev, enable);
>>   	} else if (__scm->dload_mode_addr) {
>> -		ret = qcom_scm_io_writel(__scm->dload_mode_addr,
>> -				enable ? QCOM_SCM_BOOT_SET_DLOAD_MODE : 0);
>> +		val = (enable ? QCOM_DOWNLOAD_FULLDUMP : QCOM_DOWNLOAD_NODUMP);
> unnecessary braces
> 
> Konrad
>> +		val <<= QCOM_DOWNLOAD_MODE_SHIFT;
>> +		ret = qcom_scm_io_update_field(__scm->dload_mode_addr,
>> +				QCOM_DOWNLOAD_MODE_MASK, val);
>>   	} else {
>>   		dev_err(__scm->dev,
>>   			"No available mechanism for setting download mode\n");

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
  2023-06-28 13:44     ` Andy Shevchenko
@ 2023-06-30 14:58       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 14:58 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

Thanks for your time and suggestion.

On 6/28/2023 7:14 PM, Andy Shevchenko wrote:
> On Wed, Jun 28, 2023 at 3:37 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Use qcom_scm_io_update_field() exported function introduced
>> in last commit.
> 
> the last
> 
> But what is that? Be more specific.
> 
> ...
> 
>> +       mask = (GENMASK(2, 0) << g->intr_target_bit);
> 
> Outer parentheses are not needed.

Will apply the changes.

-Mukesh

> 

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 18/21] pinctrl: qcom: Use qcom_scm_io_update_field()
@ 2023-06-30 14:58       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 14:58 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

Thanks for your time and suggestion.

On 6/28/2023 7:14 PM, Andy Shevchenko wrote:
> On Wed, Jun 28, 2023 at 3:37 PM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>
>> Use qcom_scm_io_update_field() exported function introduced
>> in last commit.
> 
> the last
> 
> But what is that? Be more specific.
> 
> ...
> 
>> +       mask = (GENMASK(2, 0) << g->intr_target_bit);
> 
> Outer parentheses are not needed.

Will apply the changes.

-Mukesh

> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 23:12     ` Rob Herring
@ 2023-06-30 16:04       ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 16:04 UTC (permalink / raw)
  To: Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/29/2023 4:42 AM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 9:45 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>>
>> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
>>> included in the ramdump.
>>>
>>> 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(gunyah) 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.
>>
>> If you only have one "backend" then you don't need the extra compexity
>> here at all, just remove that whole middle layer please and make this
>> much simpler and smaller and easier to review and possibly accept.
> 
> pstore already supports backends. Why aren't the above backends just
> pstore backends rather than having an intermediate pstore backend in
> RAM which then somehow gets moved into these minidump backends.

It can't be another pstore backend since, pstore backend(ram) is for
the system where there is a guarantees of fixed ram range content 
persist across boot, but that is not true with minidump, there is no
pstorefs kind of support with minidump.

Instead, the whole idea of backend/front-end of minidump here, is
entirely related to minidump and here minidump backend could be
anything like could be Shared memory in DDR which is shared across
multiple subsystem (CPUSS) is one of them or it could be something
where you want to collect minidump for a guest vm which guest
does not have access to backend instead it may be the hypervisor
do the register the region for the guest.

Pstore(ram) is one of the clients of minidump where, we want to collect
the console/pmsg/ftrace/dmesg logs for production devices where
DDR dump is difficult and the reason of doing this to not re-invent
the wheel and it just need physical address/size .

  +---------+     +---------+   +--------+     +---------+
  | console |     | pmsg    |   | ftrace |     | dmesg   |
  +---------+     +---------+   +--------+     +---------+
        |             |             |              |
        |             |             |              |
        +------------------------------------------+
                           |
                          \ /
                   +----------------+
             (1)   |pstore frontends|
                   +----------------+
                           |
                          \ /
                  +------------------- +
             (2)  | pstore backend(ram)|
                  +--------------------+
                           |
                          \ /
                  +--------------------+
             (3)  |qcom_pstore_minidump|
                  +--------------------+

-Mukesh
> 
>> We don't add layers when they are not needed, and never when there is no
>> actual user.  If you need the extra "complexity" later, then add it
>> later when it is needed as who knows when that will ever be.
>>
>> Please redo this series based on that, thanks.
> 
> My bigger issue with this whole series is what would this all look
> like if every SoC vendor upstreamed their own custom dumping
> mechanism. That would be a mess. (I have similar opinions on the
> $soc-vendor hypervisors.)
> 
> Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-06-30 16:04       ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-06-30 16:04 UTC (permalink / raw)
  To: Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 6/29/2023 4:42 AM, Rob Herring wrote:
> On Wed, Jun 28, 2023 at 9:45 AM Greg KH <gregkh@linuxfoundation.org> wrote:
>>
>> On Wed, Jun 28, 2023 at 06:04:27PM +0530, Mukesh Ojha 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 which snippets should be
>>> included in the ramdump.
>>>
>>> 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(gunyah) 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.
>>
>> If you only have one "backend" then you don't need the extra compexity
>> here at all, just remove that whole middle layer please and make this
>> much simpler and smaller and easier to review and possibly accept.
> 
> pstore already supports backends. Why aren't the above backends just
> pstore backends rather than having an intermediate pstore backend in
> RAM which then somehow gets moved into these minidump backends.

It can't be another pstore backend since, pstore backend(ram) is for
the system where there is a guarantees of fixed ram range content 
persist across boot, but that is not true with minidump, there is no
pstorefs kind of support with minidump.

Instead, the whole idea of backend/front-end of minidump here, is
entirely related to minidump and here minidump backend could be
anything like could be Shared memory in DDR which is shared across
multiple subsystem (CPUSS) is one of them or it could be something
where you want to collect minidump for a guest vm which guest
does not have access to backend instead it may be the hypervisor
do the register the region for the guest.

Pstore(ram) is one of the clients of minidump where, we want to collect
the console/pmsg/ftrace/dmesg logs for production devices where
DDR dump is difficult and the reason of doing this to not re-invent
the wheel and it just need physical address/size .

  +---------+     +---------+   +--------+     +---------+
  | console |     | pmsg    |   | ftrace |     | dmesg   |
  +---------+     +---------+   +--------+     +---------+
        |             |             |              |
        |             |             |              |
        +------------------------------------------+
                           |
                          \ /
                   +----------------+
             (1)   |pstore frontends|
                   +----------------+
                           |
                          \ /
                  +------------------- +
             (2)  | pstore backend(ram)|
                  +--------------------+
                           |
                          \ /
                  +--------------------+
             (3)  |qcom_pstore_minidump|
                  +--------------------+

-Mukesh
> 
>> We don't add layers when they are not needed, and never when there is no
>> actual user.  If you need the extra "complexity" later, then add it
>> later when it is needed as who knows when that will ever be.
>>
>> Please redo this series based on that, thanks.
> 
> My bigger issue with this whole series is what would this all look
> like if every SoC vendor upstreamed their own custom dumping
> mechanism. That would be a mess. (I have similar opinions on the
> $soc-vendor hypervisors.)
> 
> Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-07-02  8:08   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:08 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On 28/06/2023 14:34, Mukesh Ojha 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.
> 

...hundred of unrelated lines...

>  #define PANIC_PRINT_TASK_INFO          0x00000001
>  #define PANIC_PRINT_MEM_INFO           0x00000002
> @@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
>         int old_cpu, this_cpu;
>         bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
> 
> +       in_panic = true;
>         if (panic_on_warn) {
>                 /*
>                  * This thread may hit another WARN() in the panic path.
> --------------------------------------------------------------------------
> 
> Changes in v4:

Putting changelog at the end of very long cover letter does no help us
to find it.

>  - Redesigned the driver and divided the driver into front end and backend (smem) so
>    that any new backend can be attached easily to avoid code duplication.
>  - Patch reordering as per the driver and subsystem to easier review of the code.
>  - Removed minidump specific code from remoteproc to minidump smem based driver.
>  - Enabled the all the driver as modules.
>  - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]

That's not enough. Your binding changed a lot and I doubt we proposed
such changes. You need to be specific.

>  - Address comments made qcom_pstore_minidump driver and given its Device tree
>    same set of properties as ramoops. [Luca/Kees]
>  - Added patch for MAINTAINER file.
>  - Include defconfig change as one patch as per [Krzysztof] suggestion.
>  - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
>  - Addressed comments made on dload mode patch v6 version 
>    https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
> 
> 

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-02  8:08   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:08 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio

On 28/06/2023 14:34, Mukesh Ojha 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.
> 

...hundred of unrelated lines...

>  #define PANIC_PRINT_TASK_INFO          0x00000001
>  #define PANIC_PRINT_MEM_INFO           0x00000002
> @@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
>         int old_cpu, this_cpu;
>         bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
> 
> +       in_panic = true;
>         if (panic_on_warn) {
>                 /*
>                  * This thread may hit another WARN() in the panic path.
> --------------------------------------------------------------------------
> 
> Changes in v4:

Putting changelog at the end of very long cover letter does no help us
to find it.

>  - Redesigned the driver and divided the driver into front end and backend (smem) so
>    that any new backend can be attached easily to avoid code duplication.
>  - Patch reordering as per the driver and subsystem to easier review of the code.
>  - Removed minidump specific code from remoteproc to minidump smem based driver.
>  - Enabled the all the driver as modules.
>  - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]

That's not enough. Your binding changed a lot and I doubt we proposed
such changes. You need to be specific.

>  - Address comments made qcom_pstore_minidump driver and given its Device tree
>    same set of properties as ramoops. [Luca/Kees]
>  - Added patch for MAINTAINER file.
>  - Include defconfig change as one patch as per [Krzysztof] suggestion.
>  - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
>  - Addressed comments made on dload mode patch v6 version 
>    https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
> 
> 

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-06-28 15:01       ` Mukesh Ojha
@ 2023-07-02  8:12         ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:12 UTC (permalink / raw)
  To: Mukesh Ojha, Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On 28/06/2023 17:01, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 8:17 PM, Rob Herring wrote:
>> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>
>>> Qualcomm ramoops minidump logger provide a means of storing
>>> the ramoops data to some dynamically reserved memory instead
>>> of traditionally implemented ramoops where the region should
>>> be statically fixed ram region. Its device tree binding
>>> would be exactly same as ramoops device tree binding and is
>>> going to contain traditional ramoops frontend data and this
>>> content will be collected via Qualcomm minidump infrastructure
>>> provided from the boot firmware.
>>
>> The big difference is if firmware is not deciding where this log
>> lives, then it doesn't need to be in DT. How does anything except the
>> kernel that allocates the log find the logs?
> 
> Yes, you are correct, firmware is not deciding where the logs lives
> instead here, Kernel has reserved the region where the ramoops region
> lives and later with the minidump registration where, physical
> address/size/virtual address(for parsing) are passed and that is how
> firmware is able to know and dump those region before triggering system
> reset.

Your explanation does not justify storing all this in DT. Kernel can
allocate any memory it wishes, store there logs and pass the address to
the firmware. That's it, no need for DT.

> 
> A part of this registration code you can find in 11/21
> 
>> I'm pretty sure I already said all this before.
> 
> Yes, you said this before but that's the reason i came up with vendor
> ramoops instead of changing traditional ramoops binding.

That's unexpected conclusion. Adding more bindings is not the answer to
comment that it should not be in the DTS in the first place.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-02  8:12         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:12 UTC (permalink / raw)
  To: Mukesh Ojha, Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On 28/06/2023 17:01, Mukesh Ojha wrote:
> 
> 
> On 6/28/2023 8:17 PM, Rob Herring wrote:
>> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>
>>> Qualcomm ramoops minidump logger provide a means of storing
>>> the ramoops data to some dynamically reserved memory instead
>>> of traditionally implemented ramoops where the region should
>>> be statically fixed ram region. Its device tree binding
>>> would be exactly same as ramoops device tree binding and is
>>> going to contain traditional ramoops frontend data and this
>>> content will be collected via Qualcomm minidump infrastructure
>>> provided from the boot firmware.
>>
>> The big difference is if firmware is not deciding where this log
>> lives, then it doesn't need to be in DT. How does anything except the
>> kernel that allocates the log find the logs?
> 
> Yes, you are correct, firmware is not deciding where the logs lives
> instead here, Kernel has reserved the region where the ramoops region
> lives and later with the minidump registration where, physical
> address/size/virtual address(for parsing) are passed and that is how
> firmware is able to know and dump those region before triggering system
> reset.

Your explanation does not justify storing all this in DT. Kernel can
allocate any memory it wishes, store there logs and pass the address to
the firmware. That's it, no need for DT.

> 
> A part of this registration code you can find in 11/21
> 
>> I'm pretty sure I already said all this before.
> 
> Yes, you said this before but that's the reason i came up with vendor
> ramoops instead of changing traditional ramoops binding.

That's unexpected conclusion. Adding more bindings is not the answer to
comment that it should not be in the DTS in the first place.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-30 16:04       ` Mukesh Ojha
@ 2023-07-02  8:29         ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:29 UTC (permalink / raw)
  To: Mukesh Ojha, Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio, Alex Elder

On 30/06/2023 18:04, Mukesh Ojha wrote:
>>
>>> We don't add layers when they are not needed, and never when there is no
>>> actual user.  If you need the extra "complexity" later, then add it
>>> later when it is needed as who knows when that will ever be.
>>>
>>> Please redo this series based on that, thanks.
>>
>> My bigger issue with this whole series is what would this all look
>> like if every SoC vendor upstreamed their own custom dumping
>> mechanism. That would be a mess. (I have similar opinions on the
>> $soc-vendor hypervisors.)

Mukesh,

LPC CFP is still open. There will be also Android and Kernel Debugging
LPC microconference tracks. Coming with a unified solution could be a
great topic for LPC. Solutions targeting only one user are quite often
frowned upon.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-02  8:29         ` Krzysztof Kozlowski
  0 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-02  8:29 UTC (permalink / raw)
  To: Mukesh Ojha, Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio, Alex Elder

On 30/06/2023 18:04, Mukesh Ojha wrote:
>>
>>> We don't add layers when they are not needed, and never when there is no
>>> actual user.  If you need the extra "complexity" later, then add it
>>> later when it is needed as who knows when that will ever be.
>>>
>>> Please redo this series based on that, thanks.
>>
>> My bigger issue with this whole series is what would this all look
>> like if every SoC vendor upstreamed their own custom dumping
>> mechanism. That would be a mess. (I have similar opinions on the
>> $soc-vendor hypervisors.)

Mukesh,

LPC CFP is still open. There will be also Android and Kernel Debugging
LPC microconference tracks. Coming with a unified solution could be a
great topic for LPC. Solutions targeting only one user are quite often
frowned upon.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-07-02  8:12         ` Krzysztof Kozlowski
@ 2023-07-03  6:21           ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-03  6:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
> On 28/06/2023 17:01, Mukesh Ojha wrote:
>>
>>
>> On 6/28/2023 8:17 PM, Rob Herring wrote:
>>> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>>
>>>> Qualcomm ramoops minidump logger provide a means of storing
>>>> the ramoops data to some dynamically reserved memory instead
>>>> of traditionally implemented ramoops where the region should
>>>> be statically fixed ram region. Its device tree binding
>>>> would be exactly same as ramoops device tree binding and is
>>>> going to contain traditional ramoops frontend data and this
>>>> content will be collected via Qualcomm minidump infrastructure
>>>> provided from the boot firmware.
>>>
>>> The big difference is if firmware is not deciding where this log
>>> lives, then it doesn't need to be in DT. How does anything except the
>>> kernel that allocates the log find the logs?
>>
>> Yes, you are correct, firmware is not deciding where the logs lives
>> instead here, Kernel has reserved the region where the ramoops region
>> lives and later with the minidump registration where, physical
>> address/size/virtual address(for parsing) are passed and that is how
>> firmware is able to know and dump those region before triggering system
>> reset.
> 
> Your explanation does not justify storing all this in DT. Kernel can
> allocate any memory it wishes, store there logs and pass the address to
> the firmware. That's it, no need for DT.

If you go through the driver, you will know that what it does, is
just create platform device for actual ramoops driver to probe and to
provide this it needs exact set of parameters of input what original 
ramoops DT provides, we need to keep it in DT as maintaining this in
driver will not scale well with different size/parameter size
requirement for different targets.

> 
>>
>> A part of this registration code you can find in 11/21
>>
>>> I'm pretty sure I already said all this before.
>>
>> Yes, you said this before but that's the reason i came up with vendor
>> ramoops instead of changing traditional ramoops binding.
> 
> That's unexpected conclusion. Adding more bindings is not the answer to
> comment that it should not be in the DTS in the first place.

Please suggest, what is the other way being above text as requirement..

-- Mukesh
> 
> Best regards,
> Krzysztof
> 

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-03  6:21           ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-03  6:21 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio



On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
> On 28/06/2023 17:01, Mukesh Ojha wrote:
>>
>>
>> On 6/28/2023 8:17 PM, Rob Herring wrote:
>>> On Wed, Jun 28, 2023 at 6:36 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>>
>>>> Qualcomm ramoops minidump logger provide a means of storing
>>>> the ramoops data to some dynamically reserved memory instead
>>>> of traditionally implemented ramoops where the region should
>>>> be statically fixed ram region. Its device tree binding
>>>> would be exactly same as ramoops device tree binding and is
>>>> going to contain traditional ramoops frontend data and this
>>>> content will be collected via Qualcomm minidump infrastructure
>>>> provided from the boot firmware.
>>>
>>> The big difference is if firmware is not deciding where this log
>>> lives, then it doesn't need to be in DT. How does anything except the
>>> kernel that allocates the log find the logs?
>>
>> Yes, you are correct, firmware is not deciding where the logs lives
>> instead here, Kernel has reserved the region where the ramoops region
>> lives and later with the minidump registration where, physical
>> address/size/virtual address(for parsing) are passed and that is how
>> firmware is able to know and dump those region before triggering system
>> reset.
> 
> Your explanation does not justify storing all this in DT. Kernel can
> allocate any memory it wishes, store there logs and pass the address to
> the firmware. That's it, no need for DT.

If you go through the driver, you will know that what it does, is
just create platform device for actual ramoops driver to probe and to
provide this it needs exact set of parameters of input what original 
ramoops DT provides, we need to keep it in DT as maintaining this in
driver will not scale well with different size/parameter size
requirement for different targets.

> 
>>
>> A part of this registration code you can find in 11/21
>>
>>> I'm pretty sure I already said all this before.
>>
>> Yes, you said this before but that's the reason i came up with vendor
>> ramoops instead of changing traditional ramoops binding.
> 
> That's unexpected conclusion. Adding more bindings is not the answer to
> comment that it should not be in the DTS in the first place.

Please suggest, what is the other way being above text as requirement..

-- Mukesh
> 
> Best regards,
> Krzysztof
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-07-03  6:21           ` Mukesh Ojha
@ 2023-07-03  7:20             ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03  7:20 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
> >>> The big difference is if firmware is not deciding where this log
> >>> lives, then it doesn't need to be in DT. How does anything except the
> >>> kernel that allocates the log find the logs?
> >>
> >> Yes, you are correct, firmware is not deciding where the logs lives
> >> instead here, Kernel has reserved the region where the ramoops region
> >> lives and later with the minidump registration where, physical
> >> address/size/virtual address(for parsing) are passed and that is how
> >> firmware is able to know and dump those region before triggering system
> >> reset.
> >
> > Your explanation does not justify storing all this in DT. Kernel can
> > allocate any memory it wishes, store there logs and pass the address to
> > the firmware. That's it, no need for DT.
>
> If you go through the driver, you will know that what it does, is

We talk about bindings and I should not be forced to look at the
driver to be able to understand them. Bindings should stand on their
own.

> just create platform device for actual ramoops driver to probe and to

Not really justification for Devicetree anyway. Whatever your driver
is doing, is driver's business, not bindings.

> provide this it needs exact set of parameters of input what original
> ramoops DT provides, we need to keep it in DT as maintaining this in
> driver will not scale well with different size/parameter size
> requirement for different targets.

Really? Why? I don't see a problem in scaling. At all.

>
> >
> >>
> >> A part of this registration code you can find in 11/21
> >>
> >>> I'm pretty sure I already said all this before.
> >>
> >> Yes, you said this before but that's the reason i came up with vendor
> >> ramoops instead of changing traditional ramoops binding.
> >
> > That's unexpected conclusion. Adding more bindings is not the answer to
> > comment that it should not be in the DTS in the first place.
>
> Please suggest, what is the other way being above text as requirement..

I do not see any requirement for us there. Forcing me to figure out
how to add non-hardware property to DT is not the way to convince
reviewers. But if you insist - we have ABI for this, called sysfs. If
it is debugging feature, then debugfs.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-03  7:20             ` Krzysztof Kozlowski
  0 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03  7:20 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
> >>> The big difference is if firmware is not deciding where this log
> >>> lives, then it doesn't need to be in DT. How does anything except the
> >>> kernel that allocates the log find the logs?
> >>
> >> Yes, you are correct, firmware is not deciding where the logs lives
> >> instead here, Kernel has reserved the region where the ramoops region
> >> lives and later with the minidump registration where, physical
> >> address/size/virtual address(for parsing) are passed and that is how
> >> firmware is able to know and dump those region before triggering system
> >> reset.
> >
> > Your explanation does not justify storing all this in DT. Kernel can
> > allocate any memory it wishes, store there logs and pass the address to
> > the firmware. That's it, no need for DT.
>
> If you go through the driver, you will know that what it does, is

We talk about bindings and I should not be forced to look at the
driver to be able to understand them. Bindings should stand on their
own.

> just create platform device for actual ramoops driver to probe and to

Not really justification for Devicetree anyway. Whatever your driver
is doing, is driver's business, not bindings.

> provide this it needs exact set of parameters of input what original
> ramoops DT provides, we need to keep it in DT as maintaining this in
> driver will not scale well with different size/parameter size
> requirement for different targets.

Really? Why? I don't see a problem in scaling. At all.

>
> >
> >>
> >> A part of this registration code you can find in 11/21
> >>
> >>> I'm pretty sure I already said all this before.
> >>
> >> Yes, you said this before but that's the reason i came up with vendor
> >> ramoops instead of changing traditional ramoops binding.
> >
> > That's unexpected conclusion. Adding more bindings is not the answer to
> > comment that it should not be in the DTS in the first place.
>
> Please suggest, what is the other way being above text as requirement..

I do not see any requirement for us there. Forcing me to figure out
how to add non-hardware property to DT is not the way to convince
reviewers. But if you insist - we have ABI for this, called sysfs. If
it is debugging feature, then debugfs.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-07-03  7:20             ` Krzysztof Kozlowski
@ 2023-07-03 15:55               ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-03 15:55 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio



On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>> The big difference is if firmware is not deciding where this log
>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>> kernel that allocates the log find the logs?
>>>>
>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>> instead here, Kernel has reserved the region where the ramoops region
>>>> lives and later with the minidump registration where, physical
>>>> address/size/virtual address(for parsing) are passed and that is how
>>>> firmware is able to know and dump those region before triggering system
>>>> reset.
>>>
>>> Your explanation does not justify storing all this in DT. Kernel can
>>> allocate any memory it wishes, store there logs and pass the address to
>>> the firmware. That's it, no need for DT.
>>
>> If you go through the driver, you will know that what it does, is
> 
> We talk about bindings and I should not be forced to look at the
> driver to be able to understand them. Bindings should stand on their
> own.

Why can't ramoops binding have one more feature where it can add a flag 
*dynamic* to indicate the regions are dynamic and it is for platforms
where there is another entity 'minidump' who is interested in these
regions.

> 
>> just create platform device for actual ramoops driver to probe and to
> 
> Not really justification for Devicetree anyway. Whatever your driver
> is doing, is driver's business, not bindings.
> 
>> provide this it needs exact set of parameters of input what original
>> ramoops DT provides, we need to keep it in DT as maintaining this in
>> driver will not scale well with different size/parameter size
>> requirement for different targets.
> 
> Really? Why? I don't see a problem in scaling. At all.

I had attempted it here,

https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/

but got comments related to hard coding and some in favor of having
the same set of properties what ramoops has/provides

https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/

https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/
> 
>>
>>>
>>>>
>>>> A part of this registration code you can find in 11/21
>>>>
>>>>> I'm pretty sure I already said all this before.
>>>>
>>>> Yes, you said this before but that's the reason i came up with vendor
>>>> ramoops instead of changing traditional ramoops binding.
>>>
>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>> comment that it should not be in the DTS in the first place.
>>
>> Please suggest, what is the other way being above text as requirement..
> 
> I do not see any requirement for us there. Forcing me to figure out
> how to add non-hardware property to DT is not the way to convince
> reviewers. But if you insist - we have ABI for this, called sysfs. If
> it is debugging feature, then debugfs.

ramoops already support module params and a way to pass these parameters
from bootargs but it also need to know the hard-codes addresses, so, 
doing something in sysfs will be again duplication with ramoops driver..

If this can be accommodated under ramoops, this will be very small 
change, like this

https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/

-- Mukesh
> 
> Best regards,
> Krzysztof

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-03 15:55               ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-03 15:55 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio



On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>> The big difference is if firmware is not deciding where this log
>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>> kernel that allocates the log find the logs?
>>>>
>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>> instead here, Kernel has reserved the region where the ramoops region
>>>> lives and later with the minidump registration where, physical
>>>> address/size/virtual address(for parsing) are passed and that is how
>>>> firmware is able to know and dump those region before triggering system
>>>> reset.
>>>
>>> Your explanation does not justify storing all this in DT. Kernel can
>>> allocate any memory it wishes, store there logs and pass the address to
>>> the firmware. That's it, no need for DT.
>>
>> If you go through the driver, you will know that what it does, is
> 
> We talk about bindings and I should not be forced to look at the
> driver to be able to understand them. Bindings should stand on their
> own.

Why can't ramoops binding have one more feature where it can add a flag 
*dynamic* to indicate the regions are dynamic and it is for platforms
where there is another entity 'minidump' who is interested in these
regions.

> 
>> just create platform device for actual ramoops driver to probe and to
> 
> Not really justification for Devicetree anyway. Whatever your driver
> is doing, is driver's business, not bindings.
> 
>> provide this it needs exact set of parameters of input what original
>> ramoops DT provides, we need to keep it in DT as maintaining this in
>> driver will not scale well with different size/parameter size
>> requirement for different targets.
> 
> Really? Why? I don't see a problem in scaling. At all.

I had attempted it here,

https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/

but got comments related to hard coding and some in favor of having
the same set of properties what ramoops has/provides

https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/

https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/
> 
>>
>>>
>>>>
>>>> A part of this registration code you can find in 11/21
>>>>
>>>>> I'm pretty sure I already said all this before.
>>>>
>>>> Yes, you said this before but that's the reason i came up with vendor
>>>> ramoops instead of changing traditional ramoops binding.
>>>
>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>> comment that it should not be in the DTS in the first place.
>>
>> Please suggest, what is the other way being above text as requirement..
> 
> I do not see any requirement for us there. Forcing me to figure out
> how to add non-hardware property to DT is not the way to convince
> reviewers. But if you insist - we have ABI for this, called sysfs. If
> it is debugging feature, then debugfs.

ramoops already support module params and a way to pass these parameters
from bootargs but it also need to know the hard-codes addresses, so, 
doing something in sysfs will be again duplication with ramoops driver..

If this can be accommodated under ramoops, this will be very small 
change, like this

https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/

-- Mukesh
> 
> Best regards,
> Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-02  8:29         ` Krzysztof Kozlowski
@ 2023-07-03 21:05           ` Trilok Soni
  -1 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-03 21:05 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mukesh Ojha, Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio, Alex Elder

On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>
>>>> We don't add layers when they are not needed, and never when there is no
>>>> actual user.  If you need the extra "complexity" later, then add it
>>>> later when it is needed as who knows when that will ever be.
>>>>
>>>> Please redo this series based on that, thanks.
>>>
>>> My bigger issue with this whole series is what would this all look
>>> like if every SoC vendor upstreamed their own custom dumping
>>> mechanism. That would be a mess. (I have similar opinions on the
>>> $soc-vendor hypervisors.)
> 
> Mukesh,
> 
> LPC CFP is still open. There will be also Android and Kernel Debugging
> LPC microconference tracks. Coming with a unified solution could be a
> great topic for LPC. Solutions targeting only one user are quite often
> frowned upon.

LPC is far out and in November. Can we not have others speak up if they 
have the similar solution now? We can expand this to linux-kernel and 
ask for the other SOC vendors to chime in. I am sure that we may have 
existing solutions which came in for the one user first like Intel RDT 
if I remember. I am sure ARM MPAM usecase was present at that time but 
Intel RDT based solution which was x86 specific but accepted.

---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-03 21:05           ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-03 21:05 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mukesh Ojha, Rob Herring, Greg KH
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio, Alex Elder

On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>
>>>> We don't add layers when they are not needed, and never when there is no
>>>> actual user.  If you need the extra "complexity" later, then add it
>>>> later when it is needed as who knows when that will ever be.
>>>>
>>>> Please redo this series based on that, thanks.
>>>
>>> My bigger issue with this whole series is what would this all look
>>> like if every SoC vendor upstreamed their own custom dumping
>>> mechanism. That would be a mess. (I have similar opinions on the
>>> $soc-vendor hypervisors.)
> 
> Mukesh,
> 
> LPC CFP is still open. There will be also Android and Kernel Debugging
> LPC microconference tracks. Coming with a unified solution could be a
> great topic for LPC. Solutions targeting only one user are quite often
> frowned upon.

LPC is far out and in November. Can we not have others speak up if they 
have the similar solution now? We can expand this to linux-kernel and 
ask for the other SOC vendors to chime in. I am sure that we may have 
existing solutions which came in for the one user first like Intel RDT 
if I remember. I am sure ARM MPAM usecase was present at that time but 
Intel RDT based solution which was x86 specific but accepted.

---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-07-03 15:55               ` Mukesh Ojha
@ 2023-07-04  5:57                 ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-04  5:57 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 03/07/2023 17:55, Mukesh Ojha wrote:
> 
> 
> On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
>> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>>> The big difference is if firmware is not deciding where this log
>>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>>> kernel that allocates the log find the logs?
>>>>>
>>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>>> instead here, Kernel has reserved the region where the ramoops region
>>>>> lives and later with the minidump registration where, physical
>>>>> address/size/virtual address(for parsing) are passed and that is how
>>>>> firmware is able to know and dump those region before triggering system
>>>>> reset.
>>>>
>>>> Your explanation does not justify storing all this in DT. Kernel can
>>>> allocate any memory it wishes, store there logs and pass the address to
>>>> the firmware. That's it, no need for DT.
>>>
>>> If you go through the driver, you will know that what it does, is
>>
>> We talk about bindings and I should not be forced to look at the
>> driver to be able to understand them. Bindings should stand on their
>> own.
> 
> Why can't ramoops binding have one more feature where it can add a flag 
> *dynamic* to indicate the regions are dynamic and it is for platforms
> where there is another entity 'minidump' who is interested in these
> regions.

Because we do not define dynamic stuff in Devicetree. Dynamic means
defined by SW or runtime configurable. It is against the entire idea of
Devicetree which is for non-discoverable hardware.

> 
>>
>>> just create platform device for actual ramoops driver to probe and to
>>
>> Not really justification for Devicetree anyway. Whatever your driver
>> is doing, is driver's business, not bindings.
>>
>>> provide this it needs exact set of parameters of input what original
>>> ramoops DT provides, we need to keep it in DT as maintaining this in
>>> driver will not scale well with different size/parameter size
>>> requirement for different targets.
>>
>> Really? Why? I don't see a problem in scaling. At all.
> 
> I had attempted it here,
> 
> https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/
> 
> but got comments related to hard coding and some in favor of having
> the same set of properties what ramoops has/provides
> 
> https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/
> 
> https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/

Then you were tricked. I don't get why someone else suggests that
non-hardware property should be part of Devicetree, but anyway it's the
call of Devicetree binding maintainers, not someone else. DT is not
dumping ground for all the system configuration variables.


>>
>>>
>>>>
>>>>>
>>>>> A part of this registration code you can find in 11/21
>>>>>
>>>>>> I'm pretty sure I already said all this before.
>>>>>
>>>>> Yes, you said this before but that's the reason i came up with vendor
>>>>> ramoops instead of changing traditional ramoops binding.
>>>>
>>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>>> comment that it should not be in the DTS in the first place.
>>>
>>> Please suggest, what is the other way being above text as requirement..
>>
>> I do not see any requirement for us there. Forcing me to figure out
>> how to add non-hardware property to DT is not the way to convince
>> reviewers. But if you insist - we have ABI for this, called sysfs. If
>> it is debugging feature, then debugfs.
> 
> ramoops already support module params and a way to pass these parameters
> from bootargs but it also need to know the hard-codes addresses, so, 
> doing something in sysfs will be again duplication with ramoops driver..

Why do you need hard-coded addresses?

> 
> If this can be accommodated under ramoops, this will be very small 
> change, like this
> 
> https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/

That's also funny patch - missing bindings updated, missing CC DT
maintainers.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-04  5:57                 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 176+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-04  5:57 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 03/07/2023 17:55, Mukesh Ojha wrote:
> 
> 
> On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
>> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>>> The big difference is if firmware is not deciding where this log
>>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>>> kernel that allocates the log find the logs?
>>>>>
>>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>>> instead here, Kernel has reserved the region where the ramoops region
>>>>> lives and later with the minidump registration where, physical
>>>>> address/size/virtual address(for parsing) are passed and that is how
>>>>> firmware is able to know and dump those region before triggering system
>>>>> reset.
>>>>
>>>> Your explanation does not justify storing all this in DT. Kernel can
>>>> allocate any memory it wishes, store there logs and pass the address to
>>>> the firmware. That's it, no need for DT.
>>>
>>> If you go through the driver, you will know that what it does, is
>>
>> We talk about bindings and I should not be forced to look at the
>> driver to be able to understand them. Bindings should stand on their
>> own.
> 
> Why can't ramoops binding have one more feature where it can add a flag 
> *dynamic* to indicate the regions are dynamic and it is for platforms
> where there is another entity 'minidump' who is interested in these
> regions.

Because we do not define dynamic stuff in Devicetree. Dynamic means
defined by SW or runtime configurable. It is against the entire idea of
Devicetree which is for non-discoverable hardware.

> 
>>
>>> just create platform device for actual ramoops driver to probe and to
>>
>> Not really justification for Devicetree anyway. Whatever your driver
>> is doing, is driver's business, not bindings.
>>
>>> provide this it needs exact set of parameters of input what original
>>> ramoops DT provides, we need to keep it in DT as maintaining this in
>>> driver will not scale well with different size/parameter size
>>> requirement for different targets.
>>
>> Really? Why? I don't see a problem in scaling. At all.
> 
> I had attempted it here,
> 
> https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/
> 
> but got comments related to hard coding and some in favor of having
> the same set of properties what ramoops has/provides
> 
> https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/
> 
> https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/

Then you were tricked. I don't get why someone else suggests that
non-hardware property should be part of Devicetree, but anyway it's the
call of Devicetree binding maintainers, not someone else. DT is not
dumping ground for all the system configuration variables.


>>
>>>
>>>>
>>>>>
>>>>> A part of this registration code you can find in 11/21
>>>>>
>>>>>> I'm pretty sure I already said all this before.
>>>>>
>>>>> Yes, you said this before but that's the reason i came up with vendor
>>>>> ramoops instead of changing traditional ramoops binding.
>>>>
>>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>>> comment that it should not be in the DTS in the first place.
>>>
>>> Please suggest, what is the other way being above text as requirement..
>>
>> I do not see any requirement for us there. Forcing me to figure out
>> how to add non-hardware property to DT is not the way to convince
>> reviewers. But if you insist - we have ABI for this, called sysfs. If
>> it is debugging feature, then debugfs.
> 
> ramoops already support module params and a way to pass these parameters
> from bootargs but it also need to know the hard-codes addresses, so, 
> doing something in sysfs will be again duplication with ramoops driver..

Why do you need hard-coded addresses?

> 
> If this can be accommodated under ramoops, this will be very small 
> change, like this
> 
> https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/

That's also funny patch - missing bindings updated, missing CC DT
maintainers.

Best regards,
Krzysztof


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 23:12     ` Rob Herring
@ 2023-07-04  9:27       ` Linus Walleij
  -1 siblings, 0 replies; 176+ messages in thread
From: Linus Walleij @ 2023-07-04  9:27 UTC (permalink / raw)
  To: Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:

> My bigger issue with this whole series is what would this all look
> like if every SoC vendor upstreamed their own custom dumping
> mechanism. That would be a mess. (I have similar opinions on the
> $soc-vendor hypervisors.)

I agree with Rob's stance.

I think it would be useful to get input from the hwtracing developers
(Alexander and Mathieu) who faced this "necessarily different" issue
with all the hwtrace mechanisms and found a way out of it. I suspect
they can have an idea of how this should be abstracted.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-04  9:27       ` Linus Walleij
  0 siblings, 0 replies; 176+ messages in thread
From: Linus Walleij @ 2023-07-04  9:27 UTC (permalink / raw)
  To: Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:

> My bigger issue with this whole series is what would this all look
> like if every SoC vendor upstreamed their own custom dumping
> mechanism. That would be a mess. (I have similar opinions on the
> $soc-vendor hypervisors.)

I agree with Rob's stance.

I think it would be useful to get input from the hwtracing developers
(Alexander and Mathieu) who faced this "necessarily different" issue
with all the hwtrace mechanisms and found a way out of it. I suspect
they can have an idea of how this should be abstracted.

Yours,
Linus Walleij

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-04  9:27       ` Linus Walleij
@ 2023-07-05 17:29         ` Trilok Soni
  -1 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-05 17:29 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 7/4/2023 2:27 AM, Linus Walleij wrote:
> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
> 
>> My bigger issue with this whole series is what would this all look
>> like if every SoC vendor upstreamed their own custom dumping
>> mechanism. That would be a mess. (I have similar opinions on the
>> $soc-vendor hypervisors.)
> 
> I agree with Rob's stance.
> 
> I think it would be useful to get input from the hwtracing developers
> (Alexander and Mathieu) who faced this "necessarily different" issue
> with all the hwtrace mechanisms and found a way out of it. I suspect
> they can have an idea of how this should be abstracted.

Any mailing list you suggest we expand to so that we get inputs from the 
hwtracing developers and maintainers or just look into the MAINTAINERS 
file and start an email thread?

We are fine to submit the abstract for the LPC in next two weeks, but 
prefer to have lot of good discussion before it on the mailing list, so 
that we have code to talk about in LPC.

---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-05 17:29         ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-05 17:29 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 7/4/2023 2:27 AM, Linus Walleij wrote:
> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
> 
>> My bigger issue with this whole series is what would this all look
>> like if every SoC vendor upstreamed their own custom dumping
>> mechanism. That would be a mess. (I have similar opinions on the
>> $soc-vendor hypervisors.)
> 
> I agree with Rob's stance.
> 
> I think it would be useful to get input from the hwtracing developers
> (Alexander and Mathieu) who faced this "necessarily different" issue
> with all the hwtrace mechanisms and found a way out of it. I suspect
> they can have an idea of how this should be abstracted.

Any mailing list you suggest we expand to so that we get inputs from the 
hwtracing developers and maintainers or just look into the MAINTAINERS 
file and start an email thread?

We are fine to submit the abstract for the LPC in next two weeks, but 
prefer to have lot of good discussion before it on the mailing list, so 
that we have code to talk about in LPC.

---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
  2023-06-29  9:16       ` Mukesh Ojha
@ 2023-07-05 23:27         ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-07-05 23:27 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Thu, Jun 29, 2023 at 3:16 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
>
>
> On 6/29/2023 4:27 AM, Rob Herring wrote:
> > On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
> >>
> >> This driver was inspired from the fact pstore ram region should be
> >> fixed and boot firmware need to have awarness about this region,
> >> so that it will be persistent across boot. But, there are many
> >> QCOM SoC which does not support warm boot from hardware but they
> >> have minidump support from the software, and for them, there is
> >> no need of this pstore ram region to be fixed, but at the same
> >> time have interest in the pstore frontends data. So, this driver
> >> get the dynamic reserved region from the ram and register the
> >> ramoops platform device.
> >>
> >>   +---------+     +---------+   +--------+     +---------+
> >>   | console |     | pmsg    |   | ftrace |     | dmesg   |
> >>   +---------+     +---------+   +--------+     +---------+
> >>         |             |             |              |
> >>         |             |             |              |
> >>         +------------------------------------------+
> >>                            |
> >>                           \ /
> >>                    +----------------+
> >>              (1)   |pstore frontends|
> >>                    +----------------+
> >>                            |
> >>                           \ /
> >>                   +------------------- +
> >>              (2)  | pstore backend(ram)|
> >>                   +--------------------+
> >>                            |
> >>                           \ /
> >>                   +--------------------+
> >>              (3)  |qcom_pstore_minidump|
> >>                   +--------------------+
> >>                            |
> >>                           \ /
> >>                     +---------------+
> >>              (4)    | qcom_minidump |
> >>                     +---------------+
> >>
> >> This driver will route all the pstore front data to the stored
> >> in qcom pstore reserved region and the reason of showing an
> >> arrow from (3) to (4) as qcom_pstore_minidump driver will register
> >> all the available frontends region with qcom minidump driver
> >> in upcoming patch.
> >>
> >> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> >> ---
> >>   drivers/soc/qcom/Kconfig                | 12 +++++
> >>   drivers/soc/qcom/Makefile               |  1 +
> >>   drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
> >
> > drivers/soc/ is the dumping ground for things with no other place. As
> > this is a pstore driver, it belongs with pstore.
>
> The inspiration of this driver was taken from
> drivers/platform/chrome/chromeos_pstore.c, do you think that is misplaced ?

The difference is really that's nothing more than platform specific
logic to instantiate a normal ramoops device. It's kind of ugly, yes,
but it's still just a normal ramoops device in the end. Your case is
that plus all the extra parts for minidump.

Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 10/21] soc: qcom: Add qcom's pstore minidump driver support
@ 2023-07-05 23:27         ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-07-05 23:27 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: corbet, agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, mathieu.poirier,
	catalin.marinas, will, linus.walleij, andy.shevchenko, linux-doc,
	linux-kernel, linux-arm-msm, devicetree, linux-hardening,
	linux-remoteproc, linux-arm-kernel, linux-gpio

On Thu, Jun 29, 2023 at 3:16 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>
>
>
> On 6/29/2023 4:27 AM, Rob Herring wrote:
> > On Wed, Jun 28, 2023 at 6:37 AM Mukesh Ojha <quic_mojha@quicinc.com> wrote:
> >>
> >> This driver was inspired from the fact pstore ram region should be
> >> fixed and boot firmware need to have awarness about this region,
> >> so that it will be persistent across boot. But, there are many
> >> QCOM SoC which does not support warm boot from hardware but they
> >> have minidump support from the software, and for them, there is
> >> no need of this pstore ram region to be fixed, but at the same
> >> time have interest in the pstore frontends data. So, this driver
> >> get the dynamic reserved region from the ram and register the
> >> ramoops platform device.
> >>
> >>   +---------+     +---------+   +--------+     +---------+
> >>   | console |     | pmsg    |   | ftrace |     | dmesg   |
> >>   +---------+     +---------+   +--------+     +---------+
> >>         |             |             |              |
> >>         |             |             |              |
> >>         +------------------------------------------+
> >>                            |
> >>                           \ /
> >>                    +----------------+
> >>              (1)   |pstore frontends|
> >>                    +----------------+
> >>                            |
> >>                           \ /
> >>                   +------------------- +
> >>              (2)  | pstore backend(ram)|
> >>                   +--------------------+
> >>                            |
> >>                           \ /
> >>                   +--------------------+
> >>              (3)  |qcom_pstore_minidump|
> >>                   +--------------------+
> >>                            |
> >>                           \ /
> >>                     +---------------+
> >>              (4)    | qcom_minidump |
> >>                     +---------------+
> >>
> >> This driver will route all the pstore front data to the stored
> >> in qcom pstore reserved region and the reason of showing an
> >> arrow from (3) to (4) as qcom_pstore_minidump driver will register
> >> all the available frontends region with qcom minidump driver
> >> in upcoming patch.
> >>
> >> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> >> ---
> >>   drivers/soc/qcom/Kconfig                | 12 +++++
> >>   drivers/soc/qcom/Makefile               |  1 +
> >>   drivers/soc/qcom/qcom_pstore_minidump.c | 85 +++++++++++++++++++++++++++++++++
> >
> > drivers/soc/ is the dumping ground for things with no other place. As
> > this is a pstore driver, it belongs with pstore.
>
> The inspiration of this driver was taken from
> drivers/platform/chrome/chromeos_pstore.c, do you think that is misplaced ?

The difference is really that's nothing more than platform specific
logic to instantiate a normal ramoops device. It's kind of ugly, yes,
but it's still just a normal ramoops device in the end. Your case is
that plus all the extra parts for minidump.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-03 21:05           ` Trilok Soni
@ 2023-07-06 17:20             ` Mathieu Poirier
  -1 siblings, 0 replies; 176+ messages in thread
From: Mathieu Poirier @ 2023-07-06 17:20 UTC (permalink / raw)
  To: Trilok Soni
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Rob Herring, Greg KH, corbet,
	agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> > On 30/06/2023 18:04, Mukesh Ojha wrote:
> > > > 
> > > > > We don't add layers when they are not needed, and never when there is no
> > > > > actual user.  If you need the extra "complexity" later, then add it
> > > > > later when it is needed as who knows when that will ever be.
> > > > > 
> > > > > Please redo this series based on that, thanks.
> > > > 
> > > > My bigger issue with this whole series is what would this all look
> > > > like if every SoC vendor upstreamed their own custom dumping
> > > > mechanism. That would be a mess. (I have similar opinions on the
> > > > $soc-vendor hypervisors.)
> > 
> > Mukesh,
> > 
> > LPC CFP is still open. There will be also Android and Kernel Debugging
> > LPC microconference tracks. Coming with a unified solution could be a
> > great topic for LPC. Solutions targeting only one user are quite often
> > frowned upon.
> 
> LPC is far out and in November. Can we not have others speak up if they have
> the similar solution now? We can expand this to linux-kernel and ask for the
> other SOC vendors to chime in. I am sure that we may have existing solutions
> which came in for the one user first like Intel RDT if I remember. I am sure
> ARM MPAM usecase was present at that time but Intel RDT based solution which
> was x86 specific but accepted.

I am not familiar with Intel RDT and Arm MPAM but the community is always
improving on the way it does things.

LPC is indeed far out in November but it is an opportunity to cover the
groundwork needed to have this discussion.  It is always best to improve on
something then introduce something new.  Even better if something specific such
as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
hwtracing Linus referred to.  The perf framework wasn't a perfect fit but it was
enhanced to accommodate our requirements.  I suggest to look at what is currently
available and come up with a strategy to be presented at LPC - event better if
you have a prototype.  If you can't find anything or the drawbacks inherent to
each avenue outweigh the benefits then we can have that conversation at LPC.

> 
> ---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-06 17:20             ` Mathieu Poirier
  0 siblings, 0 replies; 176+ messages in thread
From: Mathieu Poirier @ 2023-07-06 17:20 UTC (permalink / raw)
  To: Trilok Soni
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Rob Herring, Greg KH, corbet,
	agross, andersson, konrad.dybcio, krzysztof.kozlowski+dt,
	conor+dt, keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> > On 30/06/2023 18:04, Mukesh Ojha wrote:
> > > > 
> > > > > We don't add layers when they are not needed, and never when there is no
> > > > > actual user.  If you need the extra "complexity" later, then add it
> > > > > later when it is needed as who knows when that will ever be.
> > > > > 
> > > > > Please redo this series based on that, thanks.
> > > > 
> > > > My bigger issue with this whole series is what would this all look
> > > > like if every SoC vendor upstreamed their own custom dumping
> > > > mechanism. That would be a mess. (I have similar opinions on the
> > > > $soc-vendor hypervisors.)
> > 
> > Mukesh,
> > 
> > LPC CFP is still open. There will be also Android and Kernel Debugging
> > LPC microconference tracks. Coming with a unified solution could be a
> > great topic for LPC. Solutions targeting only one user are quite often
> > frowned upon.
> 
> LPC is far out and in November. Can we not have others speak up if they have
> the similar solution now? We can expand this to linux-kernel and ask for the
> other SOC vendors to chime in. I am sure that we may have existing solutions
> which came in for the one user first like Intel RDT if I remember. I am sure
> ARM MPAM usecase was present at that time but Intel RDT based solution which
> was x86 specific but accepted.

I am not familiar with Intel RDT and Arm MPAM but the community is always
improving on the way it does things.

LPC is indeed far out in November but it is an opportunity to cover the
groundwork needed to have this discussion.  It is always best to improve on
something then introduce something new.  Even better if something specific such
as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
hwtracing Linus referred to.  The perf framework wasn't a perfect fit but it was
enhanced to accommodate our requirements.  I suggest to look at what is currently
available and come up with a strategy to be presented at LPC - event better if
you have a prototype.  If you can't find anything or the drawbacks inherent to
each avenue outweigh the benefits then we can have that conversation at LPC.

> 
> ---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-03 21:05           ` Trilok Soni
@ 2023-07-06 17:40             ` Rob Herring
  -1 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-07-06 17:40 UTC (permalink / raw)
  To: Trilok Soni
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>
> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> > On 30/06/2023 18:04, Mukesh Ojha wrote:
> >>>
> >>>> We don't add layers when they are not needed, and never when there is no
> >>>> actual user.  If you need the extra "complexity" later, then add it
> >>>> later when it is needed as who knows when that will ever be.
> >>>>
> >>>> Please redo this series based on that, thanks.
> >>>
> >>> My bigger issue with this whole series is what would this all look
> >>> like if every SoC vendor upstreamed their own custom dumping
> >>> mechanism. That would be a mess. (I have similar opinions on the
> >>> $soc-vendor hypervisors.)
> >
> > Mukesh,
> >
> > LPC CFP is still open. There will be also Android and Kernel Debugging
> > LPC microconference tracks. Coming with a unified solution could be a
> > great topic for LPC. Solutions targeting only one user are quite often
> > frowned upon.
>
> LPC is far out and in November. Can we not have others speak up if they
> have the similar solution now? We can expand this to linux-kernel and
> ask for the other SOC vendors to chime in. I am sure that we may have
> existing solutions which came in for the one user first like Intel RDT
> if I remember. I am sure ARM MPAM usecase was present at that time but
> Intel RDT based solution which was x86 specific but accepted.

RDT predated MPAM. resctrl is the kernel feature, and it supports
Intel and AMD which are not identical. resctrl is being (extensively)
refactored to add in MPAM support.

You are not the first here like Intel RDT, so I fail to see the
parallel with minidump. We have an existing logging to persistent
storage mechanism which is pstore. You should integrate into that
rather than grafting something on to the side or underneath.

Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-06 17:40             ` Rob Herring
  0 siblings, 0 replies; 176+ messages in thread
From: Rob Herring @ 2023-07-06 17:40 UTC (permalink / raw)
  To: Trilok Soni
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>
> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
> > On 30/06/2023 18:04, Mukesh Ojha wrote:
> >>>
> >>>> We don't add layers when they are not needed, and never when there is no
> >>>> actual user.  If you need the extra "complexity" later, then add it
> >>>> later when it is needed as who knows when that will ever be.
> >>>>
> >>>> Please redo this series based on that, thanks.
> >>>
> >>> My bigger issue with this whole series is what would this all look
> >>> like if every SoC vendor upstreamed their own custom dumping
> >>> mechanism. That would be a mess. (I have similar opinions on the
> >>> $soc-vendor hypervisors.)
> >
> > Mukesh,
> >
> > LPC CFP is still open. There will be also Android and Kernel Debugging
> > LPC microconference tracks. Coming with a unified solution could be a
> > great topic for LPC. Solutions targeting only one user are quite often
> > frowned upon.
>
> LPC is far out and in November. Can we not have others speak up if they
> have the similar solution now? We can expand this to linux-kernel and
> ask for the other SOC vendors to chime in. I am sure that we may have
> existing solutions which came in for the one user first like Intel RDT
> if I remember. I am sure ARM MPAM usecase was present at that time but
> Intel RDT based solution which was x86 specific but accepted.

RDT predated MPAM. resctrl is the kernel feature, and it supports
Intel and AMD which are not identical. resctrl is being (extensively)
refactored to add in MPAM support.

You are not the first here like Intel RDT, so I fail to see the
parallel with minidump. We have an existing logging to persistent
storage mechanism which is pstore. You should integrate into that
rather than grafting something on to the side or underneath.

Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-06 17:40             ` Rob Herring
@ 2023-07-06 18:07               ` Trilok Soni
  -1 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-06 18:07 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On 7/6/2023 10:40 AM, Rob Herring wrote:
> On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>>
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they
>> have the similar solution now? We can expand this to linux-kernel and
>> ask for the other SOC vendors to chime in. I am sure that we may have
>> existing solutions which came in for the one user first like Intel RDT
>> if I remember. I am sure ARM MPAM usecase was present at that time but
>> Intel RDT based solution which was x86 specific but accepted.
> 
> RDT predated MPAM. resctrl is the kernel feature, and it supports
> Intel and AMD which are not identical. resctrl is being (extensively)
> refactored to add in MPAM support.
> 
> You are not the first here like Intel RDT, so I fail to see the
> parallel with minidump. We have an existing logging to persistent
> storage mechanism which is pstore. You should integrate into that
> rather than grafting something on to the side or underneath.
> 

Mukesh will chime in once he looks at the hwtracing suggested by Linus W 
and see if it fits. Mukesh seems have already looked at pstore and 
discussions/patches are there w/ pstore logic I believe, but it is okay 
if they are not perfect if we are still not decided on the right 
framework. Best to decide if the existing frameworks fits or not or we 
need to create the new one.

I would still prefer if other SOC vendors chime in here, since I am sure 
in the Mobile and Embedded world various SOCs may have requirements to 
get specific portion of the ramdump only for the quick analysis and 
meeting the storage requirements on the device for its collection.

As mentioned on another patch, we are fine the submit abstract at LPC 
debug MC, but I would like the framework discussion to continue so that 
we can decide during the LPC that either existing frameworks fits the 
needs or they need to be extended or new fwk is needed.

---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-06 18:07               ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-06 18:07 UTC (permalink / raw)
  To: Rob Herring
  Cc: Krzysztof Kozlowski, Mukesh Ojha, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder

On 7/6/2023 10:40 AM, Rob Herring wrote:
> On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>>
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they
>> have the similar solution now? We can expand this to linux-kernel and
>> ask for the other SOC vendors to chime in. I am sure that we may have
>> existing solutions which came in for the one user first like Intel RDT
>> if I remember. I am sure ARM MPAM usecase was present at that time but
>> Intel RDT based solution which was x86 specific but accepted.
> 
> RDT predated MPAM. resctrl is the kernel feature, and it supports
> Intel and AMD which are not identical. resctrl is being (extensively)
> refactored to add in MPAM support.
> 
> You are not the first here like Intel RDT, so I fail to see the
> parallel with minidump. We have an existing logging to persistent
> storage mechanism which is pstore. You should integrate into that
> rather than grafting something on to the side or underneath.
> 

Mukesh will chime in once he looks at the hwtracing suggested by Linus W 
and see if it fits. Mukesh seems have already looked at pstore and 
discussions/patches are there w/ pstore logic I believe, but it is okay 
if they are not perfect if we are still not decided on the right 
framework. Best to decide if the existing frameworks fits or not or we 
need to create the new one.

I would still prefer if other SOC vendors chime in here, since I am sure 
in the Mobile and Embedded world various SOCs may have requirements to 
get specific portion of the ramdump only for the quick analysis and 
meeting the storage requirements on the device for its collection.

As mentioned on another patch, we are fine the submit abstract at LPC 
debug MC, but I would like the framework discussion to continue so that 
we can decide during the LPC that either existing frameworks fits the 
needs or they need to be extended or new fwk is needed.

---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-06-28 12:34 ` Mukesh Ojha
@ 2023-07-13  4:39   ` Kathiravan T
  -1 siblings, 0 replies; 176+ messages in thread
From: Kathiravan T @ 2023-07-13  4:39 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio


On 6/28/2023 6:04 PM, Mukesh Ojha 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 which snippets should be
> included in the ramdump.
>
> 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(gunyah) 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 core of SMEM based 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 SMEM
> based 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.
>
>
>   docs: qcom: Add qualcomm minidump guide
>    kallsyms: Export kallsyms_lookup_name
>    soc: qcom: Add qcom_minidump_smem module
>    soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
>    soc: qcom: Add linux minidump smem backend driver support
>    soc: qcom: minidump: Add pending region registration support
>    soc: qcom: minidump: Add update region support
>    dt-bindings: reserved-memory: Add qcom,ramoops binding
>    pstore/ram : Export ramoops_parse_dt() symbol
>    soc: qcom: Add qcom's pstore minidump driver support
>    soc: qcom: Register pstore frontend region with minidump
>    remoteproc: qcom: Expand MD_* as MINIDUMP_*
>    remoterproc: qcom: refactor to leverage exported minidump symbol
>    MAINTAINERS: Add entry for minidump driver related support
>    arm64: defconfig: Enable Qualcomm Minidump related drivers
>    arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
>    firmware: qcom_scm: Refactor code to support multiple download mode
>    firmware: qcom_scm: Add multiple download mode support
>
> Patch 1/21 is qualcomm minidump document
> Patch 2/21 will export kallsyms_lookup_name will be needed for minidump module
> Patch 3/21 moves the minidump specific data structure and macro to
>   qcom_minidump_smem.c and later 13/21 will use the API and remove
>   minidump specific code to qcom_minidump_smem file.
> Patch 4/21 is qualcomm minidump core(frontend) driver
> Patch 5/21 implements qualcomm smem backend kernel driver
> Patch 6/21 add pending region support for the clients who came for
>   registration before minidump.
> Patch 7/21 add update region support for registered clients.
> Patch 8/21 Add dt-binding for qualcomm ramoops driver which is also a minidump client driver
> Patch 9/21 exported symbol from ramoops driver to avoid copy of the code.
> Patch 10/21 Add qcom's pstore minidump driver support which adds ramoops platform device
>              and 11/21 register existing pstore frontend regions.
> Patch 12/21 and 13/21 does some clean up and code reuse.
> Patch 16/21 enable qcom_ramoops driver for sm8450
> Patch 17-21 are not new and has already been through 6 versions and
> reason of adding here is for minidump testing purpose and it will be rebased
> automatically along with new version of minidump series.
>
> Testing of the patches has been done on sm8450 target after enabling config like
> CONFIG_PSTORE_RAM and CONFIG_PSTORE_CONSOLE and once the device boots up.
> Try crashing it via devmem2 0xf11c000(this is known to create xpu violation and
> and put the device in download mode) on command prompt.
>
> I have added download patch here numbered from 14/18 to 18/18
> Earlier download mode setting patches were sent separately
> https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Default storage type is set to via USB, so minidump would be downloaded with the
> help of x86_64 machine (running PCAT tool) attached to Qualcomm device which has
> backed minidump boot firmware support (more can be found patch 3/18)
>
> Below patch [1] is to warm reset Qualcomm device which has upstream qcom
> watchdog driver support.
>
> After applying all patches, we can boot the device and can execute
> following command.
>
> echo mini > /sys/module/qcom_scm/parameters/download_mode
> echo c > /proc/sysrq-trigger
>
> This will make the device go to download mode and collect the minidump on to the
> attached x86 machine running the Qualcomm PCAT tool(This comes as part Qualcomm
> package manager kit).
> After that we will see a bunch of predefined registered region as binary blobs files
> starts with md_* downloaded on the x86 machine on given location in PCAT tool from
> the target device.
>
> A sample client example to dump a linux region has been given in patch 3/18 and as
> well as can be seen in patch 12/18.
>
> [1]
> --------------------------->8-------------------------------------
>
> commit f1124ccebd47550b4c9627aa162d9cdceba2b76f
> Author: Mukesh Ojha <quic_mojha@quicinc.com>
> Date:   Thu Mar 16 14:08:35 2023 +0530
>
>      do not merge: watchdog bite on panic
>
>      Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index 0d2209c..767e84a 100644
> --- a/drivers/watchdog/qcom-wdt.c
> +++ b/drivers/watchdog/qcom-wdt.c
> @@ -12,6 +12,7 @@
>   #include <linux/platform_device.h>
>   #include <linux/watchdog.h>
>   #include <linux/of_device.h>
> +#include <linux/panic.h>
>
>   enum wdt_reg {
>          WDT_RST,
> @@ -114,12 +115,28 @@ static int qcom_wdt_set_pretimeout(struct watchdog_device *wdd,
>          return qcom_wdt_start(wdd);
>   }
>
> +static void qcom_wdt_bite_on_panic(struct qcom_wdt *wdt)
> +{
> +       writel(0, wdt_addr(wdt, WDT_EN));
> +       writel(1, wdt_addr(wdt, WDT_BITE_TIME));
> +       writel(1, wdt_addr(wdt, WDT_RST));
> +       writel(QCOM_WDT_ENABLE, wdt_addr(wdt, WDT_EN));
> +
> +       wmb();
> +
> +       while(1)
> +               udelay(1);
> +}
> +
>   static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,
>                              void *data)
>   {
>          struct qcom_wdt *wdt = to_qcom_wdt(wdd);
>          u32 timeout;
>
> +       if (in_panic)
> +               qcom_wdt_bite_on_panic(wdt);
> +
>          /*
>           * Trigger watchdog bite:
>           *    Setup BITE_TIME to be 128ms, and enable WDT.
> diff --git a/include/linux/panic.h b/include/linux/panic.h
> index 979b776..f913629 100644
> --- a/include/linux/panic.h
> +++ b/include/linux/panic.h
> @@ -22,6 +22,7 @@ extern int panic_on_oops;
>   extern int panic_on_unrecovered_nmi;
>   extern int panic_on_io_nmi;
>   extern int panic_on_warn;
> +extern bool in_panic;
>
>   extern unsigned long panic_on_taint;
>   extern bool panic_on_taint_nousertaint;
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 487f5b0..714f7f4 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -65,6 +65,8 @@ static unsigned int warn_limit __read_mostly;
>
>   int panic_timeout = CONFIG_PANIC_TIMEOUT;
>   EXPORT_SYMBOL_GPL(panic_timeout);
> +bool in_panic = false;
> +EXPORT_SYMBOL_GPL(in_panic);
>
>   #define PANIC_PRINT_TASK_INFO          0x00000001
>   #define PANIC_PRINT_MEM_INFO           0x00000002
> @@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
>          int old_cpu, this_cpu;
>          bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
>
> +       in_panic = true;
>          if (panic_on_warn) {
>                  /*
>                   * This thread may hit another WARN() in the panic path.
> --------------------------------------------------------------------------
>
> Changes in v4:
>   - Redesigned the driver and divided the driver into front end and backend (smem) so
>     that any new backend can be attached easily to avoid code duplication.
>   - Patch reordering as per the driver and subsystem to easier review of the code.
>   - Removed minidump specific code from remoteproc to minidump smem based driver.
>   - Enabled the all the driver as modules.
>   - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]
>   - Address comments made qcom_pstore_minidump driver and given its Device tree
>     same set of properties as ramoops. [Luca/Kees]
>   - Added patch for MAINTAINER file.
>   - Include defconfig change as one patch as per [Krzysztof] suggestion.
>   - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
>   - Addressed comments made on dload mode patch v6 version
>     https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Changes in v3: https://lore.kernel.org/lkml/1683133352-10046-1-git-send-email-quic_mojha@quicinc.com/
>   - Addressed most of the comments by Srini on v2 and refactored the minidump driver.
>      - Added platform device support
>      - Unregister region support.
>   - Added update region for clients.
>   - Added pending region support.
>   - Modified the documentation guide accordingly.
>   - Added qcom_pstore_ramdump client driver which happen to add ramoops platform
>     device and also registers ramoops region with minidump.
>   - Added download mode patch series with this minidump series.
>      https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Changes in v2: https://lore.kernel.org/lkml/1679491817-2498-1-git-send-email-quic_mojha@quicinc.com/
>   - Addressed review comment made by [quic_tsoni/bmasney] to add documentation.
>   - Addressed comments made by [srinivas.kandagatla]
>   - Dropped pstore 6/6 from the last series, till i get conclusion to get pstore
>     region in minidump.
>   - Fixed issue reported by kernel test robot.
>
> Changes in v1: https://lore.kernel.org/lkml/1676978713-7394-1-git-send-email-quic_mojha@quicinc.com/
>
> Mukesh Ojha (21):
>    docs: qcom: Add qualcomm minidump guide
>    kallsyms: Export kallsyms_lookup_name
>    soc: qcom: Add qcom_minidump_smem module
>    soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
>    soc: qcom: Add linux minidump smem backend driver support
>    soc: qcom: minidump: Add pending region registration support
>    soc: qcom: minidump: Add update region support
>    dt-bindings: reserved-memory: Add qcom,ramoops binding
>    pstore/ram : Export ramoops_parse_dt() symbol
>    soc: qcom: Add qcom's pstore minidump driver support
>    soc: qcom: Register pstore frontend region with minidump
>    remoteproc: qcom: Expand MD_* as MINIDUMP_*
>    remoterproc: qcom: refactor to leverage exported minidump symbol
>    MAINTAINERS: Add entry for minidump driver related support
>    arm64: defconfig: Enable Qualcomm Minidump related drivers
>    arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
>    firmware: qcom_scm: Refactor code to support multiple download mode
>    firmware: qcom_scm: Add multiple download mode support


Hi Mukesh,

For IPQ chipsets, for the crashdump to work, we need the below patch

firmware: scm: Modify only the download bits in TCSR register

can you post the below patches separately? Looks like minidump will take 
some time and also I don't see any dependencies for these to go along 
with the minidump. Given that, will it be possible to post the below 
patches separately?

   firmware: qcom_scm: provide a read-modify-write function
   pinctrl: qcom: Use qcom_scm_io_update_field()
   firmware: scm: Modify only the download bits in TCSR register

Do let us know if we can take these patches and post it separately.

Thanks,

Kathiravan T.


>
>   Documentation/admin-guide/index.rst                |   1 +
>   Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
>   MAINTAINERS                                        |  15 +
>   arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
>   arch/arm64/configs/defconfig                       |   4 +
>   drivers/firmware/Kconfig                           |  11 -
>   drivers/firmware/qcom_scm.c                        |  85 ++-
>   drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
>   drivers/remoteproc/qcom_common.c                   | 142 +----
>   drivers/soc/qcom/Kconfig                           |  39 ++
>   drivers/soc/qcom/Makefile                          |   3 +
>   drivers/soc/qcom/qcom_minidump.c                   | 582 +++++++++++++++++++++
>   drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
>   drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
>   drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
>   drivers/soc/qcom/smem.c                            |   9 +
>   fs/pstore/ram.c                                    |  26 +-
>   include/linux/firmware/qcom/qcom_scm.h             |   2 +
>   include/linux/pstore_ram.h                         |   2 +
>   include/soc/qcom/qcom_minidump.h                   |  64 +++
>   kernel/kallsyms.c                                  |   2 +-
>   22 files changed, 1973 insertions(+), 152 deletions(-)
>   create mode 100644 Documentation/admin-guide/qcom_minidump.rst
>   create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>   create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>   create mode 100644 include/soc/qcom/qcom_minidump.h
>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-13  4:39   ` Kathiravan T
  0 siblings, 0 replies; 176+ messages in thread
From: Kathiravan T @ 2023-07-13  4:39 UTC (permalink / raw)
  To: Mukesh Ojha, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio


On 6/28/2023 6:04 PM, Mukesh Ojha 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 which snippets should be
> included in the ramdump.
>
> 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(gunyah) 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 core of SMEM based 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 SMEM
> based 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.
>
>
>   docs: qcom: Add qualcomm minidump guide
>    kallsyms: Export kallsyms_lookup_name
>    soc: qcom: Add qcom_minidump_smem module
>    soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
>    soc: qcom: Add linux minidump smem backend driver support
>    soc: qcom: minidump: Add pending region registration support
>    soc: qcom: minidump: Add update region support
>    dt-bindings: reserved-memory: Add qcom,ramoops binding
>    pstore/ram : Export ramoops_parse_dt() symbol
>    soc: qcom: Add qcom's pstore minidump driver support
>    soc: qcom: Register pstore frontend region with minidump
>    remoteproc: qcom: Expand MD_* as MINIDUMP_*
>    remoterproc: qcom: refactor to leverage exported minidump symbol
>    MAINTAINERS: Add entry for minidump driver related support
>    arm64: defconfig: Enable Qualcomm Minidump related drivers
>    arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
>    firmware: qcom_scm: Refactor code to support multiple download mode
>    firmware: qcom_scm: Add multiple download mode support
>
> Patch 1/21 is qualcomm minidump document
> Patch 2/21 will export kallsyms_lookup_name will be needed for minidump module
> Patch 3/21 moves the minidump specific data structure and macro to
>   qcom_minidump_smem.c and later 13/21 will use the API and remove
>   minidump specific code to qcom_minidump_smem file.
> Patch 4/21 is qualcomm minidump core(frontend) driver
> Patch 5/21 implements qualcomm smem backend kernel driver
> Patch 6/21 add pending region support for the clients who came for
>   registration before minidump.
> Patch 7/21 add update region support for registered clients.
> Patch 8/21 Add dt-binding for qualcomm ramoops driver which is also a minidump client driver
> Patch 9/21 exported symbol from ramoops driver to avoid copy of the code.
> Patch 10/21 Add qcom's pstore minidump driver support which adds ramoops platform device
>              and 11/21 register existing pstore frontend regions.
> Patch 12/21 and 13/21 does some clean up and code reuse.
> Patch 16/21 enable qcom_ramoops driver for sm8450
> Patch 17-21 are not new and has already been through 6 versions and
> reason of adding here is for minidump testing purpose and it will be rebased
> automatically along with new version of minidump series.
>
> Testing of the patches has been done on sm8450 target after enabling config like
> CONFIG_PSTORE_RAM and CONFIG_PSTORE_CONSOLE and once the device boots up.
> Try crashing it via devmem2 0xf11c000(this is known to create xpu violation and
> and put the device in download mode) on command prompt.
>
> I have added download patch here numbered from 14/18 to 18/18
> Earlier download mode setting patches were sent separately
> https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Default storage type is set to via USB, so minidump would be downloaded with the
> help of x86_64 machine (running PCAT tool) attached to Qualcomm device which has
> backed minidump boot firmware support (more can be found patch 3/18)
>
> Below patch [1] is to warm reset Qualcomm device which has upstream qcom
> watchdog driver support.
>
> After applying all patches, we can boot the device and can execute
> following command.
>
> echo mini > /sys/module/qcom_scm/parameters/download_mode
> echo c > /proc/sysrq-trigger
>
> This will make the device go to download mode and collect the minidump on to the
> attached x86 machine running the Qualcomm PCAT tool(This comes as part Qualcomm
> package manager kit).
> After that we will see a bunch of predefined registered region as binary blobs files
> starts with md_* downloaded on the x86 machine on given location in PCAT tool from
> the target device.
>
> A sample client example to dump a linux region has been given in patch 3/18 and as
> well as can be seen in patch 12/18.
>
> [1]
> --------------------------->8-------------------------------------
>
> commit f1124ccebd47550b4c9627aa162d9cdceba2b76f
> Author: Mukesh Ojha <quic_mojha@quicinc.com>
> Date:   Thu Mar 16 14:08:35 2023 +0530
>
>      do not merge: watchdog bite on panic
>
>      Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
>
> diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c
> index 0d2209c..767e84a 100644
> --- a/drivers/watchdog/qcom-wdt.c
> +++ b/drivers/watchdog/qcom-wdt.c
> @@ -12,6 +12,7 @@
>   #include <linux/platform_device.h>
>   #include <linux/watchdog.h>
>   #include <linux/of_device.h>
> +#include <linux/panic.h>
>
>   enum wdt_reg {
>          WDT_RST,
> @@ -114,12 +115,28 @@ static int qcom_wdt_set_pretimeout(struct watchdog_device *wdd,
>          return qcom_wdt_start(wdd);
>   }
>
> +static void qcom_wdt_bite_on_panic(struct qcom_wdt *wdt)
> +{
> +       writel(0, wdt_addr(wdt, WDT_EN));
> +       writel(1, wdt_addr(wdt, WDT_BITE_TIME));
> +       writel(1, wdt_addr(wdt, WDT_RST));
> +       writel(QCOM_WDT_ENABLE, wdt_addr(wdt, WDT_EN));
> +
> +       wmb();
> +
> +       while(1)
> +               udelay(1);
> +}
> +
>   static int qcom_wdt_restart(struct watchdog_device *wdd, unsigned long action,
>                              void *data)
>   {
>          struct qcom_wdt *wdt = to_qcom_wdt(wdd);
>          u32 timeout;
>
> +       if (in_panic)
> +               qcom_wdt_bite_on_panic(wdt);
> +
>          /*
>           * Trigger watchdog bite:
>           *    Setup BITE_TIME to be 128ms, and enable WDT.
> diff --git a/include/linux/panic.h b/include/linux/panic.h
> index 979b776..f913629 100644
> --- a/include/linux/panic.h
> +++ b/include/linux/panic.h
> @@ -22,6 +22,7 @@ extern int panic_on_oops;
>   extern int panic_on_unrecovered_nmi;
>   extern int panic_on_io_nmi;
>   extern int panic_on_warn;
> +extern bool in_panic;
>
>   extern unsigned long panic_on_taint;
>   extern bool panic_on_taint_nousertaint;
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 487f5b0..714f7f4 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -65,6 +65,8 @@ static unsigned int warn_limit __read_mostly;
>
>   int panic_timeout = CONFIG_PANIC_TIMEOUT;
>   EXPORT_SYMBOL_GPL(panic_timeout);
> +bool in_panic = false;
> +EXPORT_SYMBOL_GPL(in_panic);
>
>   #define PANIC_PRINT_TASK_INFO          0x00000001
>   #define PANIC_PRINT_MEM_INFO           0x00000002
> @@ -261,6 +263,7 @@ void panic(const char *fmt, ...)
>          int old_cpu, this_cpu;
>          bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers;
>
> +       in_panic = true;
>          if (panic_on_warn) {
>                  /*
>                   * This thread may hit another WARN() in the panic path.
> --------------------------------------------------------------------------
>
> Changes in v4:
>   - Redesigned the driver and divided the driver into front end and backend (smem) so
>     that any new backend can be attached easily to avoid code duplication.
>   - Patch reordering as per the driver and subsystem to easier review of the code.
>   - Removed minidump specific code from remoteproc to minidump smem based driver.
>   - Enabled the all the driver as modules.
>   - Address comments made on documentation and yaml and Device tree file [Krzysztof/Konrad]
>   - Address comments made qcom_pstore_minidump driver and given its Device tree
>     same set of properties as ramoops. [Luca/Kees]
>   - Added patch for MAINTAINER file.
>   - Include defconfig change as one patch as per [Krzysztof] suggestion.
>   - Tried to remove the redundant file scope variables from the module as per [Krzysztof] suggestion.
>   - Addressed comments made on dload mode patch v6 version
>     https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Changes in v3: https://lore.kernel.org/lkml/1683133352-10046-1-git-send-email-quic_mojha@quicinc.com/
>   - Addressed most of the comments by Srini on v2 and refactored the minidump driver.
>      - Added platform device support
>      - Unregister region support.
>   - Added update region for clients.
>   - Added pending region support.
>   - Modified the documentation guide accordingly.
>   - Added qcom_pstore_ramdump client driver which happen to add ramoops platform
>     device and also registers ramoops region with minidump.
>   - Added download mode patch series with this minidump series.
>      https://lore.kernel.org/lkml/1680076012-10785-1-git-send-email-quic_mojha@quicinc.com/
>
> Changes in v2: https://lore.kernel.org/lkml/1679491817-2498-1-git-send-email-quic_mojha@quicinc.com/
>   - Addressed review comment made by [quic_tsoni/bmasney] to add documentation.
>   - Addressed comments made by [srinivas.kandagatla]
>   - Dropped pstore 6/6 from the last series, till i get conclusion to get pstore
>     region in minidump.
>   - Fixed issue reported by kernel test robot.
>
> Changes in v1: https://lore.kernel.org/lkml/1676978713-7394-1-git-send-email-quic_mojha@quicinc.com/
>
> Mukesh Ojha (21):
>    docs: qcom: Add qualcomm minidump guide
>    kallsyms: Export kallsyms_lookup_name
>    soc: qcom: Add qcom_minidump_smem module
>    soc: qcom: Add Qualcomm APSS minidump (frontend) feature support
>    soc: qcom: Add linux minidump smem backend driver support
>    soc: qcom: minidump: Add pending region registration support
>    soc: qcom: minidump: Add update region support
>    dt-bindings: reserved-memory: Add qcom,ramoops binding
>    pstore/ram : Export ramoops_parse_dt() symbol
>    soc: qcom: Add qcom's pstore minidump driver support
>    soc: qcom: Register pstore frontend region with minidump
>    remoteproc: qcom: Expand MD_* as MINIDUMP_*
>    remoterproc: qcom: refactor to leverage exported minidump symbol
>    MAINTAINERS: Add entry for minidump driver related support
>    arm64: defconfig: Enable Qualcomm Minidump related drivers
>    arm64: dts: qcom: sm8450: Add Qualcomm ramoops minidump node
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
>    firmware: qcom_scm: Refactor code to support multiple download mode
>    firmware: qcom_scm: Add multiple download mode support


Hi Mukesh,

For IPQ chipsets, for the crashdump to work, we need the below patch

firmware: scm: Modify only the download bits in TCSR register

can you post the below patches separately? Looks like minidump will take 
some time and also I don't see any dependencies for these to go along 
with the minidump. Given that, will it be possible to post the below 
patches separately?

   firmware: qcom_scm: provide a read-modify-write function
   pinctrl: qcom: Use qcom_scm_io_update_field()
   firmware: scm: Modify only the download bits in TCSR register

Do let us know if we can take these patches and post it separately.

Thanks,

Kathiravan T.


>
>   Documentation/admin-guide/index.rst                |   1 +
>   Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
>   MAINTAINERS                                        |  15 +
>   arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
>   arch/arm64/configs/defconfig                       |   4 +
>   drivers/firmware/Kconfig                           |  11 -
>   drivers/firmware/qcom_scm.c                        |  85 ++-
>   drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
>   drivers/remoteproc/qcom_common.c                   | 142 +----
>   drivers/soc/qcom/Kconfig                           |  39 ++
>   drivers/soc/qcom/Makefile                          |   3 +
>   drivers/soc/qcom/qcom_minidump.c                   | 582 +++++++++++++++++++++
>   drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
>   drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
>   drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
>   drivers/soc/qcom/smem.c                            |   9 +
>   fs/pstore/ram.c                                    |  26 +-
>   include/linux/firmware/qcom/qcom_scm.h             |   2 +
>   include/linux/pstore_ram.h                         |   2 +
>   include/soc/qcom/qcom_minidump.h                   |  64 +++
>   kernel/kallsyms.c                                  |   2 +-
>   22 files changed, 1973 insertions(+), 152 deletions(-)
>   create mode 100644 Documentation/admin-guide/qcom_minidump.rst
>   create mode 100644 Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>   create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>   create mode 100644 include/soc/qcom/qcom_minidump.h
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-13  4:39   ` Kathiravan T
  (?)
@ 2023-07-14 15:25     ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-14 15:25 UTC (permalink / raw)
  To: Kathiravan T, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio


> 
> Hi Mukesh,
> 
> For IPQ chipsets, for the crashdump to work, we need the below patch
> 
> firmware: scm: Modify only the download bits in TCSR register
> 
> can you post the below patches separately? Looks like minidump will take 
> some time and also I don't see any dependencies for these to go along 
> with the minidump. Given that, will it be possible to post the below 
> patches separately?
> 
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
> 
> Do let us know if we can take these patches and post it separately.

Yes, we can post this separately.

-Mukesh
> 
>>
>>   Documentation/admin-guide/index.rst                |   1 +
>>   Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
>>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
>>   MAINTAINERS                                        |  15 +
>>   arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
>>   arch/arm64/configs/defconfig                       |   4 +
>>   drivers/firmware/Kconfig                           |  11 -
>>   drivers/firmware/qcom_scm.c                        |  85 ++-
>>   drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
>>   drivers/remoteproc/qcom_common.c                   | 142 +----
>>   drivers/soc/qcom/Kconfig                           |  39 ++
>>   drivers/soc/qcom/Makefile                          |   3 +
>>   drivers/soc/qcom/qcom_minidump.c                   | 582 
>> +++++++++++++++++++++
>>   drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
>>   drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
>>   drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
>>   drivers/soc/qcom/smem.c                            |   9 +
>>   fs/pstore/ram.c                                    |  26 +-
>>   include/linux/firmware/qcom/qcom_scm.h             |   2 +
>>   include/linux/pstore_ram.h                         |   2 +
>>   include/soc/qcom/qcom_minidump.h                   |  64 +++
>>   kernel/kallsyms.c                                  |   2 +-
>>   22 files changed, 1973 insertions(+), 152 deletions(-)
>>   create mode 100644 Documentation/admin-guide/qcom_minidump.rst
>>   create mode 100644 
>> Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>>   create mode 100644 include/soc/qcom/qcom_minidump.h
>>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-14 15:25     ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-14 15:25 UTC (permalink / raw)
  To: Kathiravan T, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio


> 
> Hi Mukesh,
> 
> For IPQ chipsets, for the crashdump to work, we need the below patch
> 
> firmware: scm: Modify only the download bits in TCSR register
> 
> can you post the below patches separately? Looks like minidump will take 
> some time and also I don't see any dependencies for these to go along 
> with the minidump. Given that, will it be possible to post the below 
> patches separately?
> 
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
> 
> Do let us know if we can take these patches and post it separately.

Yes, we can post this separately.

-Mukesh
> 
>>
>>   Documentation/admin-guide/index.rst                |   1 +
>>   Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
>>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
>>   MAINTAINERS                                        |  15 +
>>   arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
>>   arch/arm64/configs/defconfig                       |   4 +
>>   drivers/firmware/Kconfig                           |  11 -
>>   drivers/firmware/qcom_scm.c                        |  85 ++-
>>   drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
>>   drivers/remoteproc/qcom_common.c                   | 142 +----
>>   drivers/soc/qcom/Kconfig                           |  39 ++
>>   drivers/soc/qcom/Makefile                          |   3 +
>>   drivers/soc/qcom/qcom_minidump.c                   | 582 
>> +++++++++++++++++++++
>>   drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
>>   drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
>>   drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
>>   drivers/soc/qcom/smem.c                            |   9 +
>>   fs/pstore/ram.c                                    |  26 +-
>>   include/linux/firmware/qcom/qcom_scm.h             |   2 +
>>   include/linux/pstore_ram.h                         |   2 +
>>   include/soc/qcom/qcom_minidump.h                   |  64 +++
>>   kernel/kallsyms.c                                  |   2 +-
>>   22 files changed, 1973 insertions(+), 152 deletions(-)
>>   create mode 100644 Documentation/admin-guide/qcom_minidump.rst
>>   create mode 100644 
>> Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>>   create mode 100644 include/soc/qcom/qcom_minidump.h
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-14 15:25     ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-14 15:25 UTC (permalink / raw)
  To: Kathiravan T, corbet, agross, andersson, konrad.dybcio, robh+dt,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	mathieu.poirier, catalin.marinas, will, linus.walleij,
	andy.shevchenko
  Cc: linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio


> 
> Hi Mukesh,
> 
> For IPQ chipsets, for the crashdump to work, we need the below patch
> 
> firmware: scm: Modify only the download bits in TCSR register
> 
> can you post the below patches separately? Looks like minidump will take 
> some time and also I don't see any dependencies for these to go along 
> with the minidump. Given that, will it be possible to post the below 
> patches separately?
> 
>    firmware: qcom_scm: provide a read-modify-write function
>    pinctrl: qcom: Use qcom_scm_io_update_field()
>    firmware: scm: Modify only the download bits in TCSR register
> 
> Do let us know if we can take these patches and post it separately.

Yes, we can post this separately.

-Mukesh
> 
>>
>>   Documentation/admin-guide/index.rst                |   1 +
>>   Documentation/admin-guide/qcom_minidump.rst        | 293 +++++++++++
>>   .../devicetree/bindings/soc/qcom/qcom,ramoops.yaml | 126 +++++
>>   MAINTAINERS                                        |  15 +
>>   arch/arm64/boot/dts/qcom/sm8450.dtsi               |  12 +
>>   arch/arm64/configs/defconfig                       |   4 +
>>   drivers/firmware/Kconfig                           |  11 -
>>   drivers/firmware/qcom_scm.c                        |  85 ++-
>>   drivers/pinctrl/qcom/pinctrl-msm.c                 |  12 +-
>>   drivers/remoteproc/qcom_common.c                   | 142 +----
>>   drivers/soc/qcom/Kconfig                           |  39 ++
>>   drivers/soc/qcom/Makefile                          |   3 +
>>   drivers/soc/qcom/qcom_minidump.c                   | 582 
>> +++++++++++++++++++++
>>   drivers/soc/qcom/qcom_minidump_internal.h          |  98 ++++
>>   drivers/soc/qcom/qcom_minidump_smem.c              | 387 ++++++++++++++
>>   drivers/soc/qcom/qcom_pstore_minidump.c            | 210 ++++++++
>>   drivers/soc/qcom/smem.c                            |   9 +
>>   fs/pstore/ram.c                                    |  26 +-
>>   include/linux/firmware/qcom/qcom_scm.h             |   2 +
>>   include/linux/pstore_ram.h                         |   2 +
>>   include/soc/qcom/qcom_minidump.h                   |  64 +++
>>   kernel/kallsyms.c                                  |   2 +-
>>   22 files changed, 1973 insertions(+), 152 deletions(-)
>>   create mode 100644 Documentation/admin-guide/qcom_minidump.rst
>>   create mode 100644 
>> Documentation/devicetree/bindings/soc/qcom/qcom,ramoops.yaml
>>   create mode 100644 drivers/soc/qcom/qcom_minidump.c
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_internal.h
>>   create mode 100644 drivers/soc/qcom/qcom_minidump_smem.c
>>   create mode 100644 drivers/soc/qcom/qcom_pstore_minidump.c
>>   create mode 100644 include/soc/qcom/qcom_minidump.h
>>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-05 17:29         ` Trilok Soni
  (?)
@ 2023-07-14 23:45           ` Trilok Soni
  -1 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-14 23:45 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 7/5/2023 10:29 AM, Trilok Soni wrote:
> On 7/4/2023 2:27 AM, Linus Walleij wrote:
>> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
>>
>>> My bigger issue with this whole series is what would this all look
>>> like if every SoC vendor upstreamed their own custom dumping
>>> mechanism. That would be a mess. (I have similar opinions on the
>>> $soc-vendor hypervisors.)
>>
>> I agree with Rob's stance.
>>
>> I think it would be useful to get input from the hwtracing developers
>> (Alexander and Mathieu) who faced this "necessarily different" issue
>> with all the hwtrace mechanisms and found a way out of it. I suspect
>> they can have an idea of how this should be abstracted.
> 
> Any mailing list you suggest we expand to so that we get inputs from the 
> hwtracing developers and maintainers or just look into the MAINTAINERS 
> file and start an email thread?
> 
> We are fine to submit the abstract for the LPC in next two weeks, but 
> prefer to have lot of good discussion before it on the mailing list, so 
> that we have code to talk about in LPC.

We have submitted abstract at LPC MC. Let's continue the discussion here 
though.

Mukesh, do you want to expand the lists as necessary to see if other 
soc-vendors are having any inputs here? May be add Exynos or MTK kernel 
mailing lists + linux-kernel? I don't know if anyone will respond or 
not, but let's try.

---Trilok Soni


^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-14 23:45           ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-14 23:45 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 7/5/2023 10:29 AM, Trilok Soni wrote:
> On 7/4/2023 2:27 AM, Linus Walleij wrote:
>> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
>>
>>> My bigger issue with this whole series is what would this all look
>>> like if every SoC vendor upstreamed their own custom dumping
>>> mechanism. That would be a mess. (I have similar opinions on the
>>> $soc-vendor hypervisors.)
>>
>> I agree with Rob's stance.
>>
>> I think it would be useful to get input from the hwtracing developers
>> (Alexander and Mathieu) who faced this "necessarily different" issue
>> with all the hwtrace mechanisms and found a way out of it. I suspect
>> they can have an idea of how this should be abstracted.
> 
> Any mailing list you suggest we expand to so that we get inputs from the 
> hwtracing developers and maintainers or just look into the MAINTAINERS 
> file and start an email thread?
> 
> We are fine to submit the abstract for the LPC in next two weeks, but 
> prefer to have lot of good discussion before it on the mailing list, so 
> that we have code to talk about in LPC.

We have submitted abstract at LPC MC. Let's continue the discussion here 
though.

Mukesh, do you want to expand the lists as necessary to see if other 
soc-vendors are having any inputs here? May be add Exynos or MTK kernel 
mailing lists + linux-kernel? I don't know if anyone will respond or 
not, but let's try.

---Trilok Soni


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-14 23:45           ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-14 23:45 UTC (permalink / raw)
  To: Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin
  Cc: Greg KH, Mukesh Ojha, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio

On 7/5/2023 10:29 AM, Trilok Soni wrote:
> On 7/4/2023 2:27 AM, Linus Walleij wrote:
>> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
>>
>>> My bigger issue with this whole series is what would this all look
>>> like if every SoC vendor upstreamed their own custom dumping
>>> mechanism. That would be a mess. (I have similar opinions on the
>>> $soc-vendor hypervisors.)
>>
>> I agree with Rob's stance.
>>
>> I think it would be useful to get input from the hwtracing developers
>> (Alexander and Mathieu) who faced this "necessarily different" issue
>> with all the hwtrace mechanisms and found a way out of it. I suspect
>> they can have an idea of how this should be abstracted.
> 
> Any mailing list you suggest we expand to so that we get inputs from the 
> hwtracing developers and maintainers or just look into the MAINTAINERS 
> file and start an email thread?
> 
> We are fine to submit the abstract for the LPC in next two weeks, but 
> prefer to have lot of good discussion before it on the mailing list, so 
> that we have code to talk about in LPC.

We have submitted abstract at LPC MC. Let's continue the discussion here 
though.

Mukesh, do you want to expand the lists as necessary to see if other 
soc-vendors are having any inputs here? May be add Exynos or MTK kernel 
mailing lists + linux-kernel? I don't know if anyone will respond or 
not, but let's try.

---Trilok Soni


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-14 23:45           ` Trilok Soni
@ 2023-07-18  5:47             ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18  5:47 UTC (permalink / raw)
  To: linux-samsung-soc, linux-mediatek
  Cc: Greg KH, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Trilok Soni, Linus Walleij,
	Rob Herring, Mathieu Poirier, Alexander Shishkin

+ linux-samsung-soc@vger.kernel.org
+ linux-mediatek@lists.infradead.org



On 7/15/2023 5:15 AM, Trilok Soni wrote:
> On 7/5/2023 10:29 AM, Trilok Soni wrote:
>> On 7/4/2023 2:27 AM, Linus Walleij wrote:
>>> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
>>>
>>>> My bigger issue with this whole series is what would this all look
>>>> like if every SoC vendor upstreamed their own custom dumping
>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>> $soc-vendor hypervisors.)
>>>
>>> I agree with Rob's stance.
>>>
>>> I think it would be useful to get input from the hwtracing developers
>>> (Alexander and Mathieu) who faced this "necessarily different" issue
>>> with all the hwtrace mechanisms and found a way out of it. I suspect
>>> they can have an idea of how this should be abstracted.
>>
>> Any mailing list you suggest we expand to so that we get inputs from 
>> the hwtracing developers and maintainers or just look into the 
>> MAINTAINERS file and start an email thread?
>>
>> We are fine to submit the abstract for the LPC in next two weeks, but 
>> prefer to have lot of good discussion before it on the mailing list, 
>> so that we have code to talk about in LPC.
> 
> We have submitted abstract at LPC MC. Let's continue the discussion here 
> though.
> 
> Mukesh, do you want to expand the lists as necessary to see if other 
> soc-vendors are having any inputs here? May be add Exynos or MTK kernel 
> mailing lists + linux-kernel? I don't know if anyone will respond or 
> not, but let's try.

Sure.

-Mukesh
> 
> ---Trilok Soni
> 

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18  5:47             ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18  5:47 UTC (permalink / raw)
  To: linux-samsung-soc, linux-mediatek
  Cc: Greg KH, corbet, agross, andersson, konrad.dybcio,
	krzysztof.kozlowski+dt, conor+dt, keescook, tony.luck, gpiccoli,
	catalin.marinas, will, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Trilok Soni, Linus Walleij,
	Rob Herring, Mathieu Poirier, Alexander Shishkin

+ linux-samsung-soc@vger.kernel.org
+ linux-mediatek@lists.infradead.org



On 7/15/2023 5:15 AM, Trilok Soni wrote:
> On 7/5/2023 10:29 AM, Trilok Soni wrote:
>> On 7/4/2023 2:27 AM, Linus Walleij wrote:
>>> On Thu, Jun 29, 2023 at 1:12 AM Rob Herring <robh+dt@kernel.org> wrote:
>>>
>>>> My bigger issue with this whole series is what would this all look
>>>> like if every SoC vendor upstreamed their own custom dumping
>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>> $soc-vendor hypervisors.)
>>>
>>> I agree with Rob's stance.
>>>
>>> I think it would be useful to get input from the hwtracing developers
>>> (Alexander and Mathieu) who faced this "necessarily different" issue
>>> with all the hwtrace mechanisms and found a way out of it. I suspect
>>> they can have an idea of how this should be abstracted.
>>
>> Any mailing list you suggest we expand to so that we get inputs from 
>> the hwtracing developers and maintainers or just look into the 
>> MAINTAINERS file and start an email thread?
>>
>> We are fine to submit the abstract for the LPC in next two weeks, but 
>> prefer to have lot of good discussion before it on the mailing list, 
>> so that we have code to talk about in LPC.
> 
> We have submitted abstract at LPC MC. Let's continue the discussion here 
> though.
> 
> Mukesh, do you want to expand the lists as necessary to see if other 
> soc-vendors are having any inputs here? May be add Exynos or MTK kernel 
> mailing lists + linux-kernel? I don't know if anyone will respond or 
> not, but let's try.

Sure.

-Mukesh
> 
> ---Trilok Soni
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-18  5:47             ` Mukesh Ojha
@ 2023-07-18 13:35               ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-07-18 13:35 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin

On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
> + linux-samsung-soc@vger.kernel.org
> + linux-mediatek@lists.infradead.org

What does that do?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18 13:35               ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-07-18 13:35 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin

On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
> + linux-samsung-soc@vger.kernel.org
> + linux-mediatek@lists.infradead.org

What does that do?

confused,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-18 13:35               ` Greg KH
@ 2023-07-18 13:55                 ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18 13:55 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin



On 7/18/2023 7:05 PM, Greg KH wrote:
> On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
>> + linux-samsung-soc@vger.kernel.org
>> + linux-mediatek@lists.infradead.org
> 
> What does that do?

This is to seek their feedback, if they have something similar 
requirement to debug end user device crashes.

-Mukesh
> 
> confused,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18 13:55                 ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18 13:55 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin



On 7/18/2023 7:05 PM, Greg KH wrote:
> On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
>> + linux-samsung-soc@vger.kernel.org
>> + linux-mediatek@lists.infradead.org
> 
> What does that do?

This is to seek their feedback, if they have something similar 
requirement to debug end user device crashes.

-Mukesh
> 
> confused,
> 
> greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-18 13:55                 ` Mukesh Ojha
@ 2023-07-18 14:41                   ` Greg KH
  -1 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-07-18 14:41 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin

On Tue, Jul 18, 2023 at 07:25:15PM +0530, Mukesh Ojha wrote:
> 
> 
> On 7/18/2023 7:05 PM, Greg KH wrote:
> > On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
> > > + linux-samsung-soc@vger.kernel.org
> > > + linux-mediatek@lists.infradead.org
> > 
> > What does that do?
> 
> This is to seek their feedback, if they have something similar requirement
> to debug end user device crashes.

Feedback to what?  There is no context here and no content either at
all.

Just adding a mailing list to the top of a message doesn't actually send
the thread there.

confused,

greg k-h

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18 14:41                   ` Greg KH
  0 siblings, 0 replies; 176+ messages in thread
From: Greg KH @ 2023-07-18 14:41 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Trilok Soni, Linus Walleij, Rob Herring, Mathieu Poirier,
	Alexander Shishkin

On Tue, Jul 18, 2023 at 07:25:15PM +0530, Mukesh Ojha wrote:
> 
> 
> On 7/18/2023 7:05 PM, Greg KH wrote:
> > On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
> > > + linux-samsung-soc@vger.kernel.org
> > > + linux-mediatek@lists.infradead.org
> > 
> > What does that do?
> 
> This is to seek their feedback, if they have something similar requirement
> to debug end user device crashes.

Feedback to what?  There is no context here and no content either at
all.

Just adding a mailing list to the top of a message doesn't actually send
the thread there.

confused,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-06 17:20             ` Mathieu Poirier
@ 2023-07-18 15:03               ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18 15:03 UTC (permalink / raw)
  To: Mathieu Poirier, Trilok Soni
  Cc: Krzysztof Kozlowski, Rob Herring, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder



On 7/6/2023 10:50 PM, Mathieu Poirier wrote:
> On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they have
>> the similar solution now? We can expand this to linux-kernel and ask for the
>> other SOC vendors to chime in. I am sure that we may have existing solutions
>> which came in for the one user first like Intel RDT if I remember. I am sure
>> ARM MPAM usecase was present at that time but Intel RDT based solution which
>> was x86 specific but accepted.
> 
> I am not familiar with Intel RDT and Arm MPAM but the community is always
> improving on the way it does things.
> 
> LPC is indeed far out in November but it is an opportunity to cover the
> groundwork needed to have this discussion.  It is always best to improve on
> something then introduce something new.  Even better if something specific such
> as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
> hwtracing Linus referred to.  The perf framework wasn't a perfect fit but it was
> enhanced to accommodate our requirements.  I suggest to look at what is currently
> available and come up with a strategy to be presented at LPC - event better if
> you have a prototype.  If you can't find anything or the drawbacks inherent to
> each avenue outweigh the benefits then we can have that conversation at LPC.

I was checking hwtracing[1] and pmu interface introduction of
address filtering[3] from analogy point of view, which i think you
meant that perf framework was extended to accommodate this.

Minidump is quite different and simple in its way to address the problem
of debugging on end user devices with minimum data captured to debug 
crashes and this patch series is inline with similar (core + backend)
implementation done for stm patches[1] where stm core was developed
and intel trace hub get hooked into it and later it got reused in [2] by 
coresight-stm driver.

I am still exploring if something available we can reuse but it seems 
unlikely at the moment to already available something in the kernel with
similar use case.

-Mukesh

[1]
https://lwn.net/Articles/650245/

[2]
https://lwn.net/Articles/674201/

[3]
https://lore.kernel.org/lkml/1461771888-10409-1-git-send-email-alexander.shishkin@linux.intel.com/


> 
>>
>> ---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18 15:03               ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-07-18 15:03 UTC (permalink / raw)
  To: Mathieu Poirier, Trilok Soni
  Cc: Krzysztof Kozlowski, Rob Herring, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder



On 7/6/2023 10:50 PM, Mathieu Poirier wrote:
> On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they have
>> the similar solution now? We can expand this to linux-kernel and ask for the
>> other SOC vendors to chime in. I am sure that we may have existing solutions
>> which came in for the one user first like Intel RDT if I remember. I am sure
>> ARM MPAM usecase was present at that time but Intel RDT based solution which
>> was x86 specific but accepted.
> 
> I am not familiar with Intel RDT and Arm MPAM but the community is always
> improving on the way it does things.
> 
> LPC is indeed far out in November but it is an opportunity to cover the
> groundwork needed to have this discussion.  It is always best to improve on
> something then introduce something new.  Even better if something specific such
> as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
> hwtracing Linus referred to.  The perf framework wasn't a perfect fit but it was
> enhanced to accommodate our requirements.  I suggest to look at what is currently
> available and come up with a strategy to be presented at LPC - event better if
> you have a prototype.  If you can't find anything or the drawbacks inherent to
> each avenue outweigh the benefits then we can have that conversation at LPC.

I was checking hwtracing[1] and pmu interface introduction of
address filtering[3] from analogy point of view, which i think you
meant that perf framework was extended to accommodate this.

Minidump is quite different and simple in its way to address the problem
of debugging on end user devices with minimum data captured to debug 
crashes and this patch series is inline with similar (core + backend)
implementation done for stm patches[1] where stm core was developed
and intel trace hub get hooked into it and later it got reused in [2] by 
coresight-stm driver.

I am still exploring if something available we can reuse but it seems 
unlikely at the moment to already available something in the kernel with
similar use case.

-Mukesh

[1]
https://lwn.net/Articles/650245/

[2]
https://lwn.net/Articles/674201/

[3]
https://lore.kernel.org/lkml/1461771888-10409-1-git-send-email-alexander.shishkin@linux.intel.com/


> 
>>
>> ---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-18 14:41                   ` Greg KH
@ 2023-07-18 16:22                     ` Trilok Soni
  -1 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-18 16:22 UTC (permalink / raw)
  To: Greg KH, Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin

On 7/18/2023 7:41 AM, Greg KH wrote:
> On Tue, Jul 18, 2023 at 07:25:15PM +0530, Mukesh Ojha wrote:
>>
>>
>> On 7/18/2023 7:05 PM, Greg KH wrote:
>>> On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
>>>> + linux-samsung-soc@vger.kernel.org
>>>> + linux-mediatek@lists.infradead.org
>>>
>>> What does that do?
>>
>> This is to seek their feedback, if they have something similar requirement
>> to debug end user device crashes.
> 
> Feedback to what?  There is no context here and no content either at
> all.
> 
> Just adding a mailing list to the top of a message doesn't actually send
> the thread there.
> 
> confused,

Mukesh, instead of adding the mailing lists here, we should send either 
the refreshed revision of this patchset (if there are enough changes) w/ 
MLs CCed or start a new discussion with these mailing list with the 
context of the minidump and refer these patches from the mailing list 
archives.

---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-07-18 16:22                     ` Trilok Soni
  0 siblings, 0 replies; 176+ messages in thread
From: Trilok Soni @ 2023-07-18 16:22 UTC (permalink / raw)
  To: Greg KH, Mukesh Ojha
  Cc: linux-samsung-soc, linux-mediatek, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, catalin.marinas, will, andy.shevchenko,
	linux-doc, linux-kernel, linux-arm-msm, devicetree,
	linux-hardening, linux-remoteproc, linux-arm-kernel, linux-gpio,
	Linus Walleij, Rob Herring, Mathieu Poirier, Alexander Shishkin

On 7/18/2023 7:41 AM, Greg KH wrote:
> On Tue, Jul 18, 2023 at 07:25:15PM +0530, Mukesh Ojha wrote:
>>
>>
>> On 7/18/2023 7:05 PM, Greg KH wrote:
>>> On Tue, Jul 18, 2023 at 11:17:12AM +0530, Mukesh Ojha wrote:
>>>> + linux-samsung-soc@vger.kernel.org
>>>> + linux-mediatek@lists.infradead.org
>>>
>>> What does that do?
>>
>> This is to seek their feedback, if they have something similar requirement
>> to debug end user device crashes.
> 
> Feedback to what?  There is no context here and no content either at
> all.
> 
> Just adding a mailing list to the top of a message doesn't actually send
> the thread there.
> 
> confused,

Mukesh, instead of adding the mailing lists here, we should send either 
the refreshed revision of this patchset (if there are enough changes) w/ 
MLs CCed or start a new discussion with these mailing list with the 
context of the minidump and refer these patches from the mailing list 
archives.

---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
  2023-07-04  5:57                 ` Krzysztof Kozlowski
@ 2023-07-19 10:29                   ` Luca Stefani
  -1 siblings, 0 replies; 176+ messages in thread
From: Luca Stefani @ 2023-07-19 10:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio


On 04/07/23 07:57, Krzysztof Kozlowski wrote:
> On 03/07/2023 17:55, Mukesh Ojha wrote:
>>
>> On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
>>> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>>>> The big difference is if firmware is not deciding where this log
>>>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>>>> kernel that allocates the log find the logs?
>>>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>>>> instead here, Kernel has reserved the region where the ramoops region
>>>>>> lives and later with the minidump registration where, physical
>>>>>> address/size/virtual address(for parsing) are passed and that is how
>>>>>> firmware is able to know and dump those region before triggering system
>>>>>> reset.
>>>>> Your explanation does not justify storing all this in DT. Kernel can
>>>>> allocate any memory it wishes, store there logs and pass the address to
>>>>> the firmware. That's it, no need for DT.
>>>> If you go through the driver, you will know that what it does, is
>>> We talk about bindings and I should not be forced to look at the
>>> driver to be able to understand them. Bindings should stand on their
>>> own.
>> Why can't ramoops binding have one more feature where it can add a flag
>> *dynamic* to indicate the regions are dynamic and it is for platforms
>> where there is another entity 'minidump' who is interested in these
>> regions.
> Because we do not define dynamic stuff in Devicetree. Dynamic means
> defined by SW or runtime configurable. It is against the entire idea of
> Devicetree which is for non-discoverable hardware.
>
>>>> just create platform device for actual ramoops driver to probe and to
>>> Not really justification for Devicetree anyway. Whatever your driver
>>> is doing, is driver's business, not bindings.
>>>
>>>> provide this it needs exact set of parameters of input what original
>>>> ramoops DT provides, we need to keep it in DT as maintaining this in
>>>> driver will not scale well with different size/parameter size
>>>> requirement for different targets.
>>> Really? Why? I don't see a problem in scaling. At all.
>> I had attempted it here,
>>
>> https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/
>>
>> but got comments related to hard coding and some in favor of having
>> the same set of properties what ramoops has/provides
>>
>> https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/
>>
>> https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/
> Then you were tricked. I don't get why someone else suggests that
> non-hardware property should be part of Devicetree, but anyway it's the
> call of Devicetree binding maintainers, not someone else. DT is not
> dumping ground for all the system configuration variables.

Sorry for that, I assumed the interface should be as close as possible 
to pstore, but apparently that's not the case. Why does it have to be 
different from it? It provides the same functionality and is 
configurable even if it doesn't explicitly configure non discoverable 
hardware properties.

Assuming we make the driver picks the values, how would it do that?  
Hardcoding a configuration could lead to a few problems, such as the 
allocated region being smaller than the driver defaults or driver 
defaults not fully utilizing the allocated region, possibly wasting more 
memory than it'll ever use. On top of that what happens if we want to 
configure it differently than the hardcoded default values? Via cmdline 
options? For example in the previous version it allocated the whole 
region for the console alone, while other entries, such as pmsg that 
could be useful on devices using minidump to store Android logs, was 
zero-sized.

>
>>>>>> A part of this registration code you can find in 11/21
>>>>>>
>>>>>>> I'm pretty sure I already said all this before.
>>>>>> Yes, you said this before but that's the reason i came up with vendor
>>>>>> ramoops instead of changing traditional ramoops binding.
>>>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>>>> comment that it should not be in the DTS in the first place.
>>>> Please suggest, what is the other way being above text as requirement..
>>> I do not see any requirement for us there. Forcing me to figure out
>>> how to add non-hardware property to DT is not the way to convince
>>> reviewers. But if you insist - we have ABI for this, called sysfs. If
>>> it is debugging feature, then debugfs.
>> ramoops already support module params and a way to pass these parameters
>> from bootargs but it also need to know the hard-codes addresses, so,
>> doing something in sysfs will be again duplication with ramoops driver..
> Why do you need hard-coded addresses?
>
>> If this can be accommodated under ramoops, this will be very small
>> change, like this
>>
>> https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/
> That's also funny patch - missing bindings updated, missing CC DT
> maintainers.
>
> Best regards,
> Krzysztof
>
>
>

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 08/21] dt-bindings: reserved-memory: Add qcom,ramoops binding
@ 2023-07-19 10:29                   ` Luca Stefani
  0 siblings, 0 replies; 176+ messages in thread
From: Luca Stefani @ 2023-07-19 10:29 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mukesh Ojha
  Cc: Rob Herring, corbet, agross, andersson, konrad.dybcio, conor+dt,
	keescook, tony.luck, gpiccoli, mathieu.poirier, catalin.marinas,
	will, linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio


On 04/07/23 07:57, Krzysztof Kozlowski wrote:
> On 03/07/2023 17:55, Mukesh Ojha wrote:
>>
>> On 7/3/2023 12:50 PM, Krzysztof Kozlowski wrote:
>>> On Mon, 3 Jul 2023 at 08:22, Mukesh Ojha <quic_mojha@quicinc.com> wrote:
>>>> On 7/2/2023 1:42 PM, Krzysztof Kozlowski wrote:
>>>>>>> The big difference is if firmware is not deciding where this log
>>>>>>> lives, then it doesn't need to be in DT. How does anything except the
>>>>>>> kernel that allocates the log find the logs?
>>>>>> Yes, you are correct, firmware is not deciding where the logs lives
>>>>>> instead here, Kernel has reserved the region where the ramoops region
>>>>>> lives and later with the minidump registration where, physical
>>>>>> address/size/virtual address(for parsing) are passed and that is how
>>>>>> firmware is able to know and dump those region before triggering system
>>>>>> reset.
>>>>> Your explanation does not justify storing all this in DT. Kernel can
>>>>> allocate any memory it wishes, store there logs and pass the address to
>>>>> the firmware. That's it, no need for DT.
>>>> If you go through the driver, you will know that what it does, is
>>> We talk about bindings and I should not be forced to look at the
>>> driver to be able to understand them. Bindings should stand on their
>>> own.
>> Why can't ramoops binding have one more feature where it can add a flag
>> *dynamic* to indicate the regions are dynamic and it is for platforms
>> where there is another entity 'minidump' who is interested in these
>> regions.
> Because we do not define dynamic stuff in Devicetree. Dynamic means
> defined by SW or runtime configurable. It is against the entire idea of
> Devicetree which is for non-discoverable hardware.
>
>>>> just create platform device for actual ramoops driver to probe and to
>>> Not really justification for Devicetree anyway. Whatever your driver
>>> is doing, is driver's business, not bindings.
>>>
>>>> provide this it needs exact set of parameters of input what original
>>>> ramoops DT provides, we need to keep it in DT as maintaining this in
>>>> driver will not scale well with different size/parameter size
>>>> requirement for different targets.
>>> Really? Why? I don't see a problem in scaling. At all.
>> I had attempted it here,
>>
>> https://lore.kernel.org/lkml/1683133352-10046-10-git-send-email-quic_mojha@quicinc.com/
>>
>> but got comments related to hard coding and some in favor of having
>> the same set of properties what ramoops has/provides
>>
>> https://lore.kernel.org/lkml/e25723bf-be85-b458-a84c-1a45392683bb@gmail.com/
>>
>> https://lore.kernel.org/lkml/202305161347.80204C1A0E@keescook/
> Then you were tricked. I don't get why someone else suggests that
> non-hardware property should be part of Devicetree, but anyway it's the
> call of Devicetree binding maintainers, not someone else. DT is not
> dumping ground for all the system configuration variables.

Sorry for that, I assumed the interface should be as close as possible 
to pstore, but apparently that's not the case. Why does it have to be 
different from it? It provides the same functionality and is 
configurable even if it doesn't explicitly configure non discoverable 
hardware properties.

Assuming we make the driver picks the values, how would it do that?  
Hardcoding a configuration could lead to a few problems, such as the 
allocated region being smaller than the driver defaults or driver 
defaults not fully utilizing the allocated region, possibly wasting more 
memory than it'll ever use. On top of that what happens if we want to 
configure it differently than the hardcoded default values? Via cmdline 
options? For example in the previous version it allocated the whole 
region for the console alone, while other entries, such as pmsg that 
could be useful on devices using minidump to store Android logs, was 
zero-sized.

>
>>>>>> A part of this registration code you can find in 11/21
>>>>>>
>>>>>>> I'm pretty sure I already said all this before.
>>>>>> Yes, you said this before but that's the reason i came up with vendor
>>>>>> ramoops instead of changing traditional ramoops binding.
>>>>> That's unexpected conclusion. Adding more bindings is not the answer to
>>>>> comment that it should not be in the DTS in the first place.
>>>> Please suggest, what is the other way being above text as requirement..
>>> I do not see any requirement for us there. Forcing me to figure out
>>> how to add non-hardware property to DT is not the way to convince
>>> reviewers. But if you insist - we have ABI for this, called sysfs. If
>>> it is debugging feature, then debugfs.
>> ramoops already support module params and a way to pass these parameters
>> from bootargs but it also need to know the hard-codes addresses, so,
>> doing something in sysfs will be again duplication with ramoops driver..
> Why do you need hard-coded addresses?
>
>> If this can be accommodated under ramoops, this will be very small
>> change, like this
>>
>> https://lore.kernel.org/lkml/20230622005213.458236-1-isaacmanjarres@google.com/
> That's also funny patch - missing bindings updated, missing CC DT
> maintainers.
>
> Best regards,
> Krzysztof
>
>
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-18 15:03               ` Mukesh Ojha
@ 2023-08-07 13:46                 ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-08-07 13:46 UTC (permalink / raw)
  To: Mathieu Poirier, Trilok Soni
  Cc: Krzysztof Kozlowski, Rob Herring, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder


On 7/18/2023 8:33 PM, Mukesh Ojha wrote:
> 
> 
> On 7/6/2023 10:50 PM, Mathieu Poirier wrote:
>> On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
>>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>>
>>>>>>> We don't add layers when they are not needed, and never when 
>>>>>>> there is no
>>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>>
>>>>>>> Please redo this series based on that, thanks.
>>>>>>
>>>>>> My bigger issue with this whole series is what would this all look
>>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>>> $soc-vendor hypervisors.)
>>>>
>>>> Mukesh,
>>>>
>>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>>> LPC microconference tracks. Coming with a unified solution could be a
>>>> great topic for LPC. Solutions targeting only one user are quite often
>>>> frowned upon.
>>>
>>> LPC is far out and in November. Can we not have others speak up if 
>>> they have
>>> the similar solution now? We can expand this to linux-kernel and ask 
>>> for the
>>> other SOC vendors to chime in. I am sure that we may have existing 
>>> solutions
>>> which came in for the one user first like Intel RDT if I remember. I 
>>> am sure
>>> ARM MPAM usecase was present at that time but Intel RDT based 
>>> solution which
>>> was x86 specific but accepted.
>>
>> I am not familiar with Intel RDT and Arm MPAM but the community is always
>> improving on the way it does things.
>>
>> LPC is indeed far out in November but it is an opportunity to cover the
>> groundwork needed to have this discussion.  It is always best to 
>> improve on
>> something then introduce something new.  Even better if something 
>> specific such
>> as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
>> hwtracing Linus referred to.  The perf framework wasn't a perfect fit 
>> but it was
>> enhanced to accommodate our requirements.  I suggest to look at what 
>> is currently
>> available and come up with a strategy to be presented at LPC - event 
>> better if
>> you have a prototype.  If you can't find anything or the drawbacks 
>> inherent to
>> each avenue outweigh the benefits then we can have that conversation 
>> at LPC.
> 
> I was checking hwtracing[1] and pmu interface introduction of
> address filtering[3] from analogy point of view, which i think you
> meant that perf framework was extended to accommodate this.
> 
> Minidump is quite different and simple in its way to address the problem
> of debugging on end user devices with minimum data captured to debug 
> crashes and this patch series is inline with similar (core + backend)
> implementation done for stm patches[1] where stm core was developed
> and intel trace hub get hooked into it and later it got reused in [2] by 
> coresight-stm driver.
> 
> I am still exploring if something available we can reuse but it seems 
> unlikely at the moment to already available something in the kernel with
> similar use case.


I explored about kdump and fadump(PPC) but they take another route to 
boot capture kernel, FAdump is even optimized and do not even boot
capture kernel instead reboot the same kernel with minimal
memory and once the reading of crash kernel region is complete
from user space it release the memories.

Latency in booting another kernel may not acceptable to boot time
sensitive devices like mobile, tablet etc., also to boot another
kernel will have security implication with user data..

So, Minidump is limited in its capability and uses firmware infra
to dump registered entries and boot afresh. So, it need to be
presented what need to be dumped via Minidump registration API.

If there is no comments, would like to go ahead with the next
revision of the patchset.

-Mukesh
> 
> -Mukesh
> 
> [1]
> https://lwn.net/Articles/650245/
> 
> [2]
> https://lwn.net/Articles/674201/
> 
> [3]
> https://lore.kernel.org/lkml/1461771888-10409-1-git-send-email-alexander.shishkin@linux.intel.com/
> 
> 
>>
>>>
>>> ---Trilok Soni

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-08-07 13:46                 ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-08-07 13:46 UTC (permalink / raw)
  To: Mathieu Poirier, Trilok Soni
  Cc: Krzysztof Kozlowski, Rob Herring, Greg KH, corbet, agross,
	andersson, konrad.dybcio, krzysztof.kozlowski+dt, conor+dt,
	keescook, tony.luck, gpiccoli, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder


On 7/18/2023 8:33 PM, Mukesh Ojha wrote:
> 
> 
> On 7/6/2023 10:50 PM, Mathieu Poirier wrote:
>> On Mon, Jul 03, 2023 at 02:05:58PM -0700, Trilok Soni wrote:
>>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>>
>>>>>>> We don't add layers when they are not needed, and never when 
>>>>>>> there is no
>>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>>
>>>>>>> Please redo this series based on that, thanks.
>>>>>>
>>>>>> My bigger issue with this whole series is what would this all look
>>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>>> $soc-vendor hypervisors.)
>>>>
>>>> Mukesh,
>>>>
>>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>>> LPC microconference tracks. Coming with a unified solution could be a
>>>> great topic for LPC. Solutions targeting only one user are quite often
>>>> frowned upon.
>>>
>>> LPC is far out and in November. Can we not have others speak up if 
>>> they have
>>> the similar solution now? We can expand this to linux-kernel and ask 
>>> for the
>>> other SOC vendors to chime in. I am sure that we may have existing 
>>> solutions
>>> which came in for the one user first like Intel RDT if I remember. I 
>>> am sure
>>> ARM MPAM usecase was present at that time but Intel RDT based 
>>> solution which
>>> was x86 specific but accepted.
>>
>> I am not familiar with Intel RDT and Arm MPAM but the community is always
>> improving on the way it does things.
>>
>> LPC is indeed far out in November but it is an opportunity to cover the
>> groundwork needed to have this discussion.  It is always best to 
>> improve on
>> something then introduce something new.  Even better if something 
>> specific such
>> as Intel RDT and Arm MPAM can be made more generic.  A perfect example is
>> hwtracing Linus referred to.  The perf framework wasn't a perfect fit 
>> but it was
>> enhanced to accommodate our requirements.  I suggest to look at what 
>> is currently
>> available and come up with a strategy to be presented at LPC - event 
>> better if
>> you have a prototype.  If you can't find anything or the drawbacks 
>> inherent to
>> each avenue outweigh the benefits then we can have that conversation 
>> at LPC.
> 
> I was checking hwtracing[1] and pmu interface introduction of
> address filtering[3] from analogy point of view, which i think you
> meant that perf framework was extended to accommodate this.
> 
> Minidump is quite different and simple in its way to address the problem
> of debugging on end user devices with minimum data captured to debug 
> crashes and this patch series is inline with similar (core + backend)
> implementation done for stm patches[1] where stm core was developed
> and intel trace hub get hooked into it and later it got reused in [2] by 
> coresight-stm driver.
> 
> I am still exploring if something available we can reuse but it seems 
> unlikely at the moment to already available something in the kernel with
> similar use case.


I explored about kdump and fadump(PPC) but they take another route to 
boot capture kernel, FAdump is even optimized and do not even boot
capture kernel instead reboot the same kernel with minimal
memory and once the reading of crash kernel region is complete
from user space it release the memories.

Latency in booting another kernel may not acceptable to boot time
sensitive devices like mobile, tablet etc., also to boot another
kernel will have security implication with user data..

So, Minidump is limited in its capability and uses firmware infra
to dump registered entries and boot afresh. So, it need to be
presented what need to be dumped via Minidump registration API.

If there is no comments, would like to go ahead with the next
revision of the patchset.

-Mukesh
> 
> -Mukesh
> 
> [1]
> https://lwn.net/Articles/650245/
> 
> [2]
> https://lwn.net/Articles/674201/
> 
> [3]
> https://lore.kernel.org/lkml/1461771888-10409-1-git-send-email-alexander.shishkin@linux.intel.com/
> 
> 
>>
>>>
>>> ---Trilok Soni

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
  2023-07-06 17:40             ` Rob Herring
@ 2023-08-10 16:47               ` Mukesh Ojha
  -1 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-08-10 16:47 UTC (permalink / raw)
  To: Rob Herring, Trilok Soni
  Cc: Krzysztof Kozlowski, Greg KH, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, mathieu.poirier, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder



On 7/6/2023 11:10 PM, Rob Herring wrote:
> On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>>
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they
>> have the similar solution now? We can expand this to linux-kernel and
>> ask for the other SOC vendors to chime in. I am sure that we may have
>> existing solutions which came in for the one user first like Intel RDT
>> if I remember. I am sure ARM MPAM usecase was present at that time but
>> Intel RDT based solution which was x86 specific but accepted.
> 
> RDT predated MPAM. resctrl is the kernel feature, and it supports
> Intel and AMD which are not identical. resctrl is being (extensively)
> refactored to add in MPAM support.
> 
> You are not the first here like Intel RDT, so I fail to see the
> parallel with minidump. We have an existing logging to persistent
> storage mechanism which is pstore. You should integrate into that
> rather than grafting something on to the side or underneath.

Most of the Qualcomm SoCs does not support *warm boot* and that is the
base requirement for pstore(ram) to work to preserve the content of
fixed region during the reboot. So, it will not work those SOCs.

Minidump in its capability can do more than what is available
through pstore, it can dump ramoops region as one of data point
for debugging but it can dump anything given the size and address.

We can make minidump it another backend of pstore(ram), and improve
pstore with more debug data collection during panic like timer data or 
irqstats etc. which was our final goal with minidump that way pstore
also gets benefit and minidump will just collect what is there in
pstore(ram). but for that we need base infrastructure driver to
merge.

One of the proposal made here..
https://lore.kernel.org/lkml/1683561060-2197-1-git-send-email-quic_mojha@quicinc.com/

-Mukesh
> 
> Rob

^ permalink raw reply	[flat|nested] 176+ messages in thread

* Re: [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support
@ 2023-08-10 16:47               ` Mukesh Ojha
  0 siblings, 0 replies; 176+ messages in thread
From: Mukesh Ojha @ 2023-08-10 16:47 UTC (permalink / raw)
  To: Rob Herring, Trilok Soni
  Cc: Krzysztof Kozlowski, Greg KH, corbet, agross, andersson,
	konrad.dybcio, krzysztof.kozlowski+dt, conor+dt, keescook,
	tony.luck, gpiccoli, mathieu.poirier, catalin.marinas, will,
	linus.walleij, andy.shevchenko, linux-doc, linux-kernel,
	linux-arm-msm, devicetree, linux-hardening, linux-remoteproc,
	linux-arm-kernel, linux-gpio, Alex Elder



On 7/6/2023 11:10 PM, Rob Herring wrote:
> On Mon, Jul 3, 2023 at 3:06 PM Trilok Soni <quic_tsoni@quicinc.com> wrote:
>>
>> On 7/2/2023 1:29 AM, Krzysztof Kozlowski wrote:
>>> On 30/06/2023 18:04, Mukesh Ojha wrote:
>>>>>
>>>>>> We don't add layers when they are not needed, and never when there is no
>>>>>> actual user.  If you need the extra "complexity" later, then add it
>>>>>> later when it is needed as who knows when that will ever be.
>>>>>>
>>>>>> Please redo this series based on that, thanks.
>>>>>
>>>>> My bigger issue with this whole series is what would this all look
>>>>> like if every SoC vendor upstreamed their own custom dumping
>>>>> mechanism. That would be a mess. (I have similar opinions on the
>>>>> $soc-vendor hypervisors.)
>>>
>>> Mukesh,
>>>
>>> LPC CFP is still open. There will be also Android and Kernel Debugging
>>> LPC microconference tracks. Coming with a unified solution could be a
>>> great topic for LPC. Solutions targeting only one user are quite often
>>> frowned upon.
>>
>> LPC is far out and in November. Can we not have others speak up if they
>> have the similar solution now? We can expand this to linux-kernel and
>> ask for the other SOC vendors to chime in. I am sure that we may have
>> existing solutions which came in for the one user first like Intel RDT
>> if I remember. I am sure ARM MPAM usecase was present at that time but
>> Intel RDT based solution which was x86 specific but accepted.
> 
> RDT predated MPAM. resctrl is the kernel feature, and it supports
> Intel and AMD which are not identical. resctrl is being (extensively)
> refactored to add in MPAM support.
> 
> You are not the first here like Intel RDT, so I fail to see the
> parallel with minidump. We have an existing logging to persistent
> storage mechanism which is pstore. You should integrate into that
> rather than grafting something on to the side or underneath.

Most of the Qualcomm SoCs does not support *warm boot* and that is the
base requirement for pstore(ram) to work to preserve the content of
fixed region during the reboot. So, it will not work those SOCs.

Minidump in its capability can do more than what is available
through pstore, it can dump ramoops region as one of data point
for debugging but it can dump anything given the size and address.

We can make minidump it another backend of pstore(ram), and improve
pstore with more debug data collection during panic like timer data or 
irqstats etc. which was our final goal with minidump that way pstore
also gets benefit and minidump will just collect what is there in
pstore(ram). but for that we need base infrastructure driver to
merge.

One of the proposal made here..
https://lore.kernel.org/lkml/1683561060-2197-1-git-send-email-quic_mojha@quicinc.com/

-Mukesh
> 
> Rob

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 176+ messages in thread

end of thread, other threads:[~2023-08-10 16:49 UTC | newest]

Thread overview: 176+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2023-06-28 12:34 ` [PATCH v4 01/21] docs: qcom: Add qualcomm minidump guide Mukesh Ojha
2023-06-28 12:34   ` Mukesh Ojha
2023-06-28 23:21   ` Rob Herring
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 12:34   ` Mukesh Ojha
2023-06-28 13:24   ` Andy Shevchenko
2023-06-28 13:24     ` Andy Shevchenko
2023-06-28 15:04     ` Mukesh Ojha
2023-06-28 15:04       ` Mukesh Ojha
2023-06-28 13:53   ` Pavan Kondeti
2023-06-28 13:53     ` Pavan Kondeti
2023-06-28 15:22     ` Mukesh Ojha
2023-06-28 15:22       ` Mukesh Ojha
2023-06-28 15:32       ` Will Deacon
2023-06-28 15:32         ` Will Deacon
2023-06-28 15:43         ` Greg KH
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 12:34   ` Mukesh Ojha
2023-06-28 13:31   ` Andy Shevchenko
2023-06-28 13:31     ` Andy Shevchenko
2023-06-28 15:47   ` Greg KH
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 12:34   ` Mukesh Ojha
2023-06-28 13:43   ` Andy Shevchenko
2023-06-28 13:43     ` Andy Shevchenko
2023-06-29  2:33   ` Pavan Kondeti
2023-06-29  2:33     ` Pavan Kondeti
2023-06-30  7:15     ` Mukesh Ojha
2023-06-30  7:15       ` Mukesh Ojha
2023-06-30  8:38       ` Pavan Kondeti
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 12:34   ` Mukesh Ojha
2023-06-28 13:51   ` Andy Shevchenko
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   ` Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 07/21] soc: qcom: minidump: Add update region support Mukesh Ojha
2023-06-28 12:34   ` Mukesh Ojha
2023-06-29  2:49   ` Pavan Kondeti
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 12:34   ` Mukesh Ojha
2023-06-28 14:10   ` Pavan Kondeti
2023-06-28 14:10     ` Pavan Kondeti
2023-06-28 23:17     ` Rob Herring
2023-06-28 23:17       ` Rob Herring
2023-06-29  1:45       ` Pavan Kondeti
2023-06-29  1:45         ` Pavan Kondeti
2023-06-28 14:47   ` Rob Herring
2023-06-28 14:47     ` Rob Herring
2023-06-28 15:01     ` Mukesh Ojha
2023-06-28 15:01       ` Mukesh Ojha
2023-07-02  8:12       ` Krzysztof Kozlowski
2023-07-02  8:12         ` Krzysztof Kozlowski
2023-07-03  6:21         ` Mukesh Ojha
2023-07-03  6:21           ` Mukesh Ojha
2023-07-03  7:20           ` Krzysztof Kozlowski
2023-07-03  7:20             ` Krzysztof Kozlowski
2023-07-03 15:55             ` Mukesh Ojha
2023-07-03 15:55               ` Mukesh Ojha
2023-07-04  5:57               ` Krzysztof Kozlowski
2023-07-04  5:57                 ` Krzysztof Kozlowski
2023-07-19 10:29                 ` Luca Stefani
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   ` 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 12:34   ` Mukesh Ojha
2023-06-28 22:57   ` Rob Herring
2023-06-28 22:57     ` Rob Herring
2023-06-29  9:16     ` Mukesh Ojha
2023-06-29  9:16       ` Mukesh Ojha
2023-07-05 23:27       ` Rob Herring
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-28 12:34   ` Mukesh Ojha
2023-06-30  4:55   ` Pavan Kondeti
2023-06-30  4:55     ` Pavan Kondeti
2023-06-30  9:25     ` Andy Shevchenko
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   ` Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 13/21] remoterproc: qcom: refactor to leverage exported minidump symbol Mukesh Ojha
2023-06-28 12:34   ` Mukesh Ojha
2023-06-28 15:51   ` Pavan Kondeti
2023-06-28 15:51     ` Pavan Kondeti
2023-06-29  9:20     ` Mukesh Ojha
2023-06-29  9:20       ` Mukesh Ojha
2023-06-30  3:41       ` Pavan Kondeti
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   ` 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   ` 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   ` Mukesh Ojha
2023-06-28 12:34 ` [PATCH v4 17/21] firmware: qcom_scm: provide a read-modify-write function Mukesh Ojha
2023-06-28 12:34   ` Mukesh Ojha
2023-06-30  5:01   ` Pavan Kondeti
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 12:34   ` Mukesh Ojha
2023-06-28 13:44   ` Andy Shevchenko
2023-06-28 13:44     ` Andy Shevchenko
2023-06-30 14:58     ` Mukesh Ojha
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 12:34   ` Mukesh Ojha
2023-06-28 15:20   ` Konrad Dybcio
2023-06-28 15:20     ` Konrad Dybcio
2023-06-30 14:57     ` Mukesh Ojha
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-28 12:34   ` Mukesh Ojha
2023-06-30  5:25   ` Pavan Kondeti
2023-06-30  5:25     ` Pavan Kondeti
2023-06-30  9:28     ` Andy Shevchenko
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 12:34   ` Mukesh Ojha
2023-06-28 15:45 ` [PATCH v4 00/21] Add Qualcomm Minidump kernel driver related support Greg KH
2023-06-28 15:45   ` Greg KH
2023-06-28 16:20   ` Mukesh Ojha
2023-06-28 16:20     ` Mukesh Ojha
2023-06-28 16:53     ` Greg KH
2023-06-28 16:53       ` Greg KH
2023-06-28 23:12   ` Rob Herring
2023-06-28 23:12     ` Rob Herring
2023-06-30 16:04     ` Mukesh Ojha
2023-06-30 16:04       ` Mukesh Ojha
2023-07-02  8:29       ` Krzysztof Kozlowski
2023-07-02  8:29         ` Krzysztof Kozlowski
2023-07-03 21:05         ` Trilok Soni
2023-07-03 21:05           ` Trilok Soni
2023-07-06 17:20           ` Mathieu Poirier
2023-07-06 17:20             ` Mathieu Poirier
2023-07-18 15:03             ` Mukesh Ojha
2023-07-18 15:03               ` Mukesh Ojha
2023-08-07 13:46               ` Mukesh Ojha
2023-08-07 13:46                 ` Mukesh Ojha
2023-07-06 17:40           ` Rob Herring
2023-07-06 17:40             ` Rob Herring
2023-07-06 18:07             ` Trilok Soni
2023-07-06 18:07               ` Trilok Soni
2023-08-10 16:47             ` Mukesh Ojha
2023-08-10 16:47               ` Mukesh Ojha
2023-07-04  9:27     ` Linus Walleij
2023-07-04  9:27       ` Linus Walleij
2023-07-05 17:29       ` Trilok Soni
2023-07-05 17:29         ` Trilok Soni
2023-07-14 23:45         ` Trilok Soni
2023-07-14 23:45           ` Trilok Soni
2023-07-14 23:45           ` Trilok Soni
2023-07-18  5:47           ` Mukesh Ojha
2023-07-18  5:47             ` Mukesh Ojha
2023-07-18 13:35             ` Greg KH
2023-07-18 13:35               ` Greg KH
2023-07-18 13:55               ` Mukesh Ojha
2023-07-18 13:55                 ` Mukesh Ojha
2023-07-18 14:41                 ` Greg KH
2023-07-18 14:41                   ` Greg KH
2023-07-18 16:22                   ` Trilok Soni
2023-07-18 16:22                     ` Trilok Soni
2023-07-02  8:08 ` Krzysztof Kozlowski
2023-07-02  8:08   ` Krzysztof Kozlowski
2023-07-13  4:39 ` Kathiravan T
2023-07-13  4:39   ` Kathiravan T
2023-07-14 15:25   ` Mukesh Ojha
2023-07-14 15:25     ` Mukesh Ojha
2023-07-14 15:25     ` Mukesh Ojha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.