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 E51B131B80B; Fri, 5 Sep 2025 15:12:41 +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=1757085163; cv=none; b=MGisWiVKOI03Wl841t/uRCT7Hyc03gKsGbGBhrKgKvnzYZ9TRc7AuI8CRxC08Aox6HN7ej9hD8v+pI+mLIr83YjwnX2Obja69kbNseiL9psvLKjJY3a5CuKnBAO//R0E7I+za+z1g7SPi+RpQ9eWcy2RWEs+7ZQaITpVaj61xrc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757085163; c=relaxed/simple; bh=/KX5luXYZW6HClpST7249EccgXx88bUyswNisMK+RJc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aRyaI04ACeCUDe796StuHqcK+IS4LXSmYcjk1t6a14CKubjCfEQwsPZKc8SqILBGY/pnhU01d0HFae3q1X+BXgTFF3iSWAida4DKM79MS32xUH5jrJ82H3pnJSv4p3zrom8iWh/5uiz/W9OT1siYBsKf4ioUyuP00tMF4O8RJKg= 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; 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 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 1F49C152B; Fri, 5 Sep 2025 08:12:33 -0700 (PDT) Received: from donnerap (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8B7F93F6A8; Fri, 5 Sep 2025 08:12:39 -0700 (PDT) Date: Fri, 5 Sep 2025 16:12:36 +0100 From: Andre Przywara To: Chen-Yu Tsai Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Stephen Boyd , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , linux-sunxi@lists.linux.dev, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/8] clk: sunxi-ng: mp: Fix dual-divider clock rate readback Message-ID: <20250905161236.51b6ecee@donnerap> In-Reply-To: <20250830170901.1996227-4-wens@kernel.org> References: <20250830170901.1996227-1-wens@kernel.org> <20250830170901.1996227-4-wens@kernel.org> Organization: ARM X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 31 Aug 2025 01:08:56 +0800 Chen-Yu Tsai wrote: > From: Chen-Yu Tsai > > When dual-divider clock support was introduced, the P divider offset was > left out of the .recalc_rate readback function. This causes the clock > rate to become bogus or even zero (possibly due to the P divider being > 1, leading to a divide-by-zero). Ah, a nice catch, thanks for that! Just curious, how did you find this? The MMC clocks use the dual divider type as well, but I didn't observe them being wrong? Regardless: > Fix this by incorporating the P divider offset into the calculation. > > Fixes: 45717804b75e ("clk: sunxi-ng: mp: introduce dual-divider clock") > Signed-off-by: Chen-Yu Tsai Reviewed-by: Andre Przywara Thanks, Andre > --- > drivers/clk/sunxi-ng/ccu_mp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c > index 354c981943b6..4221b1888b38 100644 > --- a/drivers/clk/sunxi-ng/ccu_mp.c > +++ b/drivers/clk/sunxi-ng/ccu_mp.c > @@ -185,7 +185,7 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw, > p &= (1 << cmp->p.width) - 1; > > if (cmp->common.features & CCU_FEATURE_DUAL_DIV) > - rate = (parent_rate / p) / m; > + rate = (parent_rate / (p + cmp->p.offset)) / m; > else > rate = (parent_rate >> p) / m; >