Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3632533imu; Mon, 28 Jan 2019 08:09:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UqNP73Hp+4FNLArdZYciH8MpckP9bvbvazfD2iFZdYwpiWokobTAtxZ7fP9Ov+N0RGbKW X-Received: by 2002:a62:9657:: with SMTP id c84mr23009893pfe.77.1548691765322; Mon, 28 Jan 2019 08:09:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548691765; cv=none; d=google.com; s=arc-20160816; b=nUwa44YMTDzki7KEdCrVsW+ctL3S/v+/+Nougw5v31g/IrarLKt/Lwf94iQD3gL5zP afftKbgkfOSX/pX5bJWI4+WJP4b+RJlVaVEPRR8a/G4EiSb4/t/unnWx+lYXoSQ9SwQa 4jfBiSZELrkGvNqxD6oIxAT/HGB88Y8t5DERiyjTuVqlMkRFB0nRM7q+skiXVcVbT0zj CwVLfN6xPJFkzSwayZ1V9Zb/qItXM9o0ts0ZecMauS2hjp85zKkTShFWB9F4eXXDCN0c UM8W71xPHpp47LD/c0/tgMOPBWJoPfr0oFBpzJzwuJsKsDWUyKy9s8g4z9XEAeAhikpW 8sPg== 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=fpE52xRktHo1xbGB0Wklj4RDvQoJhJw8/bZUThsjHvk=; b=ctTD7QeJmFPsG02xlXViZVcdy0dbKm99gXm7k+IRd6bhk3TE7DyIG6acAQi9C8d2sd F8CvpugswfcgbVrTeoJDOjgIGY+ZDKL9EdZrhwTD/8nRpBansT7OsUvWHpxYvr43E4fM fEMxs01axIwmg1wY265NhbVvxdB9PzeHdR+GqPT1GmttJ7576kHalRF98JPrnCyLf0ov mycAWb0UVYvVN2msHLqW0NAPhpk55wwgJumUvkl5mDm9k7DCKavHSbNs5eLXVnQZv+AR fDrzpKmC1GigUAUPNWT2qTSxrU4kkgyq7kxHW6TsJkjGHAe9+8z2yAD0I1RygOb6+Deg z8uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SIHNo8ex; 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 1si33508696plp.114.2019.01.28.08.09.09; Mon, 28 Jan 2019 08:09: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=SIHNo8ex; 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 S1732100AbfA1QGz (ORCPT + 99 others); Mon, 28 Jan 2019 11:06:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:56186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732066AbfA1QGo (ORCPT ); Mon, 28 Jan 2019 11:06:44 -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 5A9F12147A; Mon, 28 Jan 2019 16:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691604; bh=sSY7qvCTRrQZbN9Sxty38CmBO0GJYULe5V86bm+ByOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SIHNo8exF1DTELjXFUokDNzp5MlVrwmlmLIC/SY7pfAPf6RYVANKST3Mu3R0jXX1t RLojOqqxDF1HHRKM5+C2Ua29jGAuW9JhGxa67E36cu9ZNKV8g+ZlNJFxRQk2yxrVM/ 14XrfcFhqlD/mRlzcQdxzRYSmV7hWHvz4T7beBlQ= 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 157/258] mmc: sdhci-xenon: Fix timeout checks Date: Mon, 28 Jan 2019 10:57:43 -0500 Message-Id: <20190128155924.51521-157-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 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 c335052d0c02..caccedc836dc 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