Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3631049imu; Mon, 28 Jan 2019 08:08:09 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ec5i4a9eS+rFOL5BaEx5b3tRNRXvdiHROt2l2tmOQI9TTX5OxgF8nbIsmBmwA/RV/2i6N X-Received: by 2002:a62:5182:: with SMTP id f124mr22630127pfb.238.1548691689317; Mon, 28 Jan 2019 08:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691689; cv=none; d=google.com; s=arc-20160816; b=vvMrg2MmRA+YJ447sHX9jpv/jQEo2Q3jPCMtBRcqPlVwU3zQHWW2hvNQgJ1MIkqr8n wd7MEK4NiAg80XympmV9PAXc/2YZB28NSu/dAttE+pfBayLaTBTfCRs/DAZ9iB/eCTRi gsO/jgVMve9hzQcTx3LVLdVGAMmNR2nNBYzAKhNWLwF8LiZa6266MzrsatkQjssAf/s+ Zattdfm/bf5/l+wO21EldQq+qGSG9q6681YIogs0PcOjswW1y30VA2Ke0OJVR3BO1JB0 s5l+g9OlJuxIYddMbDJAY80zd+wMgJslIVdX6pl4qB8ijiSwEWiRHiaZdytAgmMrDQSB A73w== 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=XZLN4cev+Xxx1d/OtvCs1B+dUS/OmLV3nRXW36UsqT4=; b=IaU12L8F6kaEPFMgG5kDsylehiVybVi3ScCQKwLYKWdvaXdJLMkVidUtYVIKiQ9Vs7 u5esI1iliPEOkD+6hlW4dxZvKx62qxegNAFcjUtQz6l45yKGblCOwRq7RQLlYLQNaH7g gjRSLlyv79Zw7BK+fUBTl/+XbjxUblK2QjpKI/sl1WiFJZSmqvaP9j1PP4PXw8WwMUg9 3ilfiSdXFJzcp/0R5jWhjq98g/+2+4RUSPEZThrNS/gF2cEXpCBbcuHsk21OqHaDYMyA IWAj093oNj0Sax2+DrYKVI60twgeFY13ZuDH2DPfDaXXmIDRJBmNseDhR9UZdsOnUNIX +fmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aYf4XoV+; 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 k5si31919008pfj.153.2019.01.28.08.07.53; Mon, 28 Jan 2019 08:08:09 -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=aYf4XoV+; 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 S1732073AbfA1QGp (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:55922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbfA1QGk (ORCPT ); Mon, 28 Jan 2019 11:06:40 -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 BF12C2147A; Mon, 28 Jan 2019 16:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691599; bh=rSD6YiDphKOV7ssRm3rD1xARt4BqaXxvUmP1ln7uCNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aYf4XoV+bECAWahEuqQIfVCsxp6Xwfbxqxcd+Q3kDNpdrbup1+avLKzjBuqwk4tAT XoKHdCgeqfwavjjGm9hZXVpTxygKKQQ3vqK9WMka1pwyB30dqzN6QgruwFNC27PXE6 +5edOrfBAYMO38TnD1ivO0PcZOXrrwvSfCfZ0Be4= 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 155/258] mmc: sdhci-of-esdhc: Fix timeout checks Date: Mon, 28 Jan 2019 10:57:41 -0500 Message-Id: <20190128155924.51521-155-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 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 9cb7554a463d..a7bf8515116f 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -526,8 +526,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; @@ -591,8 +595,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