Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2760103imj; Mon, 11 Feb 2019 08:04:52 -0800 (PST) X-Google-Smtp-Source: AHgI3IZgzUkfeDa8XjxOpcmOGLVlXwWTWXFlftG2uVZBSrSDmvPxSrtb7mqNHVIkjLhOdJh0Caxv X-Received: by 2002:a17:902:7293:: with SMTP id d19mr1417342pll.29.1549901091945; Mon, 11 Feb 2019 08:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901091; cv=none; d=google.com; s=arc-20160816; b=Cy1y4GQoq4sR+DRLM9pt+qVtvrLMaanJgqGYyKx1AYpkDbSR04BgTrmLm2U72wy3Ux TFoqKuVruJQVlJNikx7T+xewVjT0WDESpL0tm/01FuCQ1nLXF+zuD8nkR6k98GrUdEI7 SLFzFMpSQX3WglDxbsWRj+gogEK1NqNEd+JhTTydudidlIfeZiza/k4gvUOsCE10StE5 0XhdHxHcLqLwWHidl+FyqYlg5Vjtd3EPo/fOHvRKkPRy8umNoN7AmJIbqULXmuVI5L/u QCRCfZyKd72CyjDjghwNxO1M7RJPbRbnuxQb9pYvaOJXMZ3I9nDyFBe59fJqLU+ojjMY HksQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gi0jMix3j68pzuRZCLEw7SecJBBE3VWyEE/KCqJDaTM=; b=yRcwmYbHWzdN6JTET2ydlV30y7e9g1b2qwKkO1cfixwQiJiq/hQcWo2F35jFHUUx7e QxC3QWKSw9egdREV8aDo/GUpyasay7Pq1+HMuCRxJyZDdtT4WOBROtOgVsBUNuGl6seW Mpp87VZ7oIuiW0Xo7DZfOCmpzuZAn7FMfNMDaEnr0pp4WGnDotc0xoPsAIkJmFV9S7be BqsdT9OKyn3Q3irODwqxPgW1s6QS9dqsQr8Ehfy1RKGxdTswxhkYmLZ09mLjOWp3raIT y5KW9jcsBQA6pG1fDYIvsFdjYUcwCOYIBvHLBQzhqz11gzL8CG62xzKMq5kMzX+1Gl6t rtCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gj9JyfC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si9713356pgi.308.2019.02.11.08.04.21; Mon, 11 Feb 2019 08:04:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0gj9JyfC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730321AbfBKQDR (ORCPT + 99 others); Mon, 11 Feb 2019 11:03:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:35720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729979AbfBKO3g (ORCPT ); Mon, 11 Feb 2019 09:29:36 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 63DF12075C; Mon, 11 Feb 2019 14:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895375; bh=nXi30idkNiVgdCxxhSumpHJehEwuLV3mWqSR+Lc2y/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0gj9JyfCWuYXjpb92QnYiGwRzTbE7PLAZboRnZp+n8vpkkNirHueyijYaBXpOZzVI SPL3A1mEekr0t/eh3eprhk6CIv+e0EXf1UWF0Vs2pNSutdZe6YdO5LStBJAgh6ia2G HTq/BNjkrP/pZR/eeyUKMKH3NPiS1IpLM00vL6/Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Zhoujie Wu , Ulf Hansson , Sasha Levin Subject: [PATCH 4.20 177/352] mmc: sdhci-xenon: Fix timeout checks Date: Mon, 11 Feb 2019 15:16:44 +0100 Message-Id: <20190211141858.350541657@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 0e6e7c2ff397e1bbebc882ca3132148aaaef1ddd ] Always check the wait condition before returning timeout. Signed-off-by: Adrian Hunter Reviewed-by: Zhoujie Wu Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci-xenon-phy.c | 10 +++++++--- drivers/mmc/host/sdhci-xenon.c | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/sdhci-xenon-phy.c b/drivers/mmc/host/sdhci-xenon-phy.c index 5956e90380e8..5b5eb53a63d2 100644 --- a/drivers/mmc/host/sdhci-xenon-phy.c +++ b/drivers/mmc/host/sdhci-xenon-phy.c @@ -357,9 +357,13 @@ static int xenon_emmc_phy_enable_dll(struct sdhci_host *host) /* Wait max 32 ms */ timeout = ktime_add_ms(ktime_get(), 32); - while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) & - XENON_DLL_LOCK_STATE)) { - if (ktime_after(ktime_get(), timeout)) { + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) & + XENON_DLL_LOCK_STATE) + break; + if (timedout) { dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n"); return -ETIMEDOUT; } diff --git a/drivers/mmc/host/sdhci-xenon.c b/drivers/mmc/host/sdhci-xenon.c index 4d0791f6ec23..a0b5089b3274 100644 --- a/drivers/mmc/host/sdhci-xenon.c +++ b/drivers/mmc/host/sdhci-xenon.c @@ -34,9 +34,13 @@ static int xenon_enable_internal_clk(struct sdhci_host *host) sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL); /* Wait max 20 ms */ timeout = ktime_add_ms(ktime_get(), 20); - while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) - & SDHCI_CLOCK_INT_STABLE)) { - if (ktime_after(ktime_get(), timeout)) { + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + if (reg & SDHCI_CLOCK_INT_STABLE) + break; + if (timedout) { dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n"); return -ETIMEDOUT; } -- 2.19.1