linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>,
	 Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Jonas Jelonek <jelonek.jonas@gmail.com>,
	 Harshal Gohel <hg@simonwunderlich.de>,
	 Simon Wunderlich <sw@simonwunderlich.de>,
	 Sven Eckelmann <sven@narfation.org>,
	stable@vger.kernel.org
Subject: [PATCH v2 2/4] i2c: rtl9300: Increase timeout for transfer polling
Date: Sun, 03 Aug 2025 18:54:39 +0200	[thread overview]
Message-ID: <20250803-i2c-rtl9300-multi-byte-v2-2-9b7b759fe2b6@narfation.org> (raw)
In-Reply-To: <20250803-i2c-rtl9300-multi-byte-v2-0-9b7b759fe2b6@narfation.org>

The timeout for transfers was only set to 2ms. Because of this relatively
low limit, 12-byte read operations to the frontend MCU of a RTL8239 POE PSE
chip cluster was consistently resulting in a timeout.

The original OpenWrt downstream driver [1] was not using any timeout limit
at all. This is also possible by setting the timeout_us parameter of
regmap_read_poll_timeout() to 0. But since the driver currently is
implements the ETIMEDOUT error, it is more sensible to increase the timeout
in such a way that the communication with the (quite common) Realtek
I2C-connected POE management solution is possible.

[1] https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/realtek/files-6.12/drivers/i2c/busses/i2c-rtl9300.c;h=c4d973195ef39dc56d6207e665d279745525fcac#l202

Cc: <stable@vger.kernel.org>
Fixes: c366be720235 ("i2c: Add driver for the RTL9300 I2C controller")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 drivers/i2c/busses/i2c-rtl9300.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-rtl9300.c b/drivers/i2c/busses/i2c-rtl9300.c
index 1b3cbe3ea84a4fa480c5c00438eecc551d047348..a10e5e6e00075fabb8906d56f09f5b9141fbc06e 100644
--- a/drivers/i2c/busses/i2c-rtl9300.c
+++ b/drivers/i2c/busses/i2c-rtl9300.c
@@ -178,7 +178,7 @@ static int rtl9300_i2c_execute_xfer(struct rtl9300_i2c *i2c, char read_write,
 		return ret;
 
 	ret = regmap_read_poll_timeout(i2c->regmap, i2c->reg_base + RTL9300_I2C_MST_CTRL1,
-				       val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 2000);
+				       val, !(val & RTL9300_I2C_MST_CTRL1_I2C_TRIG), 100, 100000);
 	if (ret)
 		return ret;
 

-- 
2.47.2


  parent reply	other threads:[~2025-08-03 16:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-03 16:54 [PATCH v2 0/4] i2c: rtl9300: Fix multi-byte I2C operations Sven Eckelmann
2025-08-03 16:54 ` [PATCH v2 1/4] i2c: rtl9300: Fix multi-byte I2C write Sven Eckelmann
2025-08-03 16:54 ` Sven Eckelmann [this message]
2025-08-03 16:54 ` [PATCH v2 3/4] i2c: rtl9300: Add missing count byte for SMBus Block Ops Sven Eckelmann
2025-08-03 22:38   ` Chris Packham
2025-08-03 16:54 ` [PATCH v2 4/4] i2c: rtl9300: Implement I2C block read and write Sven Eckelmann
2025-08-03 22:39 ` [PATCH v2 0/4] i2c: rtl9300: Fix multi-byte I2C operations Chris Packham
2025-08-04  8:35   ` Sven Eckelmann
2025-08-04 20:45     ` Chris Packham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250803-i2c-rtl9300-multi-byte-v2-2-9b7b759fe2b6@narfation.org \
    --to=sven@narfation.org \
    --cc=andi.shyti@kernel.org \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=hg@simonwunderlich.de \
    --cc=jelonek.jonas@gmail.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).