Linux USB
 help / color / mirror / Atom feed
* [PATCH v17 0/3] usb: dwc3: support two connectors sharing one HS data bus
@ 2026-11-30  1:26 Qianhui Xu
  2026-11-30  1:26 ` [PATCH v17 1/3] dt-bindings: usb: snps,dwc3: describe two connectors on " Qianhui Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Qianhui Xu @ 2026-11-30  1:26 UTC (permalink / raw)
  To: Thinh.Nguyen
  Cc: gregkh, linux-usb, robh, krzk+dt, conor+dt, devicetree,
	linux-arm-msm, linux-kernel

A rebase-only posting: the "diff --git" sections of all three patches are
the v16 content, applied unchanged onto v7.4-rc5.  Nothing in the series
changed; what changed is the base, which moved from v7.4-rc3 (aebb727447)
to v7.4-rc5 (fe6ff8d5d675) and carries Thinh Nguyen's End Transfer rework
on the gadget side and a dwc3-qcom glue rework (runtime-suspend callbacks,
extcon moved out of the glue into a dwc3-qcom-legacy file).  Neither
touches this series: the three patches apply with "git am" rc=0 and with
"patch -p1 --fuzz=0 --dry-run" rc=0, no fuzz and no offset, and the build
gate was re-run from scratch on the new base (it had last run on v14).
The per-patch AI-assistance disclosure that the v15 and v16 cover letters
promised back "when the series is regenerated as a whole" is below the
tearline of every patch now, so this regeneration discharges that promise.

1/3 and 2/3 are byte-identical to v16 in their diff sections; 3/3 differs
from v16 in exactly six metadata lines (two "index" lines and four hunk
"@@" headers of core.c/core.h, see "Changes since v16"), and "git
patch-id --stable" still gives the v15/v16 ids 5688adec43ea (2/3) and
60721b9fb7fb (3/3).

Two USB Type-C receptacles can share one High Speed D+/D- pair if a
multiplexer selects which of them drives the controller.  This series
describes that in the DWC3 binding, adds the endpoint-scoped role-switch
lookup the connectors need, and drives the shared data path from the DWC3
mode worker through the mux controller API.

"Not tested" and "Known gaps" below are the v15/v16 text, unchanged; the
hardware section now says explicitly that the recorded run predates this
rebase.

Testing on hardware

The board that needs this is a Lenovo Legion Y700 Gen 4 (SM8750).  Its
device tree is not upstream yet, so the test ran on the author's tree.  The
run recorded below is the 2026-11-25 round, and it predates this rebase:
the image carried 2/3 and 3/3 as posted here (the code of both is
unchanged since v11, the version that image was built with; 1/3 only
changes the binding and has no runtime effect), so the driver code it
exercised is the code posted in this v17, but the base of that image was
v7.4-rc3 = aebb727447, not the v7.4-rc5 base of this posting.  The image
was started with "fastboot boot", which writes nothing to the device, and
the same round also booted the board's daily kernel with the same
read-only probe script, so the only variable between the two boots is the
kernel image.

A boot test of the v7.4-rc5 build with this series applied is planned
before merge and has not run yet; the rebase changes no driver code, so
the expectation is that the run below repeats.

 - role switches: both switches of the shared controller,
   a600000.usb-port0-role-switch and a600000.usb-port1-role-switch, bind;
   "waiting_for_supplier" is 0 for both.
 - mux: /sys/class/mux is empty on the daily kernel and holds "muxchip0"
   with this series, i.e. the mux controller the binding points at is
   instantiated, which is the direct evidence that the mux path exists.
 - gadget: /sys/class/udc lists a600000.usb, and a High Speed gadget
   enumerates through this controller on connector 0 (the USB network link
   the test run itself is collected over is that gadget).
 - "Failed to create device link" lines: 7 with the series, 8 on the daily
   kernel.  The seven are the pre-existing qcom_pmic_glink family (5-0042,
   5-0043, 88e8000.phy, and a600000.usb twice, once per connector); the one
   line the candidate does not have is msm_dsi <-> panel@0, because that
   image carries no display bring-up.  The series adds no device link
   failure of its own.
 - "Fixed dependency cycle(s)" lines: 137 with the series, 141 on the daily
   kernel, all of the permitted FWLINK_FLAG_CYCLE form.
 - Type-C: port0 and port1 both present, data_role reads "host [device]" on
   both, orientation is "reverse" for port0 and empty for port1; same as the
   daily kernel.
 - Not USB, said out loud: that image logs 58 kernel warnings and 55 call
   traces the daily kernel does not log.  All of them are display stack
   (drm_crtc_wait_one_vblank, and clk_core_disable/clk_core_unprepare from a
   DSI PLL that did not lock: "DSI PLL(0) lock failed, status=0x0"), and the
   image deliberately carries no display bring-up.

Not tested, stated so that nobody has to guess

 - The two receptacles were never swapped by hand, so there is no sample of
   the mux state following the plugged receptacle.  The mux state is not
   exported anyway (no attribute under /sys/class/mux, nothing under
   /sys/kernel/debug/mux), so the only proxy available today is the
   multiplexer select line: with connector 0 active and the gadget running,
   GPIO29 reads "out low".  A flip of that line under cable movement is
   still unobserved.

Known gaps (unchanged from v14)

- Which physical receptacle corresponds to mux state 0 and which to 1 is
  still not proven on hardware; the board DTS therefore names them
  "Receptacle A" and "Receptacle B" and does not claim long/short edge.
- "gpio-mux" drives the select lines low in probe
  (devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW)), so the level left by
  the firmware is not preserved.  "idle-state" is deliberately omitted: a
  non-AS_IS idle state would drive the wrong state between
  mux_control_deselect() and the following mux_control_select().  Making the
  probe keep the pin as is (GPIOD_ASIS) is a change to drivers/mux/gpio.c and
  affects the ~70 existing gpio-mux users, so it does not belong in this
  series; it needs a separate discussion with the mux maintainer.
- dtbs_check cannot see "idle-state" values: gpio-mux.yaml declares it
  without a type or bounds, so an out-of-range value is only rejected at
  probe time.
- The board DTS is not part of this posting: the Lenovo Legion Y700 Gen 4
  file is not upstream yet and is posted with its own board series.

The static gates were re-run on the v7.4-rc5 base for this posting: the
apply, checkpatch, build and binding gates are in "Gate results" below.
The dtbs_check and sample gates were not re-run because the binding file
is byte-identical to v16's, so the v16 verdicts stand; the build gate was
re-run from scratch because the base moved.

---
*** AI-assistance disclosure ***
This series was prepared with the help of an LLM coding assistant.  The
author reviewed every line, checked every quoted claim against the tree,
and ran the gates quoted below; the design decisions and any errors are the
author's.  The same disclosure is below the tearline of each of 1/3, 2/3
and 3/3 from this version on (it was cover-only in v14, v15 and v16
because those versions kept 2/3 and 3/3 byte-identical to earlier
postings).

Changes since v16

Rebase only, onto v7.4-rc5 (fe6ff8d5d675).  The window between v7.4-rc3
(the base of v12-v16) and v7.4-rc5 moved the dwc3 gadget side and the
dwc3-qcom glue; item by item, against what this series touches:

1) Thinh Nguyen's End Transfer rework on the gadget side (reported as
   seven patches in the v7.3->v7.4 window: "Recover from End Transfer
   timeout", "Wait for End Transfer completion on ep disable", "Track a
   timed out End Transfer" and the rest).  In-tree evidence on v7.4-rc5:
   __dwc3_stop_active_transfer(), DWC3_EP_PENDING_NOOP_START and
   dwc3_remove_requests() grown a "bool interrupt" argument.  None of it
   is in a file this series modifies except core.h, where it added
   DWC3_EP_PENDING_NOOP_START (line 774) and the dwc3_remove_requests()
   declaration change (line 1742) -- both outside this series' four
   core.h hunks, which consequently land one line lower than in v16; the
   hunk bodies are unchanged.  This series does not call
   dwc3_remove_requests() and does not touch any gadget path.

2) dwc3-qcom glue rework: runtime-suspend glue callbacks and extcon moved
   out of the glue (dwc3-qcom.c has no extcon references on v7.4-rc5; the
   extcon code lives in the new dwc3-qcom-legacy.c).  This series does
   not touch dwc3-qcom.c, dwc3-qcom-legacy.c or the glue ops; the reworked
   glue drivers compile against the patched core.h (build gate below).

3) Within the files this series modifies, v7.4-rc5 differs from the
   v7.4-rc3 base of v16 by exactly three lines, all outside its hunks:
   mutex_init(&dwc->connect_mutex) in core.c, plus the two core.h lines
   of item 1.  snps,dwc3-common.yaml, roles/class.c, drd.c and debugfs.c
   are byte-identical between the two bases.  Hence: 1/3 and 2/3 diff
   sections byte-identical to v16; 3/3 differs in six metadata lines
   (index lines of core.c and core.h, @@ headers of the four core.h
   hunks) and in no content line.

4) No maintainer reply to v16 as of this posting: the author's inbox has
   no replies since 2026-11-22 (checked 2026-11-30); no reply in the
   archived thread was reachable for re-checking (lore.kernel.org and
   patchwork.kernel.org were both behind an Anubis challenge during this
   round).  sashiko reported v15 (and thereby the unchanged 2/3 and 3/3)
   with no issues.

Changes since v15

1) [sashiko, on v15 1/3, 2026-11-25, Low] "dt-bindings: usb: snps,dwc3:
   incomplete endpoint schema under port@0"

   Accepted, both halves.  v14 replaced the generic graph port on "port@0"
   with the graph "port-base" so that the port could carry two endpoints,
   and "port-base" leaves "unevaluatedProperties" open on purpose: a plain
   "endpoint" of a single-connector controller accepted "usb-role-switch" and
   "mux-state" with no schema saying what they mean there.  The "else"
   branch of "allOf" now gives "port@0" the generic graph port binding, whose
   endpoint schema does have "unevaluatedProperties: false", so both
   properties are rejected and the single-connector path is as strict as it
   was before this series.

   Second half of the same report: the pattern rejecting a third endpoint
   read '^endpoint@([2-9]|[1-9a-f][0-9a-f]+)$', which let the single hex
   digits "endpoint@a" to "endpoint@f" through, although graph.yaml accepts
   any hex unit address.  It now reads
   '^endpoint@([2-9a-f]|[0-9a-f]{2,})$', the exact complement of
   "endpoint@0"/"endpoint@1" among the addresses graph.yaml accepts, so
   "endpoint@a" and multi-digit addresses such as "endpoint@10" are rejected
   as well.

2) [sashiko, same report, Low] "dt-bindings: usb: snps,dwc3: inter-version
   changelog above tearline"

   Accepted.  "Should the "Changes since v13:" revision log be moved below
   the "---" tearline separator so that git am does not record it in the
   permanent commit message?"  Yes.  v15 1/3 still had it in the commit
   message; from this version on the revision log of a patch is below that
   patch's tearline, and 1/3's commit message carries only what belongs in
   the permanent log.

3) 2/3 and 3/3 are unchanged.  sashiko reported them with no issues, so they
   are re-posted byte-identically: "cmp" on the "diff --git" section is
   silent against v15, and "git patch-id --stable" gives 5688adec43ea and
   60721b9fb7fb, the v15 ids.  Their gate results in "Gate results" are
   therefore the ones v14 and v15 recorded; only 1/3's were re-run here.

4) Per-patch AI-assistance disclosure, still outstanding, said out loud so
   that nobody has to reconcile it: v15's cover promised it back in 1/3, 2/3
   and 3/3 "in the next version that touches those files".  This version
   touches 1/3, but 2/3 and 3/3 are byte-identical to v15, and adding the
   paragraph to 1/3 alone would leave the series inconsistent, so the
   disclosure is still in this cover letter only.  It goes back into all
   three when the series is regenerated as a whole.


Changes since v14

1) [Greg Kroah-Hartman, on v14, 2026-11-24] "Please test on real hardware
   before resending, AND also cc: the proper mailing lists (you forgot the
   usb list)."

   Adopted.  linux-usb@vger.kernel.org is Cc'ed on this thread; it was
   missing from v12, v13 and v14, and v11 was the last version that reached
   the list.  The hardware run is recorded in "Testing on hardware" above.
   1/3, 2/3 and 3/3 are byte-identical to v14: the "diff --git" section of
   each compares equal with "cmp", and the patch ids are unchanged
   (aa6ed734239b, 5688adec43ea, 60721b9fb7fb).  This posting starts a new
   thread; the v14 Message-IDs for reference: cover
   <20261124015002.1426767-1-xiaqinghuan@mail.ustc.edu.cn>.

2) Accounting, so that nobody has to reconcile the archives: v14 was posted
   twice (2026-11-24 01:50Z and 04:52Z, the second one unattended) and the
   duplicate thread was answered with an explanatory reply that asked
   readers to ignore it.  The two batches are byte-identical, so this v15
   replaces both.

3) Defect carried over, so that it is not mistaken for a new one: when v14
   regenerated the series, the per-patch AI-assistance disclosure paragraphs
   that v12 and v13 carried below each patch's "---" line were dropped,
   while v14's cover text still said every patch carried one.  For this
   resend the disclosure is in this cover letter only; it goes back into
   1/3, 2/3 and 3/3 in the next version that touches those files, since this
   posting is deliberately byte-identical to v14.  (State as of v17: the
   promise is discharged, the disclosure is in every patch, see "Changes
   since v16".)

Changes since v13

Sashiko reviewed v13 1/3 on 2026-11-23 and reported three low-severity
binding issues; all three were addressed in v14 (2/3 and 3/3 are
byte-identical to v13) and are carried here unchanged.

 - "mux-controls" now has "maxItems: 1": the shared bus is driven by one
   two-state multiplexer, so the number of mux controllers is not open.
 - Inside the "mux-controls" branch, "port@0" now rejects a plain
   "endpoint" and any "endpoint@2"+; a mux'ed bus has exactly two data
   streams and neither shape was rejected before, because the graph port
   base leaves "unevaluatedProperties" open on purpose.  Single-connector
   controllers keep the generic graph port binding untouched.
 - The "oneOf" that requires opposite "mux-state" values moved into the
   "mux-controls" branch.  Outside it, both alternatives matched whenever
   "mux-state" was absent (JSON Schema evaluates "properties" of a missing
   property as true), so a two-endpoint tree without "mux-controls" was
   rejected.  The now redundant "dependentRequired" and "mux-controls:
   false" are gone.

Changes since v11 (as posted in v12)

Posting fixes only.  The three patches of v12 were byte-identical to v11:
the "diff --git" section of each of 1/3, 2/3 and 3/3 compared with
"diff -u" against the v11 file gave empty output, and applying them on the
same base (v7.4-rc3 = aebb727447) yielded the same file blobs as v11
(snps,dwc3-common.yaml = 7a9cb5a115a6, drd.c = 906cac4f3e6e).  The binding
of 1/3 changed later, in v13 and v14; 2/3 and 3/3 are still unchanged.

6) [Krzysztof Kozlowski, on v10 1/3, 2026-11-21] "This does not go to
   commit msg, but changelog."

   Adopted in v12.  The AI-assistance disclosure paragraphs left the commit
   messages and moved below the "---" separator of 1/3, 2/3 and 3/3 (see
   item 3 under "Changes since v14" for the state of that text today).
   sashiko's [Low] on v11 1/3 ("transient AI disclosure left in commit
   message") is the same item; sashiko reported patches 2/3 and 3/3 of v11
   with no issues.

7) [Krzysztof Kozlowski, same mail] "...this one even threaded to other
   posting..."

   Adopted.  This series starts a new thread: no In-Reply-To or
   References to the v9/v10 postings.  The v9/v10 Message-IDs for
   reference: v10 cover
   <20261121022104.1507987-1-xiaqinghuan@mail.ustc.edu.cn>.

8) [Greg Kroah-Hartman, Re: v11 3/3, 2026-11-23] "What about all the
   previous versions?  Please always include them all, right?"

   Adopted.  This cover letter carries the changelog of every previous
   posting (v4, v5, v7, v8, v9, v10, v11, v12, v13 and v14 above).
   Message-IDs for reference: v11 cover
   <20261121132029.2379449-1-xiaqinghuan@mail.ustc.edu.cn>.

Changes since v10

1) [Medium, on 3/3] "Should dwc3_role_mux_deselect() be called after the
   switch (dwc->current_dr_role) block tears down the active host or gadget
   instance?"

   Accepted.  dwc3_role_mux_deselect() is now called after that switch
   block, in the same order as __dwc3_set_mode() (host/gadget exit first,
   then the data path switch), and still after
   cancel_work_sync(&dwc->drd_work).

2) [Medium, on 1/3] "Does applying $ref: '#/$defs/hs-port'
   unconditionally to port@0 cause a dtbs_check regression for
   single-connector DWC3 nodes without mux-controls?"

   Accepted, for the shape that v10 posted.  A single-connector node that
   numbers its endpoint ("port@0/endpoint@0" with "reg" only) was rejected
   by the v10 schema with "'usb-role-switch' is a required property" and
   "'mux-state' is a required property".  "port@0" keeps the generic graph
   port at the top level now; the two endpoints, their
   "usb-role-switch"/"mux-state" and the address/size cells are required by
   the "mux-controls" branch of "allOf" only, so single-connector
   controllers are described exactly as before.  An unnumbered
   "port@0/endpoint" of a non-mux controller was not rejected by the v10
   schema either; both shapes pass now.

3) [Low, on 1/3] "should the local $defs be dropped in favor of defining
   the endpoint schema under patternProperties for '^endpoint@[01]$', and
   can the Linux driver implementation details be removed from the
   binding?"

   Accepted.  The endpoint schema is inlined under "port@0" through
   patternProperties, the local "$defs" section and the "$ref" to it are
   gone, and the "mux-controls" branch no longer names driver functions.

Changes in earlier versions (full history)

v4 (2026-10-26) first posted the series: the binding described a private
"port-select-gpios" property and separate High Speed ports per connector
(port@0 and port@2); the driver drove the shared data path through a raw
GPIO from the role-switch callbacks.  v5 (2026-10-31) was a fixup round.

v7 (2026-11-06) reworked both ends:
- binding: the two connectors are two mux'ed data streams of one High Speed
  bus; "port@0" carries two endpoints with "mux-state" 0/1, and the private
  GPIO property is replaced by "mux-controls" (a phandle to a mux
  controller such as "gpio-mux").
- driver: the shared data path is driven through the mux controller API
  (devm_mux_control_get()/mux_control_select()); mux_control_select() may
  sleep, so it is only called from the mode worker.
- usb: roles: role-switch lookup extended to switches attached to a graph
  endpoint, which the two-endpoint binding needs.
v8 (same day) is the same series rebased; v6 was never posted.

v9 (2026-11-17) answered Rob Herring's 2026-11-10 review of the cover:
"port@2" is gone (the second connector is a second endpoint of "port@0"),
"port-select-gpios" is replaced by "mux-controls", the driver uses the mux
controller API, and the board DTS is posted separately.
Gate results (base: v7.4-rc5 = fe6ff8d5d675c01793b9f051d16055dd4aa75244)

  G1 apply       git am of the three patches on a pristine check-out of the
                 base above: 3/3 clean, rc=0, no offset, no fuzz, no
                 rejects; "patch -p1 --fuzz=0 --dry-run" of each patch
                 against the pristine base: rc=0 for all three.  Resulting
                 blobs snps,dwc3-common.yaml = 1f23840fd1f2,
                 class.c = ee186d542a10, core.c = dc88c3e97e4d,
                 core.h = 06af1affc7c6, debugfs.c = 82e7a334b135,
                 drd.c = 906cac4f3e6e.  The binding, class.c, debugfs.c and
                 drd.c blobs equal the v16 blobs; core.c and core.h differ
                 from the v16 blobs by the three upstream lines described
                 under "Changes since v16", all outside this series' hunks.
  G2 checkpatch  perl scripts/checkpatch.pl --strict --no-signoff --no-tree
                 1/3 0E/0W/0C (122 lines) ; 2/3 0E/0W/0C (63 lines)
                 3/3 0E/0W/0C (624 lines)
  G3 build       re-run on the new base: defconfig, then make ARCH=arm64
                 CROSS_COMPILE=aarch64-linux-gnu- O=... drivers/usb/dwc3/
                 drivers/usb/roles/: rc=0, 22 dwc3 objects plus roles
                 (including the reworked dwc3-qcom.o, dwc3-qcom-legacy.o
                 and dwc3-generic-plat.o compiled against the patched
                 core.h); the same build with W=1: rc=0, 0 warnings.
  G4 binding     make ARCH=arm64 dt_binding_check
                 targeted, DT_SCHEMA_FILES=.../usb/snps,dwc3-common.yaml
                 plus .../usb/snps,dwc3.yaml (the fragment has no examples of
                 its own): rc=0, snps,dwc3.example.dtb DTC [C], 0 diagnostics
  G5 dtbs_check  not re-run: the binding file is byte-identical to v16's, so
                 the v16 numbers stand (make ARCH=arm64 CHECK_DTBS=1, no
                 DT_SCHEMA_FILES:
                 qcom/sm8250-mtp, qcom/sm8650-mtp, qcom/sm8750-mtp,
                 qcom/sm8750-qrd: 4/4 DTC [C], 0 diagnostics;
                 12 further boards that have a dwc3 node with a port@0
                 (sm8250-mtp, sdm845-db845c, sc8280xp-crd, qdu1000-idp,
                 apq8096-db820c, imx8mp-evk, rk3588-rock-5b, rk3399-roc-pc,
                 sun50i-h6-pine-h64, zynqmp-zcu104-revA, k3-am62a7-sk,
                 exynos5433-tm2): 12/12 DTC [C] and the same 5 diagnostic
                 lines as the unpatched binding, so 0 new)
  G6 samples     not re-run, same reason: the v16 verdicts stand
                 (dt-validate, v15 schema and v16 schema side by side:
                 5/5 positives, 0 complaints under both schemas;
                 6/6 negatives rejected under both schemas;
                 2/2 negatives rejected only by the v16 schema, i.e. the
                 endpoint@a and non-mux role-props fixes)
  G7 hardware    see "Testing on hardware" above: the 2026-11-25 round
                 exercised the driver code posted here on the v7.4-rc3
                 base; the v7.4-rc5 build is not board-tested yet

  On the command shapes: DT_SCHEMA_FILES is intentionally not used for
  dtbs_check.  It is passed to dt-validate as "-l", which only keeps schemas
  whose $id matches and that still select a node themselves;
  snps,dwc3-common.yaml is a fragment without "select:", so the run reports
  nothing and looks green.  The dtbs_check rule also ends with "|| true", so
  the result is read from the diagnostics in the output, not from the exit
  status.

Qianhui Xu (3):
  dt-bindings: usb: snps,dwc3: describe two connectors on one HS data
    bus
  usb: roles: look up role switches attached to a graph endpoint
  usb: dwc3: select the shared HS data bus with a mux controller

 .../bindings/usb/snps,dwc3-common.yaml        | 106 +++++-
 drivers/usb/dwc3/core.c                       | 116 +++++-
 drivers/usb/dwc3/core.h                       |  43 +++
 drivers/usb/dwc3/debugfs.c                    |   4 +
 drivers/usb/dwc3/drd.c                        | 329 +++++++++++++++++-
 drivers/usb/roles/class.c                     |  45 +++
 6 files changed, 639 insertions(+), 4 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-11-30  1:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  1:26 [PATCH v17 0/3] usb: dwc3: support two connectors sharing one HS data bus Qianhui Xu
2026-11-30  1:26 ` [PATCH v17 1/3] dt-bindings: usb: snps,dwc3: describe two connectors on " Qianhui Xu
2026-11-30  1:26 ` [PATCH v17 2/3] usb: roles: look up role switches attached to a graph endpoint Qianhui Xu
2026-11-30  1:26 ` [PATCH v17 3/3] usb: dwc3: select the shared HS data bus with a mux controller Qianhui Xu
2026-11-30  1:35 ` [PATCH v17 0/3] usb: dwc3: support two connectors sharing one HS data bus sashiko-bot

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