All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Qianhui Xu" <xiaqinghuan@mail.ustc.edu.cn>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v13 1/3] dt-bindings: usb: snps,dwc3: describe two connectors on one HS data bus
Date: Mon, 23 Nov 2026 11:29:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-229137@kernel.org> (raw)
In-Reply-To: <20261123110858.538884-2-xiaqinghuan@mail.ustc.edu.cn>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] dt-bindings: usb: snps,dwc3: missing endpoint schema under
  port@0
- [Low] dt-bindings: usb: snps,dwc3: contradictory oneOf and redundant
  mux rules
- [Low] dt-bindings: usb: snps,dwc3: missing maxItems: 1 on mux-controls
--

commit 8c045d25978eb49158ab677f01e251bc1c6cc636
Author: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>

dt-bindings: usb: snps,dwc3: describe two connectors on one HS data bus

This commit extends the snps,dwc3-common binding to describe two USB
Type-C connectors multiplexed onto a single High Speed data bus via
mux-controls and two endpoints under port@0.

> diff --git a/Documentation/devicetree/bindings/usb/snps,dwc3-common.yaml b/Documentation/devicetree/bindings/usb/snps,dwc3-common.yaml
> index 6c0b8b6538246..7a9cb5a115a63 100644
> --- a/Documentation/devicetree/bindings/usb/snps,dwc3-common.yaml
> +++ b/Documentation/devicetree/bindings/usb/snps,dwc3-common.yaml
> @@ -26,8 +26,49 @@ allOf:
>        $ref: usb.yaml#
>      else:
>        $ref: usb-xhci.yaml#
> +  - if:
> +      required: [mux-controls]
> +    then:
> +      # A multiplexed High Speed bus only makes sense when the controller is
> +      # dual-role and both connectors can switch their role independently.
> +      required: [ports, usb-role-switch]
> +      properties:
> +        dr_mode:
> +          const: otg
> +        ports:
> +          required: [port@0]
> +          properties:
> +            port@0:
> +              required: ['#address-cells', '#size-cells',
> +                         endpoint@0, endpoint@1]
> +              patternProperties:
> +                '^endpoint@[01]$':
> +                  required: [usb-role-switch, mux-state]
> +    else:
> +      # Without a mux the High Speed port keeps the generic graph port
> +      # binding, so single-connector controllers are described as before and
> +      # the per-connector properties have no meaning.
> +      properties:
> +        mux-controls: false
> +        ports:
> +          properties:
> +            port@0:
> +              patternProperties:
> +                '^endpoint@[01]$':
> +                  properties:
> +                    usb-role-switch: false
> +                    mux-state: false
>  
>  properties:
> +  mux-controls:
> +    $ref: /schemas/types.yaml#/definitions/phandle-array
> +    description:
> +      Phandle to the multiplexer that selects which of the two connectors
> +      drives the controller's shared High Speed data bus, e.g. a
> +      "gpio-mux" controller.  Each connector is described by the endpoint@0
> +      or endpoint@1 of "port@0", and the endpoint of that connector carries
> +      its own role-switch input and the "mux-state" it is reached in.

[Severity: Low]
Should mux-controls specify maxItems: 1 instead of repeating $ref:
/schemas/types.yaml#/definitions/phandle-array?

mux-consumer.yaml already defines the phandle-array type for mux-controls
globally, and without maxItems: 1 the schema leaves the number of mux
controllers unconstrained even though the binding describes a single
two-state multiplexer.

> @@ -411,9 +452,65 @@ properties:
>  
>      properties:
>        port@0:
> -        $ref: /schemas/graph.yaml#/properties/port
> +        # The High Speed port carries the controller's HS data stream.  Two
> +        # receptacles sharing one HS D+/D- pair are two mux'ed data streams of
> +        # that one stream, so they are two endpoints of this port and not two
> +        # ports.  A single-connector controller describes the plain "endpoint"
> +        # of the graph binding and is unaffected.
> +        $ref: /schemas/graph.yaml#/$defs/port-base
> +        unevaluatedProperties: false
>          description: High Speed (HS) data bus.
>  
> +        patternProperties:
> +          '^endpoint@[01]$':
> +            $ref: /schemas/graph.yaml#/$defs/endpoint-base
> +            unevaluatedProperties: false

