From patchwork Fri Mar 17 17:42:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 13179340 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03F39C74A5B for ; Fri, 17 Mar 2023 17:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbjCQRmz (ORCPT ); Fri, 17 Mar 2023 13:42:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbjCQRmx (ORCPT ); Fri, 17 Mar 2023 13:42:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75C32233D9; Fri, 17 Mar 2023 10:42:50 -0700 (PDT) Received: from jupiter.universe (dyndsl-091-248-191-142.ewe-ip-backbone.de [91.248.191.142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id D5D6766030C5; Fri, 17 Mar 2023 17:42:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679074968; bh=dejqDCxy9oTKhCu7sjRqtctWqfmWffdDuvJGn6Vor1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvCQ8TZsAKkqSjLe/XWC1qhupMDIoouF1mxcb36nhi59Qr3KwMZsZESAaxz5JtoNa 0gEMJgkg8B2l4ed0aDIZqBljsV5wEvlRIWMpOZtvWR0NvlGFv3Ero7IIKbM0Ja9bkv LVvNrQSOSCCYuK+LG+3TxPoYxT5NexsXM3TRXdIJYpPZUFCrkYLSKI6/yZRwlmLRRM oNLzmlb32HYEZtKI24vvRZw48AUrTwuN/jmSI1++Rfb5OcqF4nI8rOXP43Gc7dcR2Q 4jXDyBS0/TACabC0ZAmWS6aMzUK9Eyu9u7fNuo7QGYs91uzyNQGT9R/MZfL6SQHTz+ qD5lakMT4IRlQ== Received: by jupiter.universe (Postfix, from userid 1000) id 40F234807E2; Fri, 17 Mar 2023 18:42:46 +0100 (CET) From: Sebastian Reichel To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv1 1/2] net: ethernet: stmmac: dwmac-rk: fix optional clock handling Date: Fri, 17 Mar 2023 18:42:42 +0100 Message-Id: <20230317174243.61500-2-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317174243.61500-1-sebastian.reichel@collabora.com> References: <20230317174243.61500-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Right now any clock errors are printed and otherwise ignored. This has multiple disadvantages: 1. it prints errors for clocks that do not exist (e.g. rk3588 reports errors for "mac_clk_rx", "mac_clk_tx" and "clk_mac_speed") 2. it does not handle errors like -EPROBE_DEFER correctly This series fixes it by switching to devm_clk_get_optional(), so that missing clocks are not considered an error and then passing on any other errors using dev_err_probe(). Signed-off-by: Sebastian Reichel --- .../net/ethernet/stmicro/stmmac/dwmac-rk.c | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 4b8fd11563e4..126812cd17e6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1479,49 +1479,50 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat) bsp_priv->clk_enabled = false; - bsp_priv->mac_clk_rx = devm_clk_get(dev, "mac_clk_rx"); + bsp_priv->mac_clk_rx = devm_clk_get_optional(dev, "mac_clk_rx"); if (IS_ERR(bsp_priv->mac_clk_rx)) - dev_err(dev, "cannot get clock %s\n", - "mac_clk_rx"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->mac_clk_rx), + "cannot get clock %s\n", "mac_clk_rx"); - bsp_priv->mac_clk_tx = devm_clk_get(dev, "mac_clk_tx"); + bsp_priv->mac_clk_tx = devm_clk_get_optional(dev, "mac_clk_tx"); if (IS_ERR(bsp_priv->mac_clk_tx)) - dev_err(dev, "cannot get clock %s\n", - "mac_clk_tx"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->mac_clk_tx), + "cannot get clock %s\n", "mac_clk_tx"); - bsp_priv->aclk_mac = devm_clk_get(dev, "aclk_mac"); + bsp_priv->aclk_mac = devm_clk_get_optional(dev, "aclk_mac"); if (IS_ERR(bsp_priv->aclk_mac)) - dev_err(dev, "cannot get clock %s\n", - "aclk_mac"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->aclk_mac), + "cannot get clock %s\n", "aclk_mac"); - bsp_priv->pclk_mac = devm_clk_get(dev, "pclk_mac"); + bsp_priv->pclk_mac = devm_clk_get_optional(dev, "pclk_mac"); if (IS_ERR(bsp_priv->pclk_mac)) - dev_err(dev, "cannot get clock %s\n", - "pclk_mac"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->pclk_mac), + "cannot get clock %s\n", "pclk_mac"); - bsp_priv->clk_mac = devm_clk_get(dev, "stmmaceth"); + bsp_priv->clk_mac = devm_clk_get_optional(dev, "stmmaceth"); if (IS_ERR(bsp_priv->clk_mac)) - dev_err(dev, "cannot get clock %s\n", - "stmmaceth"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->clk_mac), + "cannot get clock %s\n", "stmmaceth"); if (bsp_priv->phy_iface == PHY_INTERFACE_MODE_RMII) { - bsp_priv->clk_mac_ref = devm_clk_get(dev, "clk_mac_ref"); + bsp_priv->clk_mac_ref = devm_clk_get_optional(dev, "clk_mac_ref"); if (IS_ERR(bsp_priv->clk_mac_ref)) - dev_err(dev, "cannot get clock %s\n", - "clk_mac_ref"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->clk_mac_ref), + "cannot get clock %s\n", "clk_mac_ref"); if (!bsp_priv->clock_input) { bsp_priv->clk_mac_refout = - devm_clk_get(dev, "clk_mac_refout"); + devm_clk_get_optional(dev, "clk_mac_refout"); if (IS_ERR(bsp_priv->clk_mac_refout)) - dev_err(dev, "cannot get clock %s\n", - "clk_mac_refout"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->clk_mac_refout), + "cannot get clock %s\n", "clk_mac_refout"); } } - bsp_priv->clk_mac_speed = devm_clk_get(dev, "clk_mac_speed"); + bsp_priv->clk_mac_speed = devm_clk_get_optional(dev, "clk_mac_speed"); if (IS_ERR(bsp_priv->clk_mac_speed)) - dev_err(dev, "cannot get clock %s\n", "clk_mac_speed"); + return dev_err_probe(dev, PTR_ERR(bsp_priv->clk_mac_speed), + "cannot get clock %s\n", "clk_mac_speed"); if (bsp_priv->clock_input) { dev_info(dev, "clock input from PHY\n"); From patchwork Fri Mar 17 17:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 13179341 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88AE1C6FD1D for ; Fri, 17 Mar 2023 17:42:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230326AbjCQRm4 (ORCPT ); Fri, 17 Mar 2023 13:42:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230301AbjCQRmx (ORCPT ); Fri, 17 Mar 2023 13:42:53 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83FA731BDF; Fri, 17 Mar 2023 10:42:50 -0700 (PDT) Received: from jupiter.universe (dyndsl-091-248-191-142.ewe-ip-backbone.de [91.248.191.142]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id DD3F666030C6; Fri, 17 Mar 2023 17:42:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679074969; bh=jAfwTMiBYZ9JmHPeHDLPoQkj/I4GmFopx/XoUWYNTok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZyaalmUWg7i9X+DtwzcwFjLyI3BOe6Ifqh+n79qvr+/W5lAs7oEM8ODadZNy7EgB N+6LPcQphz2d0IDDpLTWywduBD9NvGCRyjJL5tcf1cTYAuwm7bIb3ed9HU47rpT14O 0bdAMovcGI+hjsve/iRCFV94a8XCX2opYT670ExgmZsoqZnLz5/co3+TJuMZbKPtF7 WAuoWgmEDNW6tqMg2i3otXjdYp8feIxyxaJQ34buEGvPNlz7vs6UleOz7fm76EjGer ccKs5uC2nggghK/GQayLmezOUm3h2hoRNIDK98yzVXecFe8DI+ZGKQFkjmpsvYgCfz DXurHO2WqmNNw== Received: by jupiter.universe (Postfix, from userid 1000) id 433334807E3; Fri, 17 Mar 2023 18:42:46 +0100 (CET) From: Sebastian Reichel To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv1 2/2] net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling Date: Fri, 17 Mar 2023 18:42:43 +0100 Message-Id: <20230317174243.61500-3-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317174243.61500-1-sebastian.reichel@collabora.com> References: <20230317174243.61500-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The usual devm_regulator_get() call already handles "optional" regulators by returning a valid dummy and printing a warning that the dummy regulator should be described properly. This code open coded the same behaviour, but masked any errors that are not -EPROBE_DEFER and is quite noisy. This change effectively unmasks and propagates regulators errors not involving -ENODEV, downgrades the error print to warning level if no regulator is specified and captures the probe defer message for /sys/kernel/debug/devices_deferred. Signed-off-by: Sebastian Reichel --- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c index 126812cd17e6..01de0174fa18 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c @@ -1680,14 +1680,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev, } } - bsp_priv->regulator = devm_regulator_get_optional(dev, "phy"); + bsp_priv->regulator = devm_regulator_get(dev, "phy"); if (IS_ERR(bsp_priv->regulator)) { - if (PTR_ERR(bsp_priv->regulator) == -EPROBE_DEFER) { - dev_err(dev, "phy regulator is not available yet, deferred probing\n"); - return ERR_PTR(-EPROBE_DEFER); - } - dev_err(dev, "no regulator found\n"); - bsp_priv->regulator = NULL; + ret = PTR_ERR(bsp_priv->regulator); + dev_err_probe(dev, ret, "failed to get phy regulator\n"); + return ERR_PTR(ret); } ret = of_property_read_string(dev->of_node, "clock_in_out", &strings);