From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: "Luca Ceresoli" <luca.ceresoli@bootlin.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"William Wu" <wulf@rock-chips.com>
Cc: "Kever Yang" <kever.yang@rock-chips.com>,
"Minas Harutyunyan" <Minas.Harutyunyan@synopsys.com>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Louis Chauvet" <louis.chauvet@bootlin.com>,
"Hervé Codina" <herve.codina@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
linux-phy@lists.infradead.org,
linux-rockchip@lists.infradead.org, linux-usb@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] phy: rockchip: inno-usb2: fix communication disruption in gadget mode
Date: Tue, 25 Nov 2025 16:39:01 +0100 [thread overview]
Message-ID: <DEHVZPZVWVTR.314J3P86OLG6X@bootlin.com> (raw)
In-Reply-To: <20250722-rk3308-fix-usb-gadget-phy-disconnect-v1-2-239872f05f17@bootlin.com>
Hello Luca,
On Tue Jul 22, 2025 at 10:43 AM CEST, Luca Ceresoli wrote:
> When the OTG USB port is used to power to SoC, configured as peripheral and
> used in gadget mode, communication stops without notice about 6 seconds
> after the gadget is configured and enumerated.
>
> The problem was observed on a Radxa Rock Pi S board, which can only be
> powered by the only USB-C connector. That connector is the only one usable
> in gadget mode. This implies the USB cable is connected from before boot
> and never disconnects while the kernel runs.
>
> The related code flow in the PHY driver code can be summarized as:
>
> * UDC start code (triggered via configfs at any time after boot)
> -> phy_init
> -> rockchip_usb2phy_init
> -> schedule_delayed_work(otg_sm_work [A], 6 sec)
> -> phy_power_on
> -> rockchip_usb2phy_power_on
> -> enable clock
> -> rockchip_usb2phy_reset
The above code flow summary was important for [PATCH 1/2] but it feels
like not as important for [PATCH 2/2], could you drop or summarise it?
The key point is that the below DCD sequence has invalid assumptions
and does side effects that don't fit if VBUS is already present. I feel
like it distracted me from the main point that is chg_det.opmode
writes.
> * Now the gadget interface is up and running.
>
> * 6 seconds later otg_sm_work starts [A]
> -> rockchip_usb2phy_otg_sm_work():
> if (B_IDLE state && VBUS present && ...):
> schedule_delayed_work(&rport->chg_work [B], 0);
>
> * immediately the chg_detect_work starts [B]
> -> rockchip_chg_detect_work():
> if chg_state is UNDEFINED:
> property_enable(base, &rphy->phy_cfg->chg_det.opmode, false); [Y]
>
> * rockchip_chg_detect_work() changes state and re-triggers itself a few
> times until it reached the DETECTED state:
> -> rockchip_chg_detect_work():
> if chg_state is DETECTED:
> property_enable(base, &rphy->phy_cfg->chg_det.opmode, true); [Z]
>
> At [Y] there is no disconnection and the USB device appears still present
> to userspace, but all existing communications stop. E.g. using a CDC serial
> gadget, the /dev/tty* devices are still present on both host and device,
> but no data is transferred anymore. The later call with a 'true' argument
> at [Z] does not restore it.
You mention "there is no disconnection" but that sounds irrelevant to
this precise commit. The issue at hand is a communication halt.
> Due to the lack of documentation, what chg_det.opmode does exactly is not
> clear, however by code inspection it seems reasonable that is disables
> something needed to keep the communication working, and testing proves that
> disabling these lines lefs gadget mode keep working. So prevent changes to
> chg_det.opmode when there is a cable connected (VBUS present).
"lefs" -> "let's", I think
With those nits
Reviewed-by: Théo Lebrun <theo.lebrun@bootlin.com>
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2025-11-25 15:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 8:43 [PATCH 0/2] phy: rockchip: inno-usb2: fix gadget mode disconnection after 6 seconds Luca Ceresoli
2025-07-22 8:43 ` [PATCH 1/2] phy: rockchip: inno-usb2: fix disconnection in gadget mode Luca Ceresoli
2025-11-25 15:28 ` Théo Lebrun
2025-11-27 9:22 ` Luca Ceresoli
2025-11-27 9:48 ` Théo Lebrun
2025-11-27 10:18 ` Luca Ceresoli
2025-11-27 12:20 ` Greg KH
2025-07-22 8:43 ` [PATCH 2/2] phy: rockchip: inno-usb2: fix communication disruption " Luca Ceresoli
2025-11-25 15:39 ` Théo Lebrun [this message]
2025-10-21 12:09 ` [PATCH 0/2] phy: rockchip: inno-usb2: fix gadget mode disconnection after 6 seconds Luca Ceresoli
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=DEHVZPZVWVTR.314J3P86OLG6X@bootlin.com \
--to=theo.lebrun@bootlin.com \
--cc=Minas.Harutyunyan@synopsys.com \
--cc=heiko@sntech.de \
--cc=herve.codina@bootlin.com \
--cc=kever.yang@rock-chips.com \
--cc=kishon@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=luca.ceresoli@bootlin.com \
--cc=stern@rowland.harvard.edu \
--cc=thomas.petazzoni@bootlin.com \
--cc=vkoul@kernel.org \
--cc=wulf@rock-chips.com \
/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).