All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Amir Ayupov" <aaupov@fb.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v5 7/7] coresight: Add pmu_pulse/extout_pulse
Date: Fri, 20 Nov 2026 15:41:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-225475@kernel.org> (raw)
In-Reply-To: <c43cc5feecb253821499be80d43f1e71ccb32193.1795182850.git.aaupov@fb.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] coresight: extout_pulse loads on 1-event ETE lacking EVENT1
  and TRCEXTOUT1
- [Low] coresight: missing coresight-cfg-preload.h include in
  coresight-cfg-pmu-pulse.c
--

commit e489c2f2f5183f248bad3a743fec51069d6bccc4
Author: Amir Ayupov <aaupov@fb.com>

coresight: Add pmu_pulse/extout_pulse

This commit adds a built-in pmu_pulse configuration and extout_pulse
feature for ETMv4/ETE to pulse external output 1 on every traced cycle for
counting via the TRCEXTOUT1 PMU event.

> diff --git a/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
> new file mode 100644
> index 0000000000000..76e8e6b5da0e9
> --- /dev/null
> +++ b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
> @@ -0,0 +1,55 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Pulse ETM external output 1 on every traced cycle for a PMU event to count.
> + * Based on coresight-cfg-afdo.c
> + */
> +
> +#include "coresight-config.h"
> +
> +/* ETMv4 includes and features */
> +#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
> +#include "coresight-etm4x-cfg.h"

[Severity: Low]
Should this file also include coresight-cfg-preload.h for the extern
declarations of extout_pulse_etm4x and pmu_pulse_etm4x?  Without it, C=1
sparse builds warn that both symbols are undeclared, as fixed for
coresight-cfg-afdo.c in commit a7195f3f9383 ("coresight: Fix undeclared
variable warnings from sparse checker").

> +
> +/*
> + * extout_pulse feature: event 1 selects the always-true resource, so ETM
> + * external output 1 pulses on every cycle while the trace unit is enabled. A
> + * PMU event counting that output (TRCEXTOUT1), for example with
> + * aux-action=pause, then fires after as many traced cycles as its sample
> + * period. Event 0 is avoided because it is the trace unit trigger, and the
> + * TRBE driver treats a detected trigger as fatal.
> + */
> +static struct cscfg_regval_desc extout_pulse_regs[] = {
> +	/* event 1: resource selector 1 (always true), drives external output 1 */
> +	{
> +		.type = CS_CFG_REG_TYPE_STD | CS_CFG_REG_TYPE_VAL_MASK,
> +		.offset = TRCEVENTCTL0R,
> +		.val32 = 0x0100,
> +		.mask32 = 0xff00,
> +	},
> +	/* end of regs */
> +};
> +
> +struct cscfg_feature_desc extout_pulse_etm4x = {
> +	.name = "extout_pulse",
> +	.description = "Pulse external output 1 on every traced cycle.\n",
> +	.match_flags = CS_CFG_MATCH_CLASS_SRC_ETM4 | CS_CFG_MATCH_CAP_ETE_TRCEXTOUT,
> +	.nr_regs = ARRAY_SIZE(extout_pulse_regs),
> +	.regs_desc = extout_pulse_regs,
> +};

[Severity: Medium]
Can extout_pulse_etm4x match and load on an ETE that only implements a
single event (caps.nr_event == 1), where EVENT1 and TRCEXTOUT1 do not
exist?

CS_CFG_MATCH_CAP_ETE_TRCEXTOUT is set by etm4_pmu_counts_extout(), which
only checks up to drvdata->caps.nr_event:

drivers/hwtracing/coresight/coresight-etm4x-core.c:etm4_pmu_counts_extout() {
	if (!etm4x_is_ete(drvdata) || !drvdata->caps.nr_event)
		return false;

	for (n = 0; n < drvdata->caps.nr_event; n++) {
		if (!pmuv3_event_implemented(ARMV8_PMUV3_PERFCTR_TRCEXTOUT0 + n))
			return false;
	}

	return true;
}

When TRCIDR0.NUMEVENT is 0 (so caps.nr_event == 1) and TRCEXTOUT0 is
implemented, etm4_pmu_counts_extout() returns true and
etm4_cfg_map_reg_offset() accepts TRCEVENTCTL0R without checking
caps.nr_event >= 2.  Enabling pmu_pulse on such a device succeeds instead
of returning -EINVAL, writing 0x0100 to the unimplemented
TRCEVENTCTL0R.EVENT1 (bits [15:8]) field with no external output pulses.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795182850.git.aaupov@fb.com?part=7

      reply	other threads:[~2026-11-20 15:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 15:21 [PATCH v5 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-11-20 15:21 ` [PATCH v5 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-11-20 15:30   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-11-20 15:36   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-11-20 15:29   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-11-20 15:30   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-11-20 15:39   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 6/7] coresight: etm4x: Report whether the PMU counts the external outputs Amir Ayupov
2026-11-20 15:36   ` sashiko-bot
2026-11-20 15:21 ` [PATCH v5 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-11-20 15:41   ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-225475@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aaupov@fb.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.