Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Elson Serrao" <elson.serrao@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 6/8] usb: misc: qcom_eud: add role-based EUD control
Date: Tue, 29 Sep 2026 21:47:03 +0000	[thread overview]
Message-ID: <20260929214703.AC9BA1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260929213513.2401005-7-elson.serrao@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: qcom_eud: missing hardware and state rollback on role switch failure
--

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

usb: misc: qcom_eud: add role-based EUD control

EUD functions by presenting itself as a USB device to the host PC and is
therefore only applicable when the port operates in device role. This patch
addresses this by treating EUD as usable only in device role, enabling or
disabling it as the port enters or leaves device role.

> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index e227d05cfecd4..5a21a2dd0b0cd 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c

[ ... ]

> @@ -306,7 +331,30 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
>  static int eud_role_switch_set(struct usb_role_switch *sw, enum usb_role role)
>  {
>  	struct eud_path *path = usb_role_switch_get_drvdata(sw);
> -	int ret;
> +	struct eud_chip *chip = path->chip;
> +	int ret = 0;
> +
> +	guard(mutex)(&chip->state_lock);
> +
> +	/*
> +	 * EUD is usable only in device role. Power it down for every other
> +	 * role to avoid keeping an unusable module 'ON'. chip->enabled
> +	 * preserves user's sysfs configuration and is not modified across
> +	 * role transitions.
> +	 */
> +	if (chip->enabled && path->num == chip->port_idx && role != path->curr_role) {
> +		if (role == USB_ROLE_DEVICE)
> +			ret = enable_eud(chip);
> +		else if (path->curr_role == USB_ROLE_DEVICE)
> +			ret = disable_eud(chip);
> +
> +		if (ret) {
> +			dev_err(chip->dev, "failed to %s EUD for role %s: %d\n",
> +				str_enable_disable(role == USB_ROLE_DEVICE),
> +				usb_role_string(role), ret);
> +			return ret;
> +		}
> +	}
>  
>  	/* curr_role tracks the role from EUD's point of view */
>  	path->curr_role = role;
> 
>  	/* Forward the role request to the USB controller */
>  	ret = usb_role_switch_set_role(path->controller_sw, role);
>  	if (ret) {
>  		dev_err(path->chip->dev, "failed to set role %s for port %u: %d\n",
>  			usb_role_string(role), path->num, ret);
>  		return ret;
>  	}

[Severity: High]
Does this error path leave the hardware and state permanently desynchronized
if the downstream controller switch fails?

If a role switch to USB_ROLE_DEVICE is requested, enable_eud() succeeds and
path->curr_role is updated.  Then usb_role_switch_set_role() is called to
forward the switch to the controller.

If this downstream switch fails and returns an error, the function returns
early without reverting path->curr_role or powering down the EUD via
disable_eud().

As noted in the commit message, enabling EUD in host role can cause the USB
controller to misbehave. Could this sequence leave the EUD hardware enabled
while the underlying USB controller remains in its previous role?

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

  reply	other threads:[~2026-09-29 21:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 21:35 [PATCH v9 0/8] Improve Qualcomm EUD driver and platform support Elson Serrao
2026-09-29 21:35 ` [PATCH v9 1/8] dt-bindings: soc: qcom: eud: Add per-path child nodes for UTMI routing Elson Serrao
2026-09-29 21:35 ` [PATCH v9 2/8] usb: misc: qcom_eud: add sysfs attribute for port selection Elson Serrao
2026-09-29 21:35 ` [PATCH v9 3/8] usb: misc: qcom_eud: add per-path High-Speed PHY control Elson Serrao
2026-09-29 21:35 ` [PATCH v9 4/8] usb: misc: qcom_eud: add per-path role switch support Elson Serrao
2026-09-29 21:35 ` [PATCH v9 5/8] usb: misc: qcom_eud: improve enable_store API Elson Serrao
2026-09-29 21:43   ` sashiko-bot
2026-09-29 22:45     ` Elson Serrao
2026-09-29 21:35 ` [PATCH v9 6/8] usb: misc: qcom_eud: add role-based EUD control Elson Serrao
2026-09-29 21:47   ` sashiko-bot [this message]
2026-09-29 22:48     ` Elson Serrao
2026-09-29 21:35 ` [PATCH v9 7/8] usb: misc: qcom_eud: fix virtual attach/detach event handling Elson Serrao
2026-09-29 21:35 ` [PATCH v9 8/8] arm64: dts: qcom: kodiak: Desribe EUD UTMI routing and connector mapping Elson Serrao
2026-10-07 10:44 ` [PATCH v9 0/8] Improve Qualcomm EUD driver and platform support Gopikrishna Garmidi

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=20260929214703.AC9BA1F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=elson.serrao@oss.qualcomm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox