Skip to contentSkip to conversation

phy: renesas: rcar-gen2: Propagate clock enable errors

PATCH In review Jiawen Liu 2 participants 2 messages Nov 29 – Nov 30

Subsystems (2)
lore
Share & tools
lore

Jiawen Liu

author
#0 lore raw

PATCH 1/1 phy: renesas: rcar-gen2: Propagate clock enable errors

On R8A7790 Lager, xHCI bring-up initializes the R-Car Gen2 USB PHY. If the USBHS clock has no existing enable reference, the CPG/MSSR provider can time out waiting for the gate to report enabled.

rcar_gen2_phy_init() ignores the clock error and accesses the PHY mux. If those accesses complete, the PHY core records a successful init and a later exit can disable and unprepare a reference it never acquired.

Check clk_prepare_enable() before accessing the mux. On failure, release the channel reservation with WRITE_ONCE() so init can be retried, and return the original error. The clock helper unwinds its own references.

Static call-path review, an ARM shmobile
object build, git diff --check, and checkpatch passed. No runtime or hardware reproduction was performed.

Fixes 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
---
 drivers/phy/renesas/phy-rcar-gen2.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/phy/renesas/phy-rcar-gen2.c +7 -1
index 414c6814ef995..e6cb834843cb3 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/module.h>
@@ -80,6 +81,7 @@ static int rcar_gen2_phy_init(struct phy *p)
 	struct rcar_gen2_phy_driver *drv = channel->drv;
 	unsigned long flags;
 	u32 ugctrl2;
+	int error;
 
 	/*
 	 * Try to acquire exclusive access to PHY.  The first driver calling
@@ -90,7 +92,11 @@ static int rcar_gen2_phy_init(struct phy *p)
 	if (cmpxchg(&channel->selected_phy, -1, phy->number) != -1)
 		return -EBUSY;
 
-	clk_prepare_enable(drv->clk);
+	error = clk_prepare_enable(drv->clk);
+	if (error) {
+		WRITE_ONCE(channel->selected_phy, -1);
+		return error;
+	}
 
 	spin_lock_irqsave(&drv->lock, flags);
 	ugctrl2 = readl(drv->base + USBHS_UGCTRL2);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · Jiawen Liu

On R8A7790 Lager, xHCI bring-up initializes the R-Car Gen2 USB PHY. If the USBHS clock has no existing enable reference, the CPG/MSSR provider can time out waiting for the gate to report enabled.

rcar_gen2_phy_init() ignores the clock error and accesses the PHY mux. If those accesses complete, the PHY core records a successful init and a later exit can disable and unprepare a reference it never acquired.

Check clk_prepare_enable() before accessing the mux. On failure, release the channel reservation with WRITE_ONCE() so init can be retried, and return the original error. The clock helper unwinds its own references.

Static call-path review, an ARM shmobile
object build, git diff --check, and checkpatch passed. No runtime or hardware reproduction was performed.

Quoted 6 lines
Fixes 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
---
 drivers/phy/renesas/phy-rcar-gen2.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

You sent multiple independent patches, to multiple independent subsystems. The amount of these patches clearly suggest this was AI generated and most likely not tested.

More importantly, you sent all this work without properly organizing relevant patches into patchsets. This makes reviewing difficult and might cause multiple reviewers to address the same issue. Replying to the entire set is impossible and requires handling each patch independently, instead of applying or discarding the set. Maintainers also won't see the bigger picture of your work. Quite worrying.

Please read kernel documentation BEFORE posting more work. It will explain you how to identify subsystems, how to organize your work per subsystem (so a patchset grouping multiple patches with a short cover letter), how to document the issue discovery method and what was or was not tested.

Best regards,
Krzysztof