mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Johan Hovold <johan@kernel.org>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	dt <devicetree@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Wesley Cheng <wesley.cheng@oss.qualcomm.com>
Subject: Re: grumpy DWC3+UCSI, usb-role-switch semantics
Date: Wed, 11 Mar 2026 19:21:23 +0000	[thread overview]
Message-ID: <20260311192118.hpf6nujgikytngvl@synopsys.com> (raw)
In-Reply-To: <8fabc049-7fdf-498a-a3ef-6f2570d510c8@oss.qualcomm.com>

On Wed, Mar 11, 2026, Konrad Dybcio wrote:
> Hi,
> 
> The description for the usb-role-switch property (usb-drd.yaml) states:
> 
>   Indicates that the device is capable of assigning the USB data role
>   (USB host or USB device) for a given USB connector, such as Type-C,
>   Type-B(micro). See connector/usb-connector.yaml.
> 
> That to me sounds like a description of the capability of the on-SoC
> controller (i.e. should/could be set regardless of device specifics),

That property description is misleading. We enable this property if we
want to use the usb role-switch framework. This has nothing to do with
the hardware capability. The description should correspond more closely
to its change log:

451d15a1731c ("dt-binding: usb: add usb-role-switch property")

> however in this configuration:
> 
> &usb {
> 	dr_mode = "host";
> 	usb-role-switch;
> };
> 
> the role switch device is never registered on devices with a DWC3
> controller, since that's handled in dwc3_drd_init(), which is only called
> if dr_mode = "otg" (or absent since otg is the default).
> 
> 
> This notably causes:
> 
> ucsi_init()
>  -> ucsi_register_port()
>     -> fwnode_usb_role_switch_get()
> 
> to loop in -EPROBE_DEFER, since the 'usb-role-switch' property is present
> on the connected DWC3 core, but the rolesw device is never registered.
> 
> Now, it seems like different drivers do this differently, e.g. DWC2 seems
> to always register a rolesw.
> 
> 
> How should we tackle this?
> 
> FWIW I'd prefer (for maintainability reasons) to not have to set/remove
> 'usb-role-switch' separately for each board, depending on whether whatever is
> at the other end of the USB cables is rolesw-capable (since again, the controller

We shouldn't do that. The usb-role-switch cannot just be inferred from
the dr_mode. The use of the usb role-switch framework needs to be
specified by the user. For example, for this particular scenario you
mentioned, the UCSI expects the role-switch handle. The dwc3 driver
wouldn't know that without the usb-role-switch property. Not every drd
platform uses the usb role-switch framework for role switching.

> itself is), but if we go that route, I'd request that we explicitly forbid the
> combination of usb-role-switch && dr_mode=host/peripheral in bindings, so that
> the computer yells at me if I overlook that
> 

The dwc3 driver can be updated to register the role-switch device if the
usb-role-switch property is set. Additionally, the role-switching
condition would need to be revised to ensure it is constrained by the
dr_mode.

It's a bit odd to be in host-only mode but also needs to use the
role-switch framework. I don't think the UCSI even uses role-switch
get_role? In anycase, the change shouldn't be an issue.

BR,
Thinh

  reply	other threads:[~2026-03-11 19:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 12:40 Konrad Dybcio
2026-03-11 19:21 ` Thinh Nguyen [this message]
2026-03-13 13:56   ` Konrad Dybcio
2026-03-13 22:14     ` Thinh Nguyen

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=20260311192118.hpf6nujgikytngvl@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=johan@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=wesley.cheng@oss.qualcomm.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

all inboxes | Powered by JetHome®