From patchwork Wed May 7 08:32:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 4126531 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 92002BFF02 for ; Wed, 7 May 2014 08:36:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC0CB20251 for ; Wed, 7 May 2014 08:35:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DA492024F for ; Wed, 7 May 2014 08:35:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhxID-0004vG-Km; Wed, 07 May 2014 08:33:33 +0000 Received: from mx07-00178001.pphosted.com ([62.209.51.94]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WhxIB-0004tp-67 for linux-arm-kernel@lists.infradead.org; Wed, 07 May 2014 08:33:32 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id s478MfYR010876; Wed, 7 May 2014 10:32:56 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 1kq7j3a13y-1 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Wed, 07 May 2014 10:32:56 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8B5BE5B; Wed, 7 May 2014 08:32:37 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 369A31621B; Wed, 7 May 2014 08:32:37 +0000 (GMT) Received: from [10.129.6.55] (10.129.6.55) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.123.3; Wed, 7 May 2014 10:32:36 +0200 Message-ID: <5369EFA3.8070908@st.com> Date: Wed, 7 May 2014 10:32:35 +0200 From: Maxime Coquelin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Shawn Guo , Sascha Hauer Subject: Re: mx6qsabresd hangs on linux-next References: <20140506141310.GA2794@dragon> <5369081D.5030400@st.com> <20140506200029.GD5858@pengutronix.de> <20140507020950.GB2794@dragon> <20140507033223.GB2798@dragon> In-Reply-To: <20140507033223.GB2798@dragon> X-Originating-IP: [10.129.6.55] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.11.96, 1.0.14, 0.0.0000 definitions=2014-05-07_02:2014-05-06, 2014-05-07, 1970-01-01 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140507_013331_628836_55249B37 X-CRM114-Status: GOOD ( 14.55 ) X-Spam-Score: -0.7 (/) Cc: Mike Turquette , Fabio Estevam , Russell King , "linux-arm-kernel@lists.infradead.org" , Sascha Hauer X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Shawn, On 05/07/2014 05:32 AM, Shawn Guo wrote: ... >>> >>> Here when a table entry matches the input div this function will return >>> exactly the input div. This means _next_div() will always return the >>> same value and clk_divider_bestdiv() has an infinite loop: >>> >>> for (i = 1; i <= maxdiv; i = _next_div(divider, i)) { >>> ... >>> } >> >> Hmmm, isn't the first thing that _next_div() does to increment the input >> div? > > I think the infinite loop happens in this case because "i" will never > exceed maxdiv for a table divider. You are right. Sorry for the regression. I thought I tested it, as I had some table-based dividers in my test setup. After checking again, it appears that I didn't had the CLK_SET_RATE_PARENT flag set on these clocks, so I didn't entered the for loop... Could the fix be to initialize "up" variable to INT_MAX in _round_up_table (see below)? I can send the patch if you are fine with it. I have no hardware to test on this week, I only have compiled this patch, not tested it. Thanks, Maxime > > Shawn > if (clkt->div == div) Tested-by: Fabio Estevam diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index b3c8396..cf9114a 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -158,7 +158,7 @@ static bool _is_valid_div(struct clk_divider *divider, unsigned int div) static int _round_up_table(const struct clk_div_table *table, int div) { const struct clk_div_table *clkt; - int up = _get_table_maxdiv(table); + int up = INT_MAX; for (clkt = table; clkt->div; clkt++) {