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: 201655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp532742dyb; Thu, 15 Feb 2024 08:57:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0FRxnc1qYWVYtdjzOGJKR0IPltucCbvPCmEk45IiCiW2UWtiTmYn7wrWU5MT2h0laMed7kI6iMMGbrTb8NBMAAUg6lw== X-Google-Smtp-Source: AGHT+IFKzmCjJ9o/g27V92W8VDozRDD335AE4B8F+jF0oc1OlKUb+Wzrmu57E8eFY0MSOtKYBwUo X-Received: by 2002:a62:c312:0:b0:6e1:338d:e01c with SMTP id v18-20020a62c312000000b006e1338de01cmr557671pfg.1.1708016241880; Thu, 15 Feb 2024 08:57:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708016241; cv=pass; d=google.com; s=arc-20160816; b=WQJdgdd02BLxdjM+IqhvsMulQHzFWJmd6dS/mS2KziUXA5lO0OeA0Yus2o4Rbsbskz IoflXiXJLn57rDfGRSWum0nCSGpfvh14amuNn2eDZd7WYd/JUyEAFSup19zMamO5aBD9 vAePhXsW87hoU6DS4fG9pe0kkMgZ3sJYNBCHLIJMDrrul4lMcC8unuDVVdxmaX1Q6umh u+p6xUa1+l8WTs4o+tnX9qwhwT441pEhO0S2hLG1NbMide3h6LmgfuKmj3YbwcbpTJV3 vzcXnKARo5u01CNW7Z1zoQeikE2hxxmxKBkDz8Ww4syvk+Xrk41IHgFOz7NsC4/foL9h swJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=5W2sSL7KXTa75TLd1u49SS6u6N4gKtVqD7M4RKYa2bU=; fh=5JSnMO1qLgeVtLVJilSQcFnAcZn2MWLSM3RnsAdOnEU=; b=GzMWwu6EwKFKX028+dYMYkOy8jedWtHnvFObjxHA7iITrsxjxlR6Pg16Qi9NcLSQJU kRToXU06MGTLZCbz+QaQX7QKc2W8uQAeMwZ8sLOyr9fMCUscqM2QkmoFYazRBBXCd9UX 9SA2bVlGhe6pV5B4uYEysXn9t8sLwKy2tjbXDNm5eYyeA15pf9uT19VtM3cYgQgW0TTR WfJ5b33ZHK+G8RFsl3KgAP3jpA6jZP69BrNeh+wPQsSIcEdRbXZu7mA6MrF3fTkmcgKR M3zkdlsi2RzELE/vwJlgB4znBSTwdj7EOzTB5ojKwoMB032Hu4wHI1voDZqGJp5hLlKM +Yhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dIxHuc+q; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67346-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67346-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i124-20020a62c182000000b006e0914b020fsi1384756pfg.38.2024.02.15.08.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 08:57:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67346-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=dIxHuc+q; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-67346-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67346-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id DED95285250 for ; Thu, 15 Feb 2024 16:56:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC1BF13EFE4; Thu, 15 Feb 2024 16:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="dIxHuc+q" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D18DA13A88D; Thu, 15 Feb 2024 16:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015968; cv=none; b=jEBEkaUbUNNu5zLp07WOj6yslSF/CfbD6wxEOEDJaFdjlKMERwsCNttyDl6PKWQLISkXAMId1+k2Ho+uEhiPvk1JyGxupDKMXvw4Hw3/GQ/ZTPvMQK+O78ex4G1zDxZTGsDNPJElS0WYJkDljucc/bQR+/N4qFqO4+ZJrHTCF8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708015968; c=relaxed/simple; bh=5i1uaFrLcLf+bPBJaKLNupRCnV7d8Nq2qANsFmWqLIY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tnYbG6C4H6lan7lchSKQXjLk2+jEYJEdwJJkA4d/s7xl8a1m5MSJSIIAUUE36TlrCcso100BUmP4CrF2KvCPa0bOta8xH59FEos0/acET1+I+OTbDM0QK7EIkkx7dLw+rM6cJ7ElvISwnll9DPid5lnREJn1jEmL+QO0WU7swqA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=dIxHuc+q; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790984838847983335 X-GMAIL-MSGID: 1790984838847983335 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;