From patchwork Thu Feb 15 16:52:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Th=C3=A9o_Lebrun?= X-Patchwork-Id: 13558852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A5E6C48BC4 for ; Thu, 15 Feb 2024 16:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=l5uB4jh9ot7H0NGpFikSLPWgZWwRDut+gQAWzizJQFg=; b=eHOg/vRrHlSJqM FCcLGkVQbOiK1ZDHLQzdoQ5JCHQGPHVfmIf3GXXpW5Z2JrccSFy2V9bICUeJcfhnvtPWZcF4CByoQ xbNAj78dvTwanruNTK2ajv8ZEaga+XzqNAR2veh6tLSP2ashuzepdNmu1fYkfapSisBiLQZb6XJA3 IDyu62cqSZNwPGngG4oj9HXz0imrmAcWqI282rzklRf6QA0p5NvKuOm2MaxxHyvvETqdkK3k1K8Wn P6zyFbulzgxBUMHnZYaMsiSm3a+p3/VG80QsRMsITjRoYhQMrh4dsrORbE4CP64NFzm2Muqh1rgdK J+sk4ALEUFoqYupZgohA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1raezy-0000000H49L-2dC4; Thu, 15 Feb 2024 16:54:10 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1raeyW-0000000H3H2-1pgt for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 16:52:46 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 5E7D8E001B; Thu, 15 Feb 2024 16:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1708015959; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5W2sSL7KXTa75TLd1u49SS6u6N4gKtVqD7M4RKYa2bU=; b=dIxHuc+q76e9Fo3tmpFDzwS3cGp4P0feO83Vi9KUPUUJCSaPlNMCIY0cNUIxKQr0bIc1Sn bXtUYDJs4Y+ZW9cILDmc4atXws9VkQ82t2IxUVlbTKGbdUXLmqZ9M96uzRZk753owpssG6 kAqWRvnh7b9Atpw6YwozbTkGZ3T5i9QZ3QriHJ19lIElgeJwdsey20ZbOp3q4FTsXwpXUB YiJ1gUavaooMS4VFu7kVZAfrPyAB5PDK+pcKQmVsFrUoYeyPlZpcfH+/aWhOUwJOn3eLwW ZeZVhbkdNQr2PLYoWVTJjMIVw0A5yDRWukutqJHs+QbSWnSRZBmlsOT7eVQICw== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Thu, 15 Feb 2024 17:52:15 +0100 Subject: [PATCH 08/13] i2c: nomadik: replace jiffies by ktime for FIFO flushing timeout MIME-Version: 1.0 Message-Id: <20240215-mbly-i2c-v1-8-19a336e91dca@bootlin.com> References: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> In-Reply-To: <20240215-mbly-i2c-v1-0-19a336e91dca@bootlin.com> To: Linus Walleij , Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer Cc: linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, Gregory Clement , Vladimir Kondratiev , Thomas Petazzoni , Tawfik Bayouk , =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_085240_703184_66747968 X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The FIFO flush function uses a jiffies amount to detect timeouts as the flushing is async. Replace with ktime to get more accurate precision and support short timeouts. Signed-off-by: Théo Lebrun Reviewed-by: Linus Walleij --- drivers/i2c/busses/i2c-nomadik.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index e68b8e0d7919..afd54999bbbb 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -219,8 +219,8 @@ static inline void i2c_clr_bit(void __iomem *reg, u32 mask) static int flush_i2c_fifo(struct nmk_i2c_dev *priv) { #define LOOP_ATTEMPTS 10 + ktime_t timeout; int i; - unsigned long timeout; /* * flush the transmit and receive FIFO. The flushing @@ -232,9 +232,9 @@ static int flush_i2c_fifo(struct nmk_i2c_dev *priv) writel((I2C_CR_FTX | I2C_CR_FRX), priv->virtbase + I2C_CR); for (i = 0; i < LOOP_ATTEMPTS; i++) { - timeout = jiffies + priv->adap.timeout; + timeout = ktime_add_us(ktime_get(), priv->timeout_usecs); - while (!time_after(jiffies, timeout)) { + while (ktime_after(timeout, ktime_get())) { if ((readl(priv->virtbase + I2C_CR) & (I2C_CR_FTX | I2C_CR_FRX)) == 0) return 0;