From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"git@amd.com" <git@amd.com>
Subject: Re: [PATCH] usb: dwc3: skip extcon lookup for fixed-role mode
Date: Wed, 25 Nov 2026 02:49:09 +0000 [thread overview]
Message-ID: <awZKeWuFsccOiJCC@vbox> (raw)
In-Reply-To: <20261116125705.323670-1-radhey.shyam.pandey@amd.com>
On Mon, Nov 16, 2026, Radhey Shyam Pandey wrote:
> As a last resort dwc3_get_extcon() walks the OF graph from the "phys"
> phandle and asks extcon for a device bound to the remote node. A PHY
> "port" node no longer implies an extcon provider though: it may link
> to a Type-C controller for orientation switching. There
> extcon_find_edev_by_node() returns -EPROBE_DEFER, the same value it
> uses for "not registered yet", so the probe defers forever.
>
> An extcon is only consulted for role switching in OTG mode, so skip
> the graph walk for a fixed role. dwc->dr_mode is still the raw device
> tree value here, as dwc3_get_dr_mode() runs after the lookup, so also
> derive the fixed cases it would force from GHWPARAMS0 and from the
> Kconfig role selection. Its remaining OTG to peripheral downgrade
> cannot be covered because it consumes dwc->edev, but it is only
> reached once the lookup has already returned NULL.
>
> The check stays below the explicit "extcon" and "linux,extcon-name"
> lookups so those keep working for a fixed role.
>
> Fixes: d182c2e1bc92 ("usb: dwc3: Don't switch OTG -> peripheral if extcon is present")
Can we Cc stable?
> Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
> ---
>
> Trace sequence before this change:
> dwc3-xilinx edec0000.usb: extcon-dbg: enter, raw dr_mode=1 node=/axi/usb@edec0000
> dwc3-xilinx edec0000.usb: extcon-dbg: phys[0]=/axi/phy@edeb8000 graph_present=1
> dwc3-xilinx edec0000.usb: extcon-dbg: graph remote node=/axi/i2c@f1000000/usb-pd@22/connector
> dwc3-xilinx edec0000.usb: extcon-dbg: HIT - no extcon bound to /axi/i2c@f1000000/usb-pd@22/connector,
> returning -EPROBE_DEFER
> ---
> drivers/usb/dwc3/core.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 372737f4750b..a70cfa9e1df1 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -2003,6 +2003,26 @@ static void dwc3_check_params(struct dwc3 *dwc)
> }
> }
>
> +/*
> + * dwc3_get_dr_mode() can force a fixed role from GHWPARAMS0 or from the
> + * Kconfig role selection, but it runs after the extcon lookup and consumes
> + * dwc->edev, so replicate the parts of that decision which do not.
This comment belongs in the commit message. Can we drop this?
> + */
> +static bool dwc3_role_is_fixed(struct dwc3 *dwc)
This duplicates part of dwc3_get_dr_mode(). Can we factor out the
hw_mode and Kconfig checks into a common helper instead?
> +{
> + unsigned int hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
> +
> + if (dwc->dr_mode == USB_DR_MODE_HOST ||
> + dwc->dr_mode == USB_DR_MODE_PERIPHERAL)
> + return true;
> +
> + if (hw_mode == DWC3_GHWPARAMS0_MODE_HOST ||
> + hw_mode == DWC3_GHWPARAMS0_MODE_GADGET)
> + return true;
> +
> + return !IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE);
> +}
> +
> static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> {
> struct device *dev = dwc->dev;
> @@ -2032,6 +2052,14 @@ static struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
> device_property_read_bool(dev, "usb-role-switch"))
> return NULL;
>
> + /*
> + * An extcon is only used for role switching in OTG mode, and the
> + * graph walk below cannot tell "no extcon" from "not registered
> + * yet", so for a fixed role it would defer the probe forever.
> + */
If we need to have a comment, we can just keep the first part of the
above:
/* An extcon is only used for role switching in OTG mode */
Thanks,
Thinh
> + if (dwc3_role_is_fixed(dwc))
> + return NULL;
> +
> /*
> * Try to get an extcon device from the USB PHY controller's "port"
> * node. Check if it has the "port" node first, to avoid printing the
>
> base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
> --
> 2.44.4
>
prev parent reply other threads:[~2026-11-25 2:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 12:57 [PATCH] usb: dwc3: skip extcon lookup for fixed-role mode Radhey Shyam Pandey
2026-11-16 13:06 ` sashiko-bot
2026-11-25 2:49 ` Thinh Nguyen [this message]
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=awZKeWuFsccOiJCC@vbox \
--to=thinh.nguyen@synopsys.com \
--cc=git@amd.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=radhey.shyam.pandey@amd.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