Linux USB
 help / color / mirror / Atom feed
* [PATCH v2 0/4] usb: gadget: udc: Rework when the gadget connects
@ 2026-11-13  9:28 Alexey Charkov
  2026-11-13  9:28 ` [PATCH v2 1/4] usb: gadget: udc: Clear a pending connection when starting the UDC Alexey Charkov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alexey Charkov @ 2026-11-13  9:28 UTC (permalink / raw)
  To: Neill Kapron, Greg Kroah-Hartman, Xu Yang, Alan Stern
  Cc: linux-usb, linux-kernel, Sebastian Reichel, Alexey Charkov,
	stable

The UDC core decides whether to enable the gadget's pullup in several
places: bind and unbind, VBUS events, usb_gadget_{de,}activate() and the
soft_connect attribute. Each applies its own rules, and
gadget->connected records both the pullup state and a request to connect
later. Since commit 62911bc82b03 ("usb: gadget: udc: skip pullup() if
already connected"), a VBUS event before bind leaves the gadget
invisible to the host until it is rebound. That happens on every boot
of an RK3576 board whose Type-C port controller sets the device role
before userspace binds a configfs gadget.

Patch 1 is the v1 fix, small enough for stable. Patches 2-4 implement
Alan's scheme: the gadget connects only while a driver is bound, VBUS is
present, the driver hasn't deactivated it and userspace hasn't
disconnected it through soft_connect. One helper records that in
udc->allow_connect under connect_lock and switches the pullup to match.
The UDC starts and stops only at bind and unbind, and the deactivation
and soft-disconnect requests are forgotten at unbind.

Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
Changes in v2:
- Add patches 2-4, reworking the connection control as Alan suggested.
- Link to v1: https://patch.msgid.link/20261112-udc-connect-v1-1-03c73259642b@flipper.net

---
Alexey Charkov (4):
      usb: gadget: udc: Clear a pending connection when starting the UDC
      usb: gadget: udc: Forget a deactivation when the gadget driver unbinds
      usb: gadget: configfs: Leave resetting the deactivation to the UDC core
      usb: gadget: udc: Decide on connecting in one place

 drivers/usb/gadget/configfs.c |   1 -
 drivers/usb/gadget/udc/core.c | 197 +++++++++++++++++++++++-------------------
 include/linux/usb/gadget.h    |   4 +-
 3 files changed, 111 insertions(+), 91 deletions(-)
---
base-commit: 6d582d78fad9d828e575ca0cdcff8ea47a77220b
change-id: 20261112-udc-connect-61e0f11cf93b

Best regards,
--  
Alexey Charkov <alchark@flipper.net>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-13  9:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13  9:28 [PATCH v2 0/4] usb: gadget: udc: Rework when the gadget connects Alexey Charkov
2026-11-13  9:28 ` [PATCH v2 1/4] usb: gadget: udc: Clear a pending connection when starting the UDC Alexey Charkov
2026-11-13  9:39   ` sashiko-bot
2026-11-13  9:28 ` [PATCH v2 2/4] usb: gadget: udc: Forget a deactivation when the gadget driver unbinds Alexey Charkov
2026-11-13  9:36   ` sashiko-bot
2026-11-13  9:28 ` [PATCH v2 3/4] usb: gadget: configfs: Leave resetting the deactivation to the UDC core Alexey Charkov
2026-11-13  9:35   ` sashiko-bot
2026-11-13  9:28 ` [PATCH v2 4/4] usb: gadget: udc: Decide on connecting in one place Alexey Charkov
2026-11-13  9:46   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox