From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6408D245031 for ; Mon, 11 May 2026 14:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778510762; cv=none; b=OW4PxXrxtkHczF2THZUNDlQobxZeRE7h3EM5DxSD5bsK+zv/NddtPRaw/+TAnt2SkobxsjtF4lg27RzonvyWWEsZJz08hlfcPVVX50PgKY7YFn06HX8VSJp3VNf0mKZutkBkvsj46wuDGNoIbh1+aCiLgYlxOwcX/w9JNXUTbrA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778510762; c=relaxed/simple; bh=OolOQTtng61WD+njTLqidYnK7V2SUybJURGMgsTgKP0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tSGPii+5qxzv5PBte5aAYbktSodM6lRPXTjHoBlCsIcGWBOLpdvw2r2O7HosUFdTVHvL1tOArpm1OD5fqjUBc2DxZDNlgUZYqBoIancPsDRsCi9+fsNfZAtmtOSIiP4bHiafjnmL247izIL0TVA+1qtEO1saMcbc94udRWBpNLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=cfqCrJSP; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="cfqCrJSP" 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 213F616F2; Mon, 11 May 2026 07:45:54 -0700 (PDT) Received: from localhost (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D854D3F836; Mon, 11 May 2026 07:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778510759; bh=OolOQTtng61WD+njTLqidYnK7V2SUybJURGMgsTgKP0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cfqCrJSPNvtleDfqihHobLOSu4wOSVuPuDEl6yScPPxZ1hdyUNIrPtbZRMEMku5YV zLxCFGBDkhu0YGuV2z1fy4/f72Y2ptR9HJV7XP1EKkedXMOsyIU7Gc6gtlcOOMAVek MNM+SFFVtcatUGduaq2RpbhwjeW7wkVZo3Jw0ihU= Date: Mon, 11 May 2026 15:45:56 +0100 From: Leo Yan To: Jie Gan Cc: Richard Cheng , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Tingwei Zhang , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] coresight: fix missing error code when trace ID is invalid Message-ID: <20260511144556.GA34802@e132581.arm.com> References: <20260511-fix-trace-id-error-v3-1-ac4c8356efff@oss.qualcomm.com> <146d34e9-caa3-4119-a3f3-79515b3f2c46@oss.qualcomm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <146d34e9-caa3-4119-a3f3-79515b3f2c46@oss.qualcomm.com> On Mon, May 11, 2026 at 05:27:10PM +0800, Jie Gan wrote: [...] > > > @@ -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; I'd advocate a bit early exit style, like: /* 0 means the device has no ID assignment, so keep searching */ if (trace_id == 0) continue; if (!IS_VALID_CS_TRACE_ID(trace_id)) return -EINVAL; path->trace_id = trace_id; return 0; Early exit can reduce indentation depth, and it handles simple cases first and then the complex logic. In some cases (maye not this case), we may benefit a bit from compiler optimization [1]. [1] https://xania.org/202512/18-partial-inlining [...] > 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? Wouldn't it need to update perf mode as well? Regarding __must_check, I searched Documentation but didn't find guidance on when it should be used. I don't want to use this annotation randomly (some functions use it and some not), this will be hard for everyone to follow up. IMO, it's fine not to use __must_check here. I would leave this to Suzuki and other maintainers if have different opinions. Thanks, Leo