Devicetree
 help / color / mirror / Atom feed
From: Elson Serrao <elson.serrao@oss.qualcomm.com>
To: sashiko-reviews@lists.linux.dev
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Subject: Re: [PATCH v9 6/8] usb: misc: qcom_eud: add role-based EUD control
Date: Tue, 29 Sep 2026 15:48:11 -0700	[thread overview]
Message-ID: <b450250d-43fe-41d2-8d7c-a13b48dd4104@oss.qualcomm.com> (raw)
In-Reply-To: <20260929214703.AC9BA1F00898@smtp.kernel.org>



On 9/29/2026 2:47 PM, sashiko-bot@kernel.org wrote:
> 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)

[...]

>>  	/* 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?
> 
This is intentional. As documented path->curr_role tracks the role requested
for the path, so EUD follows that request rather than the controller's
outcome. The host-role concern applies when the port is in host role.
Here device role was requested, so the link partner is a host, which is
exactly the setup EUD is meant for. Rolling back would not fix the controller,
which is already in an error state, and the failure is logged and returned.
Since EUD operates independently of the controller, keeping it enabled
also preserves debug access for investigating such a failure.

Thanks
Elson

  reply	other threads:[~2026-09-29 22:48 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
2026-09-29 22:48     ` Elson Serrao [this message]
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=b450250d-43fe-41d2-8d7c-a13b48dd4104@oss.qualcomm.com \
    --to=elson.serrao@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@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