From patchwork Sun Mar 8 10:02:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 5961441 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44C7E9F2A9 for ; Sun, 8 Mar 2015 10:07:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E72B2018E for ; Sun, 8 Mar 2015 10:07:46 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2ED2420121 for ; Sun, 8 Mar 2015 10:07:45 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3DB7726046B; Sun, 8 Mar 2015 11:07:44 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 99B422604A7; Sun, 8 Mar 2015 11:07:21 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id B09CB26049E; Sun, 8 Mar 2015 11:07:20 +0100 (CET) Received: from www.osadl.org (www.osadl.org [62.245.132.105]) by alsa0.perex.cz (Postfix) with ESMTP id 03BBA260457 for ; Sun, 8 Mar 2015 11:06:53 +0100 (CET) Received: from debian.hofrr.at (92-243-35-153.adsl.nanet.at [92.243.35.153] (may be forged)) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id t28A6nS5030719; Sun, 8 Mar 2015 11:06:49 +0100 From: Nicholas Mc Guire To: Liam Girdwood Date: Sun, 8 Mar 2015 06:02:38 -0400 Message-Id: <1425808958-17104-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 1.7.10.4 Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen , Axel Lin , Takashi Iwai , Xiubo Li , Mark Brown , patches@opensource.wolfsonmicro.com, Sachin Kamat , Tomi Valkeinen , Nicholas Mc Guire , Charles Keepax , linux-kernel@vger.kernel.org, abdoulaye berthe Subject: [alsa-devel] [PATCH 2/2] ASoC: wm8996: ensure lower bounds of 1 for timeout X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP wait_for_completion_timeout can be called with timeout == 0 due to msecs_to_jiffies(2) == 1 for HZ < 1000 and usecs_to_jiffies(300) == 1 for all reasonable values of HZ, thus the following timeout /= 2; sets timeout to 0. This patch simply adds a lower-bounds of 1. Signed-off-by: Nicholas Mc Guire Acked-by: Charles Keepax --- line numbers from wm9666.c linux-next -next-20150306 2101 /* Wait for the FLL to lock, using the interrupt if possible */ 2102 if (Fref > 1000000) 2103 timeout = usecs_to_jiffies(300); 2104 else 2105 timeout = msecs_to_jiffies(2); 2106 2107 /* Allow substantially longer if we've actually got the IRQ, poll 2108 * at a slightly higher rate if we don't. 2109 */ 2110 if (i2c->irq) 2111 timeout *= 10; 2112 else 2113 timeout /= 2; 2114 2115 ret = wait_for_completion_timeout(&wm8996->fll_lock, 2116 timeout); The call-path here would then be: wait_for_completion_timeout(...,timeout) -> wait_for_common action==schedule_timeout -> schedule_timeout(timeout) ... expire = timeout + jiffies; so expire == jiffies here and the timer would expire immediately for systems with HZ<1000 due to msecs_to_jiffies(2) == 1 and the following timeout /= 2 -> timeout == 0, which is probably a bit more that a "slightly higher rate". This was only compile tested for exynos_defconfig + CONFIG_COMPILE_TEST=y, SND_SOC_ALL_CODECS=m (implies CONFIG_SND_SOC_WM8996=m) Patch is against 4.0-rc2 linux-next (localversion-next is -next-20150306) sound/soc/codecs/wm8996.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 24d9705..5ded102 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -2110,7 +2110,8 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, if (i2c->irq) timeout *= 10; else - timeout /= 2; + /* ensure timeout of atleast 1 jiffies */ + timeout = timeout/2 ? : 1; for (retry = 0; retry < 10; retry++) { time_left = wait_for_completion_timeout(&wm8996->fll_lock,