Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2713684pxv; Sun, 11 Jul 2021 23:33:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3y/AW1lu15V+AvUj/8Bu7XR1QrMKBQ6lDOfGMdS8qLop3voiQzieWdFIKVM84RzArowcr X-Received: by 2002:aa7:d413:: with SMTP id z19mr64010548edq.37.1626071625272; Sun, 11 Jul 2021 23:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626071625; cv=none; d=google.com; s=arc-20160816; b=JwU6c8frh+4zGHvqBgN0gGnZDVMtQJkLuTk2qfBOZxRr+vEDKh7/+m1bKlDMLs4yxW sv/DtTf+hrN/vG2BYRXAymRXoLaxOnex4dTmfz75JoYG+eoE1ydT2FhrYg/U2w/pKPl4 M4S47TLokwQErDmqP8uoTt0A6IWitqjcYk7A2ze2H8MYGGMC1g+1blzl1uX0hpMAiryv e+eRIYCFb0aU0x/cV386REqSMuFUC5z9361e3RwKWYJnlO0iXDTTU1UJx/cElEbUdd4L u+scpnksYfKdqJ6mMmp+XRPkZ/GFpxqRQhFZwY3Hs1Z/gayFb6QqcimLs/t1sR9weEAn rkOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K5z2JRmlFJ+Qq6hE5Mgf6qIJrKmCqWLPZahqWOQRDQQ=; b=ER+OX4RR7sQTvraJjh2eqZ2q/JHIP8soRglBOGMEaQgMep7ET3qZ1k3BmssTE2sYWi 58wN3lGguRGdy9qkUt87pX5/ZE1BlKkI3P1oU1uxn5O2VfV46pbe6rrgIvFSIR39QOmL I1lxBRuPz/yl4/3jgPcwqjuiwW1LVP9sTvRWZwnJ2/OmUt7x7Vt5uLD5nCCYnQ3rtr2/ q8GHx491V4RWBnQ+lx4yDIZtobVs15V45kDopOOI2shHnXUlBVG1l36pQjcdPJA4bhkg jcgnx7wFwmWnVmCQudDGUAmdDTva7NcClLfEEf1/Iko6SUcYSvAU75WZxwiBg4qlLj72 p0Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0i00iIIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mm28si5612029ejb.598.2021.07.11.23.33.22; Sun, 11 Jul 2021 23:33:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0i00iIIp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235018AbhGLGfM (ORCPT + 99 others); Mon, 12 Jul 2021 02:35:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:48092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235930AbhGLG3j (ORCPT ); Mon, 12 Jul 2021 02:29:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6525E6121F; Mon, 12 Jul 2021 06:26:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071174; bh=IqQjlhPp88JtlnZtyQJfzcmZZPoxly7FSV8htWXjdhE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0i00iIIp+E887FNkeNSuvBwwsq7Xolt50e29p/sRPvGXQ64it+kdE1pPxcc4e4AhV n1Z+TY4nyP2Vs1zh5zzFcWhN983luZ8Rb0DURxBQacmpITOux7i8qJe8ZujmBYvc3M Y2M+SvY63uSmgN14M/OWlfGsrYkOnSW2AwYPtvlM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joachim Fenkes , Joel Stanley , Sasha Levin Subject: [PATCH 5.4 299/348] fsi/sbefifo: Fix reset timeout Date: Mon, 12 Jul 2021 08:11:23 +0200 Message-Id: <20210712060743.293843699@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joachim Fenkes [ Upstream commit 9ab1428dfe2c66b51e0b41337cd0164da0ab6080 ] On BMCs with lower timer resolution than 1ms, msleep(1) will take way longer than 1ms, so looping 10k times won't wait for 10s but significantly longer. Fix this by using jiffies like the rest of the code. Fixes: 9f4a8a2d7f9d ("fsi/sbefifo: Add driver for the SBE FIFO") Signed-off-by: Joachim Fenkes Link: https://lore.kernel.org/r/20200724071518.430515-3-joel@jms.id.au Signed-off-by: Joel Stanley Signed-off-by: Sasha Levin --- drivers/fsi/fsi-sbefifo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index 655b45c1f6ba..c8ccc99e214f 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -325,7 +325,8 @@ static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word) static int sbefifo_request_reset(struct sbefifo *sbefifo) { struct device *dev = &sbefifo->fsi_dev->dev; - u32 status, timeout; + unsigned long end_time; + u32 status; int rc; dev_dbg(dev, "Requesting FIFO reset\n"); @@ -341,7 +342,8 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo) } /* Wait for it to complete */ - for (timeout = 0; timeout < SBEFIFO_RESET_TIMEOUT; timeout++) { + end_time = jiffies + msecs_to_jiffies(SBEFIFO_RESET_TIMEOUT); + while (!time_after(jiffies, end_time)) { rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status); if (rc) { dev_err(dev, "Failed to read UP fifo status during reset" @@ -355,7 +357,7 @@ static int sbefifo_request_reset(struct sbefifo *sbefifo) return 0; } - msleep(1); + cond_resched(); } dev_err(dev, "FIFO reset timed out\n"); -- 2.30.2