Devicetree
 help / color / mirror / Atom feed
* [PATCH RFC 0/6] Coresight: Introduce Qualcomm QDCP support for QECP-owned trace blocks
@ 2026-11-19  9:01 Jie Gan
  2026-11-19  9:01 ` [PATCH RFC 1/6] dt-bindings: soc: qcom: add QDCP provider Jie Gan
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Jie Gan @ 2026-11-19  9:01 UTC (permalink / raw)
  To: Bjorn Andersson, Konrad Dybcio, Abel Vesa, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Suzuki K Poulose, Mike Leach,
	James Clark, Leo Yan, Tingwei Zhang, Maxime Coquelin,
	Alexandre Torgue, Alexander Shishkin
  Cc: linux-arm-msm, devicetree, linux-kernel, coresight,
	linux-arm-kernel, linux-stm32, Jie Gan

On Qualcomm Hawi/Maili SoCs, part of the CoreSight trace hardware is
owned by the Qualcomm Embedded Co-Processor (QECP), a separate on-die
processor that runs its own firmware and has its own view of the trace
topology. The owned blocks are an STM (System Trace Macrocell) source,
a TMC (Trace Memory Controller) configured as an ETR (Embedded Trace
Router) sink, and the internal funnels/replicators that connect them.
This hardware ships today; it is not a future design.

The Qualcomm Debug Control Protocol (QDCP) is the firmware interface
Linux uses to ask QECP to do what the AP (application processor, the
cores running Linux) cannot do itself. It is a QMI (Qualcomm MSM
Interface) service carried over QRTR (Qualcomm IPC Router), like other
Qualcomm firmware services. QECP is the co-processor that owns the
hardware; QDCP is the wire protocol Linux uses to talk to its firmware.

This series adds a QDCP provider plus an STM source driver and an ETR
sink path that use it, so a QECP-owned STM -> ETR session works through
the existing CoreSight sysfs interface.

Register ownership
------------------

The QECP-owned MMIO control/status registers are protected by hardware
access control. AP reads and writes to those ranges are blocked or
trapped, so Linux cannot touch them and there is no race to describe.
The AP does keep two things outright, with no access control involved:

 - the STM stimulus write aperture, a separate MMIO region used only
   for data writes, not for block control;
 - the ETR trace buffer, ordinary system memory (DDR) that Linux
   allocates, maps and owns exactly as for a local-MMIO ETR.

                            AP (Linux)          QECP firmware
                            ----------          -------------
  STM stimulus aperture     owned, mapped,
                            written directly
  STM control registers                         owned, access-
                                                controlled from AP
  Funnel/replicator                             owned, private, not
  routing                                       visible to Linux
  TMC-ETR control registers                     owned, access-
                                                controlled from AP
  TMC-ETR trace buffer      owned, allocated,
                            read via sysfs
  TMC-ETR RRP/RWP/STS       read over QDCP      owned, returned over
  (read/write pointers,                         QDCP on request
  status)
  Block clocks and power                        owned, controlled by
                                                firmware only

Linux owns what it can observe or allocate directly: the stimulus
aperture, the trace buffer and its sysfs lifecycle. QECP owns what
needs access to live hardware state: control registers, internal
routing, pointer/status registers, and the clocks and power of the
blocks. QDCP is the only channel between the two; there is no direct
path and no fallback.

Because firmware controls the blocks' clocks and power, the bindings
describe no clocks, clock-names or power-domains for these devices, and
the QDCP code adds no clock handling or runtime PM.

System overview
---------------

Control path (QDCP, QMI over QRTR) and data path (hardware):

  AP (Linux)                                 QECP
  ----------                                 ----

  sysfs / char dev
        |
  +-----v------------+  typed   +-----------+  QMI/QRTR  +-------------+
  | QDCP STM source  |--------->|           |            |             |
  | QDCP TMC-ETR sink|  API     | QDCP      |<---------->| QECP        |
  +------------------+          | provider  |            | firmware    |
                                | (soc/qcom)|            |             |
                                +-----------+            +------+------+
                                                                |
                                       programs STM/TMC ctl regs,
                                       ATID filter, internal routing
                                                                |
  Data path                                                     v
  ---------
  STM stimulus   +-----+   (QECP-private funnels/    +---------------+
  aperture ----->| STM |----- replicators, no DT ---->| TMC (ETR)     |
  (AP writes)    +-----+      node, not visible)      +-------+-------+
                                                              | DMA
                                                      +-------v-------+
                                                      | etr_buf       |
                                                      | (Linux memory)|
                                                      +-------+-------+
                                                              |
                                       AP reads via /dev/<tmc> (sysfs)

Enable, a trace session start (CoreSight enables sink first, then source):

  CoreSight   QDCP ETR     QDCP STM      QDCP          QECP
  core        (patch 6)    (patch 4)     provider      firmware
     |            |            |            |             |
     |--enable--->|            |            |             |
     |  sink      | alloc/reuse etr_buf,    |             |
     |            | compute paddr + IOVA    |             |
     |            |--qdcp_tmc_etr_enable()->|             |
     |            |            |            |--SG mode--->|
     |            |            |            |--FFCR------>|
     |            |            |            |--buffer---->|
     |            |            |            |--start TMC->|
     |            |            |            |<---ok-------|
     |<--ok-------|            |            |             |
     |--enable------------>    |            |             |
     |  source                 |            |             |
     |            |            |--qdcp_stm_source_enable()|
     |            |            |  (src id, trace ID,      |
     |            |            |   port mask)             |
     |            |            |            |--set ATID-->|
     |            |            |            |--start STM->|
     |            |            |            |<---ok-------|
     |<--ok------------------- |            |             |
     |            |            |            |             |
     |   trace flows STM -> (QECP-private routing) -> ETR -> etr_buf

  (SG: scatter-gather, FFCR: formatter and flush control register,
  IOVA: I/O virtual address, ATID: ATB trace ID.)

Disable and readback (source first, then sink):

  CoreSight   QDCP ETR     QDCP STM      QDCP          QECP
  core        (patch 6)    (patch 4)     provider      firmware
     |            |            |            |             |
     |--disable-------------->|            |             |
     |  source                |--qdcp_stm_source_disable()|
     |            |           |            |--clear ATID>|
     |            |           |            |--stop STM-->|
     |--disable-->|            |            |             |
     |  sink      |--qdcp_tmc_etr_disable()>|             |
     |            |            |            |--stop TMC-->|
     |            |            |            |<---ok-------|
     |            | stop confirmed? no -> keep etr_buf pinned and retry
     |            |   on the next enable, open() of /dev/<tmc> or removal
     |            | yes:                    |             |
     |            |--qdcp_tmc_get_param(RRP/RWP/STS)---->|
     |            |<--values----------------------------|
     |            | sync etr_buf, release                |
     |            |            |            |             |
  userspace reads trace from etr_buf through /dev/<tmc>, as for any ETR

Sysfs ABI
---------

This series adds no new CoreSight-wide sysfs ABI. A QDCP ETR exposes
the existing generic ETR/TMC attributes for buffer sizing and sysfs
mode enable/disable, with one omission: trigger_cntr is not exposed,
because the QDCP enable RPC does not convey it to firmware and writes
would be silently ignored. The only new attribute is a read-only
"traceid" on the QDCP STM source, like attributes other CoreSight
source drivers already expose. Userspace reads trace data from the
Linux-owned etr_buf through the same /dev/<tmc> interface as every
other ETR; there is nothing QDCP-specific for it to learn.

Why do qcom,service-id, qcom,instance-id and qcom,version come from DT?
------------------------------------------------------------------------

QDCP is a QMI client over QRTR. The only lookup primitive QMI offers a
client is qmi_add_lookup(service, version, instance): "tell me when a
server matching this tuple appears". There is no API to enumerate all
registered services and pick one, so a client must know what it is
looking for before it can look. Firmware does not advertise a list of
services for Linux to negotiate against. The (service, version,
instance) tuple is fixed by the platform firmware build, which is the
kind of static platform fact DT (devicetree) exists to describe.
qcom,service-id and qcom,instance-id are required; qcom,version is
optional and defaults to 1.

DT dependencies
---------------

The DT surface is deliberately small:

 - the provider node has one connection-N child per QMI connection,
   carrying the tuple above;
 - each consumer has a qcom,qdcp phandle to a connection-N child and an
   ID that names its block to firmware (qcom,qdcp-source-id for the
   STM, qcom,qdcp-tmc-id for the ETR);
 - the STM has its stimulus aperture in reg, and both consumers have
   the usual CoreSight graph port towards the logical path.

There are no clocks, power domains or nodes for QECP-internal topology,
so the consumers depend on nothing else in DT.

Design
------

CoreSight is a mature subsystem shared by every Arm CoreSight
implementation. This series is built so that QDCP support:

 - does not turn generic CoreSight drivers (coresight-stm.c, the shared
   parts of coresight-tmc-core.c and coresight-tmc-etr.c) into
   vendor-specific code;
 - does not invent fake CoreSight DT nodes for hardware Linux cannot
   observe or control;
 - does not need a broad refactor of TMC/ETR internals.

QDCP is therefore a firmware *provider*, not a CoreSight *device*. It
lives under drivers/soc/qcom/ next to other Qualcomm QMI services, and
consumers find it through a DT phandle, as for clocks or regulators. It
never appears in the CoreSight topology graph and has no coresight_desc.
The phandle must reference a connection-N child of the provider node,
not the top-level provider node itself.

Only Qualcomm-specific consumer drivers know about QDCP. coresight-stm.c
is untouched, and TMC/ETR gains a parallel, isolated code path chosen
once at probe time by the qcom,qdcp property, leaving the local-MMIO
ETR path unchanged in behaviour. QECP-internal topology is not modeled
in DT: there is no node for the funnels/replicators between the QDCP
STM and the QDCP ETR, since CoreSight only needs a logical
source-to-sink path to build a session.

Probe-time resolution. The QDCP ETR reads DEVID (the TMC device
configuration register) through qdcp_tmc_get_param() instead of MMIO,
rejects any config type other than ETR, and selects its coresight_ops
table and its RRP/RWP/STS readback function once, mirroring how
CoreSight resolves desc.access for MMIO vs. system-register ETMs. The
two paths never coexist on one device instance, so there is nothing to
re-check at runtime.

Lifecycle and safety rules
--------------------------

 - Firmware DMA into etr_buf is the main hazard. etr_buf is the buffer
   firmware may be writing into, and Linux clears it only after
   firmware has confirmed the TMC stop. If a stop is not confirmed,
   including a failed or timed-out enable request that firmware may
   still have executed, the buffer stays pinned: it is not synced,
   freed or replaced, and the stop is retried on the next enable, the
   next open of /dev/<tmc>, or device removal. If firmware never
   confirms, the buffer is left allocated at removal rather than freed
   under possible DMA.
 - A failed read of the RRP/RWP/STS state invalidates the buffer
   contents instead of leaving the previous capture readable.
 - The provider-consumer link is core-managed, so unbinding the
   provider first unbinds its consumers. A consumer that probes while
   the provider is already unbinding defers its probe.
 - If firmware does not confirm an STM stop, Linux still marks the
   source disabled (the CoreSight source disable op cannot fail) and
   logs a warning. The driver remembers the failed stop, so on removal
   the trace ID is kept allocated whether the stop failed during
   removal or earlier, and no other source can reuse an ID firmware may
   still be applying.
 - No lock is held across a QMI transaction wait.
 - A QMI reply that omits its result TLV, or the value TLV of a
   parameter read, is treated as a failure.

Known limitations
-----------------

 - If QECP firmware resets while a session is active, Linux is not
   notified and does not reprogram the STM or ETR. Trace stops until
   the user disables and re-enables the session, and the disable logs
   the firmware error. A provider reset notification is left
   for a follow-up once the firmware reset behaviour is defined.
 - The STM stimulus write path checks the CoreSight mode without a lock,
   exactly like coresight-stm.c. It cannot take one, because the packet
   callback is notrace and can run in atomic context, so a write can
   race with a concurrent disable.
 - QDCP-owned ETRs have no panic handler: the control registers are
   firmware-owned and not accessible from the panic path, so trace data
   is not preserved on panic.

Scope
-----

This series implements one complete path:

  QDCP STM source --(logical CoreSight path)--> QDCP ETR sink

Not included, and deferred until a platform needs it: QDCP ETF (embedded
trace FIFO)/link sinks, perf-mode (AUX) support for STM or ETR (sysfs
mode only here), other QDCP source types such as TPDM (trace, profiling
and diagnostics monitor) and OCLA (on-chip logic analyzer), a
path-helper device for no-MMIO static sources, and the TMC
BEGIN_READ/READ/END_READ firmware data-copy commands (the AP is assumed
able to read the ETR buffer directly).

Why not the power-domain framework?
-----------------------------------

The exported enable/disable calls could be modelled as a power-domain
provider's .power_on/.power_off instead of a new API. This series does
not do that, for three reasons.

 1. QDCP does not power anything on or off. The QECP-owned blocks are
    controlled entirely by firmware, and HLOS (the high-level OS, here
    Linux) has no way to request a power transition for them. When
    firmware receives a QDCP request it decides for itself what the
    block needs, including any power or clock handling, and performs
    it. The on/off value in the SET_STATE requests starts or stops the
    block's trace function, it is not a power-state request. A
    power-domain provider, whose whole purpose is to control power
    state, would describe something HLOS does not do.

 2. The calls carry data a power domain has no way to pass. The STM
    enable sends the CoreSight-allocated trace ID and a port-enable mask
    that firmware turns into its ATID filter. The ETR enable sends the
    buffer physical and IOVA address, size, scatter-gather mode and
    FFCR, in several requests. qdcp_tmc_get_param() also reads DEVID
    and RRP/RWP/STS back from firmware, which the ETR needs to
    synchronise etr_buf after a stop, and a power domain has no read
    operation.

 3. The trigger is different. A power domain follows runtime PM, which
    reacts to device usage. QDCP enable/disable must follow the
    CoreSight path lifecycle: sink first, then source, started and
    stopped by the user's sysfs enable. CoreSight already drives that
    through its source/sink ops, so the QDCP calls hang off those ops
    directly.

Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
---
Jie Gan (6):
      dt-bindings: soc: qcom: add QDCP provider
      soc: qcom: add QDCP firmware provider
      dt-bindings: arm: qcom: add QDCP STM source
      coresight: qcom: add QDCP STM source
      dt-bindings: arm: qcom: add QDCP TMC ETR sink
      coresight: tmc: add QDCP ETR sysfs support

 .../bindings/arm/qcom,coresight-stm-qdcp.yaml      | 111 +++
 .../bindings/arm/qcom,coresight-tmc-qdcp.yaml      | 102 +++
 .../devicetree/bindings/soc/qcom/qcom,qdcp.yaml    |  81 ++
 drivers/hwtracing/coresight/Kconfig                |  11 +
 drivers/hwtracing/coresight/Makefile               |   4 +-
 .../hwtracing/coresight/coresight-qcom-qdcp-stm.c  | 550 ++++++++++++
 drivers/hwtracing/coresight/coresight-tmc-core.c   | 145 ++-
 .../hwtracing/coresight/coresight-tmc-etr-qdcp.c   | 379 ++++++++
 drivers/hwtracing/coresight/coresight-tmc-etr.c    |  46 +-
 drivers/hwtracing/coresight/coresight-tmc.h        |  46 +
 drivers/soc/qcom/Kconfig                           |  12 +
 drivers/soc/qcom/Makefile                          |   1 +
 drivers/soc/qcom/qcom_qdcp.c                       | 985 +++++++++++++++++++++
 include/linux/soc/qcom/qdcp.h                      | 128 +++
 14 files changed, 2553 insertions(+), 48 deletions(-)
---
base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
change-id: 20261119-introduce-qcom-qecp-feature-f59c05a21179

Best regards,
-- 
Jie Gan <jie.gan@oss.qualcomm.com>


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

end of thread, other threads:[~2026-11-19  9:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  9:01 [PATCH RFC 0/6] Coresight: Introduce Qualcomm QDCP support for QECP-owned trace blocks Jie Gan
2026-11-19  9:01 ` [PATCH RFC 1/6] dt-bindings: soc: qcom: add QDCP provider Jie Gan
2026-11-19  9:12   ` sashiko-bot
2026-11-19  9:01 ` [PATCH RFC 2/6] soc: qcom: add QDCP firmware provider Jie Gan
2026-11-19  9:18   ` sashiko-bot
2026-11-19  9:01 ` [PATCH RFC 3/6] dt-bindings: arm: qcom: add QDCP STM source Jie Gan
2026-11-19  9:01 ` [PATCH RFC 4/6] coresight: " Jie Gan
2026-11-19  9:28   ` sashiko-bot
2026-11-19  9:01 ` [PATCH RFC 5/6] dt-bindings: arm: qcom: add QDCP TMC ETR sink Jie Gan
2026-11-19  9:01 ` [PATCH RFC 6/6] coresight: tmc: add QDCP ETR sysfs support Jie Gan
2026-11-19  9:25   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox