Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2762250imj; Mon, 11 Feb 2019 08:06:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ3FWJNYoYvQHbH9gZweHQZo2uxj/Aj4jZu0fHpptpxZnr3mEdniWp1VeYdon1Ee2/pGYfi X-Received: by 2002:a17:902:9691:: with SMTP id n17mr39141505plp.9.1549901185069; Mon, 11 Feb 2019 08:06:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901185; cv=none; d=google.com; s=arc-20160816; b=ElyUvKsoDQ5u9y8h/3W9eeVdIdk+sXmbDkXc6uRVLOxce64n7oEtUDyjYkQWz7e+PU 38/tCMNTPnLkaiMwABKLAm7YbvdSKxRXUzO/GggAxBS6ShHi4SCzxIE0abHC9FJ7O2QO gjUY+D+1Y6vD2XEHdN/yK7klL6IHIVM463O9gCBU6EoJBA6kYAEsgWoBPnH/aPe7s3FB GHdTa5CSNqrYRSY1C0SBecHd95M1VrHyzasof2Zli0QZqqQrrBj0uSc4N9qwATn6cvbs c4LaI8zc/bf1RKKlXTACaejhPRwwgsWVR45WCHnaroiKO9+cgC6AnW1MctF1oFt9X+fC b3gQ== 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=y7AqdHb1UGeyICtKIxryjZVu027w5YV8oXUVhBnwGTE=; b=MPfND+y7gr8i3fism9wVsOUH8qVz7Nya2z/B24bOnw/Aj40fR8Yubi0V+o3m1pIo2w lvpiJnRnRUXf5195uaYEqct3YrQi0V4RDLKsQSsmS3I7q6WcXRXimfqrY5JoodrPEWZC RKeEPfzt41BU5a40JUKwSW4ToKib2lusBImDJ86uMtjIDNl0QapUGG0TkHZsZA/bPoh+ y4rtsFd4upzPyH4um2lDqQGCptE5jx193rg2bmueTq2U0A5L+j8YmvPcoIJGwxct5neM WcmN5OaqncyPV4Zb1n4b2wacxjBsTBRhxX7/VQ5D4ybHS3FoJEMpQjPNSU1VHhxcHQug sgkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=A4B8Utrr; 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 l73si8070272pge.590.2019.02.11.08.05.53; Mon, 11 Feb 2019 08:06:25 -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=A4B8Utrr; 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 S1730523AbfBKQDp (ORCPT + 99 others); Mon, 11 Feb 2019 11:03:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:35242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729949AbfBKO3L (ORCPT ); Mon, 11 Feb 2019 09:29:11 -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 AB7D420844; Mon, 11 Feb 2019 14:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895351; bh=w3dJQWlZSCt6rMrOewxA9MuIMFaIYjd6D//NnVx1P6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4B8UtrrvTtF63p5YDhWCIv3ScYPVdf4Ly2t4e3fcQ2KeXI/OvkHSJ05PpcelZ3j0 UpUW6q0z2fzEtaL0RW/HjJRtI2yA9GtzVP0B50kSWHUwQUbrcdgNRQRNxRNw4N2V/b wLR0gzbKKlEEzFJucaofgpASebpSfUsXZOa1xBIk= 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.20 175/352] mmc: sdhci-of-esdhc: Fix timeout checks Date: Mon, 11 Feb 2019 15:16:42 +0100 Message-Id: <20190211141858.217322820@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 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 86fc9f022002..d111bf62acd9 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -528,8 +528,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; @@ -594,8 +598,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