From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 419F23BD629 for ; Mon, 11 May 2026 08:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778488605; cv=none; b=OKWqSx3ADDxwB+7PywMnysA+Bz84K0WsCOxRLaeqHDs6gQxi48PM2mWyyOl1xKl6sqIBWJiP80urAIH5Cm+eL/8rPdzTTWNnctZy1sJwPIwSQ8NLr/D3jYg2CUVmgLDWUuMcbviO6KQWxHeB3RxqKsyb/b0yugLPy1qAG3xEwVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778488605; c=relaxed/simple; bh=1qREOORBec6aKxoD0kZVon7OO74wBl3+y+vsp9bVJpg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=cMMHZZGCzsuv9guSZkVHFF4hF8kah1u+lKrM72VXAwojg3bfErPYBmR3kO05uX4Gq73wKJ+yQfKxJHFYHfJy30IvEFY2se6rZESzXea2+hE4QLrrJQqc0ymIK+v5qDSVM+zMBSOsJPL0cK2tOkGVN2wZx0i5KiZcCvCvjL7TT+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=P+zY65AU; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=dfc/IzBP; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="P+zY65AU"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="dfc/IzBP" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64B8I6pH1850626 for ; Mon, 11 May 2026 08:36:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=MIqti19n1VONATeE4Q2IHc whA7oL1fLAIS7StBspRDo=; b=P+zY65AUwRzuir1LeqXmkR9aX/9AkhFqqe96rn U2Qocj8JkTmWQF2uWSiyHA5X6fUatDZ9ekMKk/+sT1NfoNuooMUA3v/D5OAsuZ2w CCNy44Go2EV965190kRuSR9KLdHddDcwPH85ieSdnoumPIGPPt4jd2OaafyIh/iQ 9PwOku08z1WEzUjzz4spZ4nrI7iWQ0TaU3obN5cbdZjLxJcarCrLv1JfbKytv7Ep /XiysujhsuZSEA+bSqGbhKen1dAufgCCGMP313FHIYB4iw4F3mK5jYW5OV2QUpn3 il0Qoh8mYQ74EC6F/msBrz4flnh01C78kTCrrUNpOM+FyYkA== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e3bfvg273-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 11 May 2026 08:36:36 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ba054e0304so37115685ad.0 for ; Mon, 11 May 2026 01:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778488595; x=1779093395; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=MIqti19n1VONATeE4Q2IHcwhA7oL1fLAIS7StBspRDo=; b=dfc/IzBPRDOMMcLewJXlWu6Wubuo3sjs/KyqNhl5Lb8NdZjgF4u3KOZBXNAPT3ekqS q/mfHB8L9ofFWD+YrEatkN2npGAlcj7YcarLUJEH6ONlJzl05sAfOzy6LlWxVizZerHN uLjqpQSQbFqc/cIFjbexB0djN4wooQRATr1tv6b8QMDcsdz0RcLsVCWHMqQ8YnoBkRdk r1Qfqfn5cMNEql2zzpfCGI2ic7a3p5jqQe4FQzMcNEo70IAGn+MVzB/ee8LHfu6MMqon 2Rh8feAsL8H3KZmXcB9r55xkG/lT1tvy/q4lyEnW/tNenQ0NplFBXiaSb0CO2TJMSLBc Ejpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778488595; x=1779093395; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MIqti19n1VONATeE4Q2IHcwhA7oL1fLAIS7StBspRDo=; b=g/1nqBwkLCWHkGw7wdpaUn9NmL1xfZRQ0+k22SW3pnDMOSiHi8GJgEo6d4RelvUcWZ scj+6QxOLgyEvQX31IxpPM8KfbYFfj+1zvc0MvJ4AY7ZAHBmuShyg8SUXlQw5qpy+8E0 TMOD0i1j20+ignAlAt4KM+XpLTXucX7GG5p4bM3VjE4laDR25zF8BtnToTLZmRBJRdvS dp9Dn7zmW5v1+UsAZxvz8WLeDJK+qVnOpOlHOdhYn21KO7mpvJXjvp3ku6d803rER9pz bM89YRLeJRsSKRltpb4XA+CUKdKMPBVoWSp39eNlHfYQOAjzHiRbJCrTDrPYkat2b2lc TQrg== X-Forwarded-Encrypted: i=1; AFNElJ8mzHPxQsju8KEpg+cDgZ3Ns0WMRN3iw1+CuOq+4/7zRbHXbVYQ0iPBeDstzGJyP6ZbkgqYmyWyg5HoDx4=@vger.kernel.org X-Gm-Message-State: AOJu0YxPj57GGR2HcLxxj6MkjFtGjWA5a9/IKCd+3w1CxQ6xtPIovjXd igme4tSK72vWOvKE/5RNos8hx4NxkgOeB5rV5E4SuIt+ZNaTQPYsCZ3OqBgaINOhabYcfO6CveQ k4fOWdr5nivgdYO7+qwewADSo9TaQFQBkvl78q1XiKqP7XOOoEA2l56ZUiL3CM1wqKq4= X-Gm-Gg: Acq92OHNXDaCV91cpNLvFC0OBDEqXqj2kpOcEbs0N4htExtUMvXZUYRlLYVyckeA85y g3qdyokDhmD6XYrCw7HLFDoWXid32SANc3J5odJOBid8xyD/3HxRBajuX3kjxI5/vTYi7HdaRSg jNbupqvIVbjczSE4zt5w1ZX71Cb3LfCx5xcJXtvV5mMk4l0b0wbBdtvoOthVbptKf43KnfAe0QA 8SRzbnITV2Kbda85yZFCcUcAsxdAlO7g7q176LUdfqlZraQkBwkqJOJhHMChJWfBJu009N4Pcvj 2b/dXF8puCWwVNqGDmADBhTeGHzNaLcRgn6+gGmFxer+eSBDPNa4l0elVcLPyBLk3xBdTlMZ7Zf a2axaRuYfa5q24+x4f0mSwZlLsUNn5ms436ViawrsKQ6B02QcbGTJ8sPo2mKSAZyvieIcvAk9oZ IAd7fVH6Zp X-Received: by 2002:a17:903:986:b0:2ba:7617:a755 with SMTP id d9443c01a7336-2babd607529mr153306265ad.25.1778488595440; Mon, 11 May 2026 01:36:35 -0700 (PDT) X-Received: by 2002:a17:903:986:b0:2ba:7617:a755 with SMTP id d9443c01a7336-2babd607529mr153306015ad.25.1778488594866; Mon, 11 May 2026 01:36:34 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2baf1e90854sm95222635ad.66.2026.05.11.01.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2026 01:36:34 -0700 (PDT) From: Jie Gan Date: Mon, 11 May 2026 16:36:18 +0800 Subject: [PATCH v3] coresight: fix missing error code when trace ID is invalid Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260511-fix-trace-id-error-v3-1-ac4c8356efff@oss.qualcomm.com> X-B4-Tracking: v=1; b=H4sIAAKVAWoC/33NSw6DIBAG4KsY1sUAitGueo+mC2CgklSxgyVtj HcvuurCdDPJP49vFhItehvJuVgI2uSjD2MO1akgplfj3VIPORPBRMMka6nzbzqjMtuAWsSAFLQ DqKF1AjjJhxPavLWj11vOvY9zwM/+I/Gt+5dLnHIqHedK1rJx4C4hxvL5Ug8ThqHMhWxqEr9Sd yiJLJmOMW200pXtDqR1Xb9HbZgrBQEAAA== To: Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , Alexander Shishkin , Tingwei Zhang Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jie Gan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1778488591; l=4232; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=1qREOORBec6aKxoD0kZVon7OO74wBl3+y+vsp9bVJpg=; b=T033yAKGzJhosO2jG7wqWH7I7jDC+p3wEDh89i/KFyYCEJF7I1DKf3UfdIds4O8PsGoIR5rAj YKuroOSgrF3ANvDbigJpCgnrr8xlZQ4g1TqpiO45UXgtLmVG44U/8gh X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Authority-Analysis: v=2.4 cv=Fa4HAp+6 c=1 sm=1 tr=0 ts=6a019514 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=Um2Pa8k9VHT-vaBCBUpS:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=A6yeH-j-nhIuWHlR0BAA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: cifM4xTwUu9uzcljTWMuPCZ9XowdoyUG X-Proofpoint-ORIG-GUID: cifM4xTwUu9uzcljTWMuPCZ9XowdoyUG X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTExMDA5NCBTYWx0ZWRfX4p4gm5M0D3Ml hsJVQr6rn62Fj3iA77gUBL8v2mutP+UB+isfmyk7KueYV+14VITYpZRKN630cmZsjEydTIrTgA1 wew6371PK3LKhF62EGj3wCcRItwDqcoHHBf7GOBE3vxigch5MrY6l06OXDpDzoM9ifiEnzs4Br3 p08n39aj6dQWYh7V7C2JrcGDssVDGb/ntoFz4PGKIXSevWbPDatP5FIINv0Lo7qGWOK9wqdDl1/ jA8P51+dQ5SAczY6LEOMMsZ+wTpNd970erwm7b1mwE5Du1oOt7f/McWJS7yRY4pF+qARakieujZ Uq0ePL3NmXmvp71j11eKmAxlHPpPam9WLuSIq6A1z6xCX364x91KEkeZ0jKEx7cJaxdI4urKM4R ICIB0tQRC8moOMxR+/3/i1Nxwu8mSjOs1vuSNZJGl6pR1riUOtvem9j2WQk/O6kiLVJXItTesOS KvfoTGUcCf9GoQ+np7w== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-11_02,2026-05-08_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 priorityscore=1501 bulkscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605110094 When coresight_path_assign_trace_id() cannot assign a valid trace ID, coresight_enable_sysfs() takes the err_path goto with ret still 0, returning success to the caller despite no trace session being started. Fix this by changing coresight_path_assign_trace_id() to return int. Move the IS_VALID_CS_TRACE_ID() check inside the function so it returns -EINVAL on failure and 0 on success. Update coresight_enable_sysfs() to check the return value directly instead of inspecting path->trace_id after the call. The other caller in coresight-etm-perf.c discards the return value and continues to check path->trace_id via IS_VALID_CS_TRACE_ID() directly. This is unaffected: on failure path->trace_id is no longer written, so it remains 0, which IS_VALID_CS_TRACE_ID() rejects the same as before. Fixes: d87d76d823d1 ("Coresight: Allocate trace ID after building the path") Reviewed-by: James Clark Signed-off-by: Jie Gan --- Changes in v3: - directly return the value for clear expression. - Link to v2: https://lore.kernel.org/r/20260509-fix-trace-id-error-v2-1-c900bcbab3e9@oss.qualcomm.com Changes in v2: - Refactor the coresight_path_assign_trace_id function. - Link to v1: https://lore.kernel.org/r/20260508-fix-trace-id-error-v1-1-5f11a5456fdf@oss.qualcomm.com --- drivers/hwtracing/coresight/coresight-core.c | 14 ++++++++++---- drivers/hwtracing/coresight/coresight-priv.h | 2 +- drivers/hwtracing/coresight/coresight-sysfs.c | 4 ++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 46f247f73cf6..254db91a8ac9 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -739,8 +739,8 @@ static int coresight_get_trace_id(struct coresight_device *csdev, * Call this after creating the path and before enabling it. This leaves * the trace ID set on the path, or it remains 0 if it couldn't be assigned. */ -void coresight_path_assign_trace_id(struct coresight_path *path, - enum cs_mode mode) +int coresight_path_assign_trace_id(struct coresight_path *path, + enum cs_mode mode) { struct coresight_device *sink = coresight_get_sink(path); struct coresight_node *nd; @@ -755,10 +755,16 @@ void coresight_path_assign_trace_id(struct coresight_path *path, * Non 0 is either success or fail. */ if (trace_id != 0) { - path->trace_id = trace_id; - return; + if (IS_VALID_CS_TRACE_ID(trace_id)) { + path->trace_id = trace_id; + return 0; + } + + return -EINVAL; } } + + return -EINVAL; } /** diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 1ea882dffd70..34c7e792adbd 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -153,7 +153,7 @@ int coresight_make_links(struct coresight_device *orig, void coresight_remove_links(struct coresight_device *orig, struct coresight_connection *conn); u32 coresight_get_sink_id(struct coresight_device *csdev); -void coresight_path_assign_trace_id(struct coresight_path *path, +int coresight_path_assign_trace_id(struct coresight_path *path, enum cs_mode mode); #if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM3X) diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c index d2a6ed8bcc74..b6a870399e83 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -211,8 +211,8 @@ int coresight_enable_sysfs(struct coresight_device *csdev) goto out; } - coresight_path_assign_trace_id(path, CS_MODE_SYSFS); - if (!IS_VALID_CS_TRACE_ID(path->trace_id)) + ret = coresight_path_assign_trace_id(path, CS_MODE_SYSFS); + if (ret) goto err_path; ret = coresight_enable_path(path, CS_MODE_SYSFS); --- base-commit: 17c7841d09ee7d33557fd075562d9289b6018c90 change-id: 20260508-fix-trace-id-error-dbfdd4d8f2d1 Best regards, -- Jie Gan