Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2682848imj; Mon, 11 Feb 2019 06:59:48 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia0D10B7e/ycfBCrPlYNOM3y9couhRN3eIgnRMCVysgx1YgR9rwcvgULUJhzfFP/KDVWdYe X-Received: by 2002:a17:902:b01:: with SMTP id 1mr38434530plq.331.1549897188629; Mon, 11 Feb 2019 06:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897188; cv=none; d=google.com; s=arc-20160816; b=QMK3NN/opeGnBQmlnK4UEd8OUIruoYAtnzMfuMW7/xsaau7DMtAZh5PLELijzCaG0y Kwapw4zFnwxFWYuE1kClBaxLClghBzkiOOinltjT5Jmz9yELm0UkzAZVQXBC2WaPDQJO mTQN3RpR09QoVeJr5o8aKKFe3milq3zlaQr/BYMvyySRkzs/+08RsF73RYYSYxJzG9pv Pbnjnm/34Dt0P+OkzPF0ohkZCqDnTwctBhBvuFBhI0GiEDqM+500JFXwOZD3GfhNoaIf eQH6wyQSOg9rlkVdk9ArcgFErTQP3xF1RQ6IySAzYa0rrbqpTWXLiJizV5rA1wHS9qQr Q5rA== 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=nS1nsNs41nj5HvWSuGaQTQXn60zzcyDDvlM8zHlrwuA=; b=b6e7KWY/Is5fYFy1uMN9zlIoyRCnwIPHAl1VGJFJxu96Gi1CYYpXTGcjWr/XocFBMM /13XkF4YNtj4VmhIvkv5RsbTZDP7yyHje5S+S4iH2z/R5W234WMf/32aV8ExmCR+vj6q OpvNaPHZ3OwKJG8AoiDzOsUaRUh82qMn5/zCVshbU51iYNOy2aqb5Hkd4YQgSiXn2Ghi VtfLduNQ3blIXd+r0rvbFgExq7AH86rJf06Nj3GuH2nG+H94d36paGn+cOXU+v81iexG QTC6WWgqtiznJkyoUdsrE4Cr4PgsEmZDks4D0BYUCH64teh9FmIpOgrBDYh+vgzUu1tC V9Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q21mZsmF; 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 k69si7749769pga.176.2019.02.11.06.59.32; Mon, 11 Feb 2019 06:59:48 -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=q21mZsmF; 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 S2389187AbfBKO6n (ORCPT + 99 others); Mon, 11 Feb 2019 09:58:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:46372 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389621AbfBKO6l (ORCPT ); Mon, 11 Feb 2019 09:58:41 -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 0A1372229E; Mon, 11 Feb 2019 14:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897120; bh=68b4XN5DUbJIZ3lRYu4rXLAVPajkY6casumvTYRAwFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q21mZsmFSl4e5wiEqybhMYwsBssdj78tttPNgym9DATX+9JKuvv6/HnjeCXeaNvRB 0dDd4KvH8MZ7cXzJqd06qQ1uhyKsvgMXKjvBsFfCMVmPyE+c35n+tAdqB2FfLKrN+G ATVBKJCHtz3w6TF0M/S8JDBOiZThIHWvU37SgLO0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Yangbo Lu , Ulf Hansson , Sasha Levin Subject: [PATCH 4.14 098/205] mmc: sdhci-of-esdhc: Fix timeout checks Date: Mon, 11 Feb 2019 15:18:16 +0100 Message-Id: <20190211141835.026629910@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit ea6d027312111c6d96309ad1a684b33cb37e6764 ] Always check the wait condition before returning timeout. Signed-off-by: Adrian Hunter Reviewed-by: Yangbo Lu Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci-of-esdhc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 8332f56e6c0d..7b7d077e40fd 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -481,8 +481,12 @@ static void esdhc_clock_enable(struct sdhci_host *host, bool enable) /* Wait max 20 ms */ timeout = ktime_add_ms(ktime_get(), 20); val = ESDHC_CLOCK_STABLE; - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) { - if (ktime_after(ktime_get(), timeout)) { + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (sdhci_readl(host, ESDHC_PRSSTAT) & val) + break; + if (timedout) { pr_err("%s: Internal clock never stabilised.\n", mmc_hostname(host->mmc)); break; @@ -558,8 +562,12 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) /* Wait max 20 ms */ timeout = ktime_add_ms(ktime_get(), 20); - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) { - if (ktime_after(ktime_get(), timeout)) { + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE) + break; + if (timedout) { pr_err("%s: Internal clock never stabilised.\n", mmc_hostname(host->mmc)); return; -- 2.19.1