Skip to contentSkip to conversation

phy: generic: add error trace to detect PHY issue in uclass

PATCH New Patrick Delaunay 3 participants 16 messages Jul 3, 2020 – Sep 22, 2020

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

v3 cover phy: generic: add error trace to detect PHY issue in uclass

Hi,

it is a V3 serie for [1].

After rebase 2 patches are no more needed:
[v2,2/8] usb: gadget: dwc2: change trace level for phy errors managed by uclass [v2,6/8] usb: dwc3: change trace level for phy errors managed by uclass

And I add a patch in this V3 serie:
[PATCH v3 7/7] arm: meson: change trace level for phy errors managed

Regards,

Patrick

[1] [v2,1/8] phy: generic: add error trace to detect PHY issue in uclass
http://patchwork.ozlabs.org/project/uboot/list/?series=159187&state=*

Changes in v3:
- rebase on next branch
- removed added dm/device_compat.h include after rebase
- simplify test on ops presence after Marek review
- add update for mach-meson board-gx: new generic_phy API usage

Changes in v2:
- Rebase and add include dm/device_compat.h
- Added patch after rebase: new generic_phy API usage

Patrick Delaunay (7):
phy: generic: add error trace to detect PHY issue in uclass
board: sunxi: change trace level for phy errors managed by uclass
usb: host: ohci: change trace level for phy errors managed by uclass
usb: host: ehci-hcd: change trace level for phy errors managed by
uclass
ata: dwc-ahci: change trace level for phy errors managed by uclass
usb: musb-new: sunxi: change trace level for phy errors managed by
uclass
arm: meson: change trace level for phy errors managed by uclass

 arch/arm/mach-meson/board-gx.c  |  8 +++---
 board/sunxi/board.c             |  2 +-
 drivers/ata/dwc_ahci.c          |  4 +--
 drivers/phy/phy-uclass.c        | 45 +++++++++++++++++++++++++++++----
 drivers/usb/host/ehci-hcd.c     |  8 +++---
 drivers/usb/host/ohci-generic.c |  8 +++---
 drivers/usb/musb-new/sunxi.c    |  8 +++---
 7 files changed, 59 insertions(+), 24 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/7 phy: generic: add error trace to detect PHY issue in uclass

Add an error trace for PHY errors directly in generic phy functions provided by PHY uclass.

---

This patch is requested by Marek Vasut to avoid code duplication in usb host serie for dwc2:

See http://patchwork.ozlabs.org/patch/1176048/#2297595
[U-Boot,RESEND,1/5] usb: host: dwc2: add phy support

Changes in v3:
- rebase on next branch
- removed added dm/device_compat.h include after rebase
- simplify test on ops presence after Marek review

Changes in v2:
- Rebase and add include dm/device_compat.h

 drivers/phy/phy-uclass.c | 45 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)
drivers/phy/phy-uclass.c +40 -5
index db7f39cd0b..8f456f33d2 100644
@@ -117,56 +117,91 @@ int generic_phy_get_by_name(struct udevice *dev, const char *phy_name,
 int generic_phy_init(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!generic_phy_valid(phy))
 		return 0;
 	ops = phy_dev_ops(phy->dev);
+	if (!ops->init)
+		return 0;
+	ret = ops->init(phy);
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
+			phy->dev->name, ret);
 
-	return ops->init ? ops->init(phy) : 0;
+	return ret;
 }
 
 int generic_phy_reset(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!generic_phy_valid(phy))
 		return 0;
 	ops = phy_dev_ops(phy->dev);
+	if (!ops->reset)
+		return 0;
+	ret = ops->reset(phy);
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to reset %s: %d.\n",
+			phy->dev->name, ret);
 
-	return ops->reset ? ops->reset(phy) : 0;
+	return ret;
 }
 
 int generic_phy_exit(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!generic_phy_valid(phy))
 		return 0;
 	ops = phy_dev_ops(phy->dev);
+	if (!ops->exit)
+		return 0;
+	ret = ops->exit(phy);
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
+			phy->dev->name, ret);
 
-	return ops->exit ? ops->exit(phy) : 0;
+	return ret;
 }
 
 int generic_phy_power_on(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!generic_phy_valid(phy))
 		return 0;
 	ops = phy_dev_ops(phy->dev);
+	if (!ops->power_on)
+		return 0;
+	ret = ops->power_on(phy);
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
+			phy->dev->name, ret);
 
-	return ops->power_on ? ops->power_on(phy) : 0;
+	return ret;
 }
 
 int generic_phy_power_off(struct phy *phy)
 {
 	struct phy_ops const *ops;
+	int ret;
 
 	if (!generic_phy_valid(phy))
 		return 0;
 	ops = phy_dev_ops(phy->dev);
+	if (!ops->power_off)
+		return 0;
+	ret = ops->power_off(phy);
+	if (ret)
+		dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
+			phy->dev->name, ret);
 
-	return ops->power_off ? ops->power_off(phy) : 0;
+	return ret;
 }
 
 int generic_phy_get_bulk(struct udevice *dev, struct phy_bulk *bulk)
Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/7 phy: generic: add error trace to detect PHY issue in uclass

Quoted 4 lines · Patrick Delaunay

Add an error trace for PHY errors directly in generic phy functions provided by PHY uclass.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/9fbaa208/attachment.sig>
#3 lore raw

PATCH v3 2/7 board: sunxi: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_idebug.

---

(no changes since v1)

 board/sunxi/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/sunxi/board.c +1 -1
index f32e8f582f..f1925f032d 100644
@@ -711,7 +711,7 @@ int g_dnl_board_usb_cable_connected(void)
 
 	ret = generic_phy_init(&phy);
 	if (ret) {
-		pr_err("failed to init %s USB PHY\n", dev->name);
+		pr_debug("failed to init %s USB PHY\n", dev->name);
 		return ret;
 	}
 
Signature · 1 line
2.17.1
#4 lore raw

PATCH v3 2/7 board: sunxi: change trace level for phy errors managed by uclass

Quoted 4 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_idebug.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/d34676de/attachment.sig>
#5 lore raw

PATCH v3 3/7 usb: host: ohci: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the dev_err can be change to dev_dbg.

---

(no changes since v1)

 drivers/usb/host/ohci-generic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/ohci-generic.c +4 -4
index 631711a9e8..f1e5b4e769 100644
@@ -41,13 +41,13 @@ static int ohci_setup_phy(struct udevice *dev, int index)
 	} else {
 		ret = generic_phy_init(&priv->phy);
 		if (ret) {
-			dev_err(dev, "failed to init usb phy\n");
+			dev_dbg(dev, "failed to init usb phy\n");
 			return ret;
 		}
 
 		ret = generic_phy_power_on(&priv->phy);
 		if (ret) {
-			dev_err(dev, "failed to power on usb phy\n");
+			dev_dbg(dev, "failed to power on usb phy\n");
 			return generic_phy_exit(&priv->phy);
 		}
 	}
@@ -63,13 +63,13 @@ static int ohci_shutdown_phy(struct udevice *dev)
 	if (generic_phy_valid(&priv->phy)) {
 		ret = generic_phy_power_off(&priv->phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_dbg(dev, "failed to power off usb phy\n");
 			return ret;
 		}
 
 		ret = generic_phy_exit(&priv->phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_dbg(dev, "failed to power off usb phy\n");
 			return ret;
 		}
 	}
Signature · 1 line
2.17.1
#6 lore raw

PATCH v3 3/7 usb: host: ohci: change trace level for phy errors managed by uclass

Quoted 4 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the dev_err can be change to dev_dbg.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/05dfa34a/attachment.sig>
#7 lore raw

PATCH v3 4/7 usb: host: ehci-hcd: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

---

(no changes since v1)

 drivers/usb/host/ehci-hcd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/ehci-hcd.c +4 -4
index f79f06320b..8933f60843 100644
@@ -1762,13 +1762,13 @@ int ehci_setup_phy(struct udevice *dev, struct phy *phy, int index)
 	} else {
 		ret = generic_phy_init(phy);
 		if (ret) {
-			dev_err(dev, "failed to init usb phy\n");
+			dev_dbg(dev, "failed to init usb phy\n");
 			return ret;
 		}
 
 		ret = generic_phy_power_on(phy);
 		if (ret) {
-			dev_err(dev, "failed to power on usb phy\n");
+			dev_dbg(dev, "failed to power on usb phy\n");
 			return generic_phy_exit(phy);
 		}
 	}
@@ -1786,13 +1786,13 @@ int ehci_shutdown_phy(struct udevice *dev, struct phy *phy)
 	if (generic_phy_valid(phy)) {
 		ret = generic_phy_power_off(phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_dbg(dev, "failed to power off usb phy\n");
 			return ret;
 		}
 
 		ret = generic_phy_exit(phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_dbg(dev, "failed to power off usb phy\n");
 			return ret;
 		}
 	}
Signature · 1 line
2.17.1
#8 lore raw

PATCH v3 4/7 usb: host: ehci-hcd: change trace level for phy errors managed by uclass

Quoted 4 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/84cd55a9/attachment.sig>
#9 lore raw

PATCH v3 5/7 ata: dwc-ahci: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

---

(no changes since v1)

 drivers/ata/dwc_ahci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/dwc_ahci.c +2 -2
index 017650ae46..3c2a3ac201 100644
@@ -62,13 +62,13 @@ static int dwc_ahci_probe(struct udevice *dev)
 
 	ret = generic_phy_init(&phy);
 	if (ret) {
-		pr_err("unable to initialize the sata phy\n");
+		pr_debug("unable to initialize the sata phy\n");
 		return ret;
 	}
 
 	ret = generic_phy_power_on(&phy);
 	if (ret) {
-		pr_err("unable to power on the sata phy\n");
+		pr_debug("unable to power on the sata phy\n");
 		return ret;
 	}
 
Signature · 1 line
2.17.1
#10 lore raw

PATCH v3 5/7 ata: dwc-ahci: change trace level for phy errors managed by uclass

Quoted 4 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/8ee3b9a2/attachment.sig>
#11 lore raw

PATCH v3 6/7 usb: musb-new: sunxi: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the dev_err/pr_err can be change to dev_dbg/pr_debug.

---

(no changes since v2)

Changes in v2:
- Added patch after rebase: new generic_phy API usage

 drivers/usb/musb-new/sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/musb-new/sunxi.c +4 -4
index 53c336fc3f..06a55bf6ee 100644
@@ -257,7 +257,7 @@ static int sunxi_musb_enable(struct musb *musb)
 
 		ret = generic_phy_power_on(&glue->phy);
 		if (ret) {
-			pr_err("failed to power on USB PHY\n");
+			pr_debug("failed to power on USB PHY\n");
 			return ret;
 		}
 	}
@@ -281,7 +281,7 @@ static void sunxi_musb_disable(struct musb *musb)
 	if (is_host_enabled(musb)) {
 		ret = generic_phy_power_off(&glue->phy);
 		if (ret) {
-			pr_err("failed to power off USB PHY\n");
+			pr_debug("failed to power off USB PHY\n");
 			return;
 		}
 	}
@@ -315,7 +315,7 @@ static int sunxi_musb_init(struct musb *musb)
 
 	ret = generic_phy_init(&glue->phy);
 	if (ret) {
-		dev_err(dev, "failed to init USB PHY\n");
+		dev_dbg(dev, "failed to init USB PHY\n");
 		goto err_rst;
 	}
 
@@ -352,7 +352,7 @@ static int sunxi_musb_exit(struct musb *musb)
 	if (generic_phy_valid(&glue->phy)) {
 		ret = generic_phy_exit(&glue->phy);
 		if (ret) {
-			dev_err(dev, "failed to power off usb phy\n");
+			dev_dbg(dev, "failed to power off usb phy\n");
 			return ret;
 		}
 	}
Signature · 1 line
2.17.1
#12 lore raw

PATCH v3 6/7 usb: musb-new: sunxi: change trace level for phy errors managed by uclass

Quoted 4 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the dev_err/pr_err can be change to dev_dbg/pr_debug.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/d5dd8464/attachment.sig>
#13 lore raw

PATCH v3 7/7 arm: meson: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

---

Changes in v3:
- add update for mach-meson board-gx: new generic_phy API usage

 arch/arm/mach-meson/board-gx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-meson/board-gx.c +4 -4
index c4cc11f1de..b4fde46fcb 100644
@@ -196,8 +196,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	for (i = 0; i < 2; i++) {
 		ret = generic_phy_init(&usb_phys[i]);
 		if (ret) {
-			pr_err("Can't init USB PHY%d for %s\n",
-			       i, ofnode_get_name(dwc2_node));
+			pr_debug("Can't init USB PHY%d for %s\n",
+				 i, ofnode_get_name(dwc2_node));
 			return ret;
 		}
 	}
@@ -205,8 +205,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	for (i = 0; i < 2; i++) {
 		ret = generic_phy_power_on(&usb_phys[i]);
 		if (ret) {
-			pr_err("Can't power USB PHY%d for %s\n",
-			       i, ofnode_get_name(dwc2_node));
+			pr_debug("Can't power USB PHY%d for %s\n",
+				 i, ofnode_get_name(dwc2_node));
 			return ret;
 		}
 	}
Signature · 1 line
2.17.1
#14 lore raw

PATCH v3 7/7 arm: meson: change trace level for phy errors managed by uclass

Hi,

Le 03/07/2020 ? 17:36, Patrick Delaunay a ?crit :

Quoted 29 lines

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

---

Changes in v3:
- add update for mach-meson board-gx: new generic_phy API usage

 arch/arm/mach-meson/board-gx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-meson/board-gx.c +2 -2
index c4cc11f1de..b4fde46fcb 100644
@@ -196,8 +196,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	for (i = 0; i < 2; i++) {
 		ret = generic_phy_init(&usb_phys[i]);
 		if (ret) {
-			pr_err("Can't init USB PHY%d for %s\n",
-			       i, ofnode_get_name(dwc2_node));
+			pr_debug("Can't init USB PHY%d for %s\n",
+				 i, ofnode_get_name(dwc2_node));
 			return ret;
 		}
 	}

arch/arm/mach-meson/board-gx.c int board_usb_init(int index, enum usb_init_type init) · line 212

Quoted 10 lines
arch/arm/mach-meson/board-gx.c +2 -2
@@ -205,8 +205,8 @@ int board_usb_init(int index, enum usb_init_type init)
 	for (i = 0; i < 2; i++) {
 		ret = generic_phy_power_on(&usb_phys[i]);
 		if (ret) {
-			pr_err("Can't power USB PHY%d for %s\n",
-			       i, ofnode_get_name(dwc2_node));
+			pr_debug("Can't power USB PHY%d for %s\n",
+				 i, ofnode_get_name(dwc2_node));
 			return ret;
 		}
 	}
#15 lore raw

PATCH v3 7/7 arm: meson: change trace level for phy errors managed by uclass

In reply to Patrick Delaunay
Quoted 5 lines · Patrick Delaunay

As the error message is now displayed by generic phy functions, the pr_err can be change to pr_debug.

Applied to u-boot/next, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200922/5e6ed032/attachment.sig>