From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 BE9F23B9617 for ; Mon, 11 May 2026 09:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491639; cv=none; b=ddXq5W7aQeRkzrbILTB/V6qbakkCn5CmfjfBc5w13/Wt4xs/8VZ2+dqNw232i1dSE27Ecri5SV4b5cFAqS2MurTXb2nZmksM+HHC7wM0t92a4RfzaVw10fVEbpxJ0B+qXz1uziFI4yzEx6GGnwiOYDt+wdMykW1N/AMto71j51s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778491639; c=relaxed/simple; bh=PawrKamOTSNnXLleEjKXNxvp/GEZ+D2G+401V9H8/9E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eyBIgd5vOvOx4nxArWgA8sov6I0Oi88Wf7ec2eqXPO+tJaWRAOdC08iGnlPa4TrRO9TllxWk5Ip7sLA2s+6x8ka6P2uGnWjsz1/SltIhnJC6qjosAtIo7YP6uwGubwozpSnbLlKYyZzD88g445kbrLucMC4/hg5GupGbA+cgshM= 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=nDshcLMQ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=gKYKTDj3; arc=none smtp.client-ip=205.220.180.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="nDshcLMQ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="gKYKTDj3" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64B7FSbQ3333473 for ; Mon, 11 May 2026 09:27:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= ZDzJzgTlV5b542Ln2r9Arcy6fy3pq0bcMcvkAhVBoGU=; b=nDshcLMQzSgQ3u3m vG59/VoMFaU8bnAe7dIcL6rgghFbBVw9yFX/zLKv82BHnhtW5Suq71AR7YNb9VFv Km/CmgtNA3e/v4QWA4ELav1gClmHgBuygrrHdt7dMcFQ9e2z8b6ztZw84DHtCKzQ fxcv7me+0GKSeGEW+wq2RKHtbx/l691kyYIVsG9AV7yoyJ/9fBd2q1baQEJHYTpx /ae4ZoKV2U50t9sQyf4rzzOaOvNi8oaivz3vSDrw8SabZMfmaGseNtoPgZcJ0oML LtEgNGk7W5YnS2kmtlEgk2utDEA3FPBZ7bV1oFjqMrUio1RqtkCkMzgwAtjFxgNc DFHZxA== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e3ajgrgdp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 11 May 2026 09:27:16 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-82fa6c3a77cso2607847b3a.3 for ; Mon, 11 May 2026 02:27:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778491636; x=1779096436; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZDzJzgTlV5b542Ln2r9Arcy6fy3pq0bcMcvkAhVBoGU=; b=gKYKTDj3qPTwThSSvZ2OEkTA+fusvOd8h/sgD6REEjs922SEOY0hP/Hv22O4Sf3v8N u2ZdMd4/hM2DpUaxTDfugQ6pUqdO/lZ+/t7nFn+aTTQP9eFFL6okIcw4/0JsDTLQZmBz 1yg6XTzIF1PIxpRNZig5m8SovSaS0INWShiEZBMntk0ne/Xjvwkd1D3fzAwGKU9Vfdqm y7NcOtHPo0RNhLvVOF/UyCutLOISPrN181OL/kxo3welbfuBhopS3oeDwCWvpq6yr65i j/BHx2oZngJG3q/382I1u6Yq5gCO+5ZndRe1gxh9fcPw2CBLHDwX18pJd6SIuGngH6w3 JL9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778491636; x=1779096436; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZDzJzgTlV5b542Ln2r9Arcy6fy3pq0bcMcvkAhVBoGU=; b=bW2eE0xV8b5LGTgXHJtIbspC8/9dRlah+xAsyM6iNfo7Suh+wRbKGwg7uZZNEhm299 Vy2LUJJMQc3GR59QSIbWL+OzJdGHjghFx0be1We7CCijCN9JBoWXlozZkWxuG7FdPk54 Z+J0FS0DEGhnrnC2yre/DMZxOQhI8ZObsc2BWhK+3nRSg8Ji/yV1GJL8DwEwRKjldV/6 D7A77ZVoCZaATFEp6ePqelKEFXZ7fUASOB1qaPy55iMTgfroj1obwl3xyMI8+6qqJAE9 veYGqU8Sab9/4g6D/1ixxricRu1TZjK66N2jCr+m7/YiRUWO+00ROM2xdy1y2W5spYjl 5A4w== X-Forwarded-Encrypted: i=1; AFNElJ82uuxb8WHhRt4ME5PpMh179Lh/1ohBgDMty8+CQ2UzKUIvbVPUsiQIy1/sir00QQOhD0VwFIrk/cCMxDc=@vger.kernel.org X-Gm-Message-State: AOJu0YyjnQBxR7pub88NaFwoZ+IGDGkBlFrkZlEbYPzWhlEGXFOzjPsa AVqR++OZQ+HyweD2C3OgRTzihvq1xa9SGM1UCjoKHMrPypv6igKKMrjKPh1KBMbS2GocSuWyM7j mzMfWMmerujLEvyxM9WTjsXf/oFnacLNsV/DMFwXK9dpXyb3NQNg2W1lXl00DcBZVZKQ= X-Gm-Gg: Acq92OFo80Ua4QNx/DKU6NKenUcEiGuo0yGDGZ5oyyl/rbSoadvUHN5IlC1HaK6g+Q/ wc2EqtWdIb126mC1pXZ6yW6oyxcvLEX6sYNLLDx1Y//wtxvM5wxOxLuAXT5JyD75TC51p4u4d3F QDx0dR59Lg6JaYcSnJzOCIJTFdZHNY7NTDBiGsPt32doXwjyB84EWVkFI7W9XHDLpU7gLTFTWZ/ VN4avirOV7it9NSiXhYlYP9NlB3wm9HTMNnh4uFSXXZTLsoDhEsgrb9BminmLZ5uaY8h5ELcBIJ THVcVgOdY8QjAVLHQXqW4O45T1NlnhHKLoHGB+p4RzVp6Bm1kDP12fHInFlfG6nNm1AvEcVhmhN GnLusbjLeRFVHiRnjnVfgtbw+YDSDigUMiRyUBLyilM68mq1ThzBOcORG8G3P9sVmCrckKbt6OM M1cT9PTAk85Q== X-Received: by 2002:a05:6a00:a907:b0:829:8a84:b9fc with SMTP id d2e1a72fcca58-83cf4f760dbmr14044030b3a.8.1778491635582; Mon, 11 May 2026 02:27:15 -0700 (PDT) X-Received: by 2002:a05:6a00:a907:b0:829:8a84:b9fc with SMTP id d2e1a72fcca58-83cf4f760dbmr14044000b3a.8.1778491634961; Mon, 11 May 2026 02:27:14 -0700 (PDT) Received: from [10.133.33.31] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-839656464fasm19766905b3a.11.2026.05.11.02.27.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 May 2026 02:27:14 -0700 (PDT) Message-ID: <146d34e9-caa3-4119-a3f3-79515b3f2c46@oss.qualcomm.com> Date: Mon, 11 May 2026 17:27:10 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] coresight: fix missing error code when trace ID is invalid To: Richard Cheng Cc: Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , Alexander Shishkin , Tingwei Zhang , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260511-fix-trace-id-error-v3-1-ac4c8356efff@oss.qualcomm.com> Content-Language: en-US From: Jie Gan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=GfgnWwXL c=1 sm=1 tr=0 ts=6a01a0f4 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=wMIg9ovz4t81wBIZ_fcA:9 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-GUID: 3dn1JpFFcNaIhyI6KBz4Wk2c8t0bkrWh X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTExMDEwMyBTYWx0ZWRfX9uiDTP4wXOmp dLnqiNOBqTFpW0yV0v3rLrf7roddh3KgCIyi8gwXHKvieOvE/sh64rpsc80sbAwWCSbXeiig1oF 27FQ+e8FUNuNue3urjEwpcmM9d/dfzN7mlH6FF+5HZABHn2f8ZgWOx49XajvbgO0N+jSe6zQ7PU v77gZlhsbSwIbpH9T1r8VIM6fMBCV/Z7cDBcpwirWXLfv7kxEIPY3M8dIo3bQr8s2Ewt9k5sgYw 6gDdOyEPoC5p9LELJuqvqvH7qp0s+1dldyO8S3+QB8pr3Wc6H8VVlSgs/IvUm6FRbEnFR4MLbpo EN47Vn/7m7bn/UB8pstSB6eBcPv4YBsKTfK8VfZ1JPdct+SIqjPfc69XvhUPXNSj4OLY+ebd2T2 EIdSmegu69pSKSsi0VjssgrsCDWCral7+FvDIE2k7Cz1+4J9uuIFFrTiaJlwZeTb6r+6cQyRdBp vVLthCtCpcLdhHcSu4g== X-Proofpoint-ORIG-GUID: 3dn1JpFFcNaIhyI6KBz4Wk2c8t0bkrWh 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 clxscore=1015 suspectscore=0 impostorscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 bulkscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605110103 On 5/11/2026 5:19 PM, Richard Cheng wrote: > On Mon, May 11, 2026 at 04:36:18PM +0800, Jie Gan wrote: >> 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); > > Hi Jie, > > Thanks for your patch, > > I'm thinking will "__must_check" should be added so in the future the next caller won't accidently > introduce this class of bug ? > Hi Richard, The return value has been ignored in perf mode. It will introduce noisy by adding __must_check. So I think its better without __must_check? Thanks, Jie > Best regards, > Richard Cheng. > >> >> #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 >> >>