Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3630911imu; Mon, 28 Jan 2019 08:08:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN69QaxEEU6Acy4+HxHmEmT7gyAkMSV+WkuJy4WMR0mgw8Iq/bW6UEBJH6SeWVIC6s+R9HzB X-Received: by 2002:a17:902:765:: with SMTP id 92mr22405369pli.242.1548691682383; Mon, 28 Jan 2019 08:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691682; cv=none; d=google.com; s=arc-20160816; b=C3ieLwGOSyNxHwyZwg6E6bRRbozx31jwDXhVLr0q+007tZXm0J2wox5FiDPRWucwuO Ze3gaGE4w7P1x3VfRjuGOXuwfbBaUqeSLlFu+us6vltjwRqTLvuTB4IR/GwwhTAy1P5q LumeK8oH1CKpQnVF4AioyODofOnTcAd+GrIX5QJ6p4zH8STApDf8ghvxRsCTEAWYEeEs /1krwIQeyPj7u3Tg/tSs+SPCPMCvP5eYQ13CZOsgmcVPexj6bShETRJhTbJDfXMcNCrw vgEBNDC7paFZ8mJFDzCKhKQ4S1liP5QaLxAiGsycoRQhPY7kHLPpt1ufU2J7pfsQovv4 S+tg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pGkcdwRDC3kHSSV2dtjo4NdzWO14o/ajOvJqgiZ2YAU=; b=MYY1McgzsLn4daDX0mRnLVS+PAZo9HUvBwqUqIzLs2aisz1v1NYIvHrMX33SUd3Kwo zi8ruqIvWFv/lsYuMYlCivmyl1kIIlvVtvJcalpEhEjCLmCEbDONVdOqXJ6ZiL3oZhfb vloyqZOR7LLIm6ZW/eh68hy1Bq1zgT7jO+30ydi6LMPaXazCdzJ2+FoXTuV1Sji2A8TU ye8dwfxXzqCCk7n3wXp6/FHurKkW0PRDNmLGMftxSiQhddIQ2eL2n2O1SlG5hd5f6T42 fycw1EIU9VlZaIkygqfraaD5XpbsE6SnRdoICfK1DFTU5L/m3deaTb1xMreQddoiasdJ 4TwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aH0YobE+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g19si16401370pgj.358.2019.01.28.08.07.47; Mon, 28 Jan 2019 08:08:02 -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=aH0YobE+; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732084AbfA1QGr (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:56058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731039AbfA1QGm (ORCPT ); Mon, 28 Jan 2019 11:06:42 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E28DD20989; Mon, 28 Jan 2019 16:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691601; bh=Qi8zBp4ErWC6+27RVqVn8817acWdExkYBRiLWbTHZJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aH0YobE+sUA4noM7aJ6fKC3sSxs2JHQ1s7MnWMEIEjtpfystxNDOKlHDidqc8Fzpz 0O7eFlcLwYa4N0kHanWWDCIqgsvQT+H73Ox31PaUtxiB3hz2UwxNid5hfuDegRyJ2U J0RG5ZYQoms6YyOWUAHJotnvjUgv8vKCWBWh/BVM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Adrian Hunter , Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 156/258] mmc: sdhci-omap: Fix timeout checks Date: Mon, 28 Jan 2019 10:57:42 -0500 Message-Id: <20190128155924.51521-156-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter [ 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