[Severity: Low]
Does switching port@0 to /schemas/graph.yaml#/$defs/port-base without an
explicit properties: endpoint: schema leave plain endpoint nodes without
unevaluatedProperties: false?

In graph.yaml, port-base matches ^endpoint(@[0-9a-f]+)?$ against
endpoint-base, which intentionally omits unevaluatedProperties: false so
bindings can extend endpoint properties.  Because port@0 only sets
unevaluatedProperties: false on ^endpoint@[01]$, a single-connector
controller using a plain port@0/endpoint node can carry arbitrary
undocumented properties (including usb-role-switch or mux-state when
mux-controls is absent) without failing dtbs_check.  In addition, because
port-base evaluates any endpoint@[0-9a-f]+ node, port@0's
unevaluatedProperties: false does not reject endpoint@2, endpoint@3, or
specifying a plain endpoint alongside endpoint@0 and endpoint@1.

> +
> +            properties:
> +              usb-role-switch:
> +                type: boolean
> +                description:
> +                  This connector has its own USB role switch, registered
> +                  against this endpoint.
> +
> +              mux-state:
> +                $ref: /schemas/types.yaml#/definitions/uint32
> +                enum: [0, 1]
> +                description:
> +                  State of the High Speed data bus multiplexer which connects
> +                  this connector to the controller.  The two connectors of one
> +                  controller must use different states.
> +
> +            required: [reg]
> +
> +            dependentRequired:
> +              usb-role-switch: [mux-state]
> +              mux-state: [usb-role-switch]
> +
> +        if:
> +          required: [endpoint@0, endpoint@1]
> +        then:
> +          # The two connectors must claim opposite mux states.
> +          oneOf:
> +            - properties:
> +                endpoint@0:
> +                  properties:
> +                    mux-state:
> +                      const: 0
> +                endpoint@1:
> +                  properties:
> +                    mux-state:
> +                      const: 1
> +            - properties:
> +                endpoint@0:
> +                  properties:
> +                    mux-state:
> +                      const: 1
> +                endpoint@1:
> +                  properties:
> +                    mux-state:
> +                      const: 0

[Severity: Low]
Does this oneOf fail validation whenever endpoint@0 and endpoint@1 are
used without mux-controls?

The else branch of if: required: [mux-controls] allows endpoint@0 and
endpoint@1 under port@0 while forbidding mux-state on them.  In JSON
Schema, a properties constraint evaluates to true when the property is
absent, so when mux-state is omitted both branches of this oneOf match at
the same time and oneOf validation fails.

Also, since the top-level if/then/else already requires both
usb-role-switch and mux-state when mux-controls is present and forbids
both when it is absent, dependentRequired here and mux-controls: false in
the else branch of if: required: [mux-controls] are redundant.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123110858.538884-1-xiaqinghuan@mail.ustc.edu.cn?part=1

  reply	other threads:[~2026-11-23 11:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 11:08 [PATCH v13 0/3] usb: dwc3: support two connectors sharing one HS data bus Qianhui Xu
2026-11-23 11:08 ` [PATCH v13 1/3] dt-bindings: usb: snps,dwc3: describe two connectors on " Qianhui Xu
2026-11-23 11:29   ` sashiko-bot [this message]
2026-11-23 11:08 ` [PATCH v13 2/3] usb: roles: look up role switches attached to a graph endpoint Qianhui Xu
2026-11-23 11:08 ` [PATCH v13 3/3] usb: dwc3: select the shared HS data bus with a mux controller Qianhui Xu

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=sashiko-outbox-229137@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xiaqinghuan@mail.ustc.edu.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.