Linux Perf Users
 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 v4 7/7] coresight: Add pmu_pulse/extout_pulse
Date: Mon, 26 Oct 2026 08:50:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-184696@kernel.org> (raw)
In-Reply-To: <02268c4958153f6d2e549e4bd7b93f11ed79fa90.1792989860.git.aaupov@fb.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] coresight: extout_pulse loads on ETE with single event lacking TRCEXTOUT1
--

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

coresight: Add pmu_pulse/extout_pulse

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

> 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..61472154dd02a
> --- /dev/null
> +++ b/drivers/hwtracing/coresight/coresight-cfg-pmu-pulse.c
> @@ -0,0 +1,55 @@
[ ... ]
> +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_TRCEXTOUT,
> +	.nr_regs = ARRAY_SIZE(extout_pulse_regs),
> +	.regs_desc = extout_pulse_regs,
> +};

[Severity: Medium]
Can extout_pulse_etm4x load and enable on an ETE implementation that only
supports a single event (event 0 / TRCEXTOUT0), where event 1 and
TRCEXTOUT1 do not exist?

In drivers/hwtracing/coresight/coresight-etm4x-core.c, when TRCIDR0.NUMEVENT
is 0 and resources are present, etm4_init_arch_data() sets caps->nr_event to
1. Then etm4_pmu_counts_extout() checks whether the implemented events have
matching PMU counters:

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 drvdata->caps.nr_event == 1 and ARMV8_PMUV3_PERFCTR_TRCEXTOUT0 is
implemented, etm4_pmu_counts_extout() returns true and etm4_cscfg_register()
advertises CS_CFG_MATCH_CAP_TRCEXTOUT.

When loading the feature, etm4_cfg_load_feature() -> etm4_cfg_map_reg_offset()
maps TRCEVENTCTL0R without checking whether drvdata->caps.nr_event >= 2. By
contrast, event_store() in drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
shows that EVENT1 (bits [15:8] of TRCEVENTCTL0R) is only implemented when
caps->nr_event >= 2:

	case 1:
		/* EVENT0, bits[7:0] */
		sysfs_config->eventctrl0 = val & 0xFF;
		break;
	case 2:
		/* EVENT1, bits[15:8] */
		sysfs_config->eventctrl0 = val & 0xFFFF;
		break;

On an ETE with caps.nr_event == 1, enabling pmu_pulse will succeed and
write 0x0100 to the unimplemented EVENT1 field in TRCEVENTCTL0R while
TRCEXTOUT1 does not exist. Should CS_CFG_MATCH_CAP_TRCEXTOUT or the feature
loading path verify that event 1 (caps.nr_event >= 2 and TRCEXTOUT1) is
available?

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

  reply	other threads:[~2026-10-26  8:50 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261012230527.750567-1-aaupov@fb.com>
2026-10-25  6:39 ` [PATCH v3 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-10-25  6:39   ` [PATCH v3 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-10-25  6:45     ` sashiko-bot
2026-10-25  6:39   ` [PATCH v3 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-10-25  6:46     ` sashiko-bot
2026-10-25  6:39   ` [PATCH v3 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-10-25  6:44     ` sashiko-bot
2026-10-25  6:39   ` [PATCH v3 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-10-25  6:42     ` sashiko-bot
2026-10-25  6:39   ` [PATCH v3 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-10-25  6:47     ` sashiko-bot
2026-10-25 17:05     ` kernel test robot
2026-10-26  0:43     ` kernel test robot
2026-10-25  6:39   ` [PATCH v3 6/7] coresight: etm4x: Report whether the PMU counts the external outputs Amir Ayupov
2026-10-25  6:46     ` sashiko-bot
2026-10-25  6:39   ` [PATCH v3 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-10-25  6:50     ` sashiko-bot
2026-10-26  5:48   ` [PATCH v4 0/7] coresight: Pulse an ETM external output for a PMU event Amir Ayupov
2026-10-26  5:48     ` [PATCH v4 1/7] coresight: etm4x: Fix event count decoding Amir Ayupov
2026-10-26  8:42       ` sashiko-bot
2026-10-26  9:37       ` James Clark
2026-10-26  5:48     ` [PATCH v4 2/7] coresight: syscfg: Fail to enable a configuration not loaded on the device Amir Ayupov
2026-10-26  8:48       ` sashiko-bot
2026-10-26  5:48     ` [PATCH v4 3/7] coresight: syscfg: Match feature capabilities separately from device class Amir Ayupov
2026-10-26  8:49       ` sashiko-bot
2026-10-26  9:45       ` James Clark
2026-10-26  5:48     ` [PATCH v4 4/7] coresight: syscfg: Remove unused CS_CFG_MATCH_INST_ANY Amir Ayupov
2026-10-26  8:41       ` sashiko-bot
2026-10-26  9:45       ` James Clark
2026-10-26  5:48     ` [PATCH v4 5/7] perf: arm_pmuv3: Add pmuv3_event_implemented() Amir Ayupov
2026-10-26  8:45       ` sashiko-bot
2026-10-26  9:47       ` James Clark
2026-10-26  5:48     ` [PATCH v4 6/7] coresight: etm4x: Report whether the PMU counts the external outputs Amir Ayupov
2026-10-26  8:48       ` sashiko-bot
2026-10-26  9:49       ` James Clark
2026-10-26  5:48     ` [PATCH v4 7/7] coresight: Add pmu_pulse/extout_pulse Amir Ayupov
2026-10-26  8:50       ` sashiko-bot [this message]
2026-10-26  9:50       ` James Clark

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-184696@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox