Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752244AbbBWHdI (ORCPT ); Mon, 23 Feb 2015 02:33:08 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:41460 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751249AbbBWHdF (ORCPT ); Mon, 23 Feb 2015 02:33:05 -0500 Date: Mon, 23 Feb 2015 08:32:58 +0100 From: Sascha Hauer To: Uwe =?iso-8859-15?Q?Kleine-K=F6nig?= Cc: Mike Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, =?iso-8859-15?Q?S=F6ren?= Brinkmann , linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH 1/3] clk: divider: fix calculation of maximal parent rate for a given divider Message-ID: <20150223073258.GJ12209@pengutronix.de> References: <20150221085620.GV19388@pengutronix.de> <1424515225-6929-1-git-send-email-u.kleine-koenig@pengutronix.de> <1424515225-6929-2-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1424515225-6929-2-git-send-email-u.kleine-koenig@pengutronix.de> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:23:08 up 130 days, 18:36, 68 users, load average: 0.01, 0.03, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2003 Lines: 45 On Sat, Feb 21, 2015 at 11:40:23AM +0100, Uwe Kleine-K?nig wrote: > The rate provided at the output of a clk-divider is calculated as: > > DIV_ROUND_UP(parent_rate, div) > > since commit b11d282dbea2 (clk: divider: fix rate calculation for > fractional rates). So to yield a rate not bigger than r parent_rate > must be <= r * div. > > The effect of choosing a parent rate that is too big as was done before > this patch results in wrongly ruling out good dividers. > > Note that this is not a complete fix as __clk_round_rate might return a > value >= its 2nd parameter. Also for dividers with > CLK_DIVIDER_ROUND_CLOSEST set the calculation is not accurate. But this > fixes the test case by Sascha Hauer that uses a chain of three dividers > under a fixed clock. > > Fixes: b11d282dbea2 (clk: divider: fix rate calculation for fractional rates) > Suggested-by: Sascha Hauer > Signed-off-by: Uwe Kleine-K?nig Acked-by: Sascha Hauer This gives clk_round_rate/clk_set_rate on dividers a consistent behaviour. Also the testcases I posted seem to work fine. The only thing that might not be nice is that when a divider can only output fractional rates then the next higher integer value has to be used for clk_round_rate/clk_set_rate. A consumer should probably make no assumptions whether 333.333Hz is rounded up or down and use 334Hz to be sure anyway. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/