From patchwork Wed Mar 6 17:59:26 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: 13584361 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 1457BC54E41 for ; Wed, 6 Mar 2024 18:00:05 +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=QvXQlgBX3vo7D2fukqFr2dBWZ02+YCt0UMdrtrSMzMg=; b=2eYjETJ6qzH0ik 72zA4PhKzsEMt9IMW5jdvRrIb/7aOd6N4RhyQEPbgjUwgOcoPQ2FgyZizuprVpxf4CxKRMa2P+h8M z6RJvDf4GlaPftWiDuWVL5Is8tXwBeuLOq5w4ZFsrxVG7SuUt3CiVi8FzNusIwBdlqRl0V1nxx7ns NdQ+3f0ngHEaRjtSECr3Qptnx8IeNHDabquUNEAPTRK0O7o7/8GPw0PZqb3U08mQ2Ao7pwfRZ+X3W SQMD2HplL2sbfKqS/S79QygxcgmcI7UdS2VdevgiysB9yKyJoNP4BsUMmYHP7DwjUME9ernFTICX/ qMFSboSLUVXlhxrW7sfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhvYU-00000001JJH-0CNL; Wed, 06 Mar 2024 17:59:50 +0000 Received: from relay2-d.mail.gandi.net ([217.70.183.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhvY8-00000001J5q-3VGq for linux-arm-kernel@lists.infradead.org; Wed, 06 Mar 2024 17:59:31 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id CC2C040004; Wed, 6 Mar 2024 17:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1709747967; 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=QRiNeZgV6eBZpUWar1JZGPdnG7GRdzz01xQrVaFgykE=; b=Ji3OMBF9sh5AUUIrSf+SHwWCBVQbHN2yjqFDrGf6bsfe4EZlx1MqJwUDbZDoEoXUvMVcrs O4RXeBdjOeBcahOsp+5dYJo97Wqpk3SPjmJFwICXVdZf/vPETQHe7Ah8LD+ztGN7lc8aIt 5eVmemBd8Je7K4rKPG85K5oBjf0MlcLmxvNbX3FYTP1bvqEKsDZS6DC6KbTcTWdUk4UY3H +IAbuJuf8UZcEc4IkpXEzcyZIhP0PRf7c/Ex8O64/fSXv1qkziKtmBVk5VkCP90fX5K9B9 Hrugjol1r02k+29Emtr9BnQluYeemmvX2hIACSB3eLHogye9H5/I210WTsB6jQ== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Wed, 06 Mar 2024 18:59:26 +0100 Subject: [PATCH v3 06/11] i2c: nomadik: replace jiffies by ktime for FIFO flushing timeout MIME-Version: 1.0 Message-Id: <20240306-mbly-i2c-v3-6-605f866aa4ec@bootlin.com> References: <20240306-mbly-i2c-v3-0-605f866aa4ec@bootlin.com> In-Reply-To: <20240306-mbly-i2c-v3-0-605f866aa4ec@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?= , Wolfram Sang X-Mailer: b4 0.13.0 X-GND-Sasl: theo.lebrun@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_095929_125708_728B3557 X-CRM114-Status: GOOD ( 12.51 ) 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. Reviewed-by: Linus Walleij Reviewed-by: Wolfram Sang Reviewed-by: Andi Shyti Signed-off-by: Théo Lebrun --- 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 2ba7d082e205..020beb8ffa17 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -225,8 +225,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 @@ -238,9 +238,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;