All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Elson Serrao" <elson.serrao@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v10 4/7] usb: misc: qcom_eud: add per-path role switch support
Date: Mon, 23 Nov 2026 18:56:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-229887@kernel.org> (raw)
In-Reply-To: <20261123182847.143892-5-elson.serrao@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] usb: misc: qcom_eud: infinite probe deferral and wrong fwnode
  in eud_init_path()
--

commit 9854aac37e71428a22eccd3000ca7589c021cc4d
Author: Elson Serrao <elson.serrao@oss.qualcomm.com>

usb: misc: qcom_eud: add per-path role switch support

This commit replaces the chip-level USB role switch with per-path role
switches that relay role changes from each USB connector to its
corresponding USB controller.

> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index a3afa3bb93481..48e474bdf818c 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c
[ ... ]
> @@ -328,14 +359,61 @@ static int eud_init_path(struct eud_chip *chip, struct device_node *np)
>  				     "failed to get controller node for path %u\n", path_num);
>  
>  	path->phy = devm_of_phy_get_by_index(chip->dev, controller_node, 0);
> -	of_node_put(controller_node);
> -
> -	if (IS_ERR(path->phy))
> +	if (IS_ERR(path->phy)) {
> +		of_node_put(controller_node);
>  		return dev_err_probe(chip->dev, PTR_ERR(path->phy),
>  				     "failed to get PHY for path %d\n", path_num);
> +	}
>  
>  	chip->paths[path_num] = path;
>  
> +	of_property_read_string(controller_node, "dr_mode", &dr_mode);
> +
> +	/* No role switch needed for fixed role controllers */
> +	if (!strcmp(dr_mode, "host")) {
> +		path->curr_role = USB_ROLE_HOST;
> +		of_node_put(controller_node);
> +		return 0;
> +	}
> +
> +	if (!strcmp(dr_mode, "peripheral")) {
> +		path->curr_role = USB_ROLE_DEVICE;
> +		of_node_put(controller_node);
> +		return 0;
> +	}
> +
> +	path->curr_role = USB_ROLE_NONE;
> +
> +	sw = usb_role_switch_find_by_fwnode(of_fwnode_handle(controller_node));
> +	if (!sw) {
> +		of_node_put(controller_node);
> +		return dev_err_probe(chip->dev, -EPROBE_DEFER,
> +				     "Failed to get controller role switch for path %d\n",
> +				     path_num);
> +	}
> +	path->controller_sw = sw;
> +
> +	of_node_put(controller_node);
> +
> +	path->np = of_node_get(np);
> +	role_sw_desc.fwnode = of_fwnode_handle(path->np);
> +	role_sw_desc.set = eud_role_switch_set;
> +	role_sw_desc.driver_data = path;
> +	snprintf(path->name, sizeof(path->name), "eud-path%u", path_num);
> +	role_sw_desc.name = path->name;
> +
> +	path->eud_sw = usb_role_switch_register(chip->dev, &role_sw_desc);

[Severity: High]
As reported by Konrad Dybcio on v9 [1], will eud_init_path() defer probe
forever when a controller omits dr_mode (or sets it to "otg") without a
usb-role-switch property?

When a DWC3 node omits both dr_mode and usb-role-switch (such as
usb_2_dwc3 on SM8350), dwc3_get_dr_mode() falls back to
USB_DR_MODE_PERIPHERAL at runtime and dwc3_drd_init() never registers a
usb_role_switch:

drivers/usb/dwc3/core.c:dwc3_get_dr_mode() {
    ...
		if (mode == USB_DR_MODE_OTG && !dwc->edev &&
		    (!IS_ENABLED(CONFIG_USB_ROLE_SWITCH) ||
		     !device_property_read_bool(dwc->dev, "usb-role-switch")) &&
		    !DWC3_VER_IS_PRIOR(DWC3, 330A))
			mode = USB_DR_MODE_PERIPHERAL;
    ...
}

Because eud_init_path() only checks for explicit "host" and "peripheral"
strings before calling usb_role_switch_find_by_fwnode(), eud_probe() will
fail permanently with -EPROBE_DEFER on any board with such a path.

Also, when np is the legacy "ports" child node (handled earlier in
eud_init_path()), setting role_sw_desc.fwnode to
of_fwnode_handle(path->np) registers path->eud_sw on the "ports" node,
which of_fwnode_graph_get_port_parent() skips in favor of the parent EUD
device node during usb_role_switch_get() lookup, so the connector can
never resolve path->eud_sw.

[1] https://lore.kernel.org/r/d4907952-60e6-48d9-ad81-1a0401f3207d@oss.qualcomm.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123182847.143892-1-elson.serrao@oss.qualcomm.com?part=4

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

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 18:28 [PATCH v10 0/7] Improve Qualcomm EUD driver and platform support Elson Serrao
2026-11-23 18:28 ` [PATCH v10 1/7] dt-bindings: soc: qcom: eud: Add per-path child nodes for UTMI routing Elson Serrao
2026-11-23 18:28 ` [PATCH v10 2/7] usb: misc: qcom_eud: add sysfs attribute for port selection Elson Serrao
2026-11-23 18:28 ` [PATCH v10 3/7] usb: misc: qcom_eud: add per-path High-Speed PHY control Elson Serrao
2026-11-23 18:48   ` sashiko-bot
2026-11-23 20:39     ` Elson Serrao
2026-11-23 18:28 ` [PATCH v10 4/7] usb: misc: qcom_eud: add per-path role switch support Elson Serrao
2026-11-23 18:56   ` sashiko-bot [this message]
2026-11-23 21:36     ` Elson Serrao
2026-11-23 18:28 ` [PATCH v10 5/7] usb: misc: qcom_eud: improve enable_store API Elson Serrao
2026-11-23 18:28 ` [PATCH v10 6/7] usb: misc: qcom_eud: add role-based EUD control Elson Serrao
2026-11-23 18:28 ` [PATCH v10 7/7] usb: misc: qcom_eud: fix virtual attach/detach event handling Elson Serrao
2026-11-23 18:56 ` [PATCH v10 0/7] Improve Qualcomm EUD driver and platform support sashiko-bot

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-229887@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=elson.serrao@oss.qualcomm.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.