Skip to contentSkip to conversation

usb: xhci-dwc3: Bail out if "dr_mode" is "peripheral"

PATCH In review Siddharth Vadapalli 3 participants 5 messages Dec 6, 2024 – Jan 16, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: xhci-dwc3: Bail out if "dr_mode" is "peripheral"

Since the compatible "snps,dwc3" can be specified in the device-tree for the Designware USB Controller configured for not only Host and OTG modes of operation, but also for Peripheral mode of operation, bail out if "dr_mode" is "peripheral".

---

Hello,

This patch is based on commit
448add55297 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-pmic
of the master branch of U-Boot.

Regards,
Siddharth.

 drivers/usb/host/xhci-dwc3.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-dwc3.c +3 -0
index e3e0ceff43e..7b1311503fe 100644
@@ -208,6 +208,9 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
 	if (dr_mode == USB_DR_MODE_OTG &&
 	    dev_read_bool(dev, "usb-role-switch")) {
 		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));
Signature · 1 line
2.43.0
#1 lore raw

Hi Siddharth,

Quoted 25 lines · Siddharth Vadapalli

Since the compatible "snps,dwc3" can be specified in the device-tree for the Designware USB Controller configured for not only Host and OTG modes of operation, but also for Peripheral mode of operation, bail out if "dr_mode" is "peripheral".

---

Hello,

This patch is based on commit
448add55297 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-pmic
of the master branch of U-Boot.

Regards,
Siddharth.

 drivers/usb/host/xhci-dwc3.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-dwc3.c +0 -0
index e3e0ceff43e..7b1311503fe 100644

drivers/usb/host/xhci-dwc3.c static int xhci_dwc3_probe(struct udevice *dev) · line 216

Quoted 9 lines
drivers/usb/host/xhci-dwc3.c +3 -0
@@ -208,6 +208,9 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
 	if (dr_mode == USB_DR_MODE_OTG &&
 	    dev_read_bool(dev, "usb-role-switch")) {
 		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));

Although this proposal was suggested in [1] and later clarified in
[2] I will summarize the discussion here.

This patch fix is not sufficient for all cases as the xhci-dwc3.c driver will still be probed if dr_mode is OTG or HOST along with other platform drivers if enabled in config.

The only current solution is not not enable CONFIG_USB_XHCI_DWC3 together with another platform driver config (e.g. CONFIG_USB_DWC3_GENERIC) if snps,dwc3 should not be managed by xhci-dwc3.c.

[1] - https://lore.kernel.org/all/unf757pwgah5ylkcfdumtdo5zs2ny3nxct5u26t6up7aldqim2@mxhhtb53gw4x/
[2] - https://lore.kernel.org/all/[email protected]/

Signature · 2 lines
cheers,
-roger
#2 lore raw

Hi Siddharth,

Quoted 41 lines · Roger Quadros

Hi Siddharth,

Quoted 25 lines · Siddharth Vadapalli

Since the compatible "snps,dwc3" can be specified in the device-tree for the Designware USB Controller configured for not only Host and OTG modes of operation, but also for Peripheral mode of operation, bail out if "dr_mode" is "peripheral".

---

Hello,

This patch is based on commit
448add55297 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-pmic
of the master branch of U-Boot.

Regards,
Siddharth.

 drivers/usb/host/xhci-dwc3.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/host/xhci-dwc3.c +0 -0
index e3e0ceff43e..7b1311503fe 100644

drivers/usb/host/xhci-dwc3.c static int xhci_dwc3_probe(struct udevice *dev) · line 216

Quoted 9 lines
drivers/usb/host/xhci-dwc3.c +3 -0
@@ -208,6 +208,9 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
 	if (dr_mode == USB_DR_MODE_OTG &&
 	    dev_read_bool(dev, "usb-role-switch")) {
 		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));

Although this proposal was suggested in [1] and later clarified in
[2] I will summarize the discussion here.

Quoted 7 lines

This patch fix is not sufficient for all cases as the xhci-dwc3.c driver will still be probed if dr_mode is OTG or HOST along with other platform drivers if enabled in config.

The only current solution is not not enable CONFIG_USB_XHCI_DWC3 together with another platform driver config (e.g. CONFIG_USB_DWC3_GENERIC) if snps,dwc3 should not be managed by xhci-dwc3.c.

Given Roger's explanation, should we simply drop this, or is any other action expected from the U-Boot maintainers?

Thanks,
Mattijs

Quoted 7 lines

[1] - https://lore.kernel.org/all/unf757pwgah5ylkcfdumtdo5zs2ny3nxct5u26t6up7aldqim2@mxhhtb53gw4x/
[2] - https://lore.kernel.org/all/[email protected]/

Signature · 2 lines
cheers,
-roger
#3 lore raw
Quoted 1 line · Mattijs Korpershoek

Hi Siddharth,

Hello Mattijs,

Quoted 6 lines · Roger Quadros
Quoted 4 lines

Hi Siddharth,

On 06/12/2024 13:04, Siddharth Vadapalli wrote:

[...]

Quoted 22 lines
Quoted 22 lines
Quoted 5 lines
drivers/usb/host/xhci-dwc3.c +0 -0
index e3e0ceff43e..7b1311503fe 100644

drivers/usb/host/xhci-dwc3.c static int xhci_dwc3_probe(struct udevice *dev) · line 216

Quoted 9 lines
drivers/usb/host/xhci-dwc3.c +3 -0
@@ -208,6 +208,9 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
 	if (dr_mode == USB_DR_MODE_OTG &&
 	    dev_read_bool(dev, "usb-role-switch")) {
 		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));

Although this proposal was suggested in [1] and later clarified in
[2] I will summarize the discussion here.

This patch fix is not sufficient for all cases as the xhci-dwc3.c driver will still be probed if dr_mode is OTG or HOST along with other platform drivers if enabled in config.

Quoted 6 lines
Quoted 3 lines

The only current solution is not not enable CONFIG_USB_XHCI_DWC3 together with another platform driver config (e.g. CONFIG_USB_DWC3_GENERIC) if snps,dwc3 should not be managed by xhci-dwc3.c.

Given Roger's explanation, should we simply drop this, or is any other action expected from the U-Boot maintainers?

This patch could be dropped. Roger's suggestion is to fix this issue by updating the platform configs wherein CONFIG_USB_XHCI_DWC3 should be disabled on platforms that have "dr_mode" set to "peripheral".

Regards,
Siddharth.

#4 lore raw
Quoted 40 lines · Siddharth Vadapalli
Quoted 1 line · Mattijs Korpershoek

Hi Siddharth,

Hello Mattijs,

Quoted 6 lines · Roger Quadros
Quoted 4 lines

Hi Siddharth,

On 06/12/2024 13:04, Siddharth Vadapalli wrote:

[...]

Quoted 26 lines
Quoted 25 lines
Quoted 5 lines
drivers/usb/host/xhci-dwc3.c +0 -0
index e3e0ceff43e..7b1311503fe 100644

drivers/usb/host/xhci-dwc3.c static int xhci_dwc3_probe(struct udevice *dev) · line 216

Quoted 9 lines
drivers/usb/host/xhci-dwc3.c +3 -0
@@ -208,6 +208,9 @@ static int xhci_dwc3_probe(struct udevice *dev)
 	writel(reg, &dwc3_reg->g_usb2phycfg[0]);
 
 	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+	if (dr_mode == USB_DR_MODE_PERIPHERAL)
+		return -ENODEV;
+
 	if (dr_mode == USB_DR_MODE_OTG &&
 	    dev_read_bool(dev, "usb-role-switch")) {
 		dr_mode = usb_get_role_switch_default_mode(dev_ofnode(dev));

Although this proposal was suggested in [1] and later clarified in
[2] I will summarize the discussion here.

This patch fix is not sufficient for all cases as the xhci-dwc3.c driver will still be probed if dr_mode is OTG or HOST along with other platform drivers if enabled in config.

The only current solution is not not enable CONFIG_USB_XHCI_DWC3 together with another platform driver config (e.g. CONFIG_USB_DWC3_GENERIC) if snps,dwc3 should not be managed by xhci-dwc3.c.

Quoted 6 lines
Quoted 2 lines

Given Roger's explanation, should we simply drop this, or is any other action expected from the U-Boot maintainers?

This patch could be dropped. Roger's suggestion is to fix this issue by updating the platform configs wherein CONFIG_USB_XHCI_DWC3 should be disabled on platforms that have "dr_mode" set to "peripheral".

Thank you for confirming.

I've marked as "Handled elsewhere" on patchwork:
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 3 lines

Regards,
Siddharth.