Thread (25 messages) 25 messages, 4 authors, 2026-02-10

Re: [PATCH v2 6/9] usb: misc: qcom_eud: add host mode coordination

From: Elson Serrao <hidden>
Date: 2026-02-09 17:37:26
Also in: linux-arm-msm, linux-usb, lkml


On 2/4/2026 5:29 AM, Konrad Dybcio wrote:
On 1/27/26 12:38 AM, Elson Serrao wrote:
quoted
EUD functions by presenting itself as a USB device to the host PC for
debugging, making it incompatible in USB host mode configurations.
Enabling EUD, when in host mode can also cause the USB controller to
misbehave as the EUD hub can only have one upstream facing port.
Perhaps that's a silly idea, but would the device itself see
the debug hub, being able to essentially self-debug in a way?
This isn’t supported by the current hardware topology.

When EUD is enabled, it enumerates as a USB device to an external host via its
upstream-facing port, while the SoC USB controller sits behind the hub’s
downstream-facing port. As a result, the controller cannot enumerate or
interact with the EUD device itself, and host mode is mutually exclusive with
EUD debug on this path.

Thanks
Elson
[...]
quoted
@@ -162,32 +165,66 @@ static ssize_t enable_store(struct device *dev,
 		const char *buf, size_t count)
 {
 	struct eud_chip *chip = dev_get_drvdata(dev);
+	struct eud_path *path;
 	bool enable;
 	int ret;
 
 	if (kstrtobool(buf, &enable))
 		return -EINVAL;
 
+	mutex_lock(&chip->state_lock);
If you use guard(mutex)(&chip->state-lock), you can waive all these
conditional mutex_unlock additions
quoted
+
 	/* Skip operation if already in desired state */
-	if (chip->enabled == enable)
+	if (chip->enabled == enable) {
+		mutex_unlock(&chip->state_lock);
 		return count;
+	}
+
+	/*
+	 * Handle double-disable scenario: User is disabling EUD that was already
+	 * disabled due to host mode. Since the hardware is already disabled, we
+	 * only need to clear the host-disabled flag to prevent unwanted re-enabling
+	 * when exiting host mode. This respects the user's explicit disable request.
+	 */
+	if (!enable && chip->eud_disabled_for_host) {
+		chip->eud_disabled_for_host = false;
+		chip->enabled = false;
+		mutex_unlock(&chip->state_lock);
+		return count;
+	}
 
 	if (enable) {
+		/*
+		 * EUD functions by presenting itself as a USB device to the host PC for
+		 * debugging, making it incompatible in USB host mode configuration.
+		 * Prevent enabling EUD in this configuration to avoid hardware conflicts.
+		 */
+		path = chip->paths[chip->port_idx];
+		if (path && path->curr_role == USB_ROLE_HOST) {
+			dev_err(chip->dev, "EUD not usable in host mode configuration\n");
"in USB host mode"?

[...]
quoted
+	/*
+	 * EUD must be disabled when USB operates in host mode. EUD functions by
+	 * presenting itself as a USB device to the host PC for debugging, making
+	 * it incompatible in host mode configuration.
			   ^ with

Otherwise the logic looks good, I think this may be desired default
behavior (so that the user doesn't have to constantly keep re-enabling
EUD)

Konrad
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help