Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795980736; b=0krraw744cue2xjdG1wrHmzC3UoeOPrR4Bx6UKBFXvO5XC/jgL70X4JPqQ3EbTrbKvc4 c5FBib3kYuY+lFBiTkenbVDbH4SVWqyFD++eiwC/JfLSBp74QwnZQxF36BdOkfxNKa967 iX1XlcKu7t/D0pADA90zO1oSVGd7IK0JqvdJEBQGvjEZstV5J1S9zzc/PjXz4Uoa23Qcd nA6Fv1TOE9yMhaJiz4bVc0Qlqbvw4eWj6qAUx6sMiU9E1v1FuBO5KXW8IpFAhxldX9WJ4 KnkHrC1p1cLtGUAR6MxvUsC4U5p4eC0B7wyGp0LNf73m4OkC4T9PfFPm5Bx3M3DVfQw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795980736; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=kS62E+ArbZyyqEDkzvDi1AzMjNC1jsPL2RPKRN1Eob4=; b=bUKy4JZCqPVIGCBF/F8wfBYT/VZTPGoM7f3hT2TR8dpBaidO6FkENZmZpwpMV5OShSfh b0impxHtRUXoW5cDSb0ZsJrl38C2p5EQyaDze6+pNTu+rq2b08JMqt+o6fF4mKjw3rcMH +zd8VCRZeSudoE4SuXfoC6imJ4BU/coi5FU1HprUnwevbKYG2E798Wdy6FvcqRFt+kvnn bIEoSCysYEviphgcWdmw41+x7nqE5KZ1ETGhgBetgRm9YctU9yKSTQTKDLGHXZuzXHOT+ xJdCTNlNoFvpp6zbxzMZbKn7h47NgLzhzwMgm+5zz03RwhChQbK1g9wXIurT5gxgc+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C3Jj8l9M; arc=none smtp.remote-ip=209.85.167.43 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B7B1606A31C for ; Sun, 29 Nov 2026 19:32:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8B7B1606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=C3Jj8l9M Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5c08539c827so7533311e87.2 for ; Sun, 29 Nov 2026 11:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795980735; x=1796585535; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:content-type:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=kS62E+ArbZyyqEDkzvDi1AzMjNC1jsPL2RPKRN1Eob4=; b=C3Jj8l9MhamhocPXsqM4HWwtzrUTo1Vm9C/e37Yda7bzfvlWq7g5QqkBLY/6Q+z+0A WYdZxsvBLHoF/oF8TyiCGihGpOJwLRbEOjvH9Mz7thcNT2yIbuPnyneUeMsFFbRs+wcQ xC9wOlTNCovPumT4xUz21bBsNvxlJVq7ePzJNdjdGU2VC02Js8FfGYOVXYUxRx92Of2x swRSGthQqecWq6tjzJeeWeoGUgl9V6ts+dmSCDf1Ffn22LTQTkQ6fBVCzUDQrj/El0EY 6H2vsRsA/jY0JR1vgjhrK1PHr/BqgzfoLDsnz1AuUOTHi2R46JoKHBXFLu4AqR8+vxEW GaGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795980735; x=1796585535; h=mime-version:content-transfer-encoding:content-type:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=kS62E+ArbZyyqEDkzvDi1AzMjNC1jsPL2RPKRN1Eob4=; b=WZdwM+IenpcSxYqeKwUwZMsuNVKMWpf29kVAHyIpYKpXpGLGXW+BQyzp2MKuKlgPWS o/vpYABMl4llg5hs5qDugbDGMSvS2CmDjCginzYlBd0LwisE9PFdXjmf1SIAFhilO4q4 spQ8BvsmMVEqsgag1ACwJVZeCuUssOF4qsHMOARdmNss3rrOLvItiSPb6zlaGuSKehd1 REwxYyaEjPcGvolldumIfGnM6LoG/3Avt8xlBI8fAit1TzZoi2o8I0gpfKYIrbGij2I0 w9ujnyl7eKZPfyxxkYL2BAaPMBRDtV7EckhmbCSw85yFsEPKujhP4gXaWAxCjTQmNjPk u5eg== X-Forwarded-Encrypted: i=1; AL+hErFyBlIelNUmEtnW5OoCWYwzwIsWW1bAUb6v4TTvIevpKzYlbyZEbG0gDx2gwWGoqq0Dy734NdTmGQ0WBb7m6Fefhw==@vger.kernel.org X-Gm-Message-State: APuU4Z+6REaZxHm/BFA2An8PuiIHgClTkVnhvgfUjgM3pZhO/bBmL72Q 0cdicnaRPAHuwO3ndTywgk6Q41IVy8N99v1eMQoMPkwUl6ncf05u4K2X X-Gm-Gg: AZFdTZcLkRplaw+ctQwGdP/29++shdc3nuc+noix304Fba0vNs8EqRoUDCOChTOpliK MLIRMpxeLo8h5lGnQFkGdvUXOB07dwvrxId6B7CQXEbNze1yBoJftHhBmAFW8zJLvURaX1HnCaK SJSdSCjUdEFNpd+THWQGmdoNPEJ4CRAbTyq/lzZApszQNkreB9eotrbum0uUmPlTpt4V6UZpgDg Lkxd/2lJj0s650dfzYYLpAeB6UUwiVh5jJ96rZtaH/ixstJkbSH0t40BHFIAj5FkNUml7Rnxuca 3ZbLSQxBVwrS5lw7Y+M3UFBZgepY55iW1k7onjWFTJHeeeX8rc0HxwmRgBwRuSV32DDYnEh8NvK 5z1fIA/x3cZnPFSpUZSyAwwD/ToyuGMw9PLr95hBYADGiOqHLKT6H+doGOmQTf2MIh1wUUqDw8g y0COO+Z0FjBYPzdIyaDhTQlnipPzlGBHf75I7oVahbZO516Lch4pcoVBaUlw2THbxwaAZbf4JK0 GlQnZ37i1aAozVV37acU9LfUbZw/rFSbUxABweKCXwDWWJSQ9R5OFJSRxGpYPQnqs5XYplxxQ5J ZKcFP7qIxMKvt0oAgSCn3e99AG1k8g== X-Received: by 2002:a05:6512:3e1a:b0:5c1:45a9:c295 with SMTP id 2adb3069b0e04-5c1bc872728mr7965767e87.45.1795980734688; Sun, 29 Nov 2026 11:32:14 -0800 (PST) Received: from [127.0.1.1] ([5.195.0.150]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1bd043420sm7561895e87.57.2026.11.29.11.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 11:32:14 -0800 (PST) From: Jiawen Liu To: Vinod Koul , Geert Uytterhoeven , Magnus Damm Cc: Neil Armstrong , Manivannan Sadhasivam , linux-phy@lists.infradead.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH] phy: renesas: rcar-gen2: Propagate clock enable errors Date: Sun, 29 Nov 2026 19:25:33 +0000 Message-ID: <179598033817.2.15012984859573277634.pattern-ext-090.11@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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") Signed-off-by: Jiawen Liu --- drivers/phy/renesas/phy-rcar-gen2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 414c6814ef995..e6cb834843cb3 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -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); -- 2.34.1