Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2682894imj; Mon, 11 Feb 2019 06:59:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IZj9AYC7Ufnm99Dse4M2iRjmPpPknVPMIoKcWjInEBnPXTLYPtTp4/eyR2kPfCO5f0AAizK X-Received: by 2002:a62:5003:: with SMTP id e3mr38013814pfb.23.1549897191155; Mon, 11 Feb 2019 06:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897191; cv=none; d=google.com; s=arc-20160816; b=DCSFsdIqRtB4ZczPM8MM0HT7XgUzc5RFQXjESn3q8KU+1pCCxIXr2E6rn7xP84fQPI B51taCr57T2sLpJgBZO7PU7ok6xGaPQgDQSOah3kRh+4/hpxsbj8t83PdN6c2UPAF4Ke LzahEUfh5b9+aLRW67QLjPQC4H7RuwxTyQ7Ud4RsV23j7jDeFIqyZ7zEfE6cd2Hi3LWX Q93euiTSL4kodBwFmeL+jJgxrio+ng+BkcpWNkQz448XT+7LKkKfGij9WK+eB3o+o0UD Vj6GPxKsiR40TJEDlz4ORLH4VQOwhxVTSwgmUlb/Kbhq9vZi1g+nVI/epQKaCKqLYQ+F kBrw== 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=A2su1wFhx5lL6YC54qEeqk4WOaOakn3Szg+9GxnzqOg=; b=fevGfVD4I5drBJMJo+6fLv6mO1Uv7fPMY+rLPumGmEwRF/4YMr8ImI9XMRwj5Dvep0 VvrsQDyH2SCcEsEDyPIFerYcveWRFXBcd1TdpZnIPkJeHjPorBzk4GJwbpv6BQm2yCK8 V0/3tUO8uluL3bFohUos1M9KXaD2CQQp+pfFT3mGXLmMgcIztPq3fh9/bWoASkv58lgL wqZyV1d7v8a7l3GoEvc6G/fGLyjLRr3UR1f/sRQQnhXnwjeo4dXFCqn/t2qn9uQygT4d 8+z+97IqCRv6jDmK75SfdoTHvUadBdT0dWzQ0XOgE44OmI0TrYOsVjJ+1fmp6OCJ95Pk JVSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZnirnfTe; 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 i36si10644408plb.210.2019.02.11.06.59.34; Mon, 11 Feb 2019 06:59: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=ZnirnfTe; 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 S1729044AbfBKO6q (ORCPT + 99 others); Mon, 11 Feb 2019 09:58:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:46448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389629AbfBKO6o (ORCPT ); Mon, 11 Feb 2019 09:58:44 -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 722A3222A6; Mon, 11 Feb 2019 14:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897123; bh=/amk+QAmog6yftkj0BwTwvWkWxtV2ONmSwHJYtJQ23g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZnirnfTeWGiNjgoRRZJqXdx/Kggj2o0BWtSAUMaNRNeukpfXR460pYnm4lt1FO1K3 xKpNszXxRgzoDT8YmwWgNMs+iLQgM48rmwnb6sngAeNGa8aDfPm1Z1qLMuIWhjzefU L7cVk0qXrK/W+OUiAnXwmsb2GVhk40d6cLBvO4hc= 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.14 099/205] mmc: sdhci-xenon: Fix timeout checks Date: Mon, 11 Feb 2019 15:18:17 +0100 Message-Id: <20190211141835.080273538@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 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 ec8794335241..82051f2b7191 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