From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795776057; b=WIfjprCumkNWMriHbtkCRdYn06XCSGhZ5USBX/T81LgUEiiuWGleVFpQLJWpcsSWrPLW Kv/T8qxwqSpSac8wOeVJdVwpQX4zjf77eKWOoW4MruYRFs1VIR+RTqRrexjmNLBceqkOo NbXK0HNbJzCly30Z0X9wLUigUlPx+UYaSnCVHiTuv2U68CNDSkbES30mjCfSB3Qx85PiX 2Z+QzlRiLERw5lzGa04EE+oDSy7xtn9PT0DWrlkz8YE/djRvU3Ub7WKJZ+YVV3KXZQIG+ 3pmMa6DYhtSdGGQB2x191+rD4CQVJbxgR4zlXOlG54LPbvuEHPVNNLGC51YuolEb++A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795776057; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Subject:Date:Message-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=wRkg1D7v1brwh6BLcrTMSeTk04sUpCGspFqgyNeqWI8=; b=shuQXr2SIJ25zcOiSHgFSMQG6L5sxvogzNiFsrbsSl5p+G4YPAuCRSzmZ9NLMudTnzj/ EVDQ1NjWJFsw62wYeeipj4jr1vCvERBsC9FgHDvvV718u18AKmSyY0940KXvRvLoivxsx TISPHpZx+shpdIMY4We5HnIP5gfRjwlUa/xZlUBjjeqv7w/WIXT2kUw9ijd7mnZH5EPWU 4iF7xsqGI0ui5fSEy3+WyIxPIOsCY3Ziq6IEioyfNuc5rEEWi25N3waGEq/JdqiiR5K+R qoJeab70toKcwty6yP6gRQBZykVjB2JrwG3FXJBvxEjqf307+cSO9h+0EL7Vp9vnq8A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=flipper.net; spf=pass smtp.mailfrom=flipper.net; dkim=pass header.d=flipper.net header.i=@flipper.net header.a=rsa-sha256 header.s=google header.b=oDg3528d; arc=none smtp.remote-ip=209.85.128.49 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8CA3606A31F for ; Fri, 27 Nov 2026 10:40:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C8CA3606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=flipper.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flipper.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=flipper.net header.i=@flipper.net header.a=rsa-sha256 header.s=google header.b=oDg3528d Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso80037505e9.1 for ; Fri, 27 Nov 2026 02:40:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flipper.net; s=google; t=1795776055; x=1796380855; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=wRkg1D7v1brwh6BLcrTMSeTk04sUpCGspFqgyNeqWI8=; b=oDg3528dyAW8e9kVjWy29tU6J/vo4YknP6bAWy1omIXFeopNkGNZ3jgIHz0atznFFu z3VETAqk2ybQzDCygmuHXUJDsz60KFbKZ6RDCHm9cThLBESXvxcFYILshyMNvkghk8US WE+J27T/4kyuAFUsC3U3/ztokkMSEoRb7Ba6wJxCgFcWSsirfXlU1cdKF6lY3HEA7TjY Gg8VBe3YgfbNIWgX35fQ6oyf1mNX5xvO5CKODDvK79YT85zKfV75jRmThMk8Fx6FrABY JWLDAVCF/SEywIQHEsiSxhDZyRl6Fd7dwo9rB8AoMtee8UeK8NdZj7+l9Nxh13+vnmTG oy7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795776055; x=1796380855; h=cc:to:content-transfer-encoding:content-type:mime-version :message-id:date:subject:from:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=wRkg1D7v1brwh6BLcrTMSeTk04sUpCGspFqgyNeqWI8=; b=wxpeUZxjCo1d6wvKwkRBn3P3mXX+uCoK5SQqkVTF7i//iW4KPfrS58Su8MLktKIgtr b0XgQWdB6hKqoUwXc0hQhfnLD+8q1dRgAO920eAsLIjV1H8ilXinTlmLSzcePEAvDuYK IClNWcbJeACCXkr68nxquwZr6MfLhs7q+6/3XbiAIjiDESQkvVVQfFw+cCdwIgz6xL5I tHxyBfbfFojv5H9bQx9PwRK/LMoPZ4Iube0twn0pJWK1nOgLqDUJ3aZDlljdhE4+aexk H2fnkfjsIYUnLPVy8PJVfjKvuYchGth1DZxXOhnRcqC2FencJTZdOXrUyJmuyKRRRZSd iftg== X-Forwarded-Encrypted: i=1; AL+hErGGoTIVI0yJfocE4hB+Tu+qNIPg6gzFTGSYz5hP3805bBeW7jKIDraTwK/UkJyjwEnE8/wYP5JyybRh7TY=@vger.kernel.org X-Gm-Message-State: APuU4Z+nQtgj8nSlofI4/yUwdUU/WX/Ae/Eybtgo6DHIU63MAa/sDj5l k4+YZr8r4iQx2vaBKvbzdJRYSDE2CQWvaGRd/VBuFkyC5GXf0xXAXs8pJQxonVkyfKg= X-Gm-Gg: AZFdTZeBtynQMNqlWjqd4vcR9kyGTcOI1ftXW0ytXX2WE2J36T4M6u+V/pwo5N8zR4t ylHkopLlwp5oe6p+m5zr1nhtwUUP7K+oWbiGtF4sN85saweIJmuQNl07p/6eHlJdHbUZX3fNqKL rE9L7zoNQzgzahySLlzVuDTPupTPB9isqvOoDiHsLbL1i8PktjjiK2hwQ2+h9+VXCHS54MFKJ2G irsUVFY7NaT/1EeWl71CQIzkue1DC32Bypw7oDJJhrTAiXztYhbODTbLnyAtQztQwivyysTbsBR vr69bdc/xzJ3e7cEhj7LiEp6khWKtpQnLo1Np0U4ZEZL9nHoJPpyCPYxPin1WVuTAWnb4QuBlPB XkXU8ffeA8ap4TIs3RZQEQXn5N3SMnVtxpvWEHpsbVOu1CYc/LSquTFxqY6p+m5NXy6L0wmeTx3 9SVuY0ij599i4r6qehtqiOr8TUt6EWCVbvI+qtvs82dsjKMaBX8VWvTGc5BZlYQ3BEmBvU88EoC y9g0hNuqIgJp5p6qbHvGOh34wpObbPdYKVGxL5mpWEoAE3UxRdyO9udOvinY0WXmxKC9uuCPiUD W3GhhRnb+d4Qj9LmUCOpyAhQFN37/xSc4hvDWrPRY+JIIj65c2b4yIqSzo2t5y0ffzLJmyfa0jB MB5x1CmF9 X-Received: by 2002:a05:600c:530e:b0:4ba:eb:eb9b with SMTP id 5b1f17b1804b1-4bb8880aba2mr474922345e9.8.1795776055138; Fri, 27 Nov 2026 02:40:55 -0800 (PST) Received: from alchark-surface.localdomain (bba-86-98-194-229.alshamil.net.ae. [86.98.194.229]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6ae2dcf9sm45597649f8f.32.2026.11.27.02.40.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Nov 2026 02:40:54 -0800 (PST) From: Alexey Charkov Subject: [PATCH v2 0/6] usb: typec: fusb302: Make full PD 3.0 work on the 2.0-only FUSB302 Date: Fri, 27 Nov 2026 14:40:45 +0400 Message-Id: <20261127-fusb302-getsourcecap-v2-0-6770eb1e7945@flipper.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/4WPy26DMBBFfwV5XVd+AHZY5T+qLDzjcXCVALEBt Yry7zVBfey6Gl1p7uPcWaYUKbOuurNEa8xxHIpQLxXD3g1n4tEXzZRQrZRC8bBk0OWeac7jkpD QTVxI1NYjgtKCFeuUKMSPZ+zbadd5gXfCecvaPvqY5zF9PntXuf39U7FKLrlqoYFArgYFx3CJ0 0TpdaCZnR57S6LbUhjmvfoXoRDt6Zr3W7qUHB1ciON4vfK6DYqMoRql7cqav/DfTtn+7IrpxhM 5zymlMXHrNLqGwoEAu1VtbnB5j45zV2nvLZqDcAaMUMaB901rSbceGrIqBEfOoDEF4vEFRhagz JABAAA= X-Change-ID: 20261102-fusb302-getsourcecap-01c38dccb230 To: Heikki Krogerus , Greg Kroah-Hartman , Guenter Roeck , Yueyao Zhu , Heiko Stuebner Cc: Sebastian Reichel , Sebastian Andrzej Siewior , linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Alexey Charkov , stable@vger.kernel.org X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5860; i=alchark@flipper.net; h=from:subject:message-id; bh=h+EGZKpp9eX6rEcjqbpyOrZBNDQRM7p40IXhJq9S+Co=; b=owGbwMvMwCW2adGNfoHIK0sZT6slMWRzxpnZRDF+FFvcsye3+dqvFWKu5n4OixcGHnNZGvoyJ sHYy3x7x0QWBjEuBksxRZa535bYTjXim7XLw+MrzBxWJpAh0iINDEDAwsCXm5hXaqRjpGeqbahn aKRjrGPEwMUpAFPd+ZThf0L64q3Tt568vq9BZ+W2DxOK7pjUffsmnzbz6bEL/kud/8gxMrxdvjz vF+vn+v4FN58Er/g23axd2HLH6V2b6kN2ra48MYcLAA== X-Developer-Key: i=alchark@flipper.net; a=openpgp; fpr=9DF6A43D95320E9ABA4848F5B2A2D88F1059D4A5 The FUSB302 implements PD 2.0, whose Message Type field is four bits wide, so it decodes the PD 3.0 Get_Source_Cap_Extended (0x11) as a GoodCRC (0x1) and never acknowledges it. v1 dropped the message, which keeps TCPM in step with the partner, but leaves partners such as an Apple Studio Display soft resetting over and over. This version acknowledges it from the driver instead, resulting in a proper PD 3.0 contract with no resets even with strict partners. Patches 1-3 keep the RX FIFO in step, which the rest relies on. Patch 1 resyncs the RX FIFO by CRC after a flush cuts a packet short, patch 2 drains the FIFO on each interrupt, reading only while CC is idle, and patch 3 reads the FIFO out rather than flush it as PD RX goes on. They fix behaviour as old as the driver, which also causes resets on attach with no Get_Source_Cap_Extended involved, so they carry Fixes: and Cc: stable. Each builds on the one before, so they go to stable together and in this order. Patch 4 handles interrupts in the IRQ thread rather than a work item, as suggested in review of the switch to a threaded handler [4]. This has a nice side effect of slightly reducing the latency, as it cuts out a context switch and makes the actual IRQ handling code run at realtime priority rather than in a normal kworker thread (which sometimes queued behind other tasks in my testing, causing missed protocol timings). Patches 5 and 6 are new functionality for PD 3.0 partners. Patch 5 sends the GoodCRC from the driver, 2.2-2.8ms after the interrupt over a 400kHz I2C bus. That is too late for strict partners (such as an iPhone 17 Pro as the source), but still often produces a PD 3.0 contract, because the partners retry unacknowledged messages three times, and the software ack sent for the first one lands in the window of one of the retries. Patch 6 is a pile of black magic to make it work reliably in protocol specified timings, as long as the I2C bus runs at 400kHz or more. It reads the status and the head of the RX FIFO in one transfer and keeps the GoodCRC pre-staged in the TX FIFO, all but the TXON. The GoodCRC then goes out 0.4-0.9ms after the interrupt, and gives 100% success rate in PD 3.0 negotiation with the iPhone in my testing, with no resets at all. Patch 2 was sent on its own before [1] and is folded in here, as the rest builds on it. The issue Sashiko raised there, an unacknowledged Get_Source_Cap_Extended reaching TCPM only ahead of the Soft_Reset that follows it, goes away with patch 5, which reads and answers the message as it arrives. The series applies on top of [2] and [3] (also recorded in b4 metadata). The verbose code comments are there to keep Sashiko from suggesting, over and over, things that are not true of this chip or the broader setup. Happy to trim them down if required. Note that I ran the local Sashiko over Claude Sonnet 5.5 CLI, so it probably raised slightly different issues than the upstream Sashiko would have (it runs over Gemini 4). Tested on the FUSB302B ports of two Flipper One boards (RK3576), one sending Get_Source_Cap_Extended, Ping floods and other messages to the other at either power role, with RX FIFO flushes forced mid-packet, PD RX turned on late, and suspend to RAM with interrupts arriving through it, and against an iPhone 17 Pro, which is the strictest PD 3.0 partner I have seen so far. [1] https://lore.kernel.org/r/20261102-fusb302-drain-rxfifo-v1-1-bd9b232ab345@flipper.net [2] https://lore.kernel.org/r/20261103-husb311-cable-comm-v1-0-6217dabc1a85@flipper.net [3] https://lore.kernel.org/r/20261123-fusb302-irq-read-error-v2-1-5539a09127d8@flipper.net [4] https://lore.kernel.org/r/20260312120418.99U0NPWL@linutronix.de Signed-off-by: Alexey Charkov --- Changes in v2: - Acknowledge Get_Source_Cap_Extended from the driver instead of dropping it, so the partner sees it delivered (dropped Heikki's Ack, as the patch is new), and in time for the partner to accept it (new patches 4 and 6) - Fold in "Drain the RX FIFO on each PD interrupt" [1], now reading only while CC is idle (dropped Sebastian's Reviewed-by, as the code changed) - New patches 1 and 3 to keep the RX FIFO in step, which the rest relies on - Added Fixes: and Cc: stable to patches 1-3 - Rebased onto next-20261124, on top of [2] and [3] - Link to v1: https://patch.msgid.link/20261102-fusb302-getsourcecap-v1-1-26b5bfea4b2b@flipper.net --- Alexey Charkov (6): usb: typec: fusb302: Find the next message when the RX FIFO is out of step usb: typec: fusb302: Drain the RX FIFO on each PD interrupt usb: typec: fusb302: Read out the RX FIFO rather than flush it as PD RX goes on usb: typec: fusb302: Handle interrupts in the IRQ thread usb: typec: fusb302: Acknowledge Get_Source_Cap_Extended from the driver usb: typec: fusb302: Acknowledge Get_Source_Cap_Extended in time drivers/usb/typec/tcpm/Kconfig | 1 + drivers/usb/typec/tcpm/fusb302.c | 1036 +++++++++++++++++++++++++++++++++++--- 2 files changed, 955 insertions(+), 82 deletions(-) --- base-commit: 3dd8c790a7b7027abdd568e36db5e82ffaea7c77 change-id: 20261102-fusb302-getsourcecap-01c38dccb230 prerequisite-change-id: 20261103-husb311-cable-comm-46f2e77e4c18:v1 prerequisite-patch-id: 2ea442b68dfeee84c38efb27749d2f40487d2fff prerequisite-patch-id: 00acfb9e5b26f7f594c64b6ec87fbc5badcb59ca prerequisite-patch-id: 398e6c15de4f0c6fe4751176bc4ffe0fd1a4e58f prerequisite-patch-id: 134a18c9c2e06dc019aba39387bff53c94dc415b prerequisite-patch-id: b2e7a13203fd30a8c71b71a4856e7cee7a1bef19 prerequisite-change-id: 20261116-fusb302-irq-read-error-8a3ca5ef9ebc:v2 prerequisite-patch-id: b484440b7ee2dc68c6e5561a71804b5de607f178 Best regards, -- Alexey Charkov