Coresight for Kernel panic and watchdog reset
Subsystems (4)
v10 cover Coresight for Kernel panic and watchdog reset
This patch series is rebased on coresight-next-v6.12.
Changelog from v9:
* Add common helper function of_tmc_get_reserved_resource_by_name for better code reuse
* Reserved buffer validity and crashdata validity has been separated to avoid interdependence
* New fields added to crash metadata: version, ffcr, ffsr, mode
* Version checks added for metadata validation
* Special file /dev/crash_tmc_xxx would be available only when crash metadata is valid
* Removed READ_CRASHDATA mode meant for special casing crashdata reads. Instead, dedicated read function added for crashdata reads from reserved buffer which is common for both ETR and ETF sinks as well.
* Documentation added to Documentation/tracing/coresight/panic.rst
Changelog from v8:
* Added missing exit path on error in __tmc_probe.
* Few whitespace fixes, checkpatch fixes.
* With perf sessions honouring stop_on_flush sysfs attribute, removed redundant variable stop_on_flush_en.
Changelog from v7:
* Fixed breakage on perf test -vvvv "arm coresight". No issues seen with and without "resrv" buffer mode
* Moved the crashdev registration into a separate function.
* Removed redundant variable in tmc_etr_setup_crashdata_buf
* Avoided a redundant memcpy in tmc_panic_sync_etf.
* Tested kernel panic with trace session started uisng perf. Please see the title "Perf based testing" below for details. For this, stop_on_flush sysfs attribute is taken into consideration while starting perf sessions as well.
Changelog from v6:
* Added special device files for reading crashdata, so that read_prevboot mode flag is removed.
* Added new sysfs TMC device attribute, stop_on_flush. Stop on flush trigger event is disabled by default. User need to explicitly enable this from sysfs for panic stop to work.
* Address parameter for panicstop ETM configuration is chosen as kernel "panic" address by default.
* Added missing tmc_wait_for_tmcready during panic handling
* Few other misc code rearrangements.
Changelog from v5:
* Fixed issues reported by CONFIG_DEBUG_ATOMIC_SLEEP
* Fixed a memory leak while reading data from /dev/tmc_etrx in READ_PREVBOOT mode
* Tested reading trace data from crashdump kernel
Changelog from v4:
* Device tree binding
- Description is made more explicit on the usage of reserved memory region
- Mismatch in memory region names in dts binding and driver fixed
- Removed "mem" suffix from the memory region names
* Rename "struct tmc_register_snapshot" -> "struct tmc_crash_metadata", since it contains more than register snapshot.
Related variables are named accordingly.
* Rename struct tmc_drvdata members
resrv_buf -> crash_tbuf
metadata -> crash_mdata
* Size field in metadata refers to RSZ register and hence indicates the size in 32 bit words. ETR metadata follows this convention, the same has been extended to ETF metadata as well.
* Added crc32 for more robust metadata and tracedata validation.
* Added/modified dev_dbg messages during metadata validation
* Fixed a typo in patch 5 commit description
Changelog from v3:
* Converted the Coresight ETM driver change to a named configuration. RFC tag has been removed with this change.
* Fixed yaml issues reported by "make dt_binding_check"
* Added names for reserved memory regions 0 and 1
* Added prevalidation checks for metadata processing
* Fixed a regression introduced in RFC v3
- TMC Status register was getting saved wrongly
* Reverted memremap attribute changes from _WB to _WC to match with the dma map attributes
* Introduced reserved buffer mode specific .sync op.
This fixes a possible crash when reserved buffer mode was used in normal trace capture, due to unwanted dma maintenance operations.
*** SUBJECT HERE ***
*** BLURB HERE ***
Linu Cherian (8):
dt-bindings: arm: coresight-tmc: Add "memory-region" property
coresight: tmc-etr: Add support to use reserved trace memory
coresight: core: Add provision for panic callbacks
coresight: tmc: Enable panic sync handling
coresight: tmc: Add support for reading crash data
coresight: tmc: Stop trace capture on FlIn
coresight: config: Add preloaded configuration
Documentation: coresight: Panic support
.../bindings/arm/arm,coresight-tmc.yaml | 26 ++ Documentation/trace/coresight/panic.rst | 356 ++++++++++++++++++ drivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 ++++ drivers/hwtracing/coresight/coresight-core.c | 42 +++ .../hwtracing/coresight/coresight-tmc-core.c | 296 ++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 124 +++++- .../hwtracing/coresight/coresight-tmc-etr.c | 231 +++++++++++- drivers/hwtracing/coresight/coresight-tmc.h | 106 ++++++ include/linux/coresight.h | 24 ++ 12 files changed, 1282 insertions(+), 12 deletions(-) create mode 100644 Documentation/trace/coresight/panic.rst create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.c
Signature · 1 line
2.34.1
PATCH v10 1/8 dt-bindings: arm: coresight-tmc: Add "memory-region" property
memory-region 0: Reserved trace buffer memory
TMC ETR: When available, use this reserved memory region for trace data capture. Same region is used for trace data retention after a panic or watchdog reset.
TMC ETF: When available, use this reserved memory region for trace data retention synced from internal SRAM after a panic or watchdog reset.
memory-region 1: Reserved meta data memory
TMC ETR, ETF: When available, use this memory for register snapshot retention synced from hardware registers after a panic or watchdog reset.
---
Changelog from v9:
No changes.
.../bindings/arm/arm,coresight-tmc.yaml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)
Documentation/devicetree/bindings/arm/arm,coresight-tmc.yaml +26 -0
@@ -101,6 +101,29 @@ properties: and ETF configurations. $ref: /schemas/graph.yaml#/properties/port + memory-region: + items: + - description: Reserved trace buffer memory for ETR and ETF sinks. + For ETR, this reserved memory region is used for trace data capture. + Same region is used for trace data retention as well after a panic + or watchdog reset. + This reserved memory region is used as trace buffer or used for trace + data retention only if specifically selected by the user in sysfs + interface. + The default memory usage models for ETR in sysfs/perf modes are + otherwise unaltered. + + For ETF, this reserved memory region is used by default for + retention of trace data synced from internal SRAM after a panic + or watchdog reset. + - description: Reserved meta data memory. Used for ETR and ETF sinks + for storing metadata. + + memory-region-names: + items: + - const: tracedata + - const: metadata + required: - compatible - reg
@@ -115,6 +138,9 @@ examples: etr@20070000 { compatible = "arm,coresight-tmc", "arm,primecell"; reg = <0x20070000 0x1000>; + memory-region = <&etr_trace_mem_reserved>, + <&etr_mdata_mem_reserved>; + memory-region-names = "tracedata", "metadata"; clocks = <&oscclk6a>; clock-names = "apb_pclk";
Signature · 1 line
2.34.1
PATCH v10 2/8 coresight: tmc-etr: Add support to use reserved trace memory
In reply to Linu CherianAdd support to use reserved memory for coresight ETR trace buffer.
Introduce a new ETR buffer mode called ETR_MODE_RESRV, which becomes available when ETR device tree node is supplied with a valid reserved memory region.
ETR_MODE_RESRV can be selected only by explicit user request.
$ echo resrv >/sys/bus/coresight/devices/tmc_etr<N>/buf_mode_preferred
---
Changelog from v9:
- Added common helper function of_tmc_get_reserved_resource_by_name for better code reuse
- drvdata->crash_tbuf renamed to drvdata->resrv_buf
- In order to seperate validity of crash metadata with the availability of reserved buffer, is_tmc_reserved_region_valid was renamed to tmc_has_reserved_buffer
- Removed "Reviewed-by: James Clark <[email protected]>" due to the above changes
.../hwtracing/coresight/coresight-tmc-core.c | 50 ++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 79 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 25 ++++++ 3 files changed, 154 insertions(+)
drivers/hwtracing/coresight/coresight-tmc-core.c +50 -0
@@ -23,6 +23,7 @@#include <linux/spinlock.h> #include <linux/pm_runtime.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/coresight.h> #include <linux/amba/bus.h> #include <linux/platform_device.h>
@@ -399,6 +400,53 @@ static inline bool tmc_etr_has_non_secure_access(struct tmc_drvdata *drvdata)static const struct amba_id tmc_ids[]; +static int of_tmc_get_reserved_resource_by_name (struct device *dev, +const char *name, +struct resource *res) +{ +int index, rc = -ENODEV ; +struct device_node *node; + +if (!is_of_node (dev->fwnode)) +return -ENODEV ; + + index =of_property_match_string (dev->of_node,"memory-region-names" , + name); +if (index <0 ) +return rc; + + node =of_parse_phandle (dev->of_node,"memory-region" , index); +if (!node) +return rc; + +if (!of_address_to_resource (node,0 , res) && + res->start !=0 &&resource_size (res) !=0 ) + rc =0 ; +of_node_put (node); + +return rc; +} + +static void tmc_get_reserved_region (struct device *parent) +{ +struct tmc_drvdata *drvdata =dev_get_drvdata (parent); +struct resource res; + +if (of_tmc_get_reserved_resource_by_name (parent,"tracedata" , &res)) +return ; + + drvdata->resrv_buf.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->resrv_buf.vaddr)) { +dev_err (parent,"Reserved trace buffer mapping failed\n" ); +return ; + } + + drvdata->resrv_buf.paddr = res.start; + drvdata->resrv_buf.size =resource_size (&res); +} +/* Detect and initialise the capabilities of a TMC ETR */ static int tmc_etr_setup_caps (struct device *parent,u32 devid,struct csdev_access *access)
@@ -509,6 +557,8 @@ static int __tmc_probe(struct device *dev, struct resource *res) drvdata->size =readl_relaxed (drvdata->base +TMC_RSZ ) *4 ; } +tmc_get_reserved_region (dev); + desc.dev = dev;switch (drvdata->config_type) {
drivers/hwtracing/coresight/coresight-tmc-etr.c +79 -0
127 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +25 -0
@@ -135,6 +135,7 @@ enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */ ETR_MODE_CATU ,/* Use SG mechanism in CATU */ +ETR_MODE_RESRV ,/* Use reserved region contiguous buffer */ ETR_MODE_AUTO, /* Use the default mechanism */ };
@@ -164,6 +165,17 @@ struct etr_buf {void *private; }; +/** +* @paddr : Start address of reserved memory region. +* @vaddr : Corresponding CPU virtual address. +* @size : Size of reserved memory region. +*/ +struct tmc_resrv_buf { +phys_addr_t paddr; +void *vaddr; +size_t size; +}; +/** * struct tmc_drvdata - specifics associated to an TMC component * @pclk: APB clock if present, otherwise NULL
@@ -189,6 +201,10 @@ struct etr_buf {* @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. +* @resrv_buf: Used by ETR as hardware trace buffer and for trace data +* retention (after crash) only when ETR_MODE_RESRV buffer +* mode is enabled. Used by ETF for trace data retention +* (after crash) by default. */ struct tmc_drvdata {struct clk *pclk;
@@ -214,6 +230,7 @@ struct tmc_drvdata {struct mutex idr_mutex;struct etr_buf *sysfs_buf;struct etr_buf *perf_buf; +struct tmc_resrv_buf resrv_buf; };struct etr_buf_operations {
@@ -331,6 +348,14 @@ tmc_sg_table_buf_size(struct tmc_sg_table *sg_table)return (unsigned long )sg_table->data_pages.nr_pages <<PAGE_SHIFT ; } +static inline bool tmc_has_reserved_buffer (struct tmc_drvdata *drvdata) +{ +if (drvdata->resrv_buf.vaddr && + drvdata->resrv_buf.size) +return true; +return false; +} +struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata);void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu);
Signature · 1 line
2.34.1
PATCH v10 3/8 coresight: core: Add provision for panic callbacks
In reply to Linu CherianPanic callback handlers allows coresight device drivers to sync relevant trace data and trace metadata to reserved memory regions so that they can be retrieved later in the subsequent boot or in the crashdump kernel.
---
Changelog from v9:
- Added return checks atomic_notifier_chain_register
drivers/hwtracing/coresight/coresight-core.c | 42 ++++++++++++++++++++ include/linux/coresight.h | 12 ++++++ 2 files changed, 54 insertions(+)
drivers/hwtracing/coresight/coresight-core.c +42 -0
@@ -19,6 +19,7 @@#include <linux/property.h> #include <linux/delay.h> #include <linux/pm_runtime.h> +#include <linux/panic_notifier.h> #include "coresight-etm-perf.h" #include "coresight-priv.h"
@@ -1378,6 +1379,36 @@ const struct bus_type coresight_bustype = { .name = "coresight", }; +static int coresight_panic_sync (struct device *dev,void *data) +{ +int mode; +struct coresight_device *csdev; + +/* Run through panic sync handlers for all enabled devices */ + csdev = container_of(dev, struct coresight_device, dev); + mode =coresight_get_mode (csdev); + +if ((mode ==CS_MODE_SYSFS ) || (mode ==CS_MODE_PERF )) { +if (panic_ops (csdev)) +panic_ops (csdev)->sync (csdev); + } + +return 0 ; +} + +static int coresight_panic_cb (struct notifier_block *self, +unsigned long v,void *p) +{ +bus_for_each_dev (&coresight_bustype,NULL ,NULL , + coresight_panic_sync); + +return 0 ; +} + +static struct notifier_block coresight_notifier = { + .notifier_call = coresight_panic_cb, +}; +static int __init coresight_init (void ) {int ret;
@@ -1390,11 +1421,20 @@ static int __init coresight_init(void)if (ret) goto exit_bus_unregister; +/* Register function to be called for panic */ + ret =atomic_notifier_chain_register (&panic_notifier_list, + &coresight_notifier); +if (ret) + goto exit_perf; +/* initialise the coresight syscfg API */ ret =cscfg_init ();if (!ret)return 0 ; +atomic_notifier_chain_unregister (&panic_notifier_list, + &coresight_notifier); +exit_perf:etm_perf_exit (); exit_bus_unregister:bus_unregister (&coresight_bustype);
@@ -1404,6 +1444,8 @@ static int __init coresight_init(void) static void __exit coresight_exit(void) {cscfg_exit (); +atomic_notifier_chain_unregister (&panic_notifier_list, + &coresight_notifier);etm_perf_exit ();bus_unregister (&coresight_bustype); }
include/linux/coresight.h +12 -0
@@ -335,6 +335,7 @@ enum cs_mode {#define link_ops (csdev) csdev->ops->link_ops#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops +#define panic_ops (csdev) csdev->ops->panic_ops/** * struct coresight_ops_sink - basic operations for a sink
@@ -404,11 +405,22 @@ struct coresight_ops_helper {int (*disable)(struct coresight_device *csdev,void *data); }; + +/** +* struct coresight_ops_panic - Generic device ops for panic handing +* +* @sync : Sync the device register state/trace data +*/ +struct coresight_ops_panic { +int (*sync)(struct coresight_device *csdev); +}; +struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops; +const struct coresight_ops_panic *panic_ops; }; static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
Signature · 1 line
2.34.1
PATCH v10 4/8 coresight: tmc: Enable panic sync handling
In reply to Linu Cherian- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.
---
Changelog from v9:
- Add common helper function of_tmc_get_reserved_resource_by_name for better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent, is_tmc_reserved_region_valid renamed to tmc_has_reserved_buffer
- drvdata->crash_tbuf renamed to drvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes
.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)
drivers/hwtracing/coresight/coresight-tmc-core.c +14 -0
@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */
drivers/hwtracing/coresight/coresight-tmc-etf.c +77 -0
95 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc-etr.c +78 -0
92 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +66 -0
108 lines not on this page · raw message
Signature · 1 line
2.34.1
Suzuki K Poulose
maintainerRe: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.
The patch looks good overall. Some minor comments below.
Quoted 67 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +14
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ;
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+ +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */ + val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +
minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE == CIRCULAR_BUFFER".
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 9 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);
Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );
Why are we using "csa" here and not for TMC_CTL etc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +7
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr;
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/* +* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);
I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need dmb(ish) to make sure the writes are visible before valid is set to true.
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);
Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Quoted 33 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+out: +CS_UNLOCK (drvdata->base); +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -603,6 +675,10 @@ static const struct coresight_ops_link tmc_etf_link_ops = { .disable = tmc_disable_etf_link, }; +static const struct coresight_ops_panic tmc_etf_sync_ops = { + .sync = tmc_panic_sync_etf, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -610,6 +686,7 @@ const struct coresight_ops tmc_etb_cs_ops = {const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, + .panic_ops = &tmc_etf_sync_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +0
-0@@ -1814,6 +1814,79 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev)return 0 ;
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1824
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +8
-0} +static int tmc_panic_sync_etr (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access;
As earlier, drop the csa.
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1834
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+ mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (!drvdata->etr_buf) +return 0 ; + +/* Being in RESRV mode implies valid reserved memory as well */ +if (drvdata->etr_buf->mode !=ETR_MODE_RESRV ) +return 0 ; + + if (!tmc_has_reserved_buffer(drvdata) ||
Do we need to check this again ? We wouldn't be in ETR_MODE_RESRV otherwise, also indicated by the comment.
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +7
-0+ !tmc_has_crash_mdata_buffer(drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); +
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1851
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+/* Proceed only if ETR is enabled */ + val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);
Drop the info
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1861
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->size =csdev_access_relaxed_read32 (csa,TMC_RSZ ); + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS ); + mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR );
Please use raw reads, don't mix csa and raw reads.
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1872
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->rrp =tmc_read_rrp (drvdata); + mdata->rwp =tmc_read_rwp (drvdata); + mdata->dba =tmc_read_dba (drvdata); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + mdata->version =CS_CRASHDATA_VERSION ; + +/* +* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);
Same as earlier, doesn't buy us much
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1883
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);
Drop
Quoted 56 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+out: +CS_UNLOCK (drvdata->base); + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1822,8 +1895,13 @@ static const struct coresight_ops_sink tmc_etr_sink_ops = { .free_buffer = tmc_free_etr_buffer, }; +static const struct coresight_ops_panic tmc_etr_sync_ops = { + .sync = tmc_panic_sync_etr, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, + .panic_ops = &tmc_etr_sync_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc.h +7
-0@@ -12,6 +12,7 @@#include <linux/miscdevice.h> #include <linux/mutex.h> #include <linux/refcount.h> +#include <linux/crc32.h> #define TMC_RSZ 0x004#define TMC_STS 0x00c@@ -76,6 +77,9 @@#define TMC_AXICTL_AXCACHE_OS (0xf << 2)#define TMC_AXICTL_ARCACHE_OS (0xf << 16) +/* TMC_FFSR - 0x300 */ +#define TMC_FFSR_FT_STOPPED BIT(1) +/* TMC_FFCR - 0x304 */ #define TMC_FFCR_FLUSHMAN_BIT 6#define TMC_FFCR_EN_FMT BIT(0)@@ -94,6 +98,9 @@#define TMC_AUTH_NSID_MASK GENMASK(1, 0) +/* Major version 1 Minor version 0 */ +#define CS_CRASHDATA_VERSION (1 << 16) +enum tmc_config_type {TMC_CONFIG_TYPE_ETB ,TMC_CONFIG_TYPE_ETR ,
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 147
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc.h +7
-0@@ -131,6 +138,25 @@ enum tmc_mem_intf_width {#define CORESIGHT_SOC_600_ETR_CAPS \ (TMC_ETR_SAVE_RESTORE | TMC_ETR_AXI_ARCACHE) +/* TMC metadata region for ETR and ETF configurations */ +struct tmc_crash_metadata { +uint32_t crc32_mdata;/* crc of metadata */ +uint32_t crc32_tdata;/* crc of tracedata */ +uint32_t version;/* 31:16 Major version, 15:0 Minor version */ +uint32_t valid;/* Indicate if this ETF/ETR was enabled */ +uint32_t size;/* Ram Size register */
Please could you not keep this "plain bytes" ? Or rename the field to tmc_ram_size if we want to stick to TMC RAM SIZE register. It is very easy to confuse it with "normal" bytes.
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 148
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t sts;/* Status register */
tmc_sts
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 149
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t mode;/* Mode register */
tmc_mode
This doesn't look packed. Please could you add a padding here to make sure the fields are 64bit aligned ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 150
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffcr;/* Formatter and flush control register */
tmc_ffcr
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 151
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffsr;/* Formatter and flush status register */
tmc_ffsr
Also, why are they both 64bit ? They are all 32bit for sure ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 152
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t reserved32[3 ];
Why do we have reserved bits here ? They should be near the 32bit fields.
I think, once you fix the type of ffcr and ffsr things, everything will be in order.
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 158
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc.h +6
-0+uint64_t rrp;/* Ram Read pointer register */ +uint64_t rwp;/* Ram Write pointer register */ +uint64_t dba;/* Data buffer address register */ +uint64_t trace_paddr;/* Phys address of trace buffer */ +uint64_t reserved64[3 ]; +};
Suzuki
Quoted 65 lines
drivers/hwtracing/coresight/coresight-tmc.h +41
-0+enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */ @@ -205,6 +231,8 @@ struct tmc_resrv_buf {* retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default. +* @crash_mdata: Reserved memory for storing tmc crash metadata. +* Used by ETR/ETF. */ struct tmc_drvdata {struct clk *pclk;@@ -231,6 +259,7 @@ struct tmc_drvdata {struct etr_buf *sysfs_buf;struct etr_buf *perf_buf;struct tmc_resrv_buf resrv_buf; +struct tmc_resrv_buf crash_mdata; };struct etr_buf_operations {@@ -356,6 +385,43 @@ static inline bool tmc_has_reserved_buffer(struct tmc_drvdata *drvdata)return false; } +static inline bool tmc_has_crash_mdata_buffer (struct tmc_drvdata *drvdata) +{ +if (drvdata->crash_mdata.vaddr && + drvdata->crash_mdata.size) +return true; +return false; +} + +static inline void tmc_crashdata_set_invalid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (tmc_has_crash_mdata_buffer (drvdata)) + mdata->valid = false; +} + +static inline uint32_t find_crash_metadata_crc (struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + + crc_size =sizeof (struct tmc_crash_metadata ) - + offsetof(struct tmc_crash_metadata , crc32_tdata); +return crc32_le (0 , (void *)&md->crc32_tdata, crc_size); +} + +static inline uint32_t find_crash_tracedata_crc (struct tmc_drvdata *drvdata, +struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + +/* Take CRC of configured buffer size to keep it simple */ + crc_size = md->size <<2 ; +return crc32_le (0 , (void *)drvdata->resrv_buf.vaddr, crc_size); +} +struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata);void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu);
Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
Hi Suzuki,
Quoted 82 lines · Suzuki K Poulose
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.The patch looks good overall. Some minor comments below.
Quoted 69 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +20
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+ val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE ==
CIRCULAR_BUFFER".
Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
Ack.
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );Why are we using "csa" here and not for
TMC_CTLetc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.
Okay.
Quoted 13 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +13
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr; +tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/*
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need
dmb(ish)to make sure the writes are visible before valid is set to true.
Ack. Will change that.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Ack.
Quoted 35 lines
Quoted 35 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+out: +CS_UNLOCK (drvdata->base); +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -603,6 +675,10 @@ static const struct coresight_ops_link tmc_etf_link_ops = { .disable = tmc_disable_etf_link, }; +static const struct coresight_ops_panic tmc_etf_sync_ops = { + .sync = tmc_panic_sync_etf, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -610,6 +686,7 @@ const struct coresight_ops tmc_etb_cs_ops = {const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, + .panic_ops = &tmc_etf_sync_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +2
-0@@ -1814,6 +1814,79 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev)return 0 ; } +static int tmc_panic_sync_etr (struct coresight_device *csdev) +{
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1823
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access;As earlier, drop the csa.
Okay.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1834
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+ mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (!drvdata->etr_buf) +return 0 ; + +/* Being in RESRV mode implies valid reserved memory as well */ +if (drvdata->etr_buf->mode !=ETR_MODE_RESRV ) +return 0 ; + + if (!tmc_has_reserved_buffer(drvdata) ||Do we need to check this again ? We wouldn't be in
ETR_MODE_RESRVotherwise, also indicated by the comment.
Will drop.
Quoted 12 lines
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ !tmc_has_crash_mdata_buffer(drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETR is enabled */ + val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out;
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1850
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+ + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Drop the info
Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1861
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->size =csdev_access_relaxed_read32 (csa,TMC_RSZ ); + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS ); + mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR );Please use raw reads, don't mix csa and raw reads.
Ack.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1872
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->rrp =tmc_read_rrp (drvdata); + mdata->rwp =tmc_read_rwp (drvdata); + mdata->dba =tmc_read_dba (drvdata); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + mdata->version =CS_CRASHDATA_VERSION ; + +/* +* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);Same as earlier, doesn't buy us much
Will convert to dmb.
Quoted 70 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1882
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Drop
Quoted 55 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+out: +CS_UNLOCK (drvdata->base); + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1822,8 +1895,13 @@ static const struct coresight_ops_sink tmc_etr_sink_ops = { .free_buffer = tmc_free_etr_buffer, }; +static const struct coresight_ops_panic tmc_etr_sync_ops = { + .sync = tmc_panic_sync_etr, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, + .panic_ops = &tmc_etr_sync_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc.h +10
-0@@ -12,6 +12,7 @@#include <linux/miscdevice.h> #include <linux/mutex.h> #include <linux/refcount.h> +#include <linux/crc32.h> #define TMC_RSZ 0x004#define TMC_STS 0x00c@@ -76,6 +77,9 @@#define TMC_AXICTL_AXCACHE_OS (0xf << 2)#define TMC_AXICTL_ARCACHE_OS (0xf << 16) +/* TMC_FFSR - 0x300 */ +#define TMC_FFSR_FT_STOPPED BIT(1) +/* TMC_FFCR - 0x304 */ #define TMC_FFCR_FLUSHMAN_BIT 6#define TMC_FFCR_EN_FMT BIT(0)@@ -94,6 +98,9 @@#define TMC_AUTH_NSID_MASK GENMASK(1, 0) +/* Major version 1 Minor version 0 */ +#define CS_CRASHDATA_VERSION (1 << 16) +enum tmc_config_type {TMC_CONFIG_TYPE_ETB ,TMC_CONFIG_TYPE_ETR ,@@ -131,6 +138,25 @@ enum tmc_mem_intf_width {#define CORESIGHT_SOC_600_ETR_CAPS \ (TMC_ETR_SAVE_RESTORE | TMC_ETR_AXI_ARCACHE) +/* TMC metadata region for ETR and ETF configurations */ +struct tmc_crash_metadata { +uint32_t crc32_mdata;/* crc of metadata */
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 147
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc.h +4
-0+uint32_t crc32_tdata;/* crc of tracedata */ +uint32_t version;/* 31:16 Major version, 15:0 Minor version */ +uint32_t valid;/* Indicate if this ETF/ETR was enabled */ +uint32_t size;/* Ram Size register */ Please could you not keep this "plain bytes" ? Or rename the field to
tmc_ram_sizeif we want to stick to TMC RAM SIZE register. It is very easy to confuse it with "normal" bytes.
Okay. Will change the name.
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 148
Quoted 2 lines
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t sts;/* Status register */
tmc_stsdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 149
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t mode;/* Mode register */
tmc_modeThis doesn't look packed. Please could you add a padding here to make sure the fields are 64bit aligned ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 150
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffcr;/* Formatter and flush control register */
tmc_ffcrdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 151
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffsr;/* Formatter and flush status register */
tmc_ffsr
Quoted 5 lines
Also, why are they both 64bit ? They are all 32bit for sure ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 152
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t reserved32[3 ];Why do we have reserved bits here ? They should be near the 32bit fields.
Have added them for the sake of future extensions, just in case if we wish to add additional registers without changing the overall metadata size.
Quoted 3 lines
I think, once you fix the type of ffcr and ffsr things, everything will be in order.
Okay will fix.
Quoted 77 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 158
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h +6
-0+uint64_t rrp;/* Ram Read pointer register */ +uint64_t rwp;/* Ram Write pointer register */ +uint64_t dba;/* Data buffer address register */ +uint64_t trace_paddr;/* Phys address of trace buffer */ +uint64_t reserved64[3 ]; +};Suzuki
Quoted 62 lines
drivers/hwtracing/coresight/coresight-tmc.h +41
-0+enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */ @@ -205,6 +231,8 @@ struct tmc_resrv_buf {* retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default. +* @crash_mdata: Reserved memory for storing tmc crash metadata. +* Used by ETR/ETF. */ struct tmc_drvdata {struct clk *pclk;@@ -231,6 +259,7 @@ struct tmc_drvdata {struct etr_buf *sysfs_buf;struct etr_buf *perf_buf;struct tmc_resrv_buf resrv_buf; +struct tmc_resrv_buf crash_mdata; };struct etr_buf_operations {@@ -356,6 +385,43 @@ static inline bool tmc_has_reserved_buffer(struct tmc_drvdata *drvdata)return false; } +static inline bool tmc_has_crash_mdata_buffer (struct tmc_drvdata *drvdata) +{ +if (drvdata->crash_mdata.vaddr && + drvdata->crash_mdata.size) +return true; +return false; +} + +static inline void tmc_crashdata_set_invalid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (tmc_has_crash_mdata_buffer (drvdata)) + mdata->valid = false; +} + +static inline uint32_t find_crash_metadata_crc (struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + + crc_size =sizeof (struct tmc_crash_metadata ) - + offsetof(struct tmc_crash_metadata , crc32_tdata); +return crc32_le (0 , (void *)&md->crc32_tdata, crc_size); +} + +static inline uint32_t find_crash_tracedata_crc (struct tmc_drvdata *drvdata, +struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + +/* Take CRC of configured buffer size to keep it simple */ + crc_size = md->size <<2 ; +return crc32_le (0 , (void *)drvdata->resrv_buf.vaddr, crc_size); +} +struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata);void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu);
Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
Hi Suzuki,
Quoted 110 lines · Linu Cherian
Hi Suzuki,
Quoted 82 lines · Suzuki K Poulose
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.The patch looks good overall. Some minor comments below.
Quoted 69 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +20
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+ val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE ==
CIRCULAR_BUFFER".Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
Quoted 1 line
Ack.
Are we okay to change this dev_dbg instead of removing it. Have found this quite useful to understand if the CTI trigger has fired.
Quoted 55 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );Why are we using "csa" here and not for
TMC_CTLetc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.Okay.
Quoted 13 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +13
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr; +tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/* Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need
dmb(ish)to make sure the writes are visible before valid is set to true.Ack. Will change that.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Quoted 1 line
Ack.
Would it be okay to convert this to dev_dbg? Helps to understand if the panic call handler has run just in case if we want to debug if the metadata saving happened or not.
Quoted 319 lines
Quoted 36 lines
Quoted 36 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+out: +CS_UNLOCK (drvdata->base); +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -603,6 +675,10 @@ static const struct coresight_ops_link tmc_etf_link_ops = { .disable = tmc_disable_etf_link, }; +static const struct coresight_ops_panic tmc_etf_sync_ops = { + .sync = tmc_panic_sync_etf, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -610,6 +686,7 @@ const struct coresight_ops tmc_etb_cs_ops = {const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, + .panic_ops = &tmc_etf_sync_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +2
-0@@ -1814,6 +1814,79 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev)return 0 ; } +static int tmc_panic_sync_etr (struct coresight_device *csdev) +{Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1823
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access;As earlier, drop the csa.
Okay.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1834
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+ mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (!drvdata->etr_buf) +return 0 ; + +/* Being in RESRV mode implies valid reserved memory as well */ +if (drvdata->etr_buf->mode !=ETR_MODE_RESRV ) +return 0 ; + + if (!tmc_has_reserved_buffer(drvdata) ||Do we need to check this again ? We wouldn't be in
ETR_MODE_RESRVotherwise, also indicated by the comment.Will drop.
Quoted 12 lines
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ !tmc_has_crash_mdata_buffer(drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETR is enabled */ + val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out;Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1850
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+ + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Drop the info
Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1861
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->size =csdev_access_relaxed_read32 (csa,TMC_RSZ ); + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS ); + mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR );Please use raw reads, don't mix csa and raw reads.
Ack.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1872
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->rrp =tmc_read_rrp (drvdata); + mdata->rwp =tmc_read_rwp (drvdata); + mdata->dba =tmc_read_dba (drvdata); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + mdata->version =CS_CRASHDATA_VERSION ; + +/* +* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);Same as earlier, doesn't buy us much
Will convert to dmb.
Quoted 70 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1882
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Drop
Quoted 55 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+out: +CS_UNLOCK (drvdata->base); + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1822,8 +1895,13 @@ static const struct coresight_ops_sink tmc_etr_sink_ops = { .free_buffer = tmc_free_etr_buffer, }; +static const struct coresight_ops_panic tmc_etr_sync_ops = { + .sync = tmc_panic_sync_etr, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, + .panic_ops = &tmc_etr_sync_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc.h +10
-0@@ -12,6 +12,7 @@#include <linux/miscdevice.h> #include <linux/mutex.h> #include <linux/refcount.h> +#include <linux/crc32.h> #define TMC_RSZ 0x004#define TMC_STS 0x00c@@ -76,6 +77,9 @@#define TMC_AXICTL_AXCACHE_OS (0xf << 2)#define TMC_AXICTL_ARCACHE_OS (0xf << 16) +/* TMC_FFSR - 0x300 */ +#define TMC_FFSR_FT_STOPPED BIT(1) +/* TMC_FFCR - 0x304 */ #define TMC_FFCR_FLUSHMAN_BIT 6#define TMC_FFCR_EN_FMT BIT(0)@@ -94,6 +98,9 @@#define TMC_AUTH_NSID_MASK GENMASK(1, 0) +/* Major version 1 Minor version 0 */ +#define CS_CRASHDATA_VERSION (1 << 16) +enum tmc_config_type {TMC_CONFIG_TYPE_ETB ,TMC_CONFIG_TYPE_ETR ,@@ -131,6 +138,25 @@ enum tmc_mem_intf_width {#define CORESIGHT_SOC_600_ETR_CAPS \ (TMC_ETR_SAVE_RESTORE | TMC_ETR_AXI_ARCACHE) +/* TMC metadata region for ETR and ETF configurations */ +struct tmc_crash_metadata { +uint32_t crc32_mdata;/* crc of metadata */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 147
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc.h +4
-0+uint32_t crc32_tdata;/* crc of tracedata */ +uint32_t version;/* 31:16 Major version, 15:0 Minor version */ +uint32_t valid;/* Indicate if this ETF/ETR was enabled */ +uint32_t size;/* Ram Size register */ Please could you not keep this "plain bytes" ? Or rename the field to
tmc_ram_sizeif we want to stick to TMC RAM SIZE register. It is very easy to confuse it with "normal" bytes.Okay. Will change the name.
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 148
Quoted 2 lines
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t sts;/* Status register */
tmc_stsdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 149
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t mode;/* Mode register */
tmc_modeThis doesn't look packed. Please could you add a padding here to make sure the fields are 64bit aligned ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 150
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffcr;/* Formatter and flush control register */
tmc_ffcrdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 151
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffsr;/* Formatter and flush status register */
tmc_ffsrQuoted 5 lines
Also, why are they both 64bit ? They are all 32bit for sure ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 152
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t reserved32[3 ];Why do we have reserved bits here ? They should be near the 32bit fields.
Have added them for the sake of future extensions, just in case if we wish to add additional registers without changing the overall metadata size.
Quoted 3 lines
I think, once you fix the type of ffcr and ffsr things, everything will be in order.
Okay will fix.
Quoted 77 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 158
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h +6
-0+uint64_t rrp;/* Ram Read pointer register */ +uint64_t rwp;/* Ram Write pointer register */ +uint64_t dba;/* Data buffer address register */ +uint64_t trace_paddr;/* Phys address of trace buffer */ +uint64_t reserved64[3 ]; +};Suzuki
Quoted 62 lines
drivers/hwtracing/coresight/coresight-tmc.h +41
-0+enum etr_mode {ETR_MODE_FLAT ,/* Uses contiguous flat buffer */ ETR_MODE_ETR_SG ,/* Uses in-built TMC ETR SG mechanism */ @@ -205,6 +231,8 @@ struct tmc_resrv_buf {* retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default. +* @crash_mdata: Reserved memory for storing tmc crash metadata. +* Used by ETR/ETF. */ struct tmc_drvdata {struct clk *pclk;@@ -231,6 +259,7 @@ struct tmc_drvdata {struct etr_buf *sysfs_buf;struct etr_buf *perf_buf;struct tmc_resrv_buf resrv_buf; +struct tmc_resrv_buf crash_mdata; };struct etr_buf_operations {@@ -356,6 +385,43 @@ static inline bool tmc_has_reserved_buffer(struct tmc_drvdata *drvdata)return false; } +static inline bool tmc_has_crash_mdata_buffer (struct tmc_drvdata *drvdata) +{ +if (drvdata->crash_mdata.vaddr && + drvdata->crash_mdata.size) +return true; +return false; +} + +static inline void tmc_crashdata_set_invalid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (tmc_has_crash_mdata_buffer (drvdata)) + mdata->valid = false; +} + +static inline uint32_t find_crash_metadata_crc (struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + + crc_size =sizeof (struct tmc_crash_metadata ) - + offsetof(struct tmc_crash_metadata , crc32_tdata); +return crc32_le (0 , (void *)&md->crc32_tdata, crc_size); +} + +static inline uint32_t find_crash_tracedata_crc (struct tmc_drvdata *drvdata, +struct tmc_crash_metadata *md) +{ +unsigned long crc_size; + +/* Take CRC of configured buffer size to keep it simple */ + crc_size = md->size <<2 ; +return crc32_le (0 , (void *)drvdata->resrv_buf.vaddr, crc_size); +} +struct coresight_device *tmc_etr_get_catu_device (struct tmc_drvdata *drvdata);void tmc_etr_set_catu_ops (const struct etr_buf_operations *catu);
Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
In reply to Linu CherianHi Suzuki,
Quoted 110 lines · Linu Cherian
Hi Suzuki,
Quoted 82 lines · Suzuki K Poulose
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.The patch looks good overall. Some minor comments below.
Quoted 69 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +20
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+ val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE ==
CIRCULAR_BUFFER".Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
Quoted 1 line
Ack.
Are we okay with converting this to dev_dbg, as this could be quite helpful to understand if the CTI trigger has occured or not.
Quoted 55 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );Why are we using "csa" here and not for
TMC_CTLetc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.Okay.
Quoted 13 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +13
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr; +tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/* Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need
dmb(ish)to make sure the writes are visible before valid is set to true.Ack. Will change that.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Quoted 1 line
Ack.
Are we okay with converting this to dev_dbg, as this could aid in debugging to understand if kernel has populated valid metadata.
Thanks.
Linu Cherian.
Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
Hi,
Please ignore this message, was sent by mistake.
Atually a repetition of message sent earlier.
Thanks.
Quoted 183 lines · Linu Cherian
Hi Suzuki,
Quoted 110 lines · Linu Cherian
Hi Suzuki,
Quoted 82 lines · Suzuki K Poulose
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.The patch looks good overall. Some minor comments below.
Quoted 69 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +20
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+ val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE ==
CIRCULAR_BUFFER".Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
Quoted 1 line
Ack.
Are we okay with converting this to
dev_dbg, as this could be quite helpful to understand if the CTI trigger has occured or not.Quoted 55 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );Why are we using "csa" here and not for
TMC_CTLetc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.Okay.
Quoted 13 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +13
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr; +tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/* Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need
dmb(ish)to make sure the writes are visible before valid is set to true.Ack. Will change that.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Quoted 1 line
Ack.
Are we okay with converting this to
dev_dbg, as this could aid in debugging to understand if kernel has populated valid metadata.Thanks.
Linu Cherian.
Re: [PATCH v10 4/8] coresight: tmc: Enable panic sync handling
In reply to Linu CherianHi Suzuki,
Quoted 367 lines · Linu Cherian
Hi Suzuki,
Quoted 82 lines · Suzuki K Poulose
Hi Linu
Quoted 7 lines · Linu Cherian
- Get reserved region from device tree node for metadata
- Define metadata format for TMC
- Add TMC ETR panic sync handler that syncs register snapshot to metadata region
- Add TMC ETF panic sync handler that syncs register snapshot to metadata region and internal SRAM to reserved trace buffer region.The patch looks good overall. Some minor comments below.
Quoted 69 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
- Inorder to keep the reserved buffer validity and crashdata validity independent,is_tmc_reserved_region_validrenamed totmc_has_reserved_buffer
-drvdata->crash_tbufrenamed todrvdata->resrv_buf
- New fields added to crash metadata: version, ffcr, ffsr, mode
- Defined crashdata version with Major version 1, Minor version 0
- Set version while creating crashdata record
- Removed Reviewed-by tag due to the above changes.../hwtracing/coresight/coresight-tmc-core.c | 14 ++++ .../hwtracing/coresight/coresight-tmc-etf.c | 77 ++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etr.c | 78 +++++++++++++++++++ drivers/hwtracing/coresight/coresight-tmc.h | 66 ++++++++++++++++ 4 files changed, 235 insertions(+)drivers/hwtracing/coresight/coresight-tmc-core.c +14
-0@@ -445,6 +445,20 @@ static void tmc_get_reserved_region(struct device *parent) drvdata->resrv_buf.paddr = res.start; drvdata->resrv_buf.size =resource_size (&res); + +if (of_tmc_get_reserved_resource_by_name (parent,"metadata" , &res)) +return ; + + drvdata->crash_mdata.vaddr =memremap (res.start, +resource_size (&res), +MEMREMAP_WC ); +if (IS_ERR_OR_NULL (drvdata->crash_mdata.vaddr)) { +dev_err (parent,"Metadata memory mapping failed\n" ); +return ; + } + + drvdata->crash_mdata.paddr = res.start; + drvdata->crash_mdata.size =resource_size (&res); }/* Detect and initialise the capabilities of a TMC ETR */ drivers/hwtracing/coresight/coresight-tmc-etf.c +20
-0@@ -590,6 +590,78 @@ static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev,return to_read; } +static int tmc_panic_sync_etf (struct coresight_device *csdev) +{ +u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access; + mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +/* Make sure we have valid reserved memory */ +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETF is enabled or configured as sink */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 616
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+ val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out; +minor nit : Since the check below is "covered" by the same comment above, please drop the extra line here to make it clear that "we check for sink" by checking the "MODE ==
CIRCULAR_BUFFER".Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 625
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +9
-0+ val =readl (drvdata->base +TMC_MODE ); +if (val !=TMC_MODE_CIRCULAR_BUFFER ) + goto out; + + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Please drop the ^^^ line. We don't want to do anything like that from a panic callback.
Ack.
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 631
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +6
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS );Why are we using "csa" here and not for
TMC_CTLetc ? Simply drop the "csa" and use the raw reads like above. TMC doesn't have anyother modes of access.Okay.
Quoted 13 lines
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +13
-0+ mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR ); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + +/* Sync Internal SRAM to reserved trace buffer region */ + drvdata->buf = drvdata->resrv_buf.vaddr; +tmc_etb_dump_hw (drvdata); +/* Store as per RSZ register convention */ + mdata->size = drvdata->len >>2 ; + mdata->version =CS_CRASHDATA_VERSION ; + +/* Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 648
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +4
-0+* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);I don't think this matters much, as this would only be read by a secondary kernel. In the worst case, you only need
dmb(ish)to make sure the writes are visible before valid is set to true.Ack. Will change that.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c static unsigned long tmc_update_etf_buffer(struct coresight_device *csdev, · line 659
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Please no "prints" from a panic call back, unless it absolutely CRITICAL.
Ack.
Quoted 35 lines
Quoted 35 lines
drivers/hwtracing/coresight/coresight-tmc-etf.c +10
-0+out: +CS_UNLOCK (drvdata->base); +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -603,6 +675,10 @@ static const struct coresight_ops_link tmc_etf_link_ops = { .disable = tmc_disable_etf_link, }; +static const struct coresight_ops_panic tmc_etf_sync_ops = { + .sync = tmc_panic_sync_etf, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -610,6 +686,7 @@ const struct coresight_ops tmc_etb_cs_ops = {const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, + .panic_ops = &tmc_etf_sync_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +2
-0@@ -1814,6 +1814,79 @@ static int tmc_disable_etr_sink(struct coresight_device *csdev)return 0 ; } +static int tmc_panic_sync_etr (struct coresight_device *csdev) +{Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1823
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+u32 val; +struct csdev_access *csa; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + csa = &drvdata->csdev->access;As earlier, drop the csa.
Okay.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1834
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+ mdata = (struct tmc_crash_metadata *)drvdata->crash_mdata.vaddr; + +if (!drvdata->etr_buf) +return 0 ; + +/* Being in RESRV mode implies valid reserved memory as well */ +if (drvdata->etr_buf->mode !=ETR_MODE_RESRV ) +return 0 ; + + if (!tmc_has_reserved_buffer(drvdata) ||Do we need to check this again ? We wouldn't be in
ETR_MODE_RESRVotherwise, also indicated by the comment.Will drop.
Quoted 12 lines
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ !tmc_has_crash_mdata_buffer(drvdata)) +return 0 ; + +tmc_crashdata_set_invalid (drvdata); + +CS_UNLOCK (drvdata->base); + +/* Proceed only if ETR is enabled */ + val =readl (drvdata->base +TMC_CTL ); +if (!(val &TMC_CTL_CAPT_EN )) + goto out;Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1850
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +6
-0+ + val =readl (drvdata->base +TMC_FFSR ); +/* Do manual flush and stop only if its not auto-stopped */ +if (!(val &TMC_FFSR_FT_STOPPED )) { +dev_info (&csdev->dev, +"%s: Triggering manual flush\n" , __func__);Drop the info
Ack.
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1861
Quoted 11 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+tmc_flush_and_stop (drvdata); + }else +tmc_wait_for_tmcready (drvdata); + +/* Sync registers from hardware to metadata region */ + mdata->size =csdev_access_relaxed_read32 (csa,TMC_RSZ ); + mdata->sts =csdev_access_relaxed_read32 (csa,TMC_STS ); + mdata->mode =csdev_access_relaxed_read32 (csa,TMC_MODE ); + mdata->ffcr =csdev_access_relaxed_read32 (csa,TMC_FFCR ); + mdata->ffsr =csdev_access_relaxed_read32 (csa,TMC_FFSR );Please use raw reads, don't mix csa and raw reads.
Ack.
Quoted 14 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1872
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->rrp =tmc_read_rrp (drvdata); + mdata->rwp =tmc_read_rwp (drvdata); + mdata->dba =tmc_read_dba (drvdata); + mdata->trace_paddr = drvdata->resrv_buf.paddr; + mdata->version =CS_CRASHDATA_VERSION ; + +/* +* Make sure all previous writes are completed, +* before we mark valid +*/ +dsb (sy);Same as earlier, doesn't buy us much
Will convert to dmb.
Quoted 70 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_disable_etr_sink(struct coresight_device *csdev) · line 1882
Quoted 12 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+ mdata->valid = true; +/* +* Below order need to maintained, since crc of metadata +* is dependent on first +*/ + mdata->crc32_tdata =find_crash_tracedata_crc (drvdata, mdata); + mdata->crc32_mdata =find_crash_metadata_crc (mdata); + +tmc_disable_hw (drvdata); + +dev_info (&csdev->dev,"%s: success\n" , __func__);Drop
Quoted 55 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +11
-0+out: +CS_UNLOCK (drvdata->base); + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1822,8 +1895,13 @@ static const struct coresight_ops_sink tmc_etr_sink_ops = { .free_buffer = tmc_free_etr_buffer, }; +static const struct coresight_ops_panic tmc_etr_sync_ops = { + .sync = tmc_panic_sync_etr, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, + .panic_ops = &tmc_etr_sync_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc.h +10
-0@@ -12,6 +12,7 @@#include <linux/miscdevice.h> #include <linux/mutex.h> #include <linux/refcount.h> +#include <linux/crc32.h> #define TMC_RSZ 0x004#define TMC_STS 0x00c@@ -76,6 +77,9 @@#define TMC_AXICTL_AXCACHE_OS (0xf << 2)#define TMC_AXICTL_ARCACHE_OS (0xf << 16) +/* TMC_FFSR - 0x300 */ +#define TMC_FFSR_FT_STOPPED BIT(1) +/* TMC_FFCR - 0x304 */ #define TMC_FFCR_FLUSHMAN_BIT 6#define TMC_FFCR_EN_FMT BIT(0)@@ -94,6 +98,9 @@#define TMC_AUTH_NSID_MASK GENMASK(1, 0) +/* Major version 1 Minor version 0 */ +#define CS_CRASHDATA_VERSION (1 << 16) +enum tmc_config_type {TMC_CONFIG_TYPE_ETB ,TMC_CONFIG_TYPE_ETR ,@@ -131,6 +138,25 @@ enum tmc_mem_intf_width {#define CORESIGHT_SOC_600_ETR_CAPS \ (TMC_ETR_SAVE_RESTORE | TMC_ETR_AXI_ARCACHE) +/* TMC metadata region for ETR and ETF configurations */ +struct tmc_crash_metadata { +uint32_t crc32_mdata;/* crc of metadata */ Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 147
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc.h +4
-0+uint32_t crc32_tdata;/* crc of tracedata */ +uint32_t version;/* 31:16 Major version, 15:0 Minor version */ +uint32_t valid;/* Indicate if this ETF/ETR was enabled */ +uint32_t size;/* Ram Size register */ Please could you not keep this "plain bytes" ? Or rename the field to
tmc_ram_sizeif we want to stick to TMC RAM SIZE register. It is very easy to confuse it with "normal" bytes.
Quoted 21 lines
Okay. Will change the name.
Quoted 19 lines
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 148
Quoted 2 lines
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t sts;/* Status register */
tmc_stsdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 149
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint32_t mode;/* Mode register */
tmc_modeThis doesn't look packed. Please could you add a padding here to make sure the fields are 64bit aligned ?
drivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 150
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffcr;/* Formatter and flush control register */
tmc_ffcrdrivers/hwtracing/coresight/coresight-tmc.h enum tmc_mem_intf_width { · line 151
Quoted 1 line
drivers/hwtracing/coresight/coresight-tmc.h +1
-0+uint64_t ffsr;/* Formatter and flush status register */
tmc_ffsr
Guess we should prefix the rwp, rrp and dba also with tmc since they are register snapshots ?
PATCH v10 5/8 coresight: tmc: Add support for reading crash data
In reply to Linu Cherian* Add support for reading crashdata using special device files. The special device files /dev/crash_tmc_xxx would be available for read file operation only when the crash data is valid.
* User can read the crash data as below
For example, for reading crash data from tmc_etf sink
#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
---
Changelog from v9:
- Removed READ_CRASHDATA mode meant for special casing crashdata read
- Added new fields full, len, offset to struct tmc_resrv_buf so as to have a common read function for ETR and ETF
- Introduced read file operation, tmc_crashdata_read specific to crashdata reads common for both ETR and ETF
- Introduced is_tmc_crashdata_valid function
Special device file /dev/crash_tmc_xxx will be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode
.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)
drivers/hwtracing/coresight/coresight-tmc-core.c +205 -1
@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" ); +return false; + } +/* Check for valid metadata */ +if (!mdata->valid) { +dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved +* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" ); + ret = -EINVAL ; + goto out; + } + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true; +out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace (struct tmc_drvdata *drvdata, +loff_t pos,size_t len,char **bufpp) +{ +s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf; + +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual; + +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare (struct tmc_drvdata *drvdata) {int ret =0 ;
@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek, }; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata); +if (ret) +return ret; + +nonseekable_open (inode, file); + +dev_dbg (&drvdata->csdev->dev,"%s: successfully opened\n" , __func__); +return 0 ; +} + +static ssize_t tmc_crashdata_read (struct file *file,char __user *data, +size_t len,loff_t *ppos) +{ +char *bufp; +ssize_t actual; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + actual =tmc_get_resvbuf_trace (drvdata, *ppos, len, &bufp); +if (actual <=0 ) +return 0 ; + +if (copy_to_user (data, bufp, actual)) { +dev_dbg (&drvdata->csdev->dev, +"%s: copy_to_user failed\n" , __func__); +return -EFAULT ; + } + + *ppos += actual; +dev_dbg (&drvdata->csdev->dev,"%zu bytes copied\n" , actual); + +return actual; + +} + +static int tmc_crashdata_release (struct inode *inode,struct file *file) +{ +int ret =0 ; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_unprepare_crashdata (drvdata); + +dev_dbg (&drvdata->csdev->dev,"%s: released\n" , __func__); +return ret; +} + +static const struct file_operations tmc_crashdata_fops = { + .owner =THIS_MODULE , + .open = tmc_crashdata_open, + .read = tmc_crashdata_read, + .release = tmc_crashdata_release, + .llseek = no_llseek, +}; +static enum tmc_mem_intf_width tmc_get_memwidth (u32 devid) {enum tmc_mem_intf_width memwidth;
@@ -533,6 +716,20 @@ static u32 tmc_etr_get_max_burst_size(struct device *dev)return burst_size; } +static void register_crash_dev_interface (struct tmc_drvdata *drvdata, +const char *name) +{ + drvdata->crashdev.name = +devm_kasprintf (&drvdata->csdev->dev,GFP_KERNEL ,"%s_%s" ,"crash" , name); + drvdata->crashdev.minor =MISC_DYNAMIC_MINOR ; + drvdata->crashdev.fops = &tmc_crashdata_fops; +if (misc_register (&drvdata->crashdev)) { +dev_dbg (&drvdata->csdev->dev, +"Failed to setup user interface for crashdata\n" ); + drvdata->crashdev.fops =NULL ; + } +} +static int __tmc_probe (struct device *dev,struct resource *res) {int ret =0 ;
@@ -633,8 +830,13 @@ static int __tmc_probe(struct device *dev, struct resource *res) drvdata->miscdev.minor =MISC_DYNAMIC_MINOR ; drvdata->miscdev.fops = &tmc_fops; ret =misc_register (&drvdata->miscdev); -if (ret) +if (ret) {coresight_unregister (drvdata->csdev); + goto out; + } + +if (is_tmc_crashdata_valid (drvdata)) +register_crash_dev_interface (drvdata, desc.name); out:return ret; }
@@ -688,6 +890,8 @@ static void __tmc_remove(struct device *dev)* handler to this device is closed. */ misc_deregister (&drvdata->miscdev); +if (drvdata->crashdev.fops) +misc_deregister (&drvdata->crashdev);coresight_unregister (drvdata->csdev); }
drivers/hwtracing/coresight/coresight-tmc-etf.c +36 -0
@@ -662,6 +662,36 @@ static int tmc_panic_sync_etf(struct coresight_device *csdev)return 0 ; } +static int tmc_etb_prepare_crashdata (struct coresight_device *csdev) +{ +unsigned long size; +struct tmc_resrv_buf *rbuf; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + mdata = drvdata->crash_mdata.vaddr; + size = mdata->size <<2 ; + + rbuf->len = size; + rbuf->offset =0 ; + rbuf->full =0 ; + +return 0 ; +} + +static int tmc_etb_unprepare_crashdata (struct coresight_device *csdev) +{ +struct tmc_resrv_buf *rbuf; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; +/* Reset valid length */ + rbuf->len =0 ; + +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,
@@ -679,6 +709,11 @@ static const struct coresight_ops_panic tmc_etf_sync_ops = { .sync = tmc_panic_sync_etf, }; +static const struct coresight_ops_crashdata tmc_etf_crashdata_ops = { + .prepare = tmc_etb_prepare_crashdata, + .unprepare = tmc_etb_unprepare_crashdata, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };
@@ -687,6 +722,7 @@ const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, .panic_ops = &tmc_etf_sync_ops, + .crashdata_ops = &tmc_etf_crashdata_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)
drivers/hwtracing/coresight/coresight-tmc-etr.c +63 -0
84 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-tmc.h +17 -1
@@ -195,11 +195,17 @@ struct etr_buf {* @paddr : Start address of reserved memory region. * @vaddr : Corresponding CPU virtual address. * @size : Size of reserved memory region. +* @full : Trace data overflow +* @offset : Offset of the trace data in the buffer for consumption. +* @len : Available trace data @buf (may round up to the beginning). */ struct tmc_resrv_buf {phys_addr_t paddr;void *vaddr;size_t size; +bool full; +unsigned long offset; +s64 len; };/**
@@ -208,6 +214,8 @@ struct tmc_resrv_buf {* @base: memory mapped base address for this component. * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.tmc" entry. +* @crashdev: specifics to handle "/dev/crash_tmc_xyz" entry for reading +* crash tracedata. * @spinlock: only one at a time pls. * @pid: Process ID of the process that owns the session that is using * this component. For example this would be the pid of the Perf
@@ -227,7 +235,10 @@ struct tmc_resrv_buf {* @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. -* @resrv_buf: Used by ETR as hardware trace buffer and for trace data +* @sysfs_crash_buf: Sysfs crashdata buffer for ETR. This is a special purpose +* buffer that is used only for mapping the trace buffer from +* previous crash and not for capturing trace. +* @resrv_buf: Used by ETR as hardware trace buffer and for trace data * retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default.
@@ -239,6 +250,7 @@ struct tmc_drvdata {void __iomem *base;struct coresight_device *csdev;struct miscdevice miscdev; +struct miscdevice crashdev;spinlock_t spinlock;pid_t pid;bool reading;
@@ -309,6 +321,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata);void tmc_enable_hw (struct tmc_drvdata *drvdata);void tmc_disable_hw (struct tmc_drvdata *drvdata);u32 tmc_get_memwidth_mask (struct tmc_drvdata *drvdata); +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata); +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata);/* ETB/ETF functions */ int tmc_read_prepare_etb (struct tmc_drvdata *drvdata);
@@ -371,6 +385,8 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, u64 offset, u64 size);ssize_t tmc_sg_table_get_data (struct tmc_sg_table *sg_table,u64 offset,size_t len,char **bufpp); + +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata);static inline unsigned long tmc_sg_table_buf_size (struct tmc_sg_table *sg_table) {
include/linux/coresight.h +12 -0
@@ -336,6 +336,7 @@ enum cs_mode {#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops#define panic_ops (csdev) csdev->ops->panic_ops +#define crashdata_ops (csdev) csdev->ops->crashdata_ops/** * struct coresight_ops_sink - basic operations for a sink
@@ -415,12 +416,23 @@ struct coresight_ops_panic {int (*sync)(struct coresight_device *csdev); }; +/** +* struct coresight_ops_crashdata - Generic device ops for crashdata mode +* +* @prepare : Preparation for reading crashdata mode +*/ +struct coresight_ops_crashdata { +int (*prepare)(struct coresight_device *csdev); +int (*unprepare)(struct coresight_device *csdev); +}; +struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops;const struct coresight_ops_panic *panic_ops; +const struct coresight_ops_crashdata *crashdata_ops; }; static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
Signature · 1 line
2.34.1
Suzuki K Poulose
maintainerRe: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_buf
Why do we need "full" ? See more on that below.
Quoted 43 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +18
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" );
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" ); +return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {
minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Quoted 20 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +20
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out;
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved +* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );
Couldn't this be made part of the "is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 13 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +13
-0+ ret = -EINVAL ; + goto out; + } + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;
Why are we dealing with drvdata->reading ? That is supposed to be only for the normal trace reading ?
Quoted 26 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +23
-0+out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace(struct tmc_drvdata *drvdata,
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 211
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ loff_t pos, size_t len, char **bufpp) +{ + s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf; + +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual;
return 0 ? Because, we went beyond the file position, not because there was an error. So, that it doesn't look like we are suppressing an ERROR ?
Quoted 20 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +15
-0+ +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare(struct tmc_drvdata *drvdata) { int ret = 0;drivers/hwtracing/coresight/coresight-tmc-core.c +0
-0@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek,
drivers/hwtracing/coresight/coresight-tmc-core.c static const struct file_operations tmc_fops = { · line 353
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +8
-0}; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata);
I don't see the point of this "prepare" and unprepare callbacks, as they can be made generic by populating the mdata->rrp,rwp fields accordingly ?
i.e., while populating the mdata-> fields, for ETR, do what you do now. For ETF you could :
mdata->rrp = 0;mdata->dba = 0;mdata->rwp = drvdata->len;mdata->size = drvdata->len >> 2;mdata->sts = TMC_STS_FULL;
Quoted 185 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +78
-1+if (ret) +return ret; + +nonseekable_open (inode, file); + +dev_dbg (&drvdata->csdev->dev,"%s: successfully opened\n" , __func__); +return 0 ; +} + +static ssize_t tmc_crashdata_read (struct file *file,char __user *data, +size_t len,loff_t *ppos) +{ +char *bufp; +ssize_t actual; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + actual =tmc_get_resvbuf_trace (drvdata, *ppos, len, &bufp); +if (actual <=0 ) +return 0 ; + +if (copy_to_user (data, bufp, actual)) { +dev_dbg (&drvdata->csdev->dev, +"%s: copy_to_user failed\n" , __func__); +return -EFAULT ; + } + + *ppos += actual; +dev_dbg (&drvdata->csdev->dev,"%zu bytes copied\n" , actual); + +return actual; + +} + +static int tmc_crashdata_release (struct inode *inode,struct file *file) +{ +int ret =0 ; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_unprepare_crashdata (drvdata); + +dev_dbg (&drvdata->csdev->dev,"%s: released\n" , __func__); +return ret; +} + +static const struct file_operations tmc_crashdata_fops = { + .owner =THIS_MODULE , + .open = tmc_crashdata_open, + .read = tmc_crashdata_read, + .release = tmc_crashdata_release, + .llseek = no_llseek, +}; +static enum tmc_mem_intf_width tmc_get_memwidth (u32 devid) {enum tmc_mem_intf_width memwidth;@@ -533,6 +716,20 @@ static u32 tmc_etr_get_max_burst_size(struct device *dev)return burst_size; } +static void register_crash_dev_interface (struct tmc_drvdata *drvdata, +const char *name) +{ + drvdata->crashdev.name = +devm_kasprintf (&drvdata->csdev->dev,GFP_KERNEL ,"%s_%s" ,"crash" , name); + drvdata->crashdev.minor =MISC_DYNAMIC_MINOR ; + drvdata->crashdev.fops = &tmc_crashdata_fops; +if (misc_register (&drvdata->crashdev)) { +dev_dbg (&drvdata->csdev->dev, +"Failed to setup user interface for crashdata\n" ); + drvdata->crashdev.fops =NULL ; + } +} +static int __tmc_probe (struct device *dev,struct resource *res) {int ret =0 ;@@ -633,8 +830,13 @@ static int __tmc_probe(struct device *dev, struct resource *res) drvdata->miscdev.minor =MISC_DYNAMIC_MINOR ; drvdata->miscdev.fops = &tmc_fops; ret =misc_register (&drvdata->miscdev); -if (ret) +if (ret) {coresight_unregister (drvdata->csdev); + goto out; + } + +if (is_tmc_crashdata_valid (drvdata)) +register_crash_dev_interface (drvdata, desc.name); out:return ret; }@@ -688,6 +890,8 @@ static void __tmc_remove(struct device *dev)* handler to this device is closed. */ misc_deregister (&drvdata->miscdev); +if (drvdata->crashdev.fops) +misc_deregister (&drvdata->crashdev);coresight_unregister (drvdata->csdev); }drivers/hwtracing/coresight/coresight-tmc-etf.c +36
-0@@ -662,6 +662,36 @@ static int tmc_panic_sync_etf(struct coresight_device *csdev)return 0 ; } +static int tmc_etb_prepare_crashdata (struct coresight_device *csdev) +{ +unsigned long size; +struct tmc_resrv_buf *rbuf; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + mdata = drvdata->crash_mdata.vaddr; + size = mdata->size <<2 ; + + rbuf->len = size; + rbuf->offset =0 ; + rbuf->full =0 ; + +return 0 ; +} + +static int tmc_etb_unprepare_crashdata (struct coresight_device *csdev) +{ +struct tmc_resrv_buf *rbuf; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; +/* Reset valid length */ + rbuf->len =0 ; + +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -679,6 +709,11 @@ static const struct coresight_ops_panic tmc_etf_sync_ops = { .sync = tmc_panic_sync_etf, }; +static const struct coresight_ops_crashdata tmc_etf_crashdata_ops = { + .prepare = tmc_etb_prepare_crashdata, + .unprepare = tmc_etb_unprepare_crashdata, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -687,6 +722,7 @@ const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, .panic_ops = &tmc_etf_sync_ops, + .crashdata_ops = &tmc_etf_crashdata_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +12
-0@@ -1887,6 +1887,55 @@ static int tmc_panic_sync_etr(struct coresight_device *csdev)return 0 ; } +static int tmc_etr_prepare_crashdata (struct coresight_device *csdev) +{ +u32 status; +u64 rrp, rwp, dba; +struct tmc_resrv_buf *rbuf; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + mdata = drvdata->crash_mdata.vaddr; + + rrp = mdata->rrp;
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_panic_sync_etr(struct coresight_device *csdev) · line 1911
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +10
-0+ rwp = mdata->rwp; + dba = mdata->dba; + status = mdata->sts; + + rbuf->full = !!(status &TMC_STS_FULL ); + +/* Sync the buffer pointers */ + rbuf->offset = rrp - dba; +if (rbuf->full) + rbuf->len = rbuf->size;
Why are we nto using mdata->size << 2 ? What if the "reserved buf" size was changes by the firmware, keeping the base same ?
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_panic_sync_etr(struct coresight_device *csdev) · line 1913
Quoted 2 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +2
-0+else + rbuf->len = rwp - rrp;
We don't seem to be using "full" anywhere else other than this routine. So we could simply drop it ?
As I mentioned above, I don't see why the "rbuf" cannot be constructed from a generic "metadata" (provided we fix the TMC-ETF mdata storage) and drop these ETF/ETR specific prepare/unprepare callbacks.
Quoted 64 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +39
-0+ +/* Additional sanity checks for validating metadata */ +if ((rbuf->offset > rbuf->size) || + (rbuf->len > rbuf->size)) { +dev_dbg (&drvdata->csdev->dev, +"Offset and length invalid in tmc crash metadata\n" ); +return -EINVAL ; + } + +return 0 ; +} + +static int tmc_etr_unprepare_crashdata (struct coresight_device *csdev) +{ +struct tmc_resrv_buf *rbuf; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + +/* Reset valid length */ + rbuf->len =0 ; + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1899,9 +1948,15 @@ static const struct coresight_ops_panic tmc_etr_sync_ops = { .sync = tmc_panic_sync_etr, }; +static const struct coresight_ops_crashdata tmc_etr_crashdata_ops = { + .prepare = tmc_etr_prepare_crashdata, + .unprepare = tmc_etr_unprepare_crashdata, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, .panic_ops = &tmc_etr_sync_ops, + .crashdata_ops = &tmc_etr_crashdata_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)@@ -1934,6 +1989,14 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)__tmc_etr_disable_hw (drvdata); drvdata->reading = true; + +/* +* The only other place we mark the metadata invalid is during +* panic handler. Normally this won't race with panic handler, +* as all cpus would be stopped before running panic handler. +*/ +if (drvdata->etr_mode ==ETR_MODE_RESRV ) +tmc_crashdata_set_invalid (drvdata); out:spin_unlock_irqrestore (&drvdata->spinlock, flags);drivers/hwtracing/coresight/coresight-tmc.h +0
-0
drivers/hwtracing/coresight/coresight-tmc.h struct etr_buf { · line 200
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc.h +3
-0@@ -195,11 +195,17 @@ struct etr_buf {* @paddr : Start address of reserved memory region. * @vaddr : Corresponding CPU virtual address. * @size : Size of reserved memory region. +* @full : Trace data overflow +* @offset : Offset of the trace data in the buffer for consumption. +* @len : Available trace data @buf (may round up to the beginning).
super minor nit: extra TAB
drivers/hwtracing/coresight/coresight-tmc.h struct etr_buf { · line 206
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc.h +1
-0*/ struct tmc_resrv_buf {phys_addr_t paddr;void *vaddr;size_t size; +bool full;
As mentioned above, drop it ^^
Quoted 15 lines
drivers/hwtracing/coresight/coresight-tmc.h +4
-0+unsigned long offset; +s64 len; };/** @@ -208,6 +214,8 @@ struct tmc_resrv_buf {* @base: memory mapped base address for this component. * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.tmc" entry. +* @crashdev: specifics to handle "/dev/crash_tmc_xyz" entry for reading +* crash tracedata. * @spinlock: only one at a time pls. * @pid: Process ID of the process that owns the session that is using * this component. For example this would be the pid of the Perf
drivers/hwtracing/coresight/coresight-tmc.h struct tmc_resrv_buf { · line 240
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc.h +3
-1@@ -227,7 +235,10 @@ struct tmc_resrv_buf {* @idr_mutex: Access serialisation for idr. * @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. -* @resrv_buf: Used by ETR as hardware trace buffer and for trace data +* @sysfs_crash_buf: Sysfs crashdata buffer for ETR. This is a special purpose +* buffer that is used only for mapping the trace buffer from +* previous crash and not for capturing trace.
This looks like a left over from the previous version. Please drop.
Quoted 46 lines
drivers/hwtracing/coresight/coresight-tmc.h +6
-0+* @resrv_buf: Used by ETR as hardware trace buffer and for trace data * retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default. @@ -239,6 +250,7 @@ struct tmc_drvdata {void __iomem *base;struct coresight_device *csdev;struct miscdevice miscdev; +struct miscdevice crashdev;spinlock_t spinlock;pid_t pid;bool reading;@@ -309,6 +321,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata);void tmc_enable_hw (struct tmc_drvdata *drvdata);void tmc_disable_hw (struct tmc_drvdata *drvdata);u32 tmc_get_memwidth_mask (struct tmc_drvdata *drvdata); +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata); +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata);/* ETB/ETF functions */ int tmc_read_prepare_etb (struct tmc_drvdata *drvdata);@@ -371,6 +385,8 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, u64 offset, u64 size);ssize_t tmc_sg_table_get_data (struct tmc_sg_table *sg_table,u64 offset,size_t len,char **bufpp); + +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata);static inline unsigned long tmc_sg_table_buf_size (struct tmc_sg_table *sg_table) {include/linux/coresight.h +1
-0@@ -336,6 +336,7 @@ enum cs_mode {#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops#define panic_ops (csdev) csdev->ops->panic_ops +#define crashdata_ops (csdev) csdev->ops->crashdata_ops/** * struct coresight_ops_sink - basic operations for a sink @@ -415,12 +416,23 @@ struct coresight_ops_panic {int (*sync)(struct coresight_device *csdev); };
include/linux/coresight.h struct coresight_ops_panic { · line 428
Quoted 10 lines
include/linux/coresight.h +10
-0+/** +* struct coresight_ops_crashdata - Generic device ops for crashdata mode +* +* @prepare : Preparation for reading crashdata mode +*/ +struct coresight_ops_crashdata { +int (*prepare)(struct coresight_device *csdev); +int (*unprepare)(struct coresight_device *csdev); +}; +
Drop these please ^^
Quoted 10 lines
include/linux/coresight.h +1
-0struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops;const struct coresight_ops_panic *panic_ops; +const struct coresight_ops_crashdata *crashdata_ops; }; static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
Re: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Quoted 74 lines · Suzuki K Poulose
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_bufWhy do we need "full" ? See more on that below.
Quoted 48 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +24
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" );
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +26
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );Couldn't this be made part of the "
is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.
Ack. Will move.
Quoted 17 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +3
-0+ ret = -EINVAL ; + goto out; + }drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;Why are we dealing with
drvdata->reading? That is supposed to be only for the normal trace reading ?
Ack. Will remove, we dont need this.
Quoted 32 lines
Quoted 32 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +28
-0+out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace (struct tmc_drvdata *drvdata, +loff_t pos,size_t len,char **bufpp) +{ +s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf;
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 211
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +5
-0+ +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual;return 0 ? Because, we went beyond the file position, not because there was an error. So, that it doesn't look like we are suppressing an ERROR ?
return 0 looks fine to me. Will recheck on this.
Quoted 35 lines
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +15
-0+ +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare (struct tmc_drvdata *drvdata){ int ret = 0;drivers/hwtracing/coresight/coresight-tmc-core.c static const struct file_operations tmc_fops = { · line 352
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +8
-0@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek, }; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata);I don't see the point of this "prepare" and unprepare callbacks, as they can be made generic by populating the mdata->rrp,rwp fields accordingly ?
Quoted 8 lines
i.e., while populating the mdata-> fields, for ETR, do what you do now. For ETF you could :
mdata->rrp= 0;mdata->dba= 0;mdata->rwp=drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;
Agree with your point that this would get rid of sink specific callbacks.
But few points to consider before we go with the above approach,
* mdata register snapshots wont be true to their definition, with such encodings.
We had a similar discussion on this earlier regarding mdata->size, ie. We decided to stick to register format instead of storing bytes.
https://lore.kernel.org/linux-arm-kernel/[email protected]/
* We will have more comparable code between normal trace buffer reading and reading trace buffer after panic with sink specific callbacks, even though we keep the code seperate.
Please let me know your thoughts on this.
Quoted 186 lines
Quoted 186 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +78
-1+if (ret) +return ret; + +nonseekable_open (inode, file); + +dev_dbg (&drvdata->csdev->dev,"%s: successfully opened\n" , __func__); +return 0 ; +} + +static ssize_t tmc_crashdata_read (struct file *file,char __user *data, +size_t len,loff_t *ppos) +{ +char *bufp; +ssize_t actual; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + actual =tmc_get_resvbuf_trace (drvdata, *ppos, len, &bufp); +if (actual <=0 ) +return 0 ; + +if (copy_to_user (data, bufp, actual)) { +dev_dbg (&drvdata->csdev->dev, +"%s: copy_to_user failed\n" , __func__); +return -EFAULT ; + } + + *ppos += actual; +dev_dbg (&drvdata->csdev->dev,"%zu bytes copied\n" , actual); + +return actual; + +} + +static int tmc_crashdata_release (struct inode *inode,struct file *file) +{ +int ret =0 ; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_unprepare_crashdata (drvdata); + +dev_dbg (&drvdata->csdev->dev,"%s: released\n" , __func__); +return ret; +} + +static const struct file_operations tmc_crashdata_fops = { + .owner =THIS_MODULE , + .open = tmc_crashdata_open, + .read = tmc_crashdata_read, + .release = tmc_crashdata_release, + .llseek = no_llseek, +}; +static enum tmc_mem_intf_width tmc_get_memwidth (u32 devid) {enum tmc_mem_intf_width memwidth;@@ -533,6 +716,20 @@ static u32 tmc_etr_get_max_burst_size(struct device *dev)return burst_size; } +static void register_crash_dev_interface (struct tmc_drvdata *drvdata, +const char *name) +{ + drvdata->crashdev.name = +devm_kasprintf (&drvdata->csdev->dev,GFP_KERNEL ,"%s_%s" ,"crash" , name); + drvdata->crashdev.minor =MISC_DYNAMIC_MINOR ; + drvdata->crashdev.fops = &tmc_crashdata_fops; +if (misc_register (&drvdata->crashdev)) { +dev_dbg (&drvdata->csdev->dev, +"Failed to setup user interface for crashdata\n" ); + drvdata->crashdev.fops =NULL ; + } +} +static int __tmc_probe (struct device *dev,struct resource *res) {int ret =0 ;@@ -633,8 +830,13 @@ static int __tmc_probe(struct device *dev, struct resource *res) drvdata->miscdev.minor =MISC_DYNAMIC_MINOR ; drvdata->miscdev.fops = &tmc_fops; ret =misc_register (&drvdata->miscdev); -if (ret) +if (ret) {coresight_unregister (drvdata->csdev); + goto out; + } + +if (is_tmc_crashdata_valid (drvdata)) +register_crash_dev_interface (drvdata, desc.name); out:return ret; }@@ -688,6 +890,8 @@ static void __tmc_remove(struct device *dev)* handler to this device is closed. */ misc_deregister (&drvdata->miscdev); +if (drvdata->crashdev.fops) +misc_deregister (&drvdata->crashdev);coresight_unregister (drvdata->csdev); }drivers/hwtracing/coresight/coresight-tmc-etf.c +36
-0@@ -662,6 +662,36 @@ static int tmc_panic_sync_etf(struct coresight_device *csdev)return 0 ; } +static int tmc_etb_prepare_crashdata (struct coresight_device *csdev) +{ +unsigned long size; +struct tmc_resrv_buf *rbuf; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + mdata = drvdata->crash_mdata.vaddr; + size = mdata->size <<2 ; + + rbuf->len = size; + rbuf->offset =0 ; + rbuf->full =0 ; + +return 0 ; +} + +static int tmc_etb_unprepare_crashdata (struct coresight_device *csdev) +{ +struct tmc_resrv_buf *rbuf; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; +/* Reset valid length */ + rbuf->len =0 ; + +return 0 ; +} +static const struct coresight_ops_sink tmc_etf_sink_ops = { .enable = tmc_enable_etf_sink, .disable = tmc_disable_etf_sink,@@ -679,6 +709,11 @@ static const struct coresight_ops_panic tmc_etf_sync_ops = { .sync = tmc_panic_sync_etf, }; +static const struct coresight_ops_crashdata tmc_etf_crashdata_ops = { + .prepare = tmc_etb_prepare_crashdata, + .unprepare = tmc_etb_unprepare_crashdata, +}; +const struct coresight_ops tmc_etb_cs_ops = { .sink_ops = &tmc_etf_sink_ops, };@@ -687,6 +722,7 @@ const struct coresight_ops tmc_etf_cs_ops = { .sink_ops = &tmc_etf_sink_ops, .link_ops = &tmc_etf_link_ops, .panic_ops = &tmc_etf_sync_ops, + .crashdata_ops = &tmc_etf_crashdata_ops, };int tmc_read_prepare_etb (struct tmc_drvdata *drvdata)drivers/hwtracing/coresight/coresight-tmc-etr.c +17
-0@@ -1887,6 +1887,55 @@ static int tmc_panic_sync_etr(struct coresight_device *csdev)return 0 ; } +static int tmc_etr_prepare_crashdata (struct coresight_device *csdev) +{ +u32 status; +u64 rrp, rwp, dba; +struct tmc_resrv_buf *rbuf; +struct tmc_crash_metadata *mdata; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + mdata = drvdata->crash_mdata.vaddr; + + rrp = mdata->rrp; + rwp = mdata->rwp; + dba = mdata->dba; + status = mdata->sts; + + rbuf->full = !!(status &TMC_STS_FULL );
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_panic_sync_etr(struct coresight_device *csdev) · line 1911
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +5
-0+ +/* Sync the buffer pointers */ + rbuf->offset = rrp - dba; +if (rbuf->full) + rbuf->len = rbuf->size;Why are we nto using
mdata->size<< 2 ? What if the "reserved buf" size was changes by the firmware, keeping the base same ?
Ack. Will change this.
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c static int tmc_panic_sync_etr(struct coresight_device *csdev) · line 1913
Quoted 3 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +2
-0+else + rbuf->len = rwp - rrp;We don't seem to be using "full" anywhere else other than this routine. So we could simply drop it ?
As I mentioned above, I don't see why the "rbuf" cannot be constructed from a generic "metadata" (provided we fix the TMC-ETF mdata storage) and drop these ETF/ETR specific prepare/unprepare callbacks.
Few concerns on this approach is posted above.
Quoted 62 lines
Quoted 62 lines
drivers/hwtracing/coresight/coresight-tmc-etr.c +39
-0+ +/* Additional sanity checks for validating metadata */ +if ((rbuf->offset > rbuf->size) || + (rbuf->len > rbuf->size)) { +dev_dbg (&drvdata->csdev->dev, +"Offset and length invalid in tmc crash metadata\n" ); +return -EINVAL ; + } + +return 0 ; +} + +static int tmc_etr_unprepare_crashdata (struct coresight_device *csdev) +{ +struct tmc_resrv_buf *rbuf; +struct tmc_drvdata *drvdata =dev_get_drvdata (csdev->dev.parent); + + rbuf = &drvdata->resrv_buf; + +/* Reset valid length */ + rbuf->len =0 ; + +return 0 ; +} +static const struct coresight_ops_sink tmc_etr_sink_ops = { .enable = tmc_enable_etr_sink, .disable = tmc_disable_etr_sink,@@ -1899,9 +1948,15 @@ static const struct coresight_ops_panic tmc_etr_sync_ops = { .sync = tmc_panic_sync_etr, }; +static const struct coresight_ops_crashdata tmc_etr_crashdata_ops = { + .prepare = tmc_etr_prepare_crashdata, + .unprepare = tmc_etr_unprepare_crashdata, +}; +const struct coresight_ops tmc_etr_cs_ops = { .sink_ops = &tmc_etr_sink_ops, .panic_ops = &tmc_etr_sync_ops, + .crashdata_ops = &tmc_etr_crashdata_ops, };int tmc_read_prepare_etr (struct tmc_drvdata *drvdata)@@ -1934,6 +1989,14 @@ int tmc_read_prepare_etr(struct tmc_drvdata *drvdata)__tmc_etr_disable_hw (drvdata); drvdata->reading = true; + +/* +* The only other place we mark the metadata invalid is during +* panic handler. Normally this won't race with panic handler, +* as all cpus would be stopped before running panic handler. +*/ +if (drvdata->etr_mode ==ETR_MODE_RESRV ) +tmc_crashdata_set_invalid (drvdata); out:spin_unlock_irqrestore (&drvdata->spinlock, flags);drivers/hwtracing/coresight/coresight-tmc.h +0
-0@@ -195,11 +195,17 @@ struct etr_buf {
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h struct etr_buf { · line 200
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc.h +3
-0* @paddr : Start address of reserved memory region. * @vaddr : Corresponding CPU virtual address. * @size : Size of reserved memory region. +* @full : Trace data overflow +* @offset : Offset of the trace data in the buffer for consumption. +* @len : Available trace data @buf (may round up to the beginning). super minor nit: extra TAB
Ack.
Quoted 25 lines
drivers/hwtracing/coresight/coresight-tmc.h struct etr_buf { · line 206
Quoted 7 lines
drivers/hwtracing/coresight/coresight-tmc.h +1
-0*/ struct tmc_resrv_buf {phys_addr_t paddr;void *vaddr;size_t size; +bool full;As mentioned above, drop it ^^
Quoted 15 lines
drivers/hwtracing/coresight/coresight-tmc.h +4
-0+unsigned long offset; +s64 len; };/** @@ -208,6 +214,8 @@ struct tmc_resrv_buf {* @base: memory mapped base address for this component. * @csdev: component vitals needed by the framework. * @miscdev: specifics to handle "/dev/xyz.tmc" entry. +* @crashdev: specifics to handle "/dev/crash_tmc_xyz" entry for reading +* crash tracedata. * @spinlock: only one at a time pls. * @pid: Process ID of the process that owns the session that is using * this component. For example this would be the pid of the Perf @@ -227,7 +235,10 @@ struct tmc_resrv_buf {* @idr_mutex: Access serialisation for idr.
Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc.h struct tmc_resrv_buf { · line 240
Quoted 6 lines
drivers/hwtracing/coresight/coresight-tmc.h +3
-1* @sysfs_buf: SYSFS buffer for ETR. * @perf_buf: PERF buffer for ETR. -* @resrv_buf: Used by ETR as hardware trace buffer and for trace data +* @sysfs_crash_buf: Sysfs crashdata buffer for ETR. This is a special purpose +* buffer that is used only for mapping the trace buffer from +* previous crash and not for capturing trace. This looks like a left over from the previous version. Please drop.
Ack.
Quoted 68 lines
Quoted 44 lines
drivers/hwtracing/coresight/coresight-tmc.h +6
-0+* @resrv_buf: Used by ETR as hardware trace buffer and for trace data * retention (after crash) only when ETR_MODE_RESRV buffer * mode is enabled. Used by ETF for trace data retention * (after crash) by default. @@ -239,6 +250,7 @@ struct tmc_drvdata {void __iomem *base;struct coresight_device *csdev;struct miscdevice miscdev; +struct miscdevice crashdev;spinlock_t spinlock;pid_t pid;bool reading;@@ -309,6 +321,8 @@ void tmc_flush_and_stop(struct tmc_drvdata *drvdata);void tmc_enable_hw (struct tmc_drvdata *drvdata);void tmc_disable_hw (struct tmc_drvdata *drvdata);u32 tmc_get_memwidth_mask (struct tmc_drvdata *drvdata); +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata); +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata);/* ETB/ETF functions */ int tmc_read_prepare_etb (struct tmc_drvdata *drvdata);@@ -371,6 +385,8 @@ void tmc_sg_table_sync_data_range(struct tmc_sg_table *table, u64 offset, u64 size);ssize_t tmc_sg_table_get_data (struct tmc_sg_table *sg_table,u64 offset,size_t len,char **bufpp); + +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata);static inline unsigned long tmc_sg_table_buf_size (struct tmc_sg_table *sg_table) {include/linux/coresight.h +1
-0@@ -336,6 +336,7 @@ enum cs_mode {#define helper_ops (csdev) csdev->ops->helper_ops#define ect_ops (csdev) csdev->ops->ect_ops#define panic_ops (csdev) csdev->ops->panic_ops +#define crashdata_ops (csdev) csdev->ops->crashdata_ops/** * struct coresight_ops_sink - basic operations for a sink @@ -415,12 +416,23 @@ struct coresight_ops_panic {int (*sync)(struct coresight_device *csdev); };include/linux/coresight.h struct coresight_ops_panic { · line 427
Quoted 10 lines
include/linux/coresight.h +10
-0+/** +* struct coresight_ops_crashdata - Generic device ops for crashdata mode +* +* @prepare : Preparation for reading crashdata mode +*/ +struct coresight_ops_crashdata { +int (*prepare)(struct coresight_device *csdev); +int (*unprepare)(struct coresight_device *csdev); +}; +Drop these please ^^
Quoted 9 lines
include/linux/coresight.h +1
-0struct coresight_ops {const struct coresight_ops_sink *sink_ops;const struct coresight_ops_link *link_ops;const struct coresight_ops_source *source_ops;const struct coresight_ops_helper *helper_ops;const struct coresight_ops_panic *panic_ops; +const struct coresight_ops_crashdata *crashdata_ops; }; static inline u32 csdev_access_relaxed_read32(struct csdev_access *csa,
Suzuki K Poulose
maintainerRe: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Quoted 236 lines · Linu Cherian
Quoted 74 lines · Suzuki K Poulose
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_bufWhy do we need "full" ? See more on that below.
Quoted 48 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +24
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" );Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +26
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );Couldn't this be made part of the "
is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.Ack. Will move.
Quoted 17 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +3
-0+ ret = -EINVAL ; + goto out; + }drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;Why are we dealing with
drvdata->reading? That is supposed to be only for the normal trace reading ?Ack. Will remove, we dont need this.
Quoted 32 lines
Quoted 32 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +28
-0+out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace (struct tmc_drvdata *drvdata, +loff_t pos,size_t len,char **bufpp) +{ +s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf;Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 211
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +5
-0+ +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual;return 0 ? Because, we went beyond the file position, not because there was an error. So, that it doesn't look like we are suppressing an ERROR ?
return 0 looks fine to me. Will recheck on this.
Quoted 35 lines
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +15
-0+ +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare (struct tmc_drvdata *drvdata){ int ret = 0;drivers/hwtracing/coresight/coresight-tmc-core.c static const struct file_operations tmc_fops = { · line 352
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +8
-0@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek, }; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata);I don't see the point of this "prepare" and unprepare callbacks, as they can be made generic by populating the mdata->rrp,rwp fields accordingly ?
Quoted 8 lines
i.e., while populating the mdata-> fields, for ETR, do what you do now. For ETF you could :
mdata->rrp= 0;mdata->dba= 0;mdata->rwp=drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;Agree with your point that this would get rid of sink specific callbacks.
Quoted 8 lines
But few points to consider before we go with the above approach,
* mdata register snapshots wont be true to their definition, with such encodings.
We had a similar discussion on this earlier regarding
mdata->size, ie. We decided to stick to register format instead of storing bytes.
https://lore.kernel.org/linux-arm-kernel/[email protected]/
Understood. But whoever fills in the metdata does need to fill the mdata information above ? Including calculating the hash. So, I think it is fair to say that mdata is populated in a way that makes sense just by looking at it. In fact, we should :
mdata->dba = <address of the tracedata>mdata->rrp = mdata->dba;mdata->rwp = mdata->rrp + drvdata->len;mdata->size = drvdata->len >> 2;mdata->sts = TMC_STS_FULL;
Rather than filling in 0's.
Quoted 4 lines
* We will have more comparable code between normal trace buffer reading and reading trace buffer after panic with sink specific callbacks, even though we keep the code seperate.
Lets not create "customs" here. We have a callback for a reason. i.e, the ETF has an internal SRAM which is not accessible directly by the CPU and ETR uses normal RAM.
While in this case, we have the data in CPU accessible RAM and the "driver" in this case is crash handling and can be agnostic of where the data was captured (ETF vs ETR)
Suzuki
Quoted 2 lines
Please let me know your thoughts on this.
Re: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Hi Suzuki,
Quoted 252 lines · Suzuki K Poulose
Quoted 236 lines · Linu Cherian
Quoted 74 lines · Suzuki K Poulose
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_bufWhy do we need "full" ? See more on that below.
Quoted 48 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +24
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" );Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +26
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );Couldn't this be made part of the "
is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.Ack. Will move.
Quoted 17 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +3
-0+ ret = -EINVAL ; + goto out; + }drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;Why are we dealing with
drvdata->reading? That is supposed to be only for the normal trace reading ?Ack. Will remove, we dont need this.
Quoted 32 lines
Quoted 32 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +28
-0+out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace (struct tmc_drvdata *drvdata, +loff_t pos,size_t len,char **bufpp) +{ +s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf;Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 211
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +5
-0+ +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual;return 0 ? Because, we went beyond the file position, not because there was an error. So, that it doesn't look like we are suppressing an ERROR ?
return 0 looks fine to me. Will recheck on this.
Quoted 35 lines
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +15
-0+ +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare (struct tmc_drvdata *drvdata){ int ret = 0;drivers/hwtracing/coresight/coresight-tmc-core.c static const struct file_operations tmc_fops = { · line 352
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +8
-0@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek, }; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata);I don't see the point of this "prepare" and unprepare callbacks, as they can be made generic by populating the mdata->rrp,rwp fields accordingly ?
Quoted 8 lines
i.e., while populating the mdata-> fields, for ETR, do what you do now. For ETF you could :
mdata->rrp= 0;mdata->dba= 0;mdata->rwp=drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;Agree with your point that this would get rid of sink specific callbacks.
Quoted 8 lines
But few points to consider before we go with the above approach,
* mdata register snapshots wont be true to their definition, with such encodings.
We had a similar discussion on this earlier regarding
mdata->size, ie. We decided to stick to register format instead of storing bytes.
https://lore.kernel.org/linux-arm-kernel/[email protected]/Understood. But whoever fills in the metdata does need to fill the mdata information above ? Including calculating the hash. So, I think it is fair to say that mdata is populated in a way that makes sense just by looking at it. In fact, we should :
Quoted 7 lines
mdata->dba= <address of the tracedata>mdata->rrp=mdata->dba;mdata->rwp=mdata->rrp+drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;Rather than filling in 0's.
Okay, will make this change for ETF and avoid the sink specific callbacks.
Quoted 7 lines
Quoted 6 lines
* We will have more comparable code between normal trace buffer reading and reading trace buffer after panic with sink specific callbacks, even though we keep the code seperate.
Quoted 7 lines
Lets not create "customs" here. We have a callback for a reason. i.e, the ETF has an internal SRAM which is not accessible directly by the CPU and ETR uses normal RAM.
While in this case, we have the data in CPU accessible RAM and the "driver" in this case is crash handling and can be agnostic of where the data was captured (ETF vs ETR)
Okay fine.
Quoted 10 lines
Suzuki
Quoted 2 lines
Please let me know your thoughts on this.
Re: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Hi Suzuki,
Quoted 262 lines · Linu Cherian
Hi Suzuki,
Quoted 259 lines · Suzuki K Poulose
Quoted 236 lines · Linu Cherian
Quoted 74 lines · Suzuki K Poulose
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_bufWhy do we need "full" ? See more on that below.
Quoted 48 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +24
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" );Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +26
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );Couldn't this be made part of the "
is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.Ack. Will move.
Quoted 17 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +3
-0+ ret = -EINVAL ; + goto out; + }drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;Why are we dealing with
drvdata->reading? That is supposed to be only for the normal trace reading ?Ack. Will remove, we dont need this.
Quoted 32 lines
Quoted 32 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +28
-0+out: +spin_unlock_irqrestore (&drvdata->spinlock, flags); +return ret; +} + +int tmc_read_unprepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret; +unsigned long flags; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->unprepare (csdev); + + drvdata->reading = false; +spin_unlock_irqrestore (&drvdata->spinlock, flags); + +return ret; +} + +static inline ssize_t tmc_get_resvbuf_trace (struct tmc_drvdata *drvdata, +loff_t pos,size_t len,char **bufpp) +{ +s64 offset; +ssize_t actual = len; +struct tmc_resrv_buf *rbuf = &drvdata->resrv_buf;Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 211
Quoted 5 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +5
-0+ +if (pos + actual > rbuf->len) + actual = rbuf->len - pos; +if (actual <=0 ) +return actual;return 0 ? Because, we went beyond the file position, not because there was an error. So, that it doesn't look like we are suppressing an ERROR ?
return 0 looks fine to me. Will recheck on this.
Quoted 35 lines
Quoted 21 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +15
-0+ +/* Compute the offset from which we read the data */ + offset = rbuf->offset + pos; +if (offset >= rbuf->size) + offset -= rbuf->size; + +/* Adjust the length to limit this transaction to end of buffer */ + actual = (actual < (rbuf->size - offset)) ? + actual : rbuf->size - offset; + + *bufpp = (char *)rbuf->vaddr + offset; + +return actual; +} +static int tmc_read_prepare (struct tmc_drvdata *drvdata){ int ret = 0;drivers/hwtracing/coresight/coresight-tmc-core.c static const struct file_operations tmc_fops = { · line 352
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +8
-0@@ -224,6 +343,70 @@ static const struct file_operations tmc_fops = { .llseek = no_llseek, }; +static int tmc_crashdata_open (struct inode *inode,struct file *file) +{ +int ret; +struct tmc_drvdata *drvdata =container_of (file->private_data, + struct tmc_drvdata, + crashdev); + + ret =tmc_read_prepare_crashdata (drvdata);I don't see the point of this "prepare" and unprepare callbacks, as they can be made generic by populating the mdata->rrp,rwp fields accordingly ?
Quoted 8 lines
i.e., while populating the mdata-> fields, for ETR, do what you do now. For ETF you could :
mdata->rrp= 0;mdata->dba= 0;mdata->rwp=drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;Agree with your point that this would get rid of sink specific callbacks.
Quoted 8 lines
But few points to consider before we go with the above approach,
* mdata register snapshots wont be true to their definition, with such encodings.
We had a similar discussion on this earlier regarding
mdata->size, ie. We decided to stick to register format instead of storing bytes.
https://lore.kernel.org/linux-arm-kernel/[email protected]/Understood. But whoever fills in the metdata does need to fill the mdata information above ? Including calculating the hash. So, I think it is fair to say that mdata is populated in a way that makes sense just by looking at it. In fact, we should :
mdata->dba= <address of the tracedata>mdata->rrp=mdata->dba;mdata->rwp=mdata->rrp+drvdata->len;mdata->size=drvdata->len>> 2;mdata->sts=TMC_STS_FULL;Rather than filling in 0's.
Just wanted to point out that, in case of watchdog reset when firmware is updating this, dba would be the physical address while in ETR case it could be virtual address (with IOMMU).
So in that regard, filling in zeros seems better to me for rrp and dba.
Please let me know your preference on this.
Thanks.
Re: [PATCH v10 5/8] coresight: tmc: Add support for reading crash data
Hi Suzuki,
Quoted 152 lines · Linu Cherian
Hi Suzuki,
Quoted 149 lines · Linu Cherian
Hi Suzuki,
Quoted 146 lines · Suzuki K Poulose
Quoted 145 lines · Linu Cherian
Quoted 74 lines · Suzuki K Poulose
Hi Linu
Quoted 9 lines · Linu Cherian
* Add support for reading crashdata using special device files. The special device files
/dev/crash_tmc_xxxwould be available for read file operation only when the crash data is valid.* User can read the crash data as below
For example, for reading crash data from
tmc_etfsink#dd if=/dev/crash_tmc_etfXX of=~/cstrace.bin
There are some comments below, please take a look.
Quoted 8 lines
Signed-off-by Anil Kumar Reddy <[email protected]>Signed-off-by Tanmay Jagdale <[email protected]>Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
- RemovedREAD_CRASHDATAmode meant for special casing crashdata read
- Added new fields full, len, offset to structtmc_resrv_bufWhy do we need "full" ? See more on that below.
Quoted 48 lines
so as to have a common read function for ETR and ETF
- Introduced read file operation,tmc_crashdata_readspecific to crashdata reads common for both ETR and ETF
- Introducedis_tmc_crashdata_validfunction
Special device file/dev/crash_tmc_xxxwill be available only when crashdata is valid.
- Version checks added to crashdata validity checks
- Mark crashdata as invalid when user starts tracing with ETR sink in "resrv" buffer mode.../hwtracing/coresight/coresight-tmc-core.c | 206 +++++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 36 +++ .../hwtracing/coresight/coresight-tmc-etr.c | 63 ++++++ drivers/hwtracing/coresight/coresight-tmc.h | 18 +- include/linux/coresight.h | 12 + 5 files changed, 333 insertions(+), 2 deletions(-)drivers/hwtracing/coresight/coresight-tmc-core.c +24
-0@@ -105,6 +105,125 @@ u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata)return mask; } +bool is_tmc_crashdata_valid (struct tmc_drvdata *drvdata) +{ +struct tmc_crash_metadata *mdata; + +if (!tmc_has_reserved_buffer (drvdata) || + !tmc_has_crash_mdata_buffer (drvdata)) +return false; + + mdata = drvdata->crash_mdata.vaddr; + +/* Check version match */ +if (mdata->version !=CS_CRASHDATA_VERSION ) +return false; + +/* Check data integrity of metadata */ +if (mdata->crc32_mdata !=find_crash_metadata_crc (mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash metadata\n" ); +return false; + } +/* Check data integrity of tracedata */ +if (mdata->crc32_tdata !=find_crash_tracedata_crc (drvdata, mdata)) { +dev_dbg (&drvdata->csdev->dev, +"CRC mismatch in tmc crash tracedata\n" );Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 135
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+return false; + } +/* Check for valid metadata */ +if (!mdata->valid) {minor nit: This could be checked right after the VERSION and we verify the CRC anyway later and thus could skip all the CRC calculations if !valid.
Ack.
Quoted 27 lines
Quoted 27 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +26
-0+dev_dbg (&drvdata->csdev->dev, +"Data invalid in tmc crash metadata\n" ); +return false; + } + +return true; +} + +int tmc_read_prepare_crashdata (struct tmc_drvdata *drvdata) +{ +int ret =0 ; +unsigned long flags; +struct tmc_crash_metadata *mdata; +struct coresight_device *csdev = drvdata->csdev; + +spin_lock_irqsave (&drvdata->spinlock, flags); + +if (!is_tmc_crashdata_valid (drvdata)) { + ret = -ENXIO ; + goto out; + } + + mdata = drvdata->crash_mdata.vaddr; +/* +* Buffer address given by metadata for retrieval of trace data +* from previous boot is expected to be same as the reserved Quoted 8 lines
drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 165
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +4
-0+* trace buffer memory region provided through DTS +*/ +if (drvdata->resrv_buf.paddr != mdata->trace_paddr) { +dev_dbg (&csdev->dev,"Trace buffer address of previous boot invalid\n" );Couldn't this be made part of the "
is_tmc_crashdata_valid()" and not repeated everytime we do the read ? Surely, this can't change after boot.Ack. Will move.
Quoted 17 lines
Quoted 4 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +3
-0+ ret = -EINVAL ; + goto out; + }drivers/hwtracing/coresight/coresight-tmc-core.c u32 tmc_get_memwidth_mask(struct tmc_drvdata *drvdata) · line 178
Quoted 10 lines
drivers/hwtracing/coresight/coresight-tmc-core.c +10
-0+ +/* Sink specific crashdata mode preparation */ + ret =crashdata_ops (csdev)->prepare (csdev); +if (ret) + goto out; + +if (mdata->sts &0x1 ) +coresight_insert_barrier_packet (drvdata->buf); + + drvdata->reading = true;Why are we dealing with
drvdata->reading? That is supposed to be only for the normal trace reading ?Ack. Will remove, we dont need this.
Looked into this further and it seems like, retaining the drvdata->reading flags would be useful to avoid simultaneous crashdata reads and regular trace capture sessions using reserve buffers.
Something like this,
+static int buf_mode_set_resrv(struct tmc_drvdata *drvdata) +{
+ unsigned long flags;
+ int err = 0;
+
+ /* Ensure there are no active crashdata read sessions */
+ spin_lock_irqsave(&drvdata->spinlock, flags);
+ if (!drvdata->reading) {
+ tmc_crashdata_set_invalid(drvdata);
+ drvdata->etr_mode = ETR_MODE_RESRV;
+
+ } else
+ err = -EINVAL;
+ spin_unlock_irqrestore(&drvdata->spinlock, flags);
+ return err;
+}
+
static ssize_t buf_mode_preferred_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t size)
{
struct tmc_drvdata *drvdata = dev_get_drvdata(dev->parent); struct etr_buf_hw buf_hw;
get_etr_buf_hw(dev, &buf_hw);
@@ -2039,7 +2050,7 @@ static ssize_t buf_mode_preferred_store(struct device *dev,
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_CATU]) && buf_hw.has_catu)
drvdata->etr_mode = ETR_MODE_CATU;
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_RESRV]) && buf_hw.has_resrv)
- drvdata->etr_mode = ETR_MODE_RESRV;
+ return buf_mode_set_resrv(drvdata);
else if (sysfs_streq(buf, buf_modes_str[ETR_MODE_AUTO]))
drvdata->etr_mode = ETR_MODE_AUTO;
else
Was acutally calling the tmc_crashdata_set_invalid in the wrong place in v10 patch.
PATCH v10 6/8 coresight: tmc: Stop trace capture on FlIn
In reply to Linu CherianConfigure TMC ETR and ETF to flush and stop trace capture on FlIn event based on sysfs attribute, /sys/bus/coresight/devices/tmc_etXn/stop_on_flush.
---
Changelog from v9:
No changes
.../hwtracing/coresight/coresight-tmc-core.c | 31 +++++++++++++++++++ .../hwtracing/coresight/coresight-tmc-etf.c | 12 ++++--- .../hwtracing/coresight/coresight-tmc-etr.c | 12 ++++--- drivers/hwtracing/coresight/coresight-tmc.h | 2 ++ 4 files changed, 47 insertions(+), 10 deletions(-)
drivers/hwtracing/coresight/coresight-tmc-core.c +31 -0
@@ -516,9 +516,40 @@ static ssize_t buffer_size_store(struct device *dev,static DEVICE_ATTR_RW (buffer_size); +static ssize_t stop_on_flush_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct tmc_drvdata *drvdata =dev_get_drvdata (dev->parent); + +return sprintf (buf,"%#x\n" , drvdata->stop_on_flush); +} + +static ssize_t stop_on_flush_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t size) +{ +int ret; +u8 val; +struct tmc_drvdata *drvdata =dev_get_drvdata (dev->parent); + + ret =kstrtou8 (buf,0 , &val); +if (ret) +return ret; +if (val) + drvdata->stop_on_flush = true; +else + drvdata->stop_on_flush = false; + +return size; +} + +static DEVICE_ATTR_RW (stop_on_flush); + +static struct attribute *coresight_tmc_attrs[] = { &dev_attr_trigger_cntr.attr, &dev_attr_buffer_size.attr, + &dev_attr_stop_on_flush.attr,NULL , };
drivers/hwtracing/coresight/coresight-tmc-etf.c +7 -5
@@ -19,6 +19,7 @@ static int tmc_set_etf_buffer(struct coresight_device *csdev,static int __tmc_etb_enable_hw (struct tmc_drvdata *drvdata) {int rc =0 ; +u32 ffcr;CS_UNLOCK (drvdata->base);
@@ -32,10 +33,12 @@ static int __tmc_etb_enable_hw(struct tmc_drvdata *drvdata) }writel_relaxed (TMC_MODE_CIRCULAR_BUFFER , drvdata->base +TMC_MODE ); -writel_relaxed (TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI | -TMC_FFCR_FON_FLIN |TMC_FFCR_FON_TRIG_EVT | -TMC_FFCR_TRIGON_TRIGIN , - drvdata->base +TMC_FFCR ); + + ffcr =TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI |TMC_FFCR_FON_FLIN | +TMC_FFCR_FON_TRIG_EVT |TMC_FFCR_TRIGON_TRIGIN ; +if (drvdata->stop_on_flush) + ffcr |=TMC_FFCR_STOP_ON_FLUSH ; +writel_relaxed (ffcr, drvdata->base +TMC_FFCR );writel_relaxed (drvdata->trigger_cntr, drvdata->base +TMC_TRG );tmc_enable_hw (drvdata);
@@ -225,7 +228,6 @@ static int tmc_enable_etf_sink_sysfs(struct coresight_device *csdev) used = true; drvdata->buf = buf; } - ret =tmc_etb_enable_hw (drvdata);if (!ret) {coresight_set_mode (csdev,CS_MODE_SYSFS );
drivers/hwtracing/coresight/coresight-tmc-etr.c +7 -5
@@ -1060,7 +1060,7 @@ static void tmc_sync_etr_buf(struct tmc_drvdata *drvdata)static int __tmc_etr_enable_hw (struct tmc_drvdata *drvdata) { -u32 axictl, sts; +u32 axictl, sts, ffcr;struct etr_buf *etr_buf = drvdata->etr_buf;int rc =0 ;
@@ -1106,10 +1106,12 @@ static int __tmc_etr_enable_hw(struct tmc_drvdata *drvdata)writel_relaxed (sts, drvdata->base +TMC_STS ); } -writel_relaxed (TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI | -TMC_FFCR_FON_FLIN |TMC_FFCR_FON_TRIG_EVT | -TMC_FFCR_TRIGON_TRIGIN , - drvdata->base +TMC_FFCR ); + ffcr =TMC_FFCR_EN_FMT |TMC_FFCR_EN_TI |TMC_FFCR_FON_FLIN | +TMC_FFCR_FON_TRIG_EVT |TMC_FFCR_TRIGON_TRIGIN ; +if (drvdata->stop_on_flush) + ffcr |=TMC_FFCR_STOP_ON_FLUSH ; +writel_relaxed (ffcr, drvdata->base +TMC_FFCR ); +writel_relaxed (drvdata->trigger_cntr, drvdata->base +TMC_TRG );tmc_enable_hw (drvdata);
drivers/hwtracing/coresight/coresight-tmc.h +2 -0
@@ -220,6 +220,7 @@ struct tmc_resrv_buf {* @pid: Process ID of the process that owns the session that is using * this component. For example this would be the pid of the Perf * process. +* @stop_on_flush: Stop on flush trigger user configuration. * @buf: Snapshot of the trace data for ETF/ETB. * @etr_buf: details of buffer used in TMC-ETR * @len: size of the available trace for ETF/ETB.
@@ -254,6 +255,7 @@ struct tmc_drvdata {spinlock_t spinlock;pid_t pid;bool reading; +bool stop_on_flush;union {char *buf;/* TMC ETB */ struct etr_buf *etr_buf;/* TMC ETR */
Signature · 1 line
2.34.1
PATCH v10 7/8 coresight: config: Add preloaded configuration
In reply to Linu CherianAdd a preloaded configuration for generating
external trigger on address match. This can be
used by CTI and ETR blocks to stop trace capture
on kernel panic.
Kernel address for "panic" function is used as the default trigger address.
This new configuration is available as, /sys/kernel/config/cs-syscfg/configurations/panicstop
---
Changelog from v9:
No changes
drivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.c
drivers/hwtracing/coresight/Makefile +1 -1
@@ -25,7 +25,7 @@ subdir-ccflags-y += $(condflags) obj-$(CONFIG_CORESIGHT) += coresight.o coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ coresight-sysfs.o coresight-syscfg.o coresight-config.o \ - coresight-cfg-preload.o coresight-cfg-afdo.o \ + coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \ coresight-syscfg-configfs.o coresight-trace-id.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \
drivers/hwtracing/coresight/coresight-cfg-preload.c +2 -0
@@ -13,6 +13,7 @@static struct cscfg_feature_desc *preload_feats[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &strobe_etm4x, + &gen_etrig_etm4x, #endifNULL };
@@ -20,6 +21,7 @@ static struct cscfg_feature_desc *preload_feats[] = {static struct cscfg_config_desc *preload_cfgs[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &afdo_etm4x, + &pstop_etm4x, #endifNULL };
drivers/hwtracing/coresight/coresight-cfg-preload.h +2 -0
@@ -10,4 +10,6 @@#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM4X )extern struct cscfg_feature_desc strobe_etm4x;extern struct cscfg_config_desc afdo_etm4x; +extern struct cscfg_feature_desc gen_etrig_etm4x; +extern struct cscfg_config_desc pstop_etm4x;#endif
drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.34.1
Suzuki K Poulose
maintainerRe: [PATCH v10 7/8] coresight: config: Add preloaded configuration
Quoted 29 lines · Linu Cherian
Add a preloaded configuration for generating
external trigger on address match. This can be
used by CTI and ETR blocks to stop trace capture
on kernel panic.Kernel address for "panic" function is used as the default trigger address.
This new configuration is available as,
/sys/kernel/config/cs-syscfg/configurations/panicstopSigned-off-by Linu Cherian <[email protected]>Reviewed-by James Clark <[email protected]>---
Changelog from v9:
No changesdrivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-)create mode 100644
drivers/hwtracing/coresight/coresight-cfg-pstop.cdrivers/hwtracing/coresight/Makefile +0
-0
drivers/hwtracing/coresight/Makefile subdir-ccflags-y += $(condflags) · line 28
Quoted 5 lines
drivers/hwtracing/coresight/Makefile +1
-1@@ -25,7 +25,7 @@ subdir-ccflags-y += $(condflags) obj-$(CONFIG_CORESIGHT) += coresight.o coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ coresight-sysfs.o coresight-syscfg.o coresight-config.o \ - coresight-cfg-preload.o coresight-cfg-afdo.o \ + coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \
Please could you only build it when ETM4X is selected ? That way you could drop the "CONFIG" check in the code ?
Quoted 40 lines
drivers/hwtracing/coresight/Makefile +0
-0coresight-syscfg-configfs.o coresight-trace-id.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \drivers/hwtracing/coresight/coresight-cfg-preload.c +2
-0@@ -13,6 +13,7 @@static struct cscfg_feature_desc *preload_feats[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &strobe_etm4x, + &gen_etrig_etm4x, #endifNULL };@@ -20,6 +21,7 @@ static struct cscfg_feature_desc *preload_feats[] = {static struct cscfg_config_desc *preload_cfgs[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &afdo_etm4x, + &pstop_etm4x, #endifNULL };drivers/hwtracing/coresight/coresight-cfg-preload.h +2
-0@@ -10,4 +10,6 @@#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM4X )extern struct cscfg_feature_desc strobe_etm4x;extern struct cscfg_config_desc afdo_etm4x; +extern struct cscfg_feature_desc gen_etrig_etm4x; +extern struct cscfg_config_desc pstop_etm4x;#endif drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +0
-0
drivers/hwtracing/coresight/coresight-cfg-pstop.c line 10
Quoted 10 lines
drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +10
-0@@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright(C) 2023 Marvell. +* Based on coresight-cfg-afdo.c +*/ + +#include "coresight-config.h" + +/* ETMv4 includes and features */ +#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM4X )
Could we not drop this check, if we only build it when CONFIG_CORESIGHT_SOURCE_ETM4X is selected. It is not useful otherwise anyways.
Rest looks fine to me
Suzuki
Quoted 73 lines
drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +73
-0+#include "coresight-etm4x-cfg.h" + +/* preload configurations and features */ + +/* preload in features for ETMv4 */ + +/* panic_stop feature */ +static struct cscfg_parameter_desc gen_etrig_params[] = { + { + .name ="address" , + .value = (u64 )panic, + }, +}; + +static struct cscfg_regval_desc gen_etrig_regs[] = { +/* resource selector */ + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCRSCTLRn (2 ), + .hw_info =ETM4_CFG_RES_SEL , + .val32 =0x40001 , + }, +/* single address comparator */ + { + .type =CS_CFG_REG_TYPE_RESOURCE |CS_CFG_REG_TYPE_VAL_64BIT | +CS_CFG_REG_TYPE_VAL_PARAM , + .offset =TRCACVRn (0 ), + .val32 =0x0 , + }, + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCACATRn (0 ), + .val64 =0xf00 , + }, +/* Driver external output[0] with comparator out */ + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCEVENTCTL0R , + .val32 =0x2 , + }, +/* end of regs */ +}; + +struct cscfg_feature_desc gen_etrig_etm4x = { + .name ="gen_etrig" , + .description ="Generate external trigger on address match\n" +"parameter \'address\': address of kernel address\n" , + .match_flags =CS_CFG_MATCH_CLASS_SRC_ETM4 , + .nr_params =ARRAY_SIZE (gen_etrig_params), + .params_desc = gen_etrig_params, + .nr_regs =ARRAY_SIZE (gen_etrig_regs), + .regs_desc = gen_etrig_regs, +}; + +/* create a panic stop configuration */ + +/* the total number of parameters in used features */ +#define PSTOP_NR_PARAMS ARRAY_SIZE(gen_etrig_params) + +static const char *pstop_ref_names[] = { +"gen_etrig" , +}; + +struct cscfg_config_desc pstop_etm4x = { + .name ="panicstop" , + .description ="Stop ETM on kernel panic\n" , + .nr_feat_refs =ARRAY_SIZE (pstop_ref_names), + .feat_ref_names = pstop_ref_names, + .nr_total_params =PSTOP_NR_PARAMS , +}; + +/* end of ETM4x configurations */ +#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */
Re: [PATCH v10 7/8] coresight: config: Add preloaded configuration
Quoted 25 lines · Suzuki K Poulose
Quoted 24 lines · Linu Cherian
Add a preloaded configuration for generating
external trigger on address match. This can be
used by CTI and ETR blocks to stop trace capture
on kernel panic.Kernel address for "panic" function is used as the default trigger address.
This new configuration is available as,
/sys/kernel/config/cs-syscfg/configurations/panicstopSigned-off-by Linu Cherian <[email protected]>Reviewed-by James Clark <[email protected]>---
Changelog from v9:
No changesdrivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 +++++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-)create mode 100644
drivers/hwtracing/coresight/coresight-cfg-pstop.c
Quoted 13 lines
drivers/hwtracing/coresight/Makefile subdir-ccflags-y += $(condflags) · line 28
Quoted 10 lines
drivers/hwtracing/coresight/Makefile +1
-1@@ -25,7 +25,7 @@ subdir-ccflags-y += $(condflags) obj-$(CONFIG_CORESIGHT) += coresight.o coresight-y := coresight-core.o coresight-etm-perf.o coresight-platform.o \ coresight-sysfs.o coresight-syscfg.o coresight-config.o \ - coresight-cfg-preload.o coresight-cfg-afdo.o \ + coresight-cfg-preload.o coresight-cfg-afdo.o coresight-cfg-pstop.o \Please could you only build it when ETM4X is selected ? That way you could drop the "CONFIG" check in the code ?
coresight-cfg-pstop feature follows the approach taken in existing features like preload, afdo etc. Hence, shall we keep the same format ? Please let me know if you think otherwise.
Quoted 46 lines
Quoted 46 lines
drivers/hwtracing/coresight/Makefile +0
-0coresight-syscfg-configfs.o coresight-trace-id.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o coresight-tmc-y := coresight-tmc-core.o coresight-tmc-etf.o \drivers/hwtracing/coresight/coresight-cfg-preload.c +2
-0@@ -13,6 +13,7 @@static struct cscfg_feature_desc *preload_feats[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &strobe_etm4x, + &gen_etrig_etm4x, #endifNULL };@@ -20,6 +21,7 @@ static struct cscfg_feature_desc *preload_feats[] = {static struct cscfg_config_desc *preload_cfgs[] = { #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) &afdo_etm4x, + &pstop_etm4x, #endifNULL };drivers/hwtracing/coresight/coresight-cfg-preload.h +2
-0@@ -10,4 +10,6 @@#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM4X )extern struct cscfg_feature_desc strobe_etm4x;extern struct cscfg_config_desc afdo_etm4x; +extern struct cscfg_feature_desc gen_etrig_etm4x; +extern struct cscfg_config_desc pstop_etm4x;#endif drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +6
-0@@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright(C) 2023 Marvell. +* Based on coresight-cfg-afdo.c +*/ +
Quoted 8 lines
drivers/hwtracing/coresight/coresight-cfg-pstop.c line 10
Quoted 4 lines
drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +4
-0+#include "coresight-config.h" + +/* ETMv4 includes and features */ +#if IS_ENABLED (CONFIG_CORESIGHT_SOURCE_ETM4X )Could we not drop this check, if we only build it when
CONFIG_CORESIGHT_SOURCE_ETM4Xis selected. It is not useful otherwise anyways.
IIUC, this arrangement might be helpful to add register configurations for future ETM versions in the same file.
Quoted 81 lines
Rest looks fine to me
Suzuki
Quoted 73 lines
drivers/hwtracing/coresight/coresight-cfg-pstop.c new file +73
-0+#include "coresight-etm4x-cfg.h" + +/* preload configurations and features */ + +/* preload in features for ETMv4 */ + +/* panic_stop feature */ +static struct cscfg_parameter_desc gen_etrig_params[] = { + { + .name ="address" , + .value = (u64 )panic, + }, +}; + +static struct cscfg_regval_desc gen_etrig_regs[] = { +/* resource selector */ + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCRSCTLRn (2 ), + .hw_info =ETM4_CFG_RES_SEL , + .val32 =0x40001 , + }, +/* single address comparator */ + { + .type =CS_CFG_REG_TYPE_RESOURCE |CS_CFG_REG_TYPE_VAL_64BIT | +CS_CFG_REG_TYPE_VAL_PARAM , + .offset =TRCACVRn (0 ), + .val32 =0x0 , + }, + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCACATRn (0 ), + .val64 =0xf00 , + }, +/* Driver external output[0] with comparator out */ + { + .type =CS_CFG_REG_TYPE_RESOURCE , + .offset =TRCEVENTCTL0R , + .val32 =0x2 , + }, +/* end of regs */ +}; + +struct cscfg_feature_desc gen_etrig_etm4x = { + .name ="gen_etrig" , + .description ="Generate external trigger on address match\n" +"parameter \'address\': address of kernel address\n" , + .match_flags =CS_CFG_MATCH_CLASS_SRC_ETM4 , + .nr_params =ARRAY_SIZE (gen_etrig_params), + .params_desc = gen_etrig_params, + .nr_regs =ARRAY_SIZE (gen_etrig_regs), + .regs_desc = gen_etrig_regs, +}; + +/* create a panic stop configuration */ + +/* the total number of parameters in used features */ +#define PSTOP_NR_PARAMS ARRAY_SIZE(gen_etrig_params) + +static const char *pstop_ref_names[] = { +"gen_etrig" , +}; + +struct cscfg_config_desc pstop_etm4x = { + .name ="panicstop" , + .description ="Stop ETM on kernel panic\n" , + .nr_feat_refs =ARRAY_SIZE (pstop_ref_names), + .feat_ref_names = pstop_ref_names, + .nr_total_params =PSTOP_NR_PARAMS , +}; + +/* end of ETM4x configurations */ +#endif /* IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X) */
PATCH v10 8/8 Documentation: coresight: Panic support
In reply to Linu CherianAdd documentation on using coresight during panic
and watchdog.
---
Changelog from v9:
This patch has been newly introduced.
Documentation/trace/coresight/panic.rst | 356 ++++++++++++++++++++++++ 1 file changed, 356 insertions(+) create mode 100644 Documentation/trace/coresight/panic.rst
Documentation/trace/coresight/panic.rst new file +356 -0
@@ -0,0 +1,356 @@ +=================================================== +Using Coresight for Kernel panic and Watchdog reset +=================================================== + +Introduction +------------ +This documentation is about using Linux coresight trace support to +debug kernel panic and watchdog reset scenarios. + +Coresight trace during Kernel panic +----------------------------------- +From the coresight driver point of view, addressing the kernel panic +situation has four main requirements. + +a. Support for allocation of trace buffer pages from reserved memory area. + Platform can advertise this using a new device tree property added to + relevant coresight nodes. + +b. Support for stopping coresight blocks at the time of panic + +c. Saving required metadata in the specified format + +d. Support for reading trace data captured at the time of panic + +Allocation of trace buffer pages from reserved RAM +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A new optional device tree property "memory-region" is added to the +ETR/ETF device nodes, that would give the base address and size of trace +buffer. + +Static allocation of trace buffers would ensure that both IOMMU enabled +and disabled cases are handled. Also, platforms that support persistent +RAM will allow users to read trace data in the subsequent boot without +booting the crashdump kernel. + +Note: +For ETR sink devices, this reserved region will be used for both trace +capture and trace data retrieval. +For ETF sink devices, internal SRAM would be used for trace capture, +and they would be synced to reserved region for retrieval. + + +Disabling coresight blocks at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In order to avoid the situation of losing relevant trace data after a +kernel panic, it would be desirable to stop the coresight blocks at the +time of panic. + +This can be achieved by configuring the comparator, CTI and sink +devices as below:: + + Trigger on panic + Comparator --->External out --->CTI -->External In---->ETR/ETF stop + +Saving metadata at the time of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Coresight metadata involves all additional data that are required for a +successful trace decode in addition to the trace data. This involves +ETR/ETF, ETE register snapshot etc. + +A new optional device property "memory-region" is added to +the ETR/ETF/ETE device nodes for this. + +Reading trace data captured at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Trace data captured at the time of panic, can be read from rebooted kernel +or from crashdump kernel using a special device file /dev/crash_tmc_xxx. +This device file is created only when there is a valid crashdata available. + +General flow of trace capture and decode incase of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +1. Enable source and sink on all the cores using the sysfs interface. + ETR sinks should have trace buffers allocated from reserved memory, + by selecting "resrv" buffer mode from sysfs. + +2. Run relevant tests. + +3. On a kernel panic, all coresight blocks are disabled, necessary + metadata is synced by kernel panic handler. + + System would eventually reboot or boot a crashdump kernel. + +4. For platforms that supports crashdump kernel, raw trace data can be + dumped using the coresight sysfs interface from the crashdump kernel + itself. Persistent RAM is not a requirement in this case. + +5. For platforms that supports persistent RAM, trace data can be dumped + using the coresight sysfs interface in the subsequent Linux boot. + Crashdump kernel is not a requirement in this case. Persistent RAM + ensures that trace data is intact across reboot. + +Coresight trace during Watchdog reset +------------------------------------- +The main difference between addressing the watchdog reset and kernel panic +case are below, + +a. Saving coresight metadata need to be taken care by the + SCP(system control processor) firmware in the specified format, + instead of kernel. + +b. Reserved memory region given by firmware for trace buffer and metadata + has to be in persistent RAM. + Note: This is a requirement for watchdog reset case but optional + in kernel panic case. + +Watchdog reset can be supported only on platforms that meet the above +two requirements. + +Sample commands for testing a Kernel panic case with ETR sink +------------------------------------------------------------- + +1. Boot Linux kernel with "crash_kexec_post_notifiers" added to the kernel + bootargs. This is mandatory if the user would like to read the tracedata + from the crashdump kernel. + +2. Enable the preloaded ETM configuration + + #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable + +3. Configure CTI using sysfs interface:: + + #./cti_setup.sh + + #cat cti_setup.sh + + + cd /sys/bus/coresight/devices/ + + ap_cti_config () { + #ETM trig out[0] trigger to Channel 0 + echo 0 4 > channels/trigin_attach + } + + etf_cti_config () { + #ETF Flush in trigger from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + etr_cti_config () { + #ETR Flush in from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + ctidevs=`find . -name "cti*"` + + for i in $ctidevs + do + cd $i + + connection=`find . -name "ete*"` + if [ ! -z "$connection" ] + then + echo "AP CTI config for $i" + ap_cti_config + fi + + connection=`find . -name "tmc_etf*"` + if [ ! -z "$connection" ] + then + echo "ETF CTI config for $i" + etf_cti_config + fi + + connection=`find . -name "tmc_etr*"` + if [ ! -z "$connection" ] + then + echo "ETR CTI config for $i" + etr_cti_config + fi + + cd .. + done + +Note: CTI connections are SOC specific and hence the above script is +added just for reference. + +4. Choose reserved buffer mode for ETR buffer + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred + +5. Enable stop on flush trigger configuration + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush + +6. Start Coresight tracing on cores 1 and 2 using sysfs interface + +7. Run some application on core 1 + #taskset -c 1 dd if=/dev/urandom of=/dev/null & + +8. Invoke kernel panic on core 2 + #echo 1 > /proc/sys/kernel/panic + #taskset -c 2 echo c > /proc/sysrq-trigger + +9. From rebooted kernel or crashdump kernel, read crashdata + + #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin + +10. Run opencsd decoder tools/scripts to generate the instruction trace. + +Sample instruction trace dump +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Core1 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.039572921 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.039572921 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.039572921 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + + ..snip + + 149.052324811 chacha_block_generic: ffff800008642d80: + 9100a3e0 add x0, + I 149.052324811 chacha_block_generic: ffff800008642d84: + b86178a2 ldr w2, [x5, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d88: + 8b010803 add x3, x0, x1, lsl #2 + I 149.052324811 chacha_block_generic: ffff800008642d8c: + b85fc063 ldur w3, [x3, #-4] + I 149.052324811 chacha_block_generic: ffff800008642d90: + 0b030042 add w2, w2, w3 + I 149.052324811 chacha_block_generic: ffff800008642d94: + b8217882 str w2, [x4, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d98: + 91000421 add x1, x1, #0x1 + I 149.052324811 chacha_block_generic: ffff800008642d9c: + f100443f cmp x1, #0x11 + + +Core 2 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.046243445 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.046243445 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.046243445 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + I 149.046243445 etm4_enable_hw: ffff800008ae1e3c: + d50323bf autiasp + E 149.046243445 etm4_enable_hw: ffff800008ae1e40: + d65f03c0 ret + A ete_sysreg_write: ffff800008adfa18 + + ..snip + + I 149.05422547 panic: ffff800008096300: + a90363f7 stp x23, x24, [sp, #48] + I 149.05422547 panic: ffff800008096304: + 6b00003f cmp w1, w0 + I 149.05422547 panic: ffff800008096308: + 3a411804 ccmn w0, #0x1, #0x4, ne // ne = any + N 149.05422547 panic: ffff80000809630c: + 540001e0 b.eq ffff800008096348 <panic+0xe0> // b.none + I 149.05422547 panic: ffff800008096310: + f90023f9 str x25, [sp, #64] + E 149.05422547 panic: ffff800008096314: + 97fe44ef bl ffff8000080276d0 <panic_smp_self_stop> + A panic: ffff80000809634c + I 149.05422547 panic: ffff80000809634c: + 910102d5 add x21, x22, #0x40 + I 149.05422547 panic: ffff800008096350: + 52800020 mov w0, #0x1 // #1 + E 149.05422547 panic: ffff800008096354: + 94166b8b bl ffff800008631180 <bust_spinlocks> + N 149.054225518 bust_spinlocks: ffff800008631180: + 340000c0 cbz w0, ffff800008631198 <bust_spinlocks+0x18> + I 149.054225518 bust_spinlocks: ffff800008631184: + f000a321 adrp x1, ffff800009a98000 <pbufs.0+0xbb8> + I 149.054225518 bust_spinlocks: ffff800008631188: + b9405c20 ldr w0, [x1, #92] + I 149.054225518 bust_spinlocks: ffff80000863118c: + 11000400 add w0, w0, #0x1 + I 149.054225518 bust_spinlocks: ffff800008631190: + b9005c20 str w0, [x1, #92] + E 149.054225518 bust_spinlocks: ffff800008631194: + d65f03c0 ret + A panic: ffff800008096358 + +Perf based testing +------------------ + +Starting perf session +~~~~~~~~~~~~~~~~~~~~~ +ETF: +perf record -e cs_etm/panicstop,@tmc_etf1/ -C 1 +perf record -e cs_etm/panicstop,@tmc_etf2/ -C 2 + +ETR: +perf record -e cs_etm/panicstop,@tmc_etr0/ -C 1,2 + +Reading trace data after panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Same sysfs based method explained above can be used to retrieve and +decode the trace data after the reboot on kernel panic.
Signature · 1 line
2.34.1
Re: [PATCH v10 8/8] Documentation: coresight: Panic support
Quoted 2 lines · Linu Cherian
+3. On a kernel panic, all coresight blocks are disabled, necessary
+ metadata is synced by kernel panic handler.
"... and necessary metadata ..."
Quoted 6 lines
(quoted diff) +6
-0+ + System would eventually reboot or boot a crashdump kernel. + +4. For platforms that supports crashdump kernel, raw trace data can be + dumped using the coresight sysfs interface from the crashdump kernel + itself. Persistent RAM is not a requirement in this case.
Review
Quoted 10 lines
(quoted diff) +10
-0+ +5. For platforms that supports persistent RAM, trace data can be dumped + using the coresight sysfs interface in the subsequent Linux boot. + Crashdump kernel is not a requirement in this case. Persistent RAM + ensures that trace data is intact across reboot. + +Coresight trace during Watchdog reset +------------------------------------- +The main difference between addressing the watchdog reset and kernel panic +case are below,
"... are:"
Quoted 80 lines
(quoted diff) +80
-0+Sample commands for testing a Kernel panic case with ETR sink +------------------------------------------------------------- + +1. Boot Linux kernel with "crash_kexec_post_notifiers" added to the kernel + bootargs. This is mandatory if the user would like to read the tracedata + from the crashdump kernel. + +2. Enable the preloaded ETM configuration + + #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable + +3. Configure CTI using sysfs interface:: + + #./cti_setup.sh + + #cat cti_setup.sh + + + cd /sys/bus/coresight/devices/ + + ap_cti_config () { + #ETM trig out[0] trigger to Channel 0 + echo 0 4 > channels/trigin_attach + } + + etf_cti_config () { + #ETF Flush in trigger from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + etr_cti_config () { + #ETR Flush in from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + ctidevs=`find . -name "cti*"` + + for i in $ctidevs + do + cd $i + + connection=`find . -name "ete*"` + if [ ! -z "$connection" ] + then + echo "AP CTI config for $i" + ap_cti_config + fi + + connection=`find . -name "tmc_etf*"` + if [ ! -z "$connection" ] + then + echo "ETF CTI config for $i" + etf_cti_config + fi + + connection=`find . -name "tmc_etr*"` + if [ ! -z "$connection" ] + then + echo "ETR CTI config for $i" + etr_cti_config + fi + + cd .. + done + +Note: CTI connections are SOC specific and hence the above script is +added just for reference. + +4. Choose reserved buffer mode for ETR buffer + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred + +5. Enable stop on flush trigger configuration + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush + +6. Start Coresight tracing on cores 1 and 2 using sysfs interface + +7. Run some application on core 1 + #taskset -c 1 dd if=/dev/urandom of=/dev/null &
Review
Quoted 10 lines
(quoted diff) +10
-0+ +8. Invoke kernel panic on core 2 + #echo 1 > /proc/sys/kernel/panic + #taskset -c 2 echo c > /proc/sysrq-trigger + +9. From rebooted kernel or crashdump kernel, read crashdata + + #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin + +10. Run opencsd decoder tools/scripts to generate the instruction trace.
Format all command lines as literal code blocks to be consistent:
---- >8 ----
Documentation/trace/coresight/panic.rst +10 -6
@@ -113,7 +113,7 @@ Sample commands for testing a Kernel panic case with ETR sink bootargs. This is mandatory if the user would like to read the tracedata from the crashdump kernel. -2. Enable the preloaded ETM configuration +2. Enable the preloaded ETM configuration:: #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable
@@ -176,22 +176,26 @@ Sample commands for testing a Kernel panic case with ETR sink Note: CTI connections are SOC specific and hence the above script is added just for reference. -4. Choose reserved buffer mode for ETR buffer +4. Choose reserved buffer mode for ETR buffer:: + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred -5. Enable stop on flush trigger configuration +5. Enable stop on flush trigger configuration:: + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush 6. Start Coresight tracing on cores 1 and 2 using sysfs interface -7. Run some application on core 1 +7. Run some application on core 1:: + #taskset -c 1 dd if=/dev/urandom of=/dev/null & -8. Invoke kernel panic on core 2 +8. Invoke kernel panic on core 2:: + #echo 1 > /proc/sys/kernel/panic #taskset -c 2 echo c > /proc/sysrq-trigger -9. From rebooted kernel or crashdump kernel, read crashdata +9. From rebooted kernel or crashdump kernel, read crashdata:: #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Re: [PATCH v10 8/8] Documentation: coresight: Panic support
Hi,
Quoted 149 lines · Bagas Sanjaya
Quoted 2 lines · Linu Cherian
+3. On a kernel panic, all coresight blocks are disabled, necessary
+ metadata is synced by kernel panic handler."... and necessary metadata ..."
Quoted 6 lines
(quoted diff) +6
-0+ + System would eventually reboot or boot a crashdump kernel. + +4. For platforms that supports crashdump kernel, raw trace data can be + dumped using the coresight sysfs interface from the crashdump kernel + itself. Persistent RAM is not a requirement in this case.Review
Quoted 10 lines
(quoted diff) +10
-0+ +5. For platforms that supports persistent RAM, trace data can be dumped + using the coresight sysfs interface in the subsequent Linux boot. + Crashdump kernel is not a requirement in this case. Persistent RAM + ensures that trace data is intact across reboot. + +Coresight trace during Watchdog reset +------------------------------------- +The main difference between addressing the watchdog reset and kernel panic +case are below,"... are:"
Quoted 80 lines
(quoted diff) +80
-0+Sample commands for testing a Kernel panic case with ETR sink +------------------------------------------------------------- + +1. Boot Linux kernel with "crash_kexec_post_notifiers" added to the kernel + bootargs. This is mandatory if the user would like to read the tracedata + from the crashdump kernel. + +2. Enable the preloaded ETM configuration + + #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable + +3. Configure CTI using sysfs interface:: + + #./cti_setup.sh + + #cat cti_setup.sh + + + cd /sys/bus/coresight/devices/ + + ap_cti_config () { + #ETM trig out[0] trigger to Channel 0 + echo 0 4 > channels/trigin_attach + } + + etf_cti_config () { + #ETF Flush in trigger from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + etr_cti_config () { + #ETR Flush in from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + ctidevs=`find . -name "cti*"` + + for i in $ctidevs + do + cd $i + + connection=`find . -name "ete*"` + if [ ! -z "$connection" ] + then + echo "AP CTI config for $i" + ap_cti_config + fi + + connection=`find . -name "tmc_etf*"` + if [ ! -z "$connection" ] + then + echo "ETF CTI config for $i" + etf_cti_config + fi + + connection=`find . -name "tmc_etr*"` + if [ ! -z "$connection" ] + then + echo "ETR CTI config for $i" + etr_cti_config + fi + + cd .. + done + +Note: CTI connections are SOC specific and hence the above script is +added just for reference. + +4. Choose reserved buffer mode for ETR buffer + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred + +5. Enable stop on flush trigger configuration + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush + +6. Start Coresight tracing on cores 1 and 2 using sysfs interface + +7. Run some application on core 1 + #taskset -c 1 dd if=/dev/urandom of=/dev/null &Review
Quoted 10 lines
(quoted diff) +10
-0+ +8. Invoke kernel panic on core 2 + #echo 1 > /proc/sys/kernel/panic + #taskset -c 2 echo c > /proc/sysrq-trigger + +9. From rebooted kernel or crashdump kernel, read crashdata + + #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin + +10. Run opencsd decoder tools/scripts to generate the instruction trace.Format all command lines as literal code blocks to be consistent:
---- >8 ----
Documentation/trace/coresight/panic.rst +7
-4@@ -113,7 +113,7 @@ Sample commands for testing a Kernel panic case with ETR sink bootargs. This is mandatory if the user would like to read the tracedata from the crashdump kernel. -2. Enable the preloaded ETM configuration +2. Enable the preloaded ETM configuration:: #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable@@ -176,22 +176,26 @@ Sample commands for testing a Kernel panic case with ETR sink Note: CTI connections are SOC specific and hence the above script is added just for reference. -4. Choose reserved buffer mode for ETR buffer +4. Choose reserved buffer mode for ETR buffer:: + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred -5. Enable stop on flush trigger configuration +5. Enable stop on flush trigger configuration:: + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush 6. Start Coresight tracing on cores 1 and 2 using sysfs interface -7. Run some application on core 1 +7. Run some application on core 1:: + #taskset -c 1 dd if=/dev/urandom of=/dev/null &
Documentation/trace/coresight/panic.rst Sample commands for testing a Kernel panic case with ETR sink · line 200
Quoted 10 lines
Documentation/trace/coresight/panic.rst +3
-2-8. Invoke kernel panic on core 2 +8. Invoke kernel panic on core 2:: + #echo 1 > /proc/sys/kernel/panic #taskset -c 2 echo c > /proc/sysrq-trigger -9. From rebooted kernel or crashdump kernel, read crashdata +9. From rebooted kernel or crashdump kernel, read crashdata:: #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin
Ack.
Quoted 5 lines
Thanks.
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Linu Cherian.
Suzuki K Poulose
maintainerRe: [PATCH v10 8/8] Documentation: coresight: Panic support
In reply to Linu CherianHi Linu
Quoted 2 lines · Linu Cherian
Add documentation on using coresight during panic
and watchdog.
Thank you so much for the documentation, this will be quite useful !
Some minor comments below.
Quoted 34 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
This patch has been newly introduced.Documentation/trace/coresight/panic.rst | 356 ++++++++++++++++++++++++ 1 file changed, 356 insertions(+)create mode 100644
Documentation/trace/coresight/panic.rstDocumentation/trace/coresight/panic.rst new file +18
-0@@ -0,0 +1,356 @@ +=================================================== +Using Coresight for Kernel panic and Watchdog reset +=================================================== + +Introduction +------------ +This documentation is about using Linux coresight trace support to +debug kernel panic and watchdog reset scenarios. + +Coresight trace during Kernel panic +----------------------------------- +From the coresight driver point of view, addressing the kernel panic +situation has four main requirements. + +a. Support for allocation of trace buffer pages from reserved memory area. + Platform can advertise this using a new device tree property added to + relevant coresight nodes. +
Documentation/trace/coresight/panic.rst line 28
Quoted 10 lines
Documentation/trace/coresight/panic.rst new file +10
-0+b. Support for stopping coresight blocks at the time of panic + +c. Saving required metadata in the specified format + +d. Support for reading trace data captured at the time of panic + +Allocation of trace buffer pages from reserved RAM +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A new optional device tree property "memory-region" is added to the +ETR/ETF device nodes, that would give the base address and size of trace
ETR/ETF => CoreSight TMC
Quoted 21 lines
Documentation/trace/coresight/panic.rst new file +21
-0+buffer. + +Static allocation of trace buffers would ensure that both IOMMU enabled +and disabled cases are handled. Also, platforms that support persistent +RAM will allow users to read trace data in the subsequent boot without +booting the crashdump kernel. + +Note: +For ETR sink devices, this reserved region will be used for both trace +capture and trace data retrieval. +For ETF sink devices, internal SRAM would be used for trace capture, +and they would be synced to reserved region for retrieval. + + +Disabling coresight blocks at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In order to avoid the situation of losing relevant trace data after a +kernel panic, it would be desirable to stop the coresight blocks at the +time of panic. + +This can be achieved by configuring the comparator, CTI and sink
Documentation/trace/coresight/panic.rst line 59
Quoted 10 lines
Documentation/trace/coresight/panic.rst new file +10
-0+devices as below:: + + Trigger on panic + Comparator --->External out --->CTI -->External In---->ETR/ETF stop + +Saving metadata at the time of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Coresight metadata involves all additional data that are required for a +successful trace decode in addition to the trace data. This involves +ETR/ETF, ETE register snapshot etc.
s/ETE/ETB ?
Documentation/trace/coresight/panic.rst line 62
Quoted 3 lines
Documentation/trace/coresight/panic.rst new file +3
-0+ +A new optional device property "memory-region" is added to +the ETR/ETF/ETE device nodes for this.
same here ^^
Quoted 80 lines
Documentation/trace/coresight/panic.rst new file +80
-0+ +Reading trace data captured at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Trace data captured at the time of panic, can be read from rebooted kernel +or from crashdump kernel using a special device file /dev/crash_tmc_xxx. +This device file is created only when there is a valid crashdata available. + +General flow of trace capture and decode incase of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +1. Enable source and sink on all the cores using the sysfs interface. + ETR sinks should have trace buffers allocated from reserved memory, + by selecting "resrv" buffer mode from sysfs. + +2. Run relevant tests. + +3. On a kernel panic, all coresight blocks are disabled, necessary + metadata is synced by kernel panic handler. + + System would eventually reboot or boot a crashdump kernel. + +4. For platforms that supports crashdump kernel, raw trace data can be + dumped using the coresight sysfs interface from the crashdump kernel + itself. Persistent RAM is not a requirement in this case. + +5. For platforms that supports persistent RAM, trace data can be dumped + using the coresight sysfs interface in the subsequent Linux boot. + Crashdump kernel is not a requirement in this case. Persistent RAM + ensures that trace data is intact across reboot. + +Coresight trace during Watchdog reset +------------------------------------- +The main difference between addressing the watchdog reset and kernel panic +case are below, + +a. Saving coresight metadata need to be taken care by the + SCP(system control processor) firmware in the specified format, + instead of kernel. + +b. Reserved memory region given by firmware for trace buffer and metadata + has to be in persistent RAM. + Note: This is a requirement for watchdog reset case but optional + in kernel panic case. + +Watchdog reset can be supported only on platforms that meet the above +two requirements. + +Sample commands for testing a Kernel panic case with ETR sink +------------------------------------------------------------- + +1. Boot Linux kernel with "crash_kexec_post_notifiers" added to the kernel + bootargs. This is mandatory if the user would like to read the tracedata + from the crashdump kernel. + +2. Enable the preloaded ETM configuration + + #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable + +3. Configure CTI using sysfs interface:: + + #./cti_setup.sh + + #cat cti_setup.sh + + + cd /sys/bus/coresight/devices/ + + ap_cti_config () { + #ETM trig out[0] trigger to Channel 0 + echo 0 4 > channels/trigin_attach + } + + etf_cti_config () { + #ETF Flush in trigger from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + etr_cti_config () { + #ETR Flush in from Channel 0 + echo 0 1 > channels/trigout_attach
Documentation/trace/coresight/panic.rst line 152
Quoted 10 lines
Documentation/trace/coresight/panic.rst new file +10
-0+ echo 1 > channels/trig_filter_enable + } + + ctidevs=`find . -name "cti*"` + + for i in $ctidevs + do + cd $i + + connection=`find . -name "ete*"`
minor nit: this could be ete or etm
Quoted 204 lines
Documentation/trace/coresight/panic.rst new file +204
-0+ if [ ! -z "$connection" ] + then + echo "AP CTI config for $i" + ap_cti_config + fi + + connection=`find . -name "tmc_etf*"` + if [ ! -z "$connection" ] + then + echo "ETF CTI config for $i" + etf_cti_config + fi + + connection=`find . -name "tmc_etr*"` + if [ ! -z "$connection" ] + then + echo "ETR CTI config for $i" + etr_cti_config + fi + + cd .. + done + +Note: CTI connections are SOC specific and hence the above script is +added just for reference. + +4. Choose reserved buffer mode for ETR buffer + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred + +5. Enable stop on flush trigger configuration + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush + +6. Start Coresight tracing on cores 1 and 2 using sysfs interface + +7. Run some application on core 1 + #taskset -c 1 dd if=/dev/urandom of=/dev/null & + +8. Invoke kernel panic on core 2 + #echo 1 > /proc/sys/kernel/panic + #taskset -c 2 echo c > /proc/sysrq-trigger + +9. From rebooted kernel or crashdump kernel, read crashdata + + #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin + +10. Run opencsd decoder tools/scripts to generate the instruction trace. + +Sample instruction trace dump +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Core1 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.039572921 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.039572921 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.039572921 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + + ..snip + + 149.052324811 chacha_block_generic: ffff800008642d80: + 9100a3e0 add x0, + I 149.052324811 chacha_block_generic: ffff800008642d84: + b86178a2 ldr w2, [x5, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d88: + 8b010803 add x3, x0, x1, lsl #2 + I 149.052324811 chacha_block_generic: ffff800008642d8c: + b85fc063 ldur w3, [x3, #-4] + I 149.052324811 chacha_block_generic: ffff800008642d90: + 0b030042 add w2, w2, w3 + I 149.052324811 chacha_block_generic: ffff800008642d94: + b8217882 str w2, [x4, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d98: + 91000421 add x1, x1, #0x1 + I 149.052324811 chacha_block_generic: ffff800008642d9c: + f100443f cmp x1, #0x11 + + +Core 2 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.046243445 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.046243445 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.046243445 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + I 149.046243445 etm4_enable_hw: ffff800008ae1e3c: + d50323bf autiasp + E 149.046243445 etm4_enable_hw: ffff800008ae1e40: + d65f03c0 ret + A ete_sysreg_write: ffff800008adfa18 + + ..snip + + I 149.05422547 panic: ffff800008096300: + a90363f7 stp x23, x24, [sp, #48] + I 149.05422547 panic: ffff800008096304: + 6b00003f cmp w1, w0 + I 149.05422547 panic: ffff800008096308: + 3a411804 ccmn w0, #0x1, #0x4, ne // ne = any + N 149.05422547 panic: ffff80000809630c: + 540001e0 b.eq ffff800008096348 <panic+0xe0> // b.none + I 149.05422547 panic: ffff800008096310: + f90023f9 str x25, [sp, #64] + E 149.05422547 panic: ffff800008096314: + 97fe44ef bl ffff8000080276d0 <panic_smp_self_stop> + A panic: ffff80000809634c + I 149.05422547 panic: ffff80000809634c: + 910102d5 add x21, x22, #0x40 + I 149.05422547 panic: ffff800008096350: + 52800020 mov w0, #0x1 // #1 + E 149.05422547 panic: ffff800008096354: + 94166b8b bl ffff800008631180 <bust_spinlocks> + N 149.054225518 bust_spinlocks: ffff800008631180: + 340000c0 cbz w0, ffff800008631198 <bust_spinlocks+0x18> + I 149.054225518 bust_spinlocks: ffff800008631184: + f000a321 adrp x1, ffff800009a98000 <pbufs.0+0xbb8> + I 149.054225518 bust_spinlocks: ffff800008631188: + b9405c20 ldr w0, [x1, #92] + I 149.054225518 bust_spinlocks: ffff80000863118c: + 11000400 add w0, w0, #0x1 + I 149.054225518 bust_spinlocks: ffff800008631190: + b9005c20 str w0, [x1, #92] + E 149.054225518 bust_spinlocks: ffff800008631194: + d65f03c0 ret + A panic: ffff800008096358 + +Perf based testing +------------------ + +Starting perf session +~~~~~~~~~~~~~~~~~~~~~ +ETF: +perf record -e cs_etm/panicstop,@tmc_etf1/ -C 1 +perf record -e cs_etm/panicstop,@tmc_etf2/ -C 2 + +ETR: +perf record -e cs_etm/panicstop,@tmc_etr0/ -C 1,2 + +Reading trace data after panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Same sysfs based method explained above can be used to retrieve and +decode the trace data after the reboot on kernel panic.
Re: [PATCH v10 8/8] Documentation: coresight: Panic support
Quoted 48 lines · Suzuki K Poulose
Hi Linu
Quoted 2 lines · Linu Cherian
Add documentation on using coresight during panic
and watchdog.Thank you so much for the documentation, this will be quite useful !
Some minor comments below.
Quoted 38 lines
Signed-off-by Linu Cherian <[email protected]>---
Changelog from v9:
This patch has been newly introduced.Documentation/trace/coresight/panic.rst | 356 ++++++++++++++++++++++++ 1 file changed, 356 insertions(+)create mode 100644
Documentation/trace/coresight/panic.rstDocumentation/trace/coresight/panic.rst new file +22
-0@@ -0,0 +1,356 @@ +=================================================== +Using Coresight for Kernel panic and Watchdog reset +=================================================== + +Introduction +------------ +This documentation is about using Linux coresight trace support to +debug kernel panic and watchdog reset scenarios. + +Coresight trace during Kernel panic +----------------------------------- +From the coresight driver point of view, addressing the kernel panic +situation has four main requirements. + +a. Support for allocation of trace buffer pages from reserved memory area. + Platform can advertise this using a new device tree property added to + relevant coresight nodes. + +b. Support for stopping coresight blocks at the time of panic + +c. Saving required metadata in the specified format +
Quoted 8 lines
Documentation/trace/coresight/panic.rst line 28
Quoted 6 lines
Documentation/trace/coresight/panic.rst new file +6
-0+d. Support for reading trace data captured at the time of panic + +Allocation of trace buffer pages from reserved RAM +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A new optional device tree property "memory-region" is added to the +ETR/ETF device nodes, that would give the base address and size of traceETR/ETF => CoreSight TMC
Ack.
Quoted 26 lines
Quoted 26 lines
Documentation/trace/coresight/panic.rst new file +25
-0+buffer. + +Static allocation of trace buffers would ensure that both IOMMU enabled +and disabled cases are handled. Also, platforms that support persistent +RAM will allow users to read trace data in the subsequent boot without +booting the crashdump kernel. + +Note: +For ETR sink devices, this reserved region will be used for both trace +capture and trace data retrieval. +For ETF sink devices, internal SRAM would be used for trace capture, +and they would be synced to reserved region for retrieval. + + +Disabling coresight blocks at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In order to avoid the situation of losing relevant trace data after a +kernel panic, it would be desirable to stop the coresight blocks at the +time of panic. + +This can be achieved by configuring the comparator, CTI and sink +devices as below:: + + Trigger on panic + Comparator --->External out --->CTI -->External In---->ETR/ETF stop
Quoted 8 lines
Documentation/trace/coresight/panic.rst line 59
Quoted 6 lines
Documentation/trace/coresight/panic.rst new file +6
-0+ +Saving metadata at the time of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Coresight metadata involves all additional data that are required for a +successful trace decode in addition to the trace data. This involves +ETR/ETF, ETE register snapshot etc.s/ETE/ETB ?
Ack.
Quoted 6 lines
Documentation/trace/coresight/panic.rst line 62
Quoted 4 lines
Documentation/trace/coresight/panic.rst new file +3
-0+ +A new optional device property "memory-region" is added to +the ETR/ETF/ETE device nodes for this.same here ^^
Ack.
Quoted 86 lines
Quoted 86 lines
Documentation/trace/coresight/panic.rst new file +84
-0+ +Reading trace data captured at the time of panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Trace data captured at the time of panic, can be read from rebooted kernel +or from crashdump kernel using a special device file /dev/crash_tmc_xxx. +This device file is created only when there is a valid crashdata available. + +General flow of trace capture and decode incase of kernel panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +1. Enable source and sink on all the cores using the sysfs interface. + ETR sinks should have trace buffers allocated from reserved memory, + by selecting "resrv" buffer mode from sysfs. + +2. Run relevant tests. + +3. On a kernel panic, all coresight blocks are disabled, necessary + metadata is synced by kernel panic handler. + + System would eventually reboot or boot a crashdump kernel. + +4. For platforms that supports crashdump kernel, raw trace data can be + dumped using the coresight sysfs interface from the crashdump kernel + itself. Persistent RAM is not a requirement in this case. + +5. For platforms that supports persistent RAM, trace data can be dumped + using the coresight sysfs interface in the subsequent Linux boot. + Crashdump kernel is not a requirement in this case. Persistent RAM + ensures that trace data is intact across reboot. + +Coresight trace during Watchdog reset +------------------------------------- +The main difference between addressing the watchdog reset and kernel panic +case are below, + +a. Saving coresight metadata need to be taken care by the + SCP(system control processor) firmware in the specified format, + instead of kernel. + +b. Reserved memory region given by firmware for trace buffer and metadata + has to be in persistent RAM. + Note: This is a requirement for watchdog reset case but optional + in kernel panic case. + +Watchdog reset can be supported only on platforms that meet the above +two requirements. + +Sample commands for testing a Kernel panic case with ETR sink +------------------------------------------------------------- + +1. Boot Linux kernel with "crash_kexec_post_notifiers" added to the kernel + bootargs. This is mandatory if the user would like to read the tracedata + from the crashdump kernel. + +2. Enable the preloaded ETM configuration + + #echo 1 > /sys/kernel/config/cs-syscfg/configurations/panicstop/enable + +3. Configure CTI using sysfs interface:: + + #./cti_setup.sh + + #cat cti_setup.sh + + + cd /sys/bus/coresight/devices/ + + ap_cti_config () { + #ETM trig out[0] trigger to Channel 0 + echo 0 4 > channels/trigin_attach + } + + etf_cti_config () { + #ETF Flush in trigger from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + etr_cti_config () { + #ETR Flush in from Channel 0 + echo 0 1 > channels/trigout_attach + echo 1 > channels/trig_filter_enable + } + + ctidevs=`find . -name "cti*"`
Quoted 8 lines
Documentation/trace/coresight/panic.rst line 152
Quoted 6 lines
Documentation/trace/coresight/panic.rst new file +6
-0+ + for i in $ctidevs + do + cd $i + + connection=`find . -name "ete*"`minor nit: this could be ete or etm
Ack.
Quoted 197 lines
Quoted 197 lines
Documentation/trace/coresight/panic.rst new file +196
-0+ if [ ! -z "$connection" ] + then + echo "AP CTI config for $i" + ap_cti_config + fi + + connection=`find . -name "tmc_etf*"` + if [ ! -z "$connection" ] + then + echo "ETF CTI config for $i" + etf_cti_config + fi + + connection=`find . -name "tmc_etr*"` + if [ ! -z "$connection" ] + then + echo "ETR CTI config for $i" + etr_cti_config + fi + + cd .. + done + +Note: CTI connections are SOC specific and hence the above script is +added just for reference. + +4. Choose reserved buffer mode for ETR buffer + #echo "resrv" > /sys/bus/coresight/devices/tmc_etr0/buf_mode_preferred + +5. Enable stop on flush trigger configuration + #echo 1 > /sys/bus/coresight/devices/tmc_etr0/stop_on_flush + +6. Start Coresight tracing on cores 1 and 2 using sysfs interface + +7. Run some application on core 1 + #taskset -c 1 dd if=/dev/urandom of=/dev/null & + +8. Invoke kernel panic on core 2 + #echo 1 > /proc/sys/kernel/panic + #taskset -c 2 echo c > /proc/sysrq-trigger + +9. From rebooted kernel or crashdump kernel, read crashdata + + #dd if=/dev/crash_tmc_etr0 of=/trace/cstrace.bin + +10. Run opencsd decoder tools/scripts to generate the instruction trace. + +Sample instruction trace dump +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Core1 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.039572921 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.039572921 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.039572921 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + + ..snip + + 149.052324811 chacha_block_generic: ffff800008642d80: + 9100a3e0 add x0, + I 149.052324811 chacha_block_generic: ffff800008642d84: + b86178a2 ldr w2, [x5, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d88: + 8b010803 add x3, x0, x1, lsl #2 + I 149.052324811 chacha_block_generic: ffff800008642d8c: + b85fc063 ldur w3, [x3, #-4] + I 149.052324811 chacha_block_generic: ffff800008642d90: + 0b030042 add w2, w2, w3 + I 149.052324811 chacha_block_generic: ffff800008642d94: + b8217882 str w2, [x4, x1, lsl #2] + I 149.052324811 chacha_block_generic: ffff800008642d98: + 91000421 add x1, x1, #0x1 + I 149.052324811 chacha_block_generic: ffff800008642d9c: + f100443f cmp x1, #0x11 + + +Core 2 dump:: + + A etm4_enable_hw: ffff800008ae1dd4 + CONTEXT EL2 etm4_enable_hw: ffff800008ae1dd4 + I etm4_enable_hw: ffff800008ae1dd4: + d503201f nop + I etm4_enable_hw: ffff800008ae1dd8: + d503201f nop + I etm4_enable_hw: ffff800008ae1ddc: + d503201f nop + I etm4_enable_hw: ffff800008ae1de0: + d503201f nop + I etm4_enable_hw: ffff800008ae1de4: + d503201f nop + I etm4_enable_hw: ffff800008ae1de8: + d503233f paciasp + I etm4_enable_hw: ffff800008ae1dec: + a9be7bfd stp x29, x30, [sp, #-32]! + I etm4_enable_hw: ffff800008ae1df0: + 910003fd mov x29, sp + I etm4_enable_hw: ffff800008ae1df4: + a90153f3 stp x19, x20, [sp, #16] + I etm4_enable_hw: ffff800008ae1df8: + 2a0003f4 mov w20, w0 + I etm4_enable_hw: ffff800008ae1dfc: + 900085b3 adrp x19, ffff800009b95000 <reserved_mem+0xc48> + I etm4_enable_hw: ffff800008ae1e00: + 910f4273 add x19, x19, #0x3d0 + I etm4_enable_hw: ffff800008ae1e04: + f8747a60 ldr x0, [x19, x20, lsl #3] + E etm4_enable_hw: ffff800008ae1e08: + b4000140 cbz x0, ffff800008ae1e30 <etm4_starting_cpu+0x50> + I 149.046243445 etm4_enable_hw: ffff800008ae1e30: + a94153f3 ldp x19, x20, [sp, #16] + I 149.046243445 etm4_enable_hw: ffff800008ae1e34: + 52800000 mov w0, #0x0 // #0 + I 149.046243445 etm4_enable_hw: ffff800008ae1e38: + a8c27bfd ldp x29, x30, [sp], #32 + I 149.046243445 etm4_enable_hw: ffff800008ae1e3c: + d50323bf autiasp + E 149.046243445 etm4_enable_hw: ffff800008ae1e40: + d65f03c0 ret + A ete_sysreg_write: ffff800008adfa18 + + ..snip + + I 149.05422547 panic: ffff800008096300: + a90363f7 stp x23, x24, [sp, #48] + I 149.05422547 panic: ffff800008096304: + 6b00003f cmp w1, w0 + I 149.05422547 panic: ffff800008096308: + 3a411804 ccmn w0, #0x1, #0x4, ne // ne = any + N 149.05422547 panic: ffff80000809630c: + 540001e0 b.eq ffff800008096348 <panic+0xe0> // b.none + I 149.05422547 panic: ffff800008096310: + f90023f9 str x25, [sp, #64] + E 149.05422547 panic: ffff800008096314: + 97fe44ef bl ffff8000080276d0 <panic_smp_self_stop> + A panic: ffff80000809634c + I 149.05422547 panic: ffff80000809634c: + 910102d5 add x21, x22, #0x40 + I 149.05422547 panic: ffff800008096350: + 52800020 mov w0, #0x1 // #1 + E 149.05422547 panic: ffff800008096354: + 94166b8b bl ffff800008631180 <bust_spinlocks> + N 149.054225518 bust_spinlocks: ffff800008631180: + 340000c0 cbz w0, ffff800008631198 <bust_spinlocks+0x18> + I 149.054225518 bust_spinlocks: ffff800008631184: + f000a321 adrp x1, ffff800009a98000 <pbufs.0+0xbb8> + I 149.054225518 bust_spinlocks: ffff800008631188: + b9405c20 ldr w0, [x1, #92] + I 149.054225518 bust_spinlocks: ffff80000863118c: + 11000400 add w0, w0, #0x1 + I 149.054225518 bust_spinlocks: ffff800008631190: + b9005c20 str w0, [x1, #92] + E 149.054225518 bust_spinlocks: ffff800008631194: + d65f03c0 ret + A panic: ffff800008096358 + +Perf based testing +------------------ + +Starting perf session +~~~~~~~~~~~~~~~~~~~~~ +ETF: +perf record -e cs_etm/panicstop,@tmc_etf1/ -C 1 +perf record -e cs_etm/panicstop,@tmc_etf2/ -C 2
Quoted 10 lines
Documentation/trace/coresight/panic.rst line 356
Quoted 8 lines
Documentation/trace/coresight/panic.rst new file +8
-0+ +ETR: +perf record -e cs_etm/panicstop,@tmc_etr0/ -C 1,2 + +Reading trace data after panic +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Same sysfs based method explained above can be used to retrieve and +decode the trace data after the reboot on kernel panic.
Linu Cherian
Hi,
Quoted 1 line · Linu Cherian
This patch series is rebased on coresight-next-v6.12.
Adding info which i missed out in the cover letter.
* V9 was posted here,
https://lore.kernel.org/linux-arm-kernel/[email protected]/
* Patches 1 & 2 adds support for allocation of trace buffer pages from reserved RAM
* Patches 3 & 4 adds support for saving metadata at the time of kernel panic
* Patch 5 adds support for reading trace data captured at the time of panic
* Patches 6 & 7 adds support for disabling coresight blocks at the time of panic
* Patch 8: Gives the full description about this feature as part of documentation
Quoted 83 lines
Changelog from v9:
* Add common helper functionof_tmc_get_reserved_resource_by_namefor better code reuse
* Reserved buffer validity and crashdata validity has been separated to avoid interdependence
* New fields added to crash metadata: version, ffcr, ffsr, mode
* Version checks added for metadata validation
* Special file/dev/crash_tmc_xxxwould be available only when crash metadata is valid
* RemovedREAD_CRASHDATAmode meant for special casing crashdata reads. Instead, dedicated read function added for crashdata reads from reserved buffer which is common for both ETR and ETF sinks as well.
* Documentation added toDocumentation/tracing/coresight/panic.rstChangelog from v8:
* Added missing exit path on error in__tmc_probe.
* Few whitespace fixes, checkpatch fixes.
* With perf sessions honouringstop_on_flushsysfs attribute, removed redundant variablestop_on_flush_en.Changelog from v7:
* Fixed breakage on perf test -vvvv "arm coresight". No issues seen with and without "resrv" buffer mode
* Moved the crashdev registration into a separate function.
* Removed redundant variable intmc_etr_setup_crashdata_buf
* Avoided a redundant memcpy intmc_panic_sync_etf.
* Tested kernel panic with trace session started uisng perf. Please see the title "Perf based testing" below for details. For this,stop_on_flushsysfs attribute is taken into consideration while starting perf sessions as well.Changelog from v6:
* Added special device files for reading crashdata, so thatread_prevbootmode flag is removed.
* Added new sysfs TMC device attribute,stop_on_flush. Stop on flush trigger event is disabled by default. User need to explicitly enable this from sysfs for panic stop to work.
* Address parameter for panicstop ETM configuration is chosen as kernel "panic" address by default.
* Added missingtmc_wait_for_tmcreadyduring panic handling
* Few other misc code rearrangements.Changelog from v5:
* Fixed issues reported byCONFIG_DEBUG_ATOMIC_SLEEP
* Fixed a memory leak while reading data from/dev/tmc_etrxinREAD_PREVBOOTmode
* Tested reading trace data from crashdump kernelChangelog from v4:
* Device tree binding
- Description is made more explicit on the usage of reserved memory region
- Mismatch in memory region names in dts binding and driver fixed
- Removed "mem" suffix from the memory region names
* Rename "structtmc_register_snapshot" -> "structtmc_crash_metadata", since it contains more than register snapshot.
Related variables are named accordingly.
* Rename structtmc_drvdatamembers
resrv_buf->crash_tbuf
metadata ->crash_mdata
* Size field in metadata refers to RSZ register and hence indicates the size in 32 bit words. ETR metadata follows this convention, the same has been extended to ETF metadata as well.
* Added crc32 for more robust metadata and tracedata validation.
* Added/modifieddev_dbgmessages during metadata validation
* Fixed a typo in patch 5 commit descriptionChangelog from v3:
* Converted the Coresight ETM driver change to a named configuration. RFC tag has been removed with this change.
* Fixed yaml issues reported by "makedt_binding_check"
* Added names for reserved memory regions 0 and 1
* Added prevalidation checks for metadata processing
* Fixed a regression introduced in RFC v3
- TMC Status register was getting saved wrongly
* Reverted memremap attribute changes from_WBto_WCto match with the dma map attributes
* Introduced reserved buffer mode specific .sync op.
This fixes a possible crash when reserved buffer mode was used in normal trace capture, due to unwanted dma maintenance operations.
Quoted 3 lines
*** SUBJECT HERE ****** BLURB HERE ***
Sorry about this.
Quoted 11 lines
Linu Cherian (8):
dt-bindings: arm: coresight-tmc: Add "memory-region" property
coresight: tmc-etr: Add support to use reserved trace memory
coresight: core: Add provision for panic callbacks
coresight: tmc: Enable panic sync handling
coresight: tmc: Add support for reading crash data
coresight: tmc: Stop trace capture on FlIn
coresight: config: Add preloaded configuration
Documentation: coresight: Panic support
Quoted 19 lines
.../bindings/arm/arm,coresight-tmc.yaml | 26 ++ Documentation/trace/coresight/panic.rst | 356 ++++++++++++++++++ drivers/hwtracing/coresight/Makefile | 2 +- .../coresight/coresight-cfg-preload.c | 2 + .../coresight/coresight-cfg-preload.h | 2 + .../hwtracing/coresight/coresight-cfg-pstop.c | 83 ++++ drivers/hwtracing/coresight/coresight-core.c | 42 +++ .../hwtracing/coresight/coresight-tmc-core.c | 296 ++++++++++++++- .../hwtracing/coresight/coresight-tmc-etf.c | 124 +++++- .../hwtracing/coresight/coresight-tmc-etr.c | 231 +++++++++++- drivers/hwtracing/coresight/coresight-tmc.h | 106 ++++++ include/linux/coresight.h | 24 ++ 12 files changed, 1282 insertions(+), 12 deletions(-) create mode 100644 Documentation/trace/coresight/panic.rst create mode 100644 drivers/hwtracing/coresight/coresight-cfg-pstop.cSignature · 1 line
2.34.1
Linu Cherian.