Skip to contentSkip to conversation

usb: chipidea: move ci_ulpi_init after the phy initialization

PATCH In review Michael Grzeschik 5 participants 5 messages Apr 2, 2024 – Jun 6, 2024

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

PATCH 1/1 usb: chipidea: move ci_ulpi_init after the phy initialization

The function ci_usb_phy_init is already handling the hw_phymode_configure path which is also only possible after we have a valid phy. So we move the ci_ulpi_init after the phy initialization to be really sure to be able to communicate with the ulpi phy.

---
 drivers/usb/chipidea/core.c | 8 ++++----
 drivers/usb/chipidea/ulpi.c | 5 -----
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/chipidea/core.c +4 -4
index 835bf2428dc6e..bada13f704b62 100644
@@ -1084,10 +1084,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ret = ci_ulpi_init(ci);
-	if (ret)
-		return ret;
-
 	if (ci->platdata->phy) {
 		ci->phy = ci->platdata->phy;
 	} else if (ci->platdata->usb_phy) {
@@ -1142,6 +1138,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		goto ulpi_exit;
 	}
 
+	ret = ci_ulpi_init(ci);
+	if (ret)
+		return ret;
+
 	ci->hw_bank.phys = res->start;
 
 	ci->irq = platform_get_irq(pdev, 0);
drivers/usb/chipidea/ulpi.c +0 -5
index dfec07e8ae1d2..89fb51e2c3ded 100644
@@ -68,11 +68,6 @@ int ci_ulpi_init(struct ci_hdrc *ci)
 	if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
 		return 0;
 
-	/*
-	 * Set PORTSC correctly so we can read/write ULPI registers for
-	 * identification purposes
-	 */
-	hw_phymode_configure(ci);
 
 	ci->ulpi_ops.read = ci_ulpi_read;
 	ci->ulpi_ops.write = ci_ulpi_write;

---
base-commit: 5bab5dc780c9ed0c69fc2f828015532acf4a7848
change-id: 20240328-chipidea-phy-misc-b3f2bc814784

Best regards,

Signature · 1 line
Michael Grzeschik <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Michael Grzeschik

The function ci_usb_phy_init is already handling the hw_phymode_configure path which is also only possible after we have a valid phy. So we move the ci_ulpi_init after the phy initialization to be really sure to be able to communicate with the ulpi phy.

Quoted 56 lines
---
 drivers/usb/chipidea/core.c | 8 ++++----
 drivers/usb/chipidea/ulpi.c | 5 -----
 2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/chipidea/core.c +4 -4
index 835bf2428dc6e..bada13f704b62 100644
@@ -1084,10 +1084,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ret = ci_ulpi_init(ci);
-	if (ret)
-		return ret;
-
 	if (ci->platdata->phy) {
 		ci->phy = ci->platdata->phy;
 	} else if (ci->platdata->usb_phy) {
@@ -1142,6 +1138,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
 		goto ulpi_exit;
 	}
 
+	ret = ci_ulpi_init(ci);
+	if (ret)
+		return ret;
+
 	ci->hw_bank.phys = res->start;
 
 	ci->irq = platform_get_irq(pdev, 0);
drivers/usb/chipidea/ulpi.c +0 -6
index dfec07e8ae1d2..89fb51e2c3ded 100644
@@ -68,11 +68,6 @@ int ci_ulpi_init(struct ci_hdrc *ci)
 	if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
 		return 0;
 
-	/*
-	 * Set PORTSC correctly so we can read/write ULPI registers for
-	 * identification purposes
-	 */
-	hw_phymode_configure(ci);
 
 	ci->ulpi_ops.read = ci_ulpi_read;
 	ci->ulpi_ops.write = ci_ulpi_write;
 
---

base-commit: 5bab5dc780c9ed0c69fc2f828015532acf4a7848
change-id: 20240328-chipidea-phy-misc-b3f2bc814784

Best regards,

Signature · 1 line
Michael Grzeschik <[email protected]>
Signature · 2 lines
Thanks,
Peter Chen
#2 lore raw
In reply to Michael Grzeschik

Dear All,

Quoted 6 lines · Michael Grzeschik

The function ci_usb_phy_init is already handling the hw_phymode_configure path which is also only possible after we have a valid phy. So we move the ci_ulpi_init after the phy initialization to be really sure to be able to communicate with the ulpi phy.

This patch landed in linux-next some time ago as commit 22ffd399e6e7 ("usb: chipidea: move ci_ulpi_init after the phy initialization"). Unfortunately it breaks host USB operation on DragonBoard410c (arch/arm64/boot/dts/qcom/apq8016-sbc.dts). There is no error nor warning in the kernel log besides the information about deferred probe on the chipidea controller:

platform ci_hdrc.0: deferred probe pending: (reason unknown)

Tomorrow I will try to investigate which operation during driver probe triggers it. If there is anything else to check that might help fixing this issue, let me know.

Quoted 52 lines
---
  drivers/usb/chipidea/core.c | 8 ++++----
  drivers/usb/chipidea/ulpi.c | 5 -----
  2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/chipidea/core.c +4 -4
index 835bf2428dc6e..bada13f704b62 100644
@@ -1084,10 +1084,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
  		return -ENODEV;
  	}
 
-	ret = ci_ulpi_init(ci);
-	if (ret)
-		return ret;
-
  	if (ci->platdata->phy) {
  		ci->phy = ci->platdata->phy;
  	} else if (ci->platdata->usb_phy) {
@@ -1142,6 +1138,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
  		goto ulpi_exit;
  	}
 
+	ret = ci_ulpi_init(ci);
+	if (ret)
+		return ret;
+
  	ci->hw_bank.phys = res->start;
 
  	ci->irq = platform_get_irq(pdev, 0);
drivers/usb/chipidea/ulpi.c +0 -6
index dfec07e8ae1d2..89fb51e2c3ded 100644
@@ -68,11 +68,6 @@ int ci_ulpi_init(struct ci_hdrc *ci)
  	if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
  		return 0;
 
-	/*
-	 * Set PORTSC correctly so we can read/write ULPI registers for
-	 * identification purposes
-	 */
-	hw_phymode_configure(ci);
 
  	ci->ulpi_ops.read = ci_ulpi_read;
  	ci->ulpi_ops.write = ci_ulpi_write;
 
---

base-commit: 5bab5dc780c9ed0c69fc2f828015532acf4a7848
change-id: 20240328-chipidea-phy-misc-b3f2bc814784

Quoted 1 line

Best regards,

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
#3 lore raw
Quoted 17 lines · Marek Szyprowski

Dear All,

Quoted 6 lines · Michael Grzeschik

The function ci_usb_phy_init is already handling the hw_phymode_configure path which is also only possible after we have a valid phy. So we move the ci_ulpi_init after the phy initialization to be really sure to be able to communicate with the ulpi phy.

This patch landed in linux-next some time ago as commit 22ffd399e6e7 ("usb: chipidea: move ci_ulpi_init after the phy initialization"). Unfortunately it breaks host USB operation on DragonBoard410c (arch/arm64/boot/dts/qcom/apq8016-sbc.dts). There is no error nor warning in the kernel log besides the information about deferred probe on the chipidea controller:

Quoted 5 lines

platform ci_hdrc.0: deferred probe pending: (reason unknown)

Tomorrow I will try to investigate which operation during driver probe triggers it. If there is anything else to check that might help fixing this issue, let me know.

I am also seeing this issue on a msm8974-based device.

There is also a report and analysis by Wouter Franken here:
https://lore.kernel.org/all/[email protected]/

Reverting the commit does fix the issue for me.

Adding to regzbot for tracking:

#regzbot introduced: 22ffd399e6e7 ^

Thanks,
Alexandre

Quoted 56 lines
Quoted 53 lines
---
  drivers/usb/chipidea/core.c | 8 ++++----
  drivers/usb/chipidea/ulpi.c | 5 -----
  2 files changed, 4 insertions(+), 9 deletions(-)
drivers/usb/chipidea/core.c +4 -4
index 835bf2428dc6e..bada13f704b62 100644
@@ -1084,10 +1084,6 @@ static int ci_hdrc_probe(struct platform_device *pdev)
  		return -ENODEV;
  	}
 
-	ret = ci_ulpi_init(ci);
-	if (ret)
-		return ret;
-
  	if (ci->platdata->phy) {
  		ci->phy = ci->platdata->phy;
  	} else if (ci->platdata->usb_phy) {
@@ -1142,6 +1138,10 @@ static int ci_hdrc_probe(struct platform_device *pdev)
  		goto ulpi_exit;
  	}
 
+	ret = ci_ulpi_init(ci);
+	if (ret)
+		return ret;
+
  	ci->hw_bank.phys = res->start;
 
  	ci->irq = platform_get_irq(pdev, 0);
drivers/usb/chipidea/ulpi.c +0 -6
index dfec07e8ae1d2..89fb51e2c3ded 100644
@@ -68,11 +68,6 @@ int ci_ulpi_init(struct ci_hdrc *ci)
  	if (ci->platdata->phy_mode != USBPHY_INTERFACE_MODE_ULPI)
  		return 0;
 
-	/*
-	 * Set PORTSC correctly so we can read/write ULPI registers for
-	 * identification purposes
-	 */
-	hw_phymode_configure(ci);
 
  	ci->ulpi_ops.read = ci_ulpi_read;
  	ci->ulpi_ops.write = ci_ulpi_write;
 
---

base-commit: 5bab5dc780c9ed0c69fc2f828015532acf4a7848
change-id: 20240328-chipidea-phy-misc-b3f2bc814784

Quoted 1 line

Best regards,

Best regards

#4 lore raw
Quoted 16 lines · Alexandre Messier
Quoted 6 lines · Marek Szyprowski
Quoted 5 lines · Michael Grzeschik

The function ci_usb_phy_init is already handling the hw_phymode_configure path which is also only possible after we have a valid phy. So we move the ci_ulpi_init after the phy initialization to be really sure to be able to communicate with the ulpi phy.

Quoted 8 lines
Quoted 1 line

This patch landed in linux-next some time ago as commit 22ffd399e6e7 ("usb: chipidea: move ci_ulpi_init after the phy initialization"). Unfortunately it breaks host USB operation on DragonBoard410c (arch/arm64/boot/dts/qcom/apq8016-sbc.dts). There is no error nor warning in the kernel log besides the information about deferred probe on the chipidea controller:

Quoted 4 lines

I am also seeing this issue on a msm8974-based device.

There is also a report and analysis by Wouter Franken here:
https://lore.kernel.org/all/[email protected]/

TWIMC, as this is easy to miss (I was extremely close to writing a status inquiry instead of writing what I'm typing now): Greg applied that revert two days ago and I assume he'll soon send it to Linus.

Ciao, Thorsten

#regzbot fix: 718d4a63c0a62d16af1d0425d515d7e76f35681e #regzbot ignore-activity