From patchwork Sat Dec 10 20:38:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Groeneveld X-Patchwork-Id: 13070432 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 65D55C4332F for ; Sat, 10 Dec 2022 20:41: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=RKm9MDG02Uo4rfNcUY3kjv7j0pXrlUZW3f1f0EeMMN0=; b=tydbVE4YDsc9iU h4+xGFmpzuyqv4MG/sXRA6oUKjeB7+i2cQxZR1o/r1Nu1diLL1/fH5Nrg9+3zk2NCanpniY7UcCSD 0/VDYTnEr9TCkzc95XFCBoBngio5v5R9mLoD8yRHMe01qzlh8FCRlnIW8nA4h2TT/aKsT+olMKiLu rQztHIGCj7xAz7Wg3JSQO93Zvj6Ot0Zukxg5VBlqX4de7rBml2TR4Yac8kak7CGwZKAaUhs00cO9/ 8k/q71YaoA15nafxTpeRdFYo4bR6//EaNtrOFFw6cGSX0/CYdvo58wKkW0zF45Xt/xaTZVnJIT8DP 18cd6f/YmS2L1sOwzxzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p46dG-005A8P-Dk; Sat, 10 Dec 2022 20:39:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p46dE-005A6V-5D for linux-arm-kernel@bombadil.infradead.org; Sat, 10 Dec 2022 20:39:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=lNLm1paGyjSFoirpoBdjsg4L7rtUMf9qWaw+l99k2AI=; b=QN9B/LomogKxw+tZJxEP7qXB/S xDkEUDTTDYB1WmOKx0H4Sq5rv/SL4h1sLxCERmBl70LzEX8+Bra1LwHZYyrGt+BEr7aFFLOGdt+i8 mQV2gYxkXgmA0UtE1p8yEAsh7AMlxABkQactY1R8nkRL/PlvW1tXxf+Q0+AbrnLOAPXdGNhZyxKua ceGaq9xXix78NP+4zCkUPTczO4kNkWfEhJfnIkup25xIhM5kqjxaasN5mAwAivZfIAgFdbkBT2D1c aFvpSueByVB6NG4eHYxhjLrZqKrU9sYs+ncgWPQHaO9Gi1nFJoWJLAkuoz/NZGh1SHqDCRdYayZh1 ZaPUfiBw==; Received: from mail-yqbcan01on2103.outbound.protection.outlook.com ([40.107.116.103] helo=CAN01-YQB-obe.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p46d8-009Bya-3a for linux-arm-kernel@lists.infradead.org; Sat, 10 Dec 2022 20:39:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HgXLKJkMLUGgcH6+4jZsY0vMPpPCM47fEM5fvNMracemX+Iyu+71ugYTHH+tBZKsPLJMBjaoDt63nEoiJoHsxO474MiqU5JBEtNPortOv7lQ3wZVRmBgPLjhzBlXsyHM3WJofFWxp7MW+YrcuUZVTG7ms0Xsw3uKgS3jEWT/DoSLh7j6UrT0zNuOXZZlheoUcM5jVcYrW63xiYx/ySHENh4CTbX7WVbTYt7LM69EQEbntNSk2AOGxQ+VUs7h8nNMLtCxMQkxJPkJXm6CXxe34LfnTubEQMxb0fc+GC8dTN56b4xCdFXI2cO2xXMZ9XevzmFXKyVA2fX6DMBhbe4TXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lNLm1paGyjSFoirpoBdjsg4L7rtUMf9qWaw+l99k2AI=; b=E/O9OSVF+4b8h64yZxInDtYNkCzLqWVllLZ+bnY+24h4AIQ7W+Uvlh14n0mpnJQaqaxfmMi/JzZ5B3zFchvdmn96vDAdgyRZS2DFQk65jApNCwpPJW4J/gi/rFW5sWOtHnISJOZ08RfycvewziIBFT6LAu4nlWPpX1JnG5e4I3KRH8vuf9auKy6KLvljqA4xWGL6efX5QJgju+sxLRbByxjx7BAS2Aim6m5Kai+zJVKqUSZk04MEFyIi8PEi7r2L+vXOi0a6IlEG8c8HpkVdi+4vI2mHTn7lShoHonT8vwT/e+2SAJWPKwBseKMD0vo11arqH2Cb2kxJHG7+cU0vYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=lenbrook.com; dmarc=pass action=none header.from=lenbrook.com; dkim=pass header.d=lenbrook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lenbrook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lNLm1paGyjSFoirpoBdjsg4L7rtUMf9qWaw+l99k2AI=; b=H/njA/feyi9R8i5iEkoYL3cZ3XF/1EipwfCtCgz1hqEBYZV5AkH4WXxwtGUAsr3ETvGQCU6GJflAYrRIEtfdfMi8s8L57DdIL9/JBF8Fs+br7Jo21mcWlee2WIc56H981r6fDTe4emfWe3cCcwVVTBX19DdGDLGC7sDL99ATmkA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=lenbrook.com; Received: from YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:e8::12) by YQBPR0101MB5880.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:c01:33::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Sat, 10 Dec 2022 20:39:23 +0000 Received: from YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM ([fe80::94a9:f6fc:9cd8:7bf8]) by YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM ([fe80::94a9:f6fc:9cd8:7bf8%9]) with mapi id 15.20.5880.019; Sat, 10 Dec 2022 20:39:22 +0000 From: Kevin Groeneveld To: Abel Vesa , Michael Turquette , Stephen Boyd , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Kevin Groeneveld Subject: [PATCH] clk: imx: pll14xx: fix recalc_rate for negative kdiv Date: Sat, 10 Dec 2022 15:38:35 -0500 Message-Id: <20221210203835.9714-1-kgroeneveld@lenbrook.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: YT1P288CA0035.CANP288.PROD.OUTLOOK.COM (2603:10b6:b01::48) To YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:e8::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YT4PR01MB9670:EE_|YQBPR0101MB5880:EE_ X-MS-Office365-Filtering-Correlation-Id: 1804bd33-8a29-46fd-45f9-08dadaee9ed4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oWCp8OlGR/oQV0OuKYkNaQM1szcbvCaekqYkCnY7Qxs4xBT8i2KNhm6t9g+aM/VSdX+aWSPeST/ZA4uRhZBy70tpXMw+FQB3hVXIlZdY+rWcbZN2Z6yjYDd/IcAPUo5yXTF7UlrWifT3N1AbkDznNxSfqBHOF5fQyMCZggWZTsBWjWbxvkKIAHv11cGGYfaKh5IA78EVFHdhcmQ8biT8eFvq00A11SlZ6UYBSqTnE/4tOiUsi9mUuv4/5PM2X3QM7MjjyqslcSDj/fKFbD46VH9ezcn/5z7p+upqamCo9qvtRgNU617COCt2Lya1pUbD3rzB2zxHu3JNbtKFcSgITsrbPVT8CaHWtYR8AliKt/fOBeWvU3UGdNnk2w47jUccLGE6rfAqRKyjw29PspTajE+LMbfHTeWG+oIEEPEILdlMJOGhpeVJf2XspPUgDruD7zCxNReDy+i7KhA2D9DGTk9DH1qklnk7L3M/F4117q/vZ5+WoFfg97Q+gWDey98X9SkJs9G7d2+SuEMp52IusJILscAzmAgLMZIcy7LNiTFHSim28Oa9jUv/tkZUggoAxQr0hdxpxyx2iSr6/ifMFJky3rxGG/SNbU99DHmlidMpRQCGaobIoo0dH2ctNzIBv7taN16Vzt9DrRPBUrRIwcndU3uoK8jy7T31GOtq6CjsFmvO6/rOOWwSa+QeaSIr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230022)(39840400004)(376002)(136003)(366004)(396003)(346002)(451199015)(6506007)(6512007)(26005)(316002)(6666004)(478600001)(6486002)(4326008)(2616005)(186003)(1076003)(41300700001)(66556008)(66476007)(8676002)(66946007)(8936002)(83380400001)(7416002)(107886003)(2906002)(5660300002)(36756003)(38100700002)(86362001)(110136005)(921005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Qi48sSSIWt6igGaRX4ZJ6rf/NHO4KqIB02YoLHtXao8GV11eMt2YPG8zlAA92ymLdJKxJtThRyDGmpjGhtK1+MAOOLx69vk+FcS2BLzU50CTxySXHOzipoHoOA1piOWAMrLqVd7f1hxh20qFcmdqDjDttRtB42pw1qpM51/xWB7qwwjtQcUVBnKT7815NjJvtaidZwnWC7wGD9VL+Y9QyO6ruvTOJSbZURJN22hBXGX5CfH63zh4d+yVlocQjOi9d9O4kuvuObfEzfmRPTSPuSVLHvdzZV9096CadslQmV3U3PYA9dXCn8Ba5sq1nVQYuJSC8J9Vv1zUZCwNW7++sWzE1NCYlMwz5+LZ0ykOO0cTQpliOSFjp7oKhtWWd8Qk7WNF/kbhfGX830m7G2Fk+pV9z4+3jwMbvYDV6pQEjyCIcOogpv8xsb6jwElrWm+FIO9CtXjZh/Au7siZszBwuvVKkrMxAiN7bP+iPGvWrmRmdyGzi+WzR2Acjd/27/1tkJ0LRPq8/aglqC1276LrTZ6N1DPyC8xB4JZUQ1scV6zL5Z0LNDjljvbXdAig8AifSUZzHugj2LQfPmL6CTG/MwjPRLW/ryGCK7Yff64O56GOhRmadothTKjEb6Fayh/EQfoDuq1uS7KGWx4an46aa8Gyq+0Nb33Yfnc2Olhzebs97O45Y2VL64FfvI1GJ7T8R75EiACnkqePQS7fmltUzirDcnbnxg6HoFRaABjFLz2VUkd/6TBZXFBqaN94cbymlaTsUGHQZtj40ySEJ7Cqpg6mHwRwh+8/vEVG1A+JNRvuULeyhH+bcqqyQmG4WX+NaftlL+21pap/u2PyT0zRvVJ4ulcnDwvQcXMGci4a11Om8HdY/N6aNTIc+8A572psTvTeGpnoOk3WIfPH3ZWIu/lZ4RFowarPQC/IZwwNu949es7wLwhz94pcb/NTFalClvz3DaHvlUmJE2wQk+Y0+Hz2mFy6Ps9zleTjiuR0QKBDvcqoiqn1/XC+cD5axt4J6azrxUpCRID6zVWLQZvjw1EcwgWo2R6bfoBv/S6rWw3BSoWRlgXwFxfpCWEbuof6qT+0mSYTpRxxhJwahqb76FjqV6NW82dAhScytAV0SUYeg50xVMUwCPVW35yyEN5s9nbg3qi4dRPHssuYJEVzlAGSze3HGGq2dlXcUYnEMzkALhNPVdug8iMSJs7hAOi8c8j21xGzxayKlImwEo203io67zgx1RbaonaSv38RkkMoprRsqQF4oR2MxTwAbiNLotdYuFplfomVfuumXYeXX4fxvql1ILTD6rGtvGD21BCdeHWwDAtMgkuFXRIJttTRW+LABgE3kDGF3OoopwQcsunZEXYVav+eP6fscdo2iQg7jVcCwJoFsr+1eUUb10mNsL0Iz1CC0957Jz9PDeMwOISlMnUcGlWZyWlVbHixEOGpP+Rtag98MixIEv5D7j6pX0f2g2eigxaUB4rXwephxgtu3/duuCRB2Ng8cPxwTYexQj3eJmV7d+MATARaFQleYuKHAIcgFz+0KbO14vMh/deH0VEoAVAZqUxjk/4PsI2tI49e1M9LJ3mHmpZdRZ5fwNWFfz/hrLQK9P50UkTmyQ== X-OriginatorOrg: lenbrook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1804bd33-8a29-46fd-45f9-08dadaee9ed4 X-MS-Exchange-CrossTenant-AuthSource: YT4PR01MB9670.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2022 20:39:22.9067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3089fb55-f9f3-4ac8-ba44-52ac0e467cb6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KrrYT9iI9yUiud26KlrbYTwUjaLtJkULtiZHB34faijrdNpF/xRDfzL12eDN8dcp1zDWNRKippJI895LMvmHeSAAb8E0b2Ic41D3Monuryo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YQBPR0101MB5880 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221210_203930_772424_68549637 X-CRM114-Status: GOOD ( 12.42 ) 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 kdiv is a signed 16 bit value in the DEV_CTL1 register. Commit 53990cf9d5b4 ("clk: imx: pll14xx: consolidate rate calculation") changed the kdiv variable from a short int to just int. When the value read from the DIV_CTL1 register is assigned directly to an int the sign of the value is lost resulting in incorrect results when the value is negative. Adding a s16 cast to the register value fixes the issue. Fixes: 53990cf9d5b4 ("clk: imx: pll14xx: consolidate rate calculation") Signed-off-by: Kevin Groeneveld Reviewed-by: Abel Vesa --- drivers/clk/imx/clk-pll14xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-pll14xx.c b/drivers/clk/imx/clk-pll14xx.c index 1d0f79e9c346..d12194d17b10 100644 --- a/drivers/clk/imx/clk-pll14xx.c +++ b/drivers/clk/imx/clk-pll14xx.c @@ -254,7 +254,7 @@ static unsigned long clk_pll14xx_recalc_rate(struct clk_hw *hw, if (pll->type == PLL_1443X) { pll_div_ctl1 = readl_relaxed(pll->base + DIV_CTL1); - kdiv = FIELD_GET(KDIV_MASK, pll_div_ctl1); + kdiv = (s16)FIELD_GET(KDIV_MASK, pll_div_ctl1); } else { kdiv = 0; }