Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2863829rwd; Mon, 29 May 2023 01:56:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67QnApvHRvnado6Jmmh1M67J41BW3UdLupnZ2JvrMTcAsxGerTRw9g21ujrUmbuEuc/C2V X-Received: by 2002:a05:6a20:4323:b0:107:10b6:4c8a with SMTP id h35-20020a056a20432300b0010710b64c8amr9665944pzk.24.1685350603231; Mon, 29 May 2023 01:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685350603; cv=none; d=google.com; s=arc-20160816; b=o+eQUdcFQVMbmj4ofpB0MsG0LLZaSLlqo7l8QUuOtoXogXH0Jk4RvWZZd03FHqXon0 JSl6fHdsE09RLsbZLbQtjXtWFOCeBiErSL3wJb2QIlupNTbe1vlC15IuqilxEatR/p6M JzMfF9G4Yq14UlvdblS8WCpieNknDqnQJNrEcpA4ImofF7mxa0HFMkGyuR9Jn1LzbQPy gwctr8qDcezmfIIEiUt8crixT2ROp5OzuSsqCN9Xk5cVQpzqiZviy7QdOojnQ666VBgZ QdhkchZoS4RB4gN1Jd+Jp1mdjJu2sxdMCaDTNa7JNRN6tTU1GFeyA1c6qrPidiDZfqOm mu7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=4Q4l+xaCzM3FUFG8D2CmS9la6Pm6rN3tGSfRWnZHibU=; b=VaOXOSk9jzhrZ8ZyukMyf7wVow1BdpDFLY2cOlPFgJGsj4jR4YrXTkQm9508lg0gMA gIggSA1CrhtQnk65RO1tQRqhcprQHvTSAtAzicDgucAmArhQqXg1B5BPGbvhxobTXdoX awB/J37oWBCF5fRK+MHREEU7xuW5+YfdJe0AemQ5dEqoAzD+uHpojcIp7sXmQ0FeADX9 J5oFxW4yY80VpxsYHKNnC/4i2ACh81xmGfUcpLoEibTqXb+aeKxDKDiak0pi0aIgNa0x zssM60gCiNtU8nnhk/Q1rHSWUUCZPko6TZ2QCAodz3UOcu2nmbRP66rGTrEFRFfAL/An FBkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NDptBfeV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d187-20020a6336c4000000b00533fce755adsi252867pga.130.2023.05.29.01.56.29; Mon, 29 May 2023 01:56:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NDptBfeV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjE2IvT (ORCPT + 99 others); Mon, 29 May 2023 04:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbjE2IvI (ORCPT ); Mon, 29 May 2023 04:51:08 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93546C2; Mon, 29 May 2023 01:50:55 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab] (unknown [IPv6:2001:b07:2ed:14ed:a962:cd4d:a84:1eab]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 86F9E6605961; Mon, 29 May 2023 09:50:53 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1685350254; bh=jtQ3UzAAL9SWJIafGv8zGAcWl+Tvfd/waNo7frdU8ns=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=NDptBfeV6vql8MIEM5QwYBfSorO2E/aNOk11MUi0WgNVihvFcC30yxaXBK2BG6Cwf hWfuHgtyQGUzqQ2NGpY0Zo8wXEqN477MTTdR2yd+d5GK9S1HKWyU22vEqw2Z6t8gMz yk35QRpPw+/sH5iuq0l597lv95EnufaqrWvHLAEhGixyO3vstzyOKdLNBgLB4nxgj1 D0oLsol8kV2xoELZPp4PXPX2hfqTa07UiKpScpWN492iHieI6FhMAe2BIS5rcDuaDU sLZEMFVjbst1wn1scDKbu4/24md9DeKrS7nzB7HM3/UXrCBpS7bvg1nbX8qj37Dhp3 2Vxbem/RuvvlQ== Message-ID: <89b3e3bb-d725-1f92-7a0d-b5bc1109dafc@collabora.com> Date: Mon, 29 May 2023 10:50:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH v2 1/2] clk: composite: Fix handling of high clock rates Content-Language: en-US To: Sebastian Reichel , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christopher Obbard , David Laight , kernel@collabora.com, stable@vger.kernel.org References: <20230526171057.66876-1-sebastian.reichel@collabora.com> <20230526171057.66876-2-sebastian.reichel@collabora.com> From: AngeloGioacchino Del Regno In-Reply-To: <20230526171057.66876-2-sebastian.reichel@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 26/05/23 19:10, Sebastian Reichel ha scritto: > ULONG_MAX is used by a few drivers to figure out the highest available > clock rate via clk_round_rate(clk, ULONG_MAX). Since abs() takes a > signed value as input, the current logic effectively calculates with > ULONG_MAX = -1, which results in the worst parent clock being chosen > instead of the best one. > > For example on Rockchip RK3588 the eMMC driver tries to figure out > the highest available clock rate. There are three parent clocks > available resulting in the following rate diffs with the existing > logic: > > GPLL: abs(18446744073709551615 - 1188000000) = 1188000001 > CPLL: abs(18446744073709551615 - 1500000000) = 1500000001 > XIN24M: abs(18446744073709551615 - 24000000) = 24000001 > > As a result the clock framework will promote a maximum supported > clock rate of 24 MHz, even though 1.5GHz are possible. With the > updated logic any casting between signed and unsigned is avoided > and the numbers look like this instead: > > GPLL: 18446744073709551615 - 1188000000 = 18446744072521551615 > CPLL: 18446744073709551615 - 1500000000 = 18446744072209551615 > XIN24M: 18446744073709551615 - 24000000 = 18446744073685551615 > > As a result the parent with the highest acceptable rate is chosen > instead of the parent clock with the lowest one. > > Cc: stable@vger.kernel.org > Fixes: 49502408007b ("mmc: sdhci-of-dwcmshc: properly determine max clock on Rockchip") > Tested-by: Christopher Obbard > Signed-off-by: Sebastian Reichel Reviewed-by: AngeloGioacchino Del Regno