Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Elson Serrao" <elson.serrao@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v5 4/9] usb: misc: qcom_eud: add per-path role switch support
Date: Mon, 03 Aug 2026 03:30:03 +0000	[thread overview]
Message-ID: <20260803033003.F2A381F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803031534.2942628-5-elson.serrao@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [High] Missing synchronization in sysfs handlers enable_store and port_store causes PHY reference count corruption and hardware desynchronization.
- [High] EUD remains physically enabled when the role switches to HOST, breaking host mode.

Pre-existing issues:
- [High] Sysfs enable_store fails to clear chip->enabled on disable, permanently locking port_store.
--

--- Patch [4]: [PATCH v5 4/9] usb: misc: qcom_eud: add per-path role switch support ---
commit b7772664d1b8d3bcc67e85e648539118fa47a9cd
Author: Elson Serrao <elson.serrao@oss.qualcomm.com>

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

This commit updates the EUD driver to support per-path role switches instead
of a single chip-level switch. It allows each path to handle independent role
management by relaying requests from the connector to the controller. The
unnecessary role switch call from enable_eud() is also removed.

> diff --git a/drivers/usb/misc/qcom_eud.c b/drivers/usb/misc/qcom_eud.c
> index 03d1c200658c8..48a4441b0c9c0 100644
> --- a/drivers/usb/misc/qcom_eud.c
> +++ b/drivers/usb/misc/qcom_eud.c

[ ... ]

> @@ -286,17 +292,39 @@ static irqreturn_t handle_eud_irq_thread(int irq, void *data)
>  	return IRQ_HANDLED;
>  }
>  
> -static void eud_role_switch_release(void *data)
> +static int eud_role_switch_set(struct usb_role_switch *sw, enum usb_role role)
>  {
> -	struct eud_chip *chip = data;
> +	struct eud_path *path = usb_role_switch_get_drvdata(sw);
> +	int ret;
> +
> +	/* 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;
> +	}
> +
> +	path->curr_role = role;
> +
> +	return 0;
> +}

[Severity: High]
Does the EUD remain physically enabled when the role switches to USB_ROLE_HOST?

If a role switch to USB_ROLE_HOST occurs, eud_role_switch_set() forwards the
request to the USB controller but doesn't appear to dynamically disable the
EUD hardware itself. Since EUD is only usable in device role, would keeping it
enabled during host role disrupt the UTMI lines and break the host connection?

[Severity: High]
Could the missing synchronization between the sysfs handlers enable_store()
and port_store() cause PHY reference count corruption?

Looking at drivers/usb/misc/qcom_eud.c, if Thread A executes enable_store()
while Thread B concurrently executes port_store(), port_store() can modify
chip->port_idx locklessly:

Thread B in port_store():
    chip->port_idx = port;

Thread A in enable_store() would then execute enable_eud() without seeing the
updated port_idx or while it is changing:

Thread A in enable_store():
    ret = enable_eud(chip);
    if (!ret)
        chip->enabled = enable;

Because neither function holds a lock, port_store() can bypass the
chip->enabled check. This might cause eud_phy_enable() to power on the PHY
for the new port. When disable_eud() is later called, could it disable the
wrong PHY and leak the power-on state for the old PHY?

[Severity: High]
This is a pre-existing issue, but does enable_store() fail to clear the
enabled flag on disable?

Looking at enable_store() in drivers/usb/misc/qcom_eud.c:

enable_store() {
    ...
    } else {
        ret = disable_eud(chip);
    }

    return ret < 0 ? ret : count;
}

If a user writes 0 to the enable sysfs attribute, this calls disable_eud(chip)
but doesn't set chip->enabled = false. Could this permanently lock
port_store(), since subsequent writes will unconditionally fail with -EBUSY
when checking if (chip->enabled)?

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

  reply	other threads:[~2026-08-03  3:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  3:15 [PATCH v5 0/9] Improve Qualcomm EUD driver and platform support Elson Serrao
2026-08-03  3:15 ` [PATCH v5 1/9] dt-bindings: soc: qcom: eud: Add per-path child nodes for UTMI routing Elson Serrao
2026-08-03  3:23   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 2/9] usb: misc: qcom_eud: add sysfs attribute for port selection Elson Serrao
2026-08-03  3:25   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 3/9] usb: misc: qcom_eud: add per-path High-Speed PHY control Elson Serrao
2026-08-03  3:28   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 4/9] usb: misc: qcom_eud: add per-path role switch support Elson Serrao
2026-08-03  3:30   ` sashiko-bot [this message]
2026-08-03  9:37   ` Peter Chen
2026-08-03  3:15 ` [PATCH v5 5/9] usb: misc: qcom_eud: improve enable_store API Elson Serrao
2026-08-03  3:25   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 6/9] usb: misc: qcom_eud: add role-based EUD control Elson Serrao
2026-08-03  3:27   ` sashiko-bot
2026-08-03  9:50   ` Peter Chen
2026-08-03  3:15 ` [PATCH v5 7/9] usb: misc: qcom_eud: fix virtual attach/detach event handling Elson Serrao
2026-08-03  3:26   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 8/9] arm64: dts: qcom: kodiak: Describe EUD UTMI path using child node Elson Serrao
2026-08-03  3:54   ` sashiko-bot
2026-08-03  3:15 ` [PATCH v5 9/9] arm64: dts: qcom: Map USB connector to EUD on Kodiak boards Elson Serrao

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=20260803033003.F2A381F000E9@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