From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ADFB606A31A for ; Tue, 1 Dec 2026 12:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AzlwrtCq; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=NzHVEdlo DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=uQO/fFUa3xMzGO3QFwFWkuqknmSyoeHZTLDJFl5nrCk=; b=AzlwrtCqf8OWMX vcFbnBelciwFt43zNocF2eINiHuA5RDTX2drMbIDEacxl5IV41pgt52uzKhIjQ95NMoNLUSChfbXc SxcgQaUjL9sjQHH6upvMR07odqdexU8jSiZ7zVzKRx+chH6dfptYP5NCtPpQfv80+dondEJrt855z SGGyLd5IAafGrZr3PFmf9b0KPCuoJjQusmGDxrY6JCWEDSJqjhJ09Sd5E0idtjxOUsYExBlk5RS5i uhYIfKKW2m5ng2IZ48Py1jiqQlLFcOE8a9dLSDtg3qPwEcXiC7rbDEzyVDDBHz3sJErKTq/xLKGVF p0bdhujSh/Q2CWOt5Sgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYMgI-00000007iXe-1nfG; Tue, 01 Dec 2026 12:09:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYMd9-00000007i9E-2auH for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 12:06:44 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7B9C1570; Tue, 1 Dec 2026 04:06:39 -0800 (PST) Received: from [10.2.197.99] (ewhatever.cambridge.arm.com [10.2.197.99]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF4813F86F; Tue, 1 Dec 2026 04:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796126802; bh=yYTuYVMhjMcbtBBiXvgff8/l7GWkqDsyJCGBpRdBRiU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NzHVEdlo1zG8q1RVWHdD/AGK1a3e0NOeN++bPMFxvBpCkIUXS9IK9ALfco4gpjsN9 zs42uhohH9lDKSAkixPuU2bs1K5zwj4NRFlE9MBscnOV+cgyliaN4siL5/dSgoWT/J iw9lVCUeJxrXscs3TmrNZBeLKF7ez3n6cl1ScWHw= Message-ID: Date: Tue, 1 Dec 2026 12:06:39 +0000 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 18/23] coresight: trbe: Keep the perf handle in per-CPU data To: Leo Yan , Mike Leach , James Clark , Alexander Shishkin , Anshuman Khandual , Tamas Petz , Tamas Zsoldos , Suyash Mahar , Amir Ayupov Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, coresight@lists.linaro.org References: <20261016-trbe_enable_disable_irq_handle_refactor-v2-0-3f57cf3199b1@arm.com> <20261016-trbe_enable_disable_irq_handle_refactor-v2-18-3f57cf3199b1@arm.com> Content-Language: en-US From: Suzuki K Poulose In-Reply-To: <20261016-trbe_enable_disable_irq_handle_refactor-v2-18-3f57cf3199b1@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_040643_776708_C9E42BB3 X-CRM114-Status: GOOD ( 23.74 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On 16/10/2026 17:55, Leo Yan wrote: > Arm SPE owns a per-CPU perf output handle for the PMU lifetime. TRBE > instead receives a handle from CoreSight when enabling its sink. > > Store that session handle in trbe_cpudata instead of a separate per-CPU > pointer array, and pass the CPU data as the per-CPU IRQ context. Use this > context directly for overflow and spurious interrupt handling so local > hardware control does not depend on the current AUX buffer configuration. > > Allocate the CPU data before registering the IRQ and free it after > releasing the IRQ, keeping the IRQ context valid throughout registration. > > Signed-off-by: Leo Yan > --- > drivers/hwtracing/coresight/coresight-trbe.c | 44 ++++++++++++---------------- > 1 file changed, 19 insertions(+), 25 deletions(-) > > diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c > index 9a469c8009ce8a8a8b804c2b63a68e741f1dceaa..2328aab0a084a0ac123e950f846f404d120ec2c0 100644 > --- a/drivers/hwtracing/coresight/coresight-trbe.c > +++ b/drivers/hwtracing/coresight/coresight-trbe.c > @@ -139,6 +139,7 @@ struct trbe_save_state { > * @cpu - CPU this TRBE belongs to. > * @mode - Mode of current operation. (perf/disabled) > * @buf - Buffer configuration retained for the enabled session. > + * @handle - Perf output handle from successful enable until disable. > * @drvdata - TRBE specific drvdata > * @errata - Bit map for the errata on this TRBE. > */ > @@ -149,6 +150,7 @@ struct trbe_cpudata { > int cpu; > enum cs_mode mode; > struct trbe_buf *buf; > + struct perf_output_handle *handle; > struct trbe_drvdata *drvdata; > struct trbe_save_state save_state; > DECLARE_BITMAP(errata, TRBE_ERRATA_MAX); > @@ -156,7 +158,6 @@ struct trbe_cpudata { > > struct trbe_drvdata { > struct trbe_cpudata __percpu *cpudata; > - struct perf_output_handle * __percpu *handle; > struct hlist_node hotplug_node; > int irq; > cpumask_t supported_cpus; > @@ -1091,7 +1092,7 @@ static int arm_trbe_enable(struct coresight_device *csdev, enum cs_mode mode, > return ret; > } > > - *this_cpu_ptr(drvdata->handle) = handle; > + cpudata->handle = handle; > cpudata->buf = buf; > cpudata->mode = mode; > return 0; > @@ -1112,16 +1113,15 @@ static int arm_trbe_disable(struct coresight_device *csdev) > trbe_drain_and_disable_local(cpudata); > clr_trbe_status(); > > - *this_cpu_ptr(drvdata->handle) = NULL; > buf->cpudata = NULL; > + cpudata->handle = NULL; > cpudata->buf = NULL; > cpudata->mode = CS_MODE_DISABLED; > return 0; > } > > -static void trbe_handle_spurious(struct perf_output_handle *handle) > +static void trbe_handle_spurious(struct trbe_cpudata *cpudata) > { > - struct trbe_buf *buf = etm_perf_sink_config(handle); > u64 trblimitr = read_sysreg_s(SYS_TRBLIMITR_EL1); > > /* > @@ -1129,11 +1129,12 @@ static void trbe_handle_spurious(struct perf_output_handle *handle) > * back without modifying the buffer parameters to > * retain the trace collected so far. > */ > - set_trbe_enabled(buf->cpudata, trblimitr); > + set_trbe_enabled(cpudata, trblimitr); > } > > -static int trbe_handle_overflow(struct perf_output_handle *handle) > +static int trbe_handle_overflow(struct trbe_cpudata *cpudata) > { Why are we changing this ? We have access to handle in the caller, and we can simply pass it down ? > + struct perf_output_handle *handle = cpudata->handle; > struct perf_event *event = handle->event; > struct trbe_buf *buf = etm_perf_sink_config(handle); > unsigned long size; > @@ -1203,9 +1204,8 @@ static u64 cpu_prohibit_trace(void) > > static irqreturn_t arm_trbe_irq_handler(int irq, void *dev) > { > - struct perf_output_handle **handle_ptr = dev; > - struct perf_output_handle *handle = *handle_ptr; > - struct trbe_buf *buf; > + struct trbe_cpudata *cpudata = dev; > + struct perf_output_handle *handle = cpudata->handle; > enum trbe_fault_action act; > u64 status; > bool truncated = false; > @@ -1232,18 +1232,17 @@ static irqreturn_t arm_trbe_irq_handler(int irq, void *dev) > * Ensure the trace is visible to the CPUs and > * any external aborts have been resolved. > */ > - buf = etm_perf_sink_config(handle); > - trbe_drain_and_disable_local(buf->cpudata); > + trbe_drain_and_disable_local(cpudata); > clr_trbe_irq(); > isb(); > > act = trbe_get_fault_act(handle, status); > switch (act) { > case TRBE_FAULT_ACT_WRAP: > - truncated = !!trbe_handle_overflow(handle); > + truncated = !!trbe_handle_overflow(cpudata); Why are we changing this ? > break; > case TRBE_FAULT_ACT_SPURIOUS: > - trbe_handle_spurious(handle); > + trbe_handle_spurious(cpudata); Same as above ? Rest looks fine by me Suzuki