From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 55D4F2D47E8; Wed, 19 Nov 2025 15:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564751; cv=none; b=AuupqZfgRNhwtT4Q2mrKfWs+hDveHyQOxAC/WINQ03sPJ6q30Oq1NupMKhNpRQYctlAj7MsWLco5kGnX49nFcni6Xc0wxVhwZa4ZqDddsdurO13AaRNpZLdIB1aOMVn4CgY2ThcaGQOsrGhSSlSk/kpJGVdG0Zg1lckPFMBbKlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564751; c=relaxed/simple; bh=efvmwvyH51DRySXYvY+dRFfd2BHtm2P6hLkC1+Fl7/U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kk7NzGPxu7BiIi+wjg9QlO+Okj2b47NEk3lrqipWz8Ufa6CxfKpzGC7OKGOiQ+CzojfdAN6ESnn/1Mojm2T3SXFW+1mC6GFYy6XFl3F7Ayzyizq/3loWcs0DE4rCk7r1KDd4JVhNOem9vfiq4+Uy3hh031P7ReLaweWi+PgFLHY= 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=YHUUReFr; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="YHUUReFr" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id BFE941A1BBC; Wed, 19 Nov 2025 15:05:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 94A1E60699; Wed, 19 Nov 2025 15:05:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6EE2A10371A72; Wed, 19 Nov 2025 16:05:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564746; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=uP7CKXUyQl6rzRBAXqJUK1ve75kUt2tdvnwbigkav/k=; b=YHUUReFrys4JSwmM6rrTCmyNmvQxORzHzmUkZRzu8v5XgrKAYqOf3YULOH0modRVPaDo1r AJfxOq+j/K/RhJb6btQ8ZU7VN8K5rpTU6iCSnHkV0PUoiGRvsh+MPb60MGOXjMKThsC5g+ 99vWYMdMCLr9S+vjpY6XMmN8LkqnkBUn3KgtJf85pjMgAppSw0bJ+x0ABL7pqX5nlYZOHE Ktx3UEtuZV8vZ14sBxTUFvjRn+FEav7c8Loqq0BM89LS8qth7gS4HrWZginsE8NLIFvULG x1k31LyHfdSWbnTk8dCp2HAOTCNZEwMt+2chhbkq1NXxCwOW8VBj2JrK2xNI+A== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:30 +0100 Subject: [PATCH v3 1/7] dt-bindings: i2c: dw: Add Mobileye I2C controllers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-1-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add compatible string for the DesignWare-based I2C controllers present in Mobileye Eyeq6Lplus SoC, with a fallback to the default compatible. The same controllers are also present in the EyeQ7H, so add a compatible for those with a fallback to the Eyeq6Lplus compatible. Signed-off-by: Beno=C3=AEt Monin Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml= b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml index d904191bb0c6..914200188809 100644 --- a/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml +++ b/Documentation/devicetree/bindings/i2c/snps,designware-i2c.yaml @@ -34,8 +34,15 @@ properties: - const: snps,designware-i2c - description: Baikal-T1 SoC System I2C controller const: baikal,bt1-sys-i2c + - description: Mobileye EyeQ DesignWare I2C controller + items: + - enum: + - mobileye,eyeq7h-i2c + - const: mobileye,eyeq6lplus-i2c + - const: snps,designware-i2c - items: - enum: + - mobileye,eyeq6lplus-i2c - mscc,ocelot-i2c - sophgo,sg2044-i2c - thead,th1520-i2c --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 E4DCA366DD0 for ; Wed, 19 Nov 2025 15:05:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564753; cv=none; b=LbOtZa90fq16bzpOTfngMcWtaxt6p5fNlzP/0BnpwC49SfI05bB0rsuVp/TLHx/w/5RQme0I6sBF80vgB2of7phUaRi34ypLxhZeRfk0vioq57aMmARtHD7rFUPtHlK9g80VCT60TfmmH9qoUGC6y6tyLTQWCdEYWp1XfAvJdPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564753; c=relaxed/simple; bh=WKh+pejM9hfHa2BSnJjsrQaHkPrQsIOlT7b7pTmVq2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EjS/6Kvilzti0+N2eBe7GbhdjM9hE3DzLttqwCAZ6PMevgkmL8E5bJwsopQN+HvZ4Z3LV/tuJrUj7z2+Rzy1Iy2OrZWGaVImbqpzOY64z59PVmB74oL13TtIDdomUPk6CswvqxKrjxStaSIwLs1RxpHYlU2WBEYw5h7I4DTrHIE= 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=qAk4mt8c; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qAk4mt8c" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 1EFA14E417A7; Wed, 19 Nov 2025 15:05:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E6ACA60699; Wed, 19 Nov 2025 15:05:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A430B10371A79; Wed, 19 Nov 2025 16:05:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564748; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=KEDzDzfEfee6+CFpZ6uK6nefkuW8cBA73Z7esFgKm9I=; b=qAk4mt8cXTcl53hszfw619krrvzBKq7zO7yxlzsBsWZtcSpDhnBKLckH15XrMozi0CJzrI rS7q6knt8+xU6qDpPqHuUFel/XKw0ZCI4cft3flbnPCQrEKHB3NtgtMjffpJN5EoHWSOsK +9xLGNylNgNcFLz4R17rdw4opAjOayGZjHYf0CX7nzBiK/2wSuBuwTFXfdFLc3MB3F/+eg i4ErorLo+1CWXdbcGGBUKqtYgs1xEGHC9oLI8g4wfk4jsImtmHNi13VcSHaQPAvPBC5kzZ V56dQoTFiGDCMsaQzpkNtP8yoQm6B2FnhGYbwK72FPn/rwk7OQpmzQNVQRq4zQ== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:31 +0100 Subject: [PATCH v3 2/7] i2c: designware: Optimize flag reading in i2c_dw_read() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-2-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Optimize the i2c_dw_read() function by reading the message flags only once per message, rather than for every byte. The message flags are accessed both in the outer loop and the inner loop, so move the declaration of the local flags variable to the outer loop. The message index is only modified by the outer loop, so reading the flags in the inner loop was always getting the same value. Signed-off-by: Beno=C3=AEt Monin Reviewed-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-master.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index 41e9b5ecad20..ec4fc2708d03 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -586,11 +586,12 @@ i2c_dw_read(struct dw_i2c_dev *dev) unsigned int rx_valid; =20 for (; dev->msg_read_idx < dev->msgs_num; dev->msg_read_idx++) { + u32 flags =3D msgs[dev->msg_read_idx].flags; unsigned int tmp; u32 len; u8 *buf; =20 - if (!(msgs[dev->msg_read_idx].flags & I2C_M_RD)) + if (!(flags & I2C_M_RD)) continue; =20 if (!(dev->status & STATUS_READ_IN_PROGRESS)) { @@ -604,8 +605,6 @@ i2c_dw_read(struct dw_i2c_dev *dev) regmap_read(dev->map, DW_IC_RXFLR, &rx_valid); =20 for (; len > 0 && rx_valid > 0; len--, rx_valid--) { - u32 flags =3D msgs[dev->msg_read_idx].flags; - regmap_read(dev->map, DW_IC_DATA_CMD, &tmp); tmp &=3D DW_IC_DATA_CMD_DAT; /* Ensure length byte is a valid value */ --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 5A04936C0BF for ; Wed, 19 Nov 2025 15:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564756; cv=none; b=PwLvT+ukbqeHVIRYzNp0IoQvTDAbDZjI7SlQcR81P8ZcmxIiCGDSONZiAIGUaPPVkE5iC00w7ARktL2awPJr3RmPNyDxB9ccmEpX+bAfkKmbkkPZftqbupaSMhSFkbDRWfczBMYah/UY565ykkS4OU9elEFSae+UfOWMaZ8WM88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564756; c=relaxed/simple; bh=SQ44A0XbMBVMUX2F/XWXBVZp+MXlViOti9RGs3xJvno=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E25E1LIrL9zzAqVTl3Txl4LDENAvo/c6ZBsc2pfXrf9AXdg1Ey+5FaSoMhPReq5Fjpo8faPIBpc5ZnUZAUUPKP5KPwtSYIi1Dj0P5W9TWk/o9Z5n/86pic3AgeA1wHFtpla2w7n1YPEMvzkp66aY3PfCLCI4soC0ArTiM6YfzVU= 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=VrTfYX2N; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="VrTfYX2N" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id BDC4AC1118E; Wed, 19 Nov 2025 15:05:30 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 032F660699; Wed, 19 Nov 2025 15:05:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id DED5210371A77; Wed, 19 Nov 2025 16:05:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564751; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=L+qA8S4EJP9fZkZtJYvgOIOwnRJEyUP1zgCHLfAmpE4=; b=VrTfYX2N++b/UnMVPlHRzZLAT4dW7wcJmjMRISFE9x/h3hCLXPK76btm1s10oj1Oq8U8T1 hU+M3ac0XsnAkf9OUoZ9Effr5RBxEHaScD4TcOT2dgpQjF5YVHrA1/B4HClcpLuMCE+SB1 jB1YrpxhdqfqEdol5M+wkFtPgAfOoD+kHhjYW0FpGVHgTw2xj36s29HqwANVuH9l4MK2bv YYscpkg/4PID2Vwc94ciYrbn2l/Iso4j629EUWsV9EGBWUp2yMweKNFcGqm4b78wd9mIHD f0+9gKst1FpwpWJpVe6YtwIOeGBZ/UO6zVR5xeFnAK00LGz8EZcuZg/yd0i6tA== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:32 +0100 Subject: [PATCH v3 3/7] i2c: designware: Sort compatible strings in alphabetical order Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-3-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Reorder the of_device_id structures so that they are in alphabetical order. Also drop the unneeded inner trailing comma in the "snps,designware-i2c" struct. Reviewed-by: Andy Shevchenko Signed-off-by: Beno=C3=AEt Monin --- drivers/i2c/busses/i2c-designware-platdrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/buss= es/i2c-designware-platdrv.c index 34d881572351..d7d764f7554d 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -345,9 +345,9 @@ static void dw_i2c_plat_remove(struct platform_device *= pdev) } =20 static const struct of_device_id dw_i2c_of_match[] =3D { - { .compatible =3D "snps,designware-i2c", }, - { .compatible =3D "mscc,ocelot-i2c", .data =3D (void *)MODEL_MSCC_OCELOT = }, { .compatible =3D "baikal,bt1-sys-i2c", .data =3D (void *)MODEL_BAIKAL_BT= 1 }, + { .compatible =3D "mscc,ocelot-i2c", .data =3D (void *)MODEL_MSCC_OCELOT = }, + { .compatible =3D "snps,designware-i2c" }, {} }; MODULE_DEVICE_TABLE(of, dw_i2c_of_match); --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 F14CD36C0C6; Wed, 19 Nov 2025 15:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564758; cv=none; b=M9ApQou/RqM5G5CpvzfBaeWeHHDRkfSBN4gh6vWcPppmrE1WDrC38vxW0IMNqQZiBJe9kt8WfEc3Z7z44jv7njh0EqPr5j40VbOm3lq1RhBt5S8oUghmKIah4KOVbicBHW4kRLrzMAK0wrAkdxlYWDUFqyZMsqLPio11wdYFl10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564758; c=relaxed/simple; bh=JAD3o+Asv4ra2douzOxGIAujqehO/m/bD7MQB3mKQOo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mIW8dJWGuKSZQpx9monlY1ZCgawS4ZMASnWGPUkysxVdPA1tHcMJiJeMBE5QCuLq7Mw7Se2WdGO3g9B157E5xzoSfoR14X/uUC0ysJtjNM0D8WQo2GmnCOTw+EMNsCzPjuBeND7dtVshilNmKPNn3JGYHNTDZNKYPwUmdR8WbXA= 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=e/in0rUY; arc=none smtp.client-ip=185.171.202.116 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="e/in0rUY" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 23274C1118F; Wed, 19 Nov 2025 15:05:33 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5DF7E60699; Wed, 19 Nov 2025 15:05:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1364310371A72; Wed, 19 Nov 2025 16:05:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564753; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Qzc+vWJ+lMZNvL35gxSncb6y0244QxztXKe0Ufrhtu0=; b=e/in0rUYVRnahj3Kiblq14cIxtCSTEa/Ra4dtgZvkAXjiAjGkT/8NoawlhqIIFJaAR4FHH 7wG8YFqcmgmYv0AwkEFyJ2d2b0ucd9CcSYr8hh08l+VSe4kv5wFIO7EY60iZFO/npAjis5 OGUlSGChwqkzPt51kj3JYAYU/bc4EcKM7rZFriP2BDMpnp0RtQWj95oO/HnLtGsrxof9WD MY6TEh557VbCUIS0uP94JaMhXa6dFXwTj4fWz2n2bfPLRABo02hisG6WIY1chp8Y3f8iIY 0K2KjtiWXZCR5PocNocJXrK8VsKCjkKNka8XsuYYzyBYsoYDVmyT79rTC92GAg== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:33 +0100 Subject: [PATCH v3 4/7] i2c: designware: Use runtime PM macro for auto-cleanup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-4-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Simplify runtime PM handling in i2c_dw_xfer() by using the pm_runtime_active_auto_try guard. This adds the proper handling for runtime PM resume errors and allows us to get rid of the done_nolock label. Signed-off-by: Beno=C3=AEt Monin Reviewed-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-master.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index ec4fc2708d03..fe708c7cd282 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -811,12 +811,13 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg = msgs[], int num) =20 dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num); =20 - pm_runtime_get_sync(dev->dev); + ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev); + if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) + return -ENXIO; =20 switch (dev->flags & MODEL_MASK) { case MODEL_AMD_NAVI_GPU: - ret =3D amd_i2c_dw_xfer_quirk(adap, msgs, num); - goto done_nolock; + return amd_i2c_dw_xfer_quirk(adap, msgs, num); default: break; } @@ -834,7 +835,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg ms= gs[], int num) =20 ret =3D i2c_dw_acquire_lock(dev); if (ret) - goto done_nolock; + return ret; =20 ret =3D i2c_dw_wait_bus_not_busy(dev); if (ret < 0) @@ -899,9 +900,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg ms= gs[], int num) done: i2c_dw_release_lock(dev); =20 -done_nolock: - pm_runtime_put_autosuspend(dev->dev); - return ret; } =20 --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 1434F36CDF4; Wed, 19 Nov 2025 15:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564760; cv=none; b=SpaOspkhUU/yjJkiw7j4tRl8Wlg3DnCBm/PQPoirwRkPSr3QHcXrfvfmwIUyw5Q2MjhPyFsGHFlnEPqTn4KdmjDeDqz4CibVV7sS51sbJvsFzIzFH94h/fvpXMyZScoYLe6mru+L3LRbe95BvH8QvFAm+QfKJ2KPFDhh4nK2RRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564760; c=relaxed/simple; bh=IHl2DvpSuwQKADH4Pe7EPdpN4Sz/hS3LMkepCgaFm/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g1XNyOYBIdgf8QfYvXJcS4QSrbuspkN7cFTCSyosfuqJd9bN7JOfyAoeKuHB/uea9UIKB0OKOUycvN9uqbf3RozdhLaAIDnAfCjYYvA4b/+45vIfA6PxDP56myWhdJ0Qfx4bqfFs4Bpi1Hry9gmVkBiBGYrYpz6guULKAiUExuc= 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=gx/4zp65; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="gx/4zp65" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id CF9241A1BB1; Wed, 19 Nov 2025 15:05:57 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A551560699; Wed, 19 Nov 2025 15:05:57 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 46D3A10371A7A; Wed, 19 Nov 2025 16:05:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564756; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=65yzdyfBuP2Eg+ljTJ7FEAcjZHmS44KiAE99qDDTtos=; b=gx/4zp65DJdIxVpNefbXa7nUQ/DHwLnpLg39wmIoT/bGhb41MOrs3cLSWUoLK+d7/rDMfV ImPgmfE6uYSXf0a1IfOMNAj5gz2P/1OhuPzoVks2uGuJs0vNuEWx4ZIKs7p9KZWH5m/km3 +bXUKkkIUKVrJSdBIiGOIORcf61jajetIEnXb+lEY8CuhAUFwsiPDI0sQ6lgjGJOfJKLx/ twWKbu/uS0oppSvOhT5d3/WqmPMm+KqviqgEmENZTEV82ei2FhYBcjokPLrWNy+xZkX214 MXouwnWNdJNyiDszd8dY5TP5bZY7PUGWfYM32495oW45/BYlHHApeBOUPII0mQ== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:34 +0100 Subject: [PATCH v3 5/7] i2c: designware: Add dedicated algorithm for AMD NAVI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-5-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Apart from runtime PM, there is nothing in common between i2c_dw_xfer() and amd_i2c_dw_xfer_quirk(), so give AMD NAVI controller its own algorithm instead of calling the quirk from i2c_dw_xfer(). Add runtime PM handling to amd_i2c_dw_xfer_quirk() and a dedicated i2c_algorithm for AMD NAVI controllers. The adapter algorithm is set during probe based on the device model. This way we avoid checking for the device model at the start of every transfer. Signed-off-by: Beno=C3=AEt Monin Reviewed-by: Andy Shevchenko --- drivers/i2c/busses/i2c-designware-master.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index fe708c7cd282..12a1194bec52 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -354,6 +354,10 @@ static int amd_i2c_dw_xfer_quirk(struct i2c_adapter *a= dap, struct i2c_msg *msgs, u8 *tx_buf; unsigned int val; =20 + ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev); + if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) + return -ENXIO; + /* * In order to enable the interrupt for UCSI i.e. AMD NAVI GPU card, * it is mandatory to set the right value in specific register @@ -815,13 +819,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg m= sgs[], int num) if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) return -ENXIO; =20 - switch (dev->flags & MODEL_MASK) { - case MODEL_AMD_NAVI_GPU: - return amd_i2c_dw_xfer_quirk(adap, msgs, num); - default: - break; - } - reinit_completion(&dev->cmd_complete); dev->msgs =3D msgs; dev->msgs_num =3D num; @@ -908,6 +905,11 @@ static const struct i2c_algorithm i2c_dw_algo =3D { .functionality =3D i2c_dw_func, }; =20 +static const struct i2c_algorithm amd_i2c_dw_algo =3D { + .xfer =3D amd_i2c_dw_xfer_quirk, + .functionality =3D i2c_dw_func, +}; + static const struct i2c_adapter_quirks i2c_dw_quirks =3D { .flags =3D I2C_AQ_NO_ZERO_LEN, }; @@ -1043,7 +1045,10 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) scnprintf(adap->name, sizeof(adap->name), "Synopsys DesignWare I2C adapter"); adap->retries =3D 3; - adap->algo =3D &i2c_dw_algo; + if ((dev->flags & MODEL_MASK) =3D=3D MODEL_AMD_NAVI_GPU) + adap->algo =3D &amd_i2c_dw_algo; + else + adap->algo =3D &i2c_dw_algo; adap->quirks =3D &i2c_dw_quirks; adap->dev.parent =3D dev->dev; i2c_set_adapdata(adap, dev); --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 D71C736C0C6; Wed, 19 Nov 2025 15:06:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564763; cv=none; b=G88NYnr0GCpPJExxBVBw6kdO00V5ZrnsL/FFfhCG9yl/2vDHJxTM4dHRhlTFrFdDMPMxWIt1BmQ/tR76f0zk/Xpaz2OMVmu8tp5YFcZ5JLEq42UNcgXg/hGAMLWNjCQ2qzPi22VfCKsW+9lrhlkYV9kfXsMmMtD9OZzITYjPPCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564763; c=relaxed/simple; bh=LhCfcJ35YQcG/24/9rqQ3ufLfEUur75OY9iQ8U3ea6o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dzgfhno/8Rbts8kTeKr8u0rBR1npLaKVDGRnccwCriWHI1RpYiITWuWR4TO9tLzUGGlGE5QFE0xp/xyJliLOFNjFYs51ZGQnm2DUeJqXEl7Y9NVzH281q1t6UO7Nncp7BLBxVM/L7te2Ehn8TvOYO+wcgwybrCAH8yNwDp5+79g= 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=cUJflAV7; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="cUJflAV7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 6DD3A4E417AB; Wed, 19 Nov 2025 15:06:00 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3CB1F60699; Wed, 19 Nov 2025 15:06:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A933310371A6A; Wed, 19 Nov 2025 16:05:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564759; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=8hxzXQ0hH1z9qNYjukKB00iVarsR6FUGtWFVY0f4TCI=; b=cUJflAV7FUTGdVeNB1FRN/uMjD5g4Ib1J0GP7XRMZxBpWzuf7fikbWbzClsyUvsN3D0CMc JHvjO9wk8XLitWKXK7weGjZTEemzauhRDBzagc5fxBtN13GSFxC0HU5UCjMM0yI3BEAHuH A0R0dA3wq4IBNzANeN4GoIEqOfZ77b92gq7cxyy8SEYSx8GkjeW4dfnueOCEuBeJMt4qCH seeL5joNtEuSbAAKA4l/Q6YvpR/w+8ZmX3+E9P0xnju7rL4WZ7PjtgqixXdby0Z5/zFNh1 X38v8BuaxGlsQGISimdJwh5d3ojAOzn2ueOT/wd1H3E3JNozMbznRiFL5EjvBg== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:35 +0100 Subject: [PATCH v3 6/7] i2c: designware: Implement I2C_M_STOP support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-6-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Add the support of the I2C_M_STOP flag in i2c_msg by splitting i2c_dw_xfer() in two: __i2c_dw_xfer_one_part() for the core transfer logic and i2c_dw_xfer() for handling the high-level transaction management. In detail __i2c_dw_xfer_one_part() starts a transaction and wait for its completion, either with a STOP on the bus or an error. i2c_dw_xfer() loops over the messages to search for the I2C_M_STOP flag and calls __i2c_dw_xfer_one_part() for each part of the messages up to a STOP or the end of the messages array. i2c_dw_xfer() takes care of runtime PM and holds the hardware lock on the bus while calling __i2c_dw_xfer_one_part(), this allows grouping multiple accesses to device that support a STOP in a transaction when done via i2c_dev I2C_RDWR ioctl. Also, now that we have a lookup of the messages in i2c_dw_xfer() prior to each transaction, we use it to make sure the messages are valid for the transaction. We check that the target address does not change before starting the transaction instead of aborting the transfer while it is happening, as it was done in i2c_dw_xfer_msg(). The target address can only be changed after an I2C_M_STOP flag, i.e after a STOP on the i2c bus. The I2C_FUNC_PROTOCOL_MANGLING flag is added to the list of functionalities supported by the controller, except for the AMD NAVI i2c controller which uses its own xfer() function and is left untouched. Signed-off-by: Beno=C3=AEt Monin --- drivers/i2c/busses/i2c-designware-master.c | 108 +++++++++++++++++++++----= ---- 1 file changed, 81 insertions(+), 27 deletions(-) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index 12a1194bec52..2977c13c709c 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -435,7 +435,6 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) struct i2c_msg *msgs =3D dev->msgs; u32 intr_mask; int tx_limit, rx_limit; - u32 addr =3D msgs[dev->msg_write_idx].addr; u32 buf_len =3D dev->tx_buf_len; u8 *buf =3D dev->tx_buf; bool need_restart =3D false; @@ -446,18 +445,6 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) for (; dev->msg_write_idx < dev->msgs_num; dev->msg_write_idx++) { u32 flags =3D msgs[dev->msg_write_idx].flags; =20 - /* - * If target address has changed, we need to - * reprogram the target address in the I2C - * adapter when we are done with this transfer. - */ - if (msgs[dev->msg_write_idx].addr !=3D addr) { - dev_err(dev->dev, - "%s: invalid target address\n", __func__); - dev->msg_err =3D -EINVAL; - break; - } - if (!(dev->status & STATUS_WRITE_IN_PROGRESS)) { /* new i2c_msg */ buf =3D msgs[dev->msg_write_idx].buf; @@ -805,20 +792,15 @@ static int i2c_dw_wait_transfer(struct dw_i2c_dev *de= v) } =20 /* - * Prepare controller for a transaction and call i2c_dw_xfer_msg. + * Prepare controller for a transaction, start the transfer of the msgs + * and wait for completion, either a STOP or a error. + * Return the number of messages transferred or a negative error code. */ static int -i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) +__i2c_dw_xfer_one_part(struct dw_i2c_dev *dev, struct i2c_msg *msgs, size_= t num) { - struct dw_i2c_dev *dev =3D i2c_get_adapdata(adap); int ret; =20 - dev_dbg(dev->dev, "%s: msgs: %d\n", __func__, num); - - ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev); - if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) - return -ENXIO; - reinit_completion(&dev->cmd_complete); dev->msgs =3D msgs; dev->msgs_num =3D num; @@ -830,10 +812,6 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg m= sgs[], int num) dev->abort_source =3D 0; dev->rx_outstanding =3D 0; =20 - ret =3D i2c_dw_acquire_lock(dev); - if (ret) - return ret; - ret =3D i2c_dw_wait_bus_not_busy(dev); if (ret < 0) goto done; @@ -894,10 +872,83 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg = msgs[], int num) =20 ret =3D -EIO; =20 +done: + return ret; +} + +/* + * Check that the message pointed by @idx in the @msgs array + * respects the limitation of the controller. + */ +static inline bool +i2c_dw_msg_is_valid(struct dw_i2c_dev *dev, const struct i2c_msg *msgs, si= ze_t idx) +{ + /* The first message of a transaction is valid */ + if (!idx) + return true; + + /* + * We cannot change the target address during a transaction, so make + * sure the address is identical to the one of the previous message. + */ + if (msgs[idx - 1].addr !=3D msgs[idx].addr) { + dev_err(dev->dev, "invalid target address\n"); + return false; + } + + return true; +} + +static int +i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) +{ + struct dw_i2c_dev *dev =3D i2c_get_adapdata(adap); + struct i2c_msg *msgs_part; + size_t cnt; + int ret; + + dev_dbg(dev->dev, "msgs: %d\n", num); + + ACQUIRE(pm_runtime_active_auto_try, pm)(dev->dev); + if (ACQUIRE_ERR(pm_runtime_active_auto_try, &pm)) + return -ENXIO; + + ret =3D i2c_dw_acquire_lock(dev); + if (ret) + return ret; + + /* + * If the I2C_M_STOP is present in some the messages, + * we do one transaction for each part up to the STOP. + */ + for (msgs_part =3D msgs; msgs_part < msgs + num; msgs_part +=3D cnt) { + /* + * Count the messages in a transaction, up to a STOP + * or the end of the msgs. + */ + for (cnt =3D 1; ; cnt++) { + if (!i2c_dw_msg_is_valid(dev, msgs_part, cnt - 1)) { + ret =3D -EINVAL; + goto done; + } + + if ((msgs_part[cnt - 1].flags & I2C_M_STOP) || + (msgs_part + cnt =3D=3D msgs + num)) + break; + } + + /* transfer one part up to a STOP */ + ret =3D __i2c_dw_xfer_one_part(dev, msgs_part, cnt); + if (ret < 0) + break; + } + done: i2c_dw_release_lock(dev); =20 - return ret; + if (ret < 0) + return ret; + return num; } =20 static const struct i2c_algorithm i2c_dw_algo =3D { @@ -920,6 +971,9 @@ void i2c_dw_configure_master(struct dw_i2c_dev *dev) =20 dev->functionality =3D I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY; =20 + if ((dev->flags & MODEL_MASK) !=3D MODEL_AMD_NAVI_GPU) + dev->functionality |=3D I2C_FUNC_PROTOCOL_MANGLING; + dev->master_cfg =3D DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE | DW_IC_CON_RESTART_EN; =20 --=20 2.51.1 From nobody Tue Dec 2 02:20:21 2025 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 8531E2BDC0C; Wed, 19 Nov 2025 15:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564767; cv=none; b=NfIZoqOmd0qWvi1MpxtmwUwDBPpNdGtkLBceGOlaU4bnfWLTkUrYF+8EsDJTmKVuN3bggQQsyml7odZloIatVw0JxJemznHruUH828H341ZJHO15Uj1QeLnBcmYY0/iRoW61+dpBOEGbkXDYl0eFeP3N8DFHO3ebAttaMR88BYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763564767; c=relaxed/simple; bh=XMjhU5xBGVE+BteNaWxQS1rFxs2lHbDdMUeAq5fPn98=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mrI+IRLShqS/XrWD004+i7FZ/BGnoF0sUl5XyQjrKx0RKaitW0bNPiea/0oKKGy/gpiFCth6k9YbU0IbNIwziOgpDIrwhsV1cJZPXzfcklpX9LJ7QERHYINlf+8tChZgTs78sldF+r/lmwSJVJueDRhrrg1wxq4ONCjfPjzrYBk= 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=c38y875G; arc=none smtp.client-ip=185.246.85.4 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="c38y875G" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 1D42E4E417AC; Wed, 19 Nov 2025 15:06:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DEED360699; Wed, 19 Nov 2025 15:06:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5E61D10371A7C; Wed, 19 Nov 2025 16:05:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1763564761; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Qlwe5TwEIuTzD/7egh2Z/AjPfw+YwtKdtWet50MaR+k=; b=c38y875GsbRAeytEOKF6p/L4tbghDOm1SE2hMHoTclk8/RZfYgz5QS8zv0W4hWUHTR6N5U Z6tOCP4ga/nWYTYwhesK/SM6U5cQg99UcVk5pZGO038mrguJgN5v0ULGi7Qd/PYRjwt3N1 j7cCL/OsQX7IOj3M1aQvCWiDORvQfku4NMjeXXtf5x05hGbTxJp43FL/9TheQuyhu71T5h PXnbmfIkbLZ//r2bKaivP/dLq6pOTN1zVtmTz0ymJrNoMMA6THkmnEI94AvMr5EH1DAAph BZv6UJ03FBp7ItL/w8U+7P90EFS4lhajbI7dEzD3Bq66ZVGUzRKhu0rRRmkF9Q== From: =?utf-8?q?Beno=C3=AEt_Monin?= Date: Wed, 19 Nov 2025 16:05:36 +0100 Subject: [PATCH v3 7/7] i2c: designware: Support of controller with IC_EMPTYFIFO_HOLD_MASTER disabled Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251119-i2c-dw-v3-7-bc4bc2a2cbac@bootlin.com> References: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> In-Reply-To: <20251119-i2c-dw-v3-0-bc4bc2a2cbac@bootlin.com> To: Andi Shyti , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jarkko Nikula , Mika Westerberg , Andy Shevchenko , Jan Dabros , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt Cc: Thomas Petazzoni , Gregory CLEMENT , =?utf-8?q?Th=C3=A9o_Lebrun?= , Tawfik Bayouk , Vladimir Kondratiev , Dmitry Guzman , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev, =?utf-8?q?Beno=C3=AEt_Monin?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 If IC_EMPTYFIFO_HOLD_MASTER_EN parameter is 0, "Stop" and "Repeated Start" bits in command register does not exist, thus it is impossible to send several consecutive write messages in a single hardware batch. The existing implementation worked with such configuration incorrectly: all consecutive write messages are joined into a single message without any Start/Stop or Repeated Start conditions. For example, the following command: i2ctransfer -y 0 w1@0x55 0x00 w1@0x55 0x01 does the same as i2ctransfer -y 0 w2@0x55 0x00 0x01 In i2c_dw_msg_is_valid(), we ensure that we do not have such sequence of messages requiring a RESTART, aborting the transfer on controller that cannot emit them explicitly. This behavior is activated by compatible entries because the state of the IC_EMPTYFIFO_HOLD_MASTER_EN parameter cannot be detected at runtime. Add the compatible entry for Mobileye SoCs needing the workaround. There is another possible problem with this controller configuration: When the CPU is putting commands to the FIFO, this process must not be interrupted because if FIFO buffer gets empty, the controller finishes the I2C transaction and generates STOP condition on the bus. If we continue writing the remainder of the message to the FIFO, the controller will start emitting a new transaction with those data. This turns a single a single message into multiple I2C transactions. To protect against FIFO underrun, two changes are done: First we flag the interrupt with IRQF_NO_THREAD, to prevent it from running in a thread on PREEMPT-RT kernel. This ensures that we are not interrupted when filling the FIFO as it is very time-senstive. For example, being preempted after writing a single byte in the FIFO with a 1MHz bus gives us only 18=C2=B5s before an underrun. Second in i2c_dw_process_transfer(), we abort if a STOP is detected while a read or a write is in progress. This can occur when processing a message larger than the FIFO. In that case the message is processed in parts, and rely on the TX EMPTY interrupt to refill the FIFO when it gets below a threshold. If servicing this interrupt is delayed for too long, it can trigger a FIFO underrun, thus an unwanted STOP. Originally-by: Dmitry Guzman Signed-off-by: Beno=C3=AEt Monin --- drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-master.c | 32 +++++++++++++++++++++++++= ++++ drivers/i2c/busses/i2c-designware-platdrv.c | 1 + 3 files changed, 34 insertions(+) diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/= i2c-designware-core.h index 347843b4f5dd..a31a8698e511 100644 --- a/drivers/i2c/busses/i2c-designware-core.h +++ b/drivers/i2c/busses/i2c-designware-core.h @@ -311,6 +311,7 @@ struct dw_i2c_dev { #define ACCESS_NO_IRQ_SUSPEND BIT(1) #define ARBITRATION_SEMAPHORE BIT(2) #define ACCESS_POLLING BIT(3) +#define NO_EMPTYFIFO_HOLD_MASTER BIT(4) =20 #define MODEL_MSCC_OCELOT BIT(8) #define MODEL_BAIKAL_BT1 BIT(9) diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busse= s/i2c-designware-master.c index 2977c13c709c..3486a8c760e0 100644 --- a/drivers/i2c/busses/i2c-designware-master.c +++ b/drivers/i2c/busses/i2c-designware-master.c @@ -710,6 +710,14 @@ static void i2c_dw_process_transfer(struct dw_i2c_dev = *dev, unsigned int stat) if (stat & DW_IC_INTR_TX_EMPTY) i2c_dw_xfer_msg(dev); =20 + /* Abort if we detect a STOP in the middle of a read or a write */ + if ((stat & DW_IC_INTR_STOP_DET) && + (dev->status & (STATUS_READ_IN_PROGRESS | STATUS_WRITE_IN_PROGRESS)))= { + dev_err(dev->dev, "spurious STOP detected\n"); + dev->rx_outstanding =3D 0; + dev->msg_err =3D -EIO; + } + /* * No need to modify or disable the interrupt mask here. * i2c_dw_xfer_msg() will take care of it according to @@ -896,6 +904,16 @@ i2c_dw_msg_is_valid(struct dw_i2c_dev *dev, const stru= ct i2c_msg *msgs, size_t i return false; } =20 + /* + * Make sure we don't need explicit RESTART between two messages + * in the same direction for controllers that cannot emit them. + */ + if (dev->flags & NO_EMPTYFIFO_HOLD_MASTER && + (msgs[idx - 1].flags & I2C_M_RD) =3D=3D (msgs[idx].flags & I2C_M_RD))= { + dev_err(dev->dev, "cannot emit RESTART\n"); + return false; + } + return true; } =20 @@ -1113,6 +1131,20 @@ int i2c_dw_probe_master(struct dw_i2c_dev *dev) irq_flags =3D IRQF_SHARED | IRQF_COND_SUSPEND; } =20 + /* + * The first writing to TX FIFO buffer causes transmission start. If + * IC_EMPTYFIFO_HOLD_MASTER_EN is not set, when TX FIFO gets empty, I2C + * controller finishes the transaction. If writing to FIFO is + * interrupted, FIFO can get empty and the transaction will be finished + * prematurely. FIFO buffer is filled in IRQ handler, but in PREEMPT_RT + * kernel IRQ handler by default is executed in thread that can be + * preempted with another higher priority thread or an interrupt. So, + * IRQF_NO_THREAD flag is required in order to prevent any preemption + * when filling the FIFO. + */ + if (dev->flags & NO_EMPTYFIFO_HOLD_MASTER) + irq_flags |=3D IRQF_NO_THREAD; + ret =3D i2c_dw_acquire_lock(dev); if (ret) return ret; diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/buss= es/i2c-designware-platdrv.c index d7d764f7554d..4aad3dc51fbc 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c @@ -346,6 +346,7 @@ static void dw_i2c_plat_remove(struct platform_device *= pdev) =20 static const struct of_device_id dw_i2c_of_match[] =3D { { .compatible =3D "baikal,bt1-sys-i2c", .data =3D (void *)MODEL_BAIKAL_BT= 1 }, + { .compatible =3D "mobileye,eyeq6lplus-i2c", .data =3D (void *)NO_EMPTYFI= FO_HOLD_MASTER }, { .compatible =3D "mscc,ocelot-i2c", .data =3D (void *)MODEL_MSCC_OCELOT = }, { .compatible =3D "snps,designware-i2c" }, {} --=20 2.51.1