Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2655745imj; Mon, 11 Feb 2019 06:33:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IZgSpF0wy89jaHYsvgMOIxe39en59mAfLasf4Zajh2rcWvoxafaIJHj4pTpf/v6bBx8GjH0 X-Received: by 2002:a63:101:: with SMTP id 1mr33796130pgb.152.1549895601548; Mon, 11 Feb 2019 06:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895601; cv=none; d=google.com; s=arc-20160816; b=DRyVYnw8oQQQ4QN6MEUFk3wQLCYNBK9Fe6bGMmispRfXNKEHlW/GTU3GgVVes9XoqN 0XphDuwQ9IXBkRn3p7AF0ffCj6WhP9UTNZ831spf6nRwi1xCDJ7delXYOIUpcO99oGXi HE/psWIUGRrsY6w7UhPpV59+3nVed/7PbM7Z5DCB7nf8KH7kvqt8DTlX4qtYKjcpPnQ/ +aD1PgRAtKo+lbkvE5kQsEvKCFAMgfF7saLUwR2mHvjmQ8lZYfx+vPSXqPr8egBqMVu7 xYI7lOPQHPfw1B9t5gcOPaVBSGuF+YJRYRIIvEqdHdsMi/K7xKHSzw4hnFlF69dv7LHP 3Atw== 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=3Ry8SMNKxAujvNwrFFbNKpnV+Hwl3bCW3r7KGumeWKA=; b=mQ1VuuebYbIvhWV6v7Lv1zCWHmgjT51pkXRW0sRy0oocKyy72qsVA44qKYxEw9cg8a /lbdoEI15qeu0NJqeLS81bpMyWZYO1yG1iWkCAQGMQsQ+CWtJszUXlTGefzQRKx2El09 1n1yGicryliTZA0REiuPRT3EbDitOJ9mraLeCMXRt+bueRTX7ECfnwBAX9EEuaK4vwnB TnmYXiS7VvN7MnUs5FK+ZP+WkGztbfvSYyVawhmo8pS+zPO977lgod66895XlcEd8DJc 9WnKpEmSEnCwr0lRoXHbIZMaV3YcaKQWQH9qghb5Hrk1plJtit1ngfD1AAa5pdgDtQ0+ 60lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ApfyJjyY; 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 u64si10512481pfi.239.2019.02.11.06.33.05; Mon, 11 Feb 2019 06:33:21 -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=ApfyJjyY; 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 S1730277AbfBKObS (ORCPT + 99 others); Mon, 11 Feb 2019 09:31:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:38072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728242AbfBKObQ (ORCPT ); Mon, 11 Feb 2019 09:31:16 -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 8A7FA20844; Mon, 11 Feb 2019 14:31:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895476; bh=p7rQwGGpEihrN2jmghXOLqkbHHr76DunJYUFtNP8KI0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApfyJjyYwXQHuMsbGFN9TEWae4xU9PqTqcDFRMGOqhPVlCXUWiRQFvYUQrzzgZPw7 +FnwI1a63OfDWj/po7IpcTZP+u0UF97pWy4m6RjyY2UycUrRq405+NGWFgKKhf17tB /lvxJgGkYyOsFQQxwZRfEiXvnn72kikEOVToOhlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adrian Hunter , Kishon Vijay Abraham I , Ulf Hansson , Sasha Levin Subject: [PATCH 4.20 176/352] mmc: sdhci-omap: Fix timeout checks Date: Mon, 11 Feb 2019 15:16:43 +0100 Message-Id: <20190211141858.285366192@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 9f0ea0bda1d06120b053bb0c283f54afec59293d ] Always check the wait condition before returning timeout. Signed-off-by: Adrian Hunter Acked-by: Kishon Vijay Abraham I Signed-off-by: Ulf Hansson Signed-off-by: Sasha Levin --- drivers/mmc/host/sdhci-omap.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c index d264391616f9..d02f5cf76b3d 100644 --- a/drivers/mmc/host/sdhci-omap.c +++ b/drivers/mmc/host/sdhci-omap.c @@ -220,8 +220,12 @@ static void sdhci_omap_conf_bus_power(struct sdhci_omap_host *omap_host, /* wait 1ms */ timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT); - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) { - if (WARN_ON(ktime_after(ktime_get(), timeout))) + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP) + break; + if (WARN_ON(timedout)) return; usleep_range(5, 10); } @@ -653,8 +657,12 @@ static void sdhci_omap_init_74_clocks(struct sdhci_host *host, u8 power_mode) /* wait 1ms */ timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT); - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) { - if (WARN_ON(ktime_after(ktime_get(), timeout))) + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN) + break; + if (WARN_ON(timedout)) return; usleep_range(5, 10); } -- 2.19.1