Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp893874ybt; Fri, 19 Jun 2020 17:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLWccs0SjTFo5ddxHBIFvHp7MKWn2vNAXOHnlMsAQ/NAeJSS0OFVlfizAOoNZ6QXbij3MW X-Received: by 2002:aa7:dc50:: with SMTP id g16mr6082127edu.318.1592612078866; Fri, 19 Jun 2020 17:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592612078; cv=none; d=google.com; s=arc-20160816; b=ufSDRKidmpSt53NsUBCCHiHfI/QSBTYygmcyGEmVET/dQp6SbxO7WgdOBSiV+eO2DZ y1miudY4Ugk5w6gx4V4asBCMYb75J8RclddF6aZPms8de3W5werz2lEKHRGRSw5VM3e8 AZHc008CfY1lWVM4yLfLNTkA5s5aCbESzX2UvQmJKHrdAwzpvdl23khFwEx+inK9I/xo tiqKhaSDZ6v+wFwArN7PSJoZwmEKe3aYK50sSJhuy3qI3aYDw2ntCah69eRbU2iyJT8L 0+vOAuBl5fByhANqQUnj+gAEEUuP92yeM+2h8FN94U7FeTZu+zN06AYP9dX9g/KYj6BU R1pQ== 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=LJfdAbaERRMWU+25WM2M9SidexU0b/8Um8pAUJpfa4k=; b=z8Fh2hkic4wbfvvuDLhWl/LJFLHALpu2lmy/Jl2/kRgYSyjbsgTnh34ftYzKk7SO50 hgEb9/QXK0pV39b6Rzevl6jqlZOHsoJ/ooGx4PeqbjgKFucs/hPIDxpgMJ8YtAu2oZXY JA6kYVV8G4I/sDMNWaX0XQPEotAEVfrZCFKs5GSlUt04dTK+LHAOkD4zNI3u87FeLM7I SCd0WHauho8RV1JPnWYCRLQrDCh91g1eb186DfuAqnlt4EkFZdN62dQb5nq+zRuzr7tM rqoLS5gCTRRScj+6hCyaPdMqiwzuuQ6Vg0K1Ci2TryvQbtbw0Y/wqtfRLcOSreU4dUg6 fTDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f5Lzi1vD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm10si4709683ejb.507.2020.06.19.17.14.16; Fri, 19 Jun 2020 17:14:38 -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=@kernel.org header.s=default header.b=f5Lzi1vD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393848AbgFSPb5 (ORCPT + 99 others); Fri, 19 Jun 2020 11:31:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404874AbgFSPbq (ORCPT ); Fri, 19 Jun 2020 11:31:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 8CBD220786; Fri, 19 Jun 2020 15:31:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580706; bh=cnbGbbHSMj46Cwtqzz0LD7AuWiPIvqCAFyoE1CsdBqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f5Lzi1vDltnijLErXT1XjaDzlGZgak7xO4TVaR7YT3Sno2a9R2akkZaLZQtC/50TR q13VkRn7IYcmi41rOdrrWy6z+zZJ3t+PvFCvJpiI+9S+ZaxSRd0bNvZh7T2P2Q+keE jsFU8jut4YeIECqI0loNmh3tc+DJmz1MC5KQYa10= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tudor Ambarus , Boris Brezillon , Miquel Raynal Subject: [PATCH 5.7 352/376] mtd: rawnand: Fix nand_gpio_waitrdy() Date: Fri, 19 Jun 2020 16:34:30 +0200 Message-Id: <20200619141726.982950815@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Boris Brezillon commit e45a4b652dbd2f8b5a3b8e97e89f602a58cb28aa upstream. Mimic what's done in nand_soft_waitrdy() and add one to the jiffies timeout so we don't end up waiting less than actually required. Reported-by: Tudor Ambarus Fixes: b0e137ad24b6c ("mtd: rawnand: Provide helper for polling GPIO R/B pin") Cc: Signed-off-by: Boris Brezillon Reviewed-by: Tudor Ambarus Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200518155237.297549-1-boris.brezillon@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/raw/nand_base.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -736,8 +736,14 @@ EXPORT_SYMBOL_GPL(nand_soft_waitrdy); int nand_gpio_waitrdy(struct nand_chip *chip, struct gpio_desc *gpiod, unsigned long timeout_ms) { - /* Wait until R/B pin indicates chip is ready or timeout occurs */ - timeout_ms = jiffies + msecs_to_jiffies(timeout_ms); + + /* + * Wait until R/B pin indicates chip is ready or timeout occurs. + * +1 below is necessary because if we are now in the last fraction + * of jiffy and msecs_to_jiffies is 1 then we will wait only that + * small jiffy fraction - possibly leading to false timeout. + */ + timeout_ms = jiffies + msecs_to_jiffies(timeout_ms) + 1; do { if (gpiod_get_value_cansleep(gpiod)) return 0;