From patchwork Fri Nov 15 05:36:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hardevsinh Palaniya X-Patchwork-Id: 13875881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AAABD6DDD5 for ; Fri, 15 Nov 2024 05:40:11 +0000 (UTC) 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:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-ID:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=SVz4AKcMAuwonFvZ/Gp9Ev2rF/JsS/L1xWYm5V4XvyY=; b=i6EHv3AHCYZ1yQ/O0l+4coSn1I yXi2eqHxFL33uucMA32r+ZWBpqJ1TxhwwjWksat7C4csMRi9VWsFvaUR8QselDVN5RV1TAClcS3uk lBwhdK0Eo/+DuvxN660qO9ywe9pREI52rJzEt4ZolKWwmDA7przXd67v9LUW33k8RfZwAoA7on5Xr 6sIONwFmc/6jDLXlB4ai9o9KIIngweZtDeP+gWgPfYgQDj2METFexzPJZVsT8DGZ4wtwSHuI+CkVp DLoUbxFzg4Tj+pyiiVkNHi1tcV5WrSrCFQT9mNTu+zW8mRHxbBiGJVtQGrYZl30einUNMe+SQ+wOm /3UVNn8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tBp3j-00000001gL5-24Q9; Fri, 15 Nov 2024 05:39:55 +0000 Received: from mail-centralindiaazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c408::3] helo=PNZPR01CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tBp2o-00000001gGa-1zOD for linux-arm-kernel@lists.infradead.org; Fri, 15 Nov 2024 05:38:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MxZ8ZTYuIIN8H0GKNmUbI0Q3s0AekLcK4WN02L+C/WzJ5J5XdV2miiHz926y8+zU+//CNRYEi3QqWWjCaU/+v6zpk0nUgXpTicrrXlBAmK2LfjQ6pZL1XNmQjuvgtlRXou+RqJOx5msbf5HIFP/2ba/63dqqMtel4idtSqeGnL/d4tq9katEIqKZColhTtoSUfvPCjqe5XhAWPRFi0ds5H1zwJSujJwwJkNZ+/A171PvH7RF1V4dxAqwDbTDyBmcCJW9Xh7TLbFSdMe6W3bjtJaMyBa/fksao7RLPF+NcCnofvp9k16fIkj7exs9qXKUTxltyP6SOZ5KeX2h58GQqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SVz4AKcMAuwonFvZ/Gp9Ev2rF/JsS/L1xWYm5V4XvyY=; b=DaqU8T4d0Kejv8mBUIlg4Lqy2pgoaxcOefi/BgQHC7UcV6q3cBpkQUfuM0VPAVEQEjvhWJUBe4oyhTT2sGkZElrUYJ9Lyn0opWO6xcrjDoh4nXr5HMDX+x6IjqaW1Kf+z3mOIBp7hx7sybvcGX5LHdV3YWOIeQiNNZlCgnDbR54F5hG56iHy23ZhY+39bM07J5PJdWuX86WiPYc5igr8UnFSCtWUYxIiuXHb+oRhffenDmbjQP+cR+6iv3BK8cSDtxAhBEUubyQA9taMmYT0TAMB5fATskfOJORll21Ifvhiyi/wGSanYaqxDGWwQ30POuSS/0zMv/a9mJ3MeWNWuw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=siliconsignals.io; dmarc=pass action=none header.from=siliconsignals.io; dkim=pass header.d=siliconsignals.io; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=siliconsignals.io; Received: from PN0P287MB2843.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:204::8) by PN0P287MB1589.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:180::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Fri, 15 Nov 2024 05:38:35 +0000 Received: from PN0P287MB2843.INDP287.PROD.OUTLOOK.COM ([fe80::1134:92d7:1f68:2fac]) by PN0P287MB2843.INDP287.PROD.OUTLOOK.COM ([fe80::1134:92d7:1f68:2fac%3]) with mapi id 15.20.8158.017; Fri, 15 Nov 2024 05:38:35 +0000 From: Hardevsinh Palaniya To: will@kernel.org, broonie@kernel.org, anshuman.khandual@arm.com Cc: Hardevsinh Palaniya , Catalin Marinas , Marc Zyngier , Oliver Upton , Ard Biesheuvel , Mark Rutland , Joey Gouly , Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4] arm64/cpufeature: Refactor conditional logic in init_cpu_ftr_reg() Date: Fri, 15 Nov 2024 11:06:35 +0530 Message-ID: <20241115053740.20523-1-hardevsinh.palaniya@siliconsignals.io> X-Mailer: git-send-email 2.43.0 X-ClientProxiedBy: PN3PR01CA0140.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:bf::12) To PN0P287MB2843.INDP287.PROD.OUTLOOK.COM (2603:1096:c01:204::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN0P287MB2843:EE_|PN0P287MB1589:EE_ X-MS-Office365-Filtering-Correlation-Id: 611c1095-92f6-4060-e250-08dd0537bf9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|7416014|376014|52116014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: sSXezjCdTyPadODL68QLivLQtbmdClSTTGSY/2pYHCUxHnuAy9w0etKjqxgJCG34/cW3z+9RTlvG9Pk68khuw3mAdAfPW/WhmZGz9ElyRoAuoVSIRuDdDQBxUMT4c9BHUl5JX6+q7AKSemyL7/ZFL4yDcMMT0XjtW3zqdmCtr23PO/2mKh+3gxsOkAyWaPnJmmGMy++gaBtaDnPDFnwottOfQRjOIT0bepc5ubAcbcP+djLbxP7hj36W6QZdnGXMjLS9eiv/TdzzOlrhxBT+vxxAWp9c0puSsFVX+Nr/wa7/ir5Ju4XlneRvbfW6+nOp4m8TtAkjDU8Fvkqtk8bQzGzFvr1DWiP7XtUXTVbp81LL4nm8WzqzgbQJQb4YEr0b9HUnmwjsRlm8BUabyrpvED6vcrn43NdUYaNtPDlsXs2DN3Nu0LRa8bfyyi7cw0fY5h6RBVn6SpomFxGlfG6srjiGxrpuCg3dgzbiNR8IUNMkakv0aQuV7AZOj4OsbAm4r0C8RjvNKVZNpQWScGV+cRCcJBe3UqTOdYJu3QSg8rcR2HDOuwkh9MFkaGDfM7dqDswFRXZjdFoKzRqHISAdGSnUdXcTJDInLpTOLQ/RZkodVXt+xdeO0H5UkPo7RsBic7y6wOAjQRmhMe06i6xrBALN09t80kGkNdu9txsB9OPPllX50eJp03+Pp+nfjOBhMTYRQaYoVhv/mBxQL/DgS4eLFTd8HexDng1r/3o5+Rg/WiXs+Yeya7qgYZT1wYeZatYHSTgxUoVpU9tZPshfDuLH2S1xVpGkqohXwuc9cRxU/ryyJywudCz1QjvlL5oxY5VRU1D+P26okhvMa25Uya/ZjaWRH14dlSZTtS6gr05MAvAGKZN0RR+hLE7Moaau7KMAlQ/GZwOsr84EncFIOu+rEvnkWsEPmFwBkJTKbFKZFhE/Zl3bi7PEcF8rSZjfZNXK3vMhJTGiowca/DadTFmRY1BCunpgiAG0l142tNRHK6XqcA0eVaTyymGqPi23v19RFjgu6levFx8zDjQsOcqpitj0Qa1xOcmCDZcU4M7GgAJQNQ6midsxyNXMcae9yzUrEDQujJpWHtbWFhhRTfihRpOlOCWIOk0CckctKRdPhYrJSle7PSx562AWjpb+h9xbjcg1k0Wu9yeoolVWTsTtLROyCtWhVn18BPanz4PhDSAUOCczXvMWn2kTDMQuwJuSa3QX4tHY2NRhw8TNeVHBuqjLOtD1AN0SibwAQ8NeuOjHphZbmt23MQvOglWpcIkSCIzz5PsSa4JfF/JEKvXV1PsKR+HKQbzvbZPJTjQiLjJsMLWthbM/0cbvgNHmKkqL/ty6ap2C0Prtfrkuu/xIs6fVG+q2ntv+YcECr3E= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PN0P287MB2843.INDP287.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(366016)(7416014)(376014)(52116014)(1800799024)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tS6nOd1PySjMeQXcLIb0gHgI19IhLgf12VS4L1CORpzqfNb/7XeB/ctom8rrkC+g//ALO2oDVc2gf+VxU5g309H3qfdZnc1Puf7uL+AhAaYVbxRZeFYVN7n8rrdKriNrwXC5uKWCcjnNdCzNxfVqaDx3TfzmxwPMvWDn6i8iHlx24vmddn8wKSIK1FDOPSagc1yOAB2FhFXeNx94g2ra65zA//gTN0ILHmzzRs04p6MyrCwC71CYzwWGmPs2e8ZOaOZhlSAxe1d7UBNzqX0e+nfmNglVbkpS/oA90OpIWArSATlyhVYKS1XjWkXU+zudtLX9Sr3GHSgWQybV/O93+8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o7Sh/0vJunOZVC2q8ZbznNlG+metBz7uNmJlQMYRlj+xtGm30k17qRL11GD28pmfDtylmmd/4wSfk20rkUD97sVioXS13dGUiqxfHMdCiBBI+bx4I9g8HcPZID0ePdaeumMRXOQx+CLqDT1BqQzq8Ql9SHUlWfLJOjmeCEmynpCrK6hB97TJ4Xtp+7ksuWS7j25z1YdQAcwVWbm8pDBSDGawY5mMryc5dSO/km8PBzWHmVTRGqd4oKnOCQ+bLfq X-OriginatorOrg: siliconsignals.io X-MS-Exchange-CrossTenant-Network-Message-Id: 611c1095-92f6-4060-e250-08dd0537bf9f X-MS-Exchange-CrossTenant-AuthSource: PN0P287MB2843.INDP287.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2024 05:38:35.3904 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 7ec5089e-a433-4bd1-a638-82ee62e21d37 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YLR2S4L0uYawDQx5qaCKvlZlCC0+G5M01RjZnTUzpYvW1RdagV3/PRFgf6vL9z/uv1qGkWDbVLZDuOerC40ppXhxLUubo4qhnrK09zysW0Vn7wHZHXR1EeN78e4iq0e3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PN0P287MB1589 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241114_213858_511881_B9CB2DBA X-CRM114-Status: GOOD ( 12.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Unnecessarily checks ftr_ovr == tmp in an extra else if, which is not needed because that condition would already be true by default if the previous conditions are not satisfied. if (ftr_ovr != tmp) { } else if (ftr_new != tmp) { } else if (ftr_ovr == tmp) { Logic: The first and last conditions are inverses of each other, so the last condition must be true if the first two conditions are false. Additionally, all branches set the variable str, making the subsequent "if (str)" check redundant Reviewed-by: Mark Brown Reviewed-by: Anshuman Khandual Signed-off-by: Hardevsinh Palaniya --- Changelog in V2: - remove str check Change in V3: - Add logic in commit msg - Add review tag Change in V4: - Change subject line - Add review tag --- arch/arm64/kernel/cpufeature.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430..728709483fb7 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -989,17 +989,16 @@ static void init_cpu_ftr_reg(u32 sys_reg, u64 new) /* Override was valid */ ftr_new = tmp; str = "forced"; - } else if (ftr_ovr == tmp) { + } else { /* Override was the safe value */ str = "already set"; } - if (str) - pr_warn("%s[%d:%d]: %s to %llx\n", - reg->name, - ftrp->shift + ftrp->width - 1, - ftrp->shift, str, - tmp & (BIT(ftrp->width) - 1)); + pr_warn("%s[%d:%d]: %s to %llx\n", + reg->name, + ftrp->shift + ftrp->width - 1, + ftrp->shift, str, + tmp & (BIT(ftrp->width) - 1)); } else if ((ftr_mask & reg->override->val) == ftr_mask) { reg->override->val &= ~ftr_mask; pr_warn("%s[%d:%d]: impossible override, ignored\n",