From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 887F0C433E0 for ; Mon, 8 Feb 2021 14:15:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4CD0564E6C for ; Mon, 8 Feb 2021 14:15:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbhBHOPQ (ORCPT ); Mon, 8 Feb 2021 09:15:16 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57084 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbhBHN6d (ORCPT ); Mon, 8 Feb 2021 08:58:33 -0500 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , , , , , Subject: [PATCH v2 17/24] net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers Date: Mon, 8 Feb 2021 16:56:01 +0300 Message-ID: <20210208135609.7685-18-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pointers need to be nullified otherwise the stmmac_remove_config_dt() method called after them being initialized will disable the clocks. That then will cause a WARN() backtrace being printed since the clocks would be also disabled in the locally defined remove method. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 27254b27d7ed..20b3696fb776 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -123,39 +123,46 @@ static int dwc_qos_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat, struct stmmac_resources *stmmac_res) { + struct clk *clk; int err; - plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); - if (IS_ERR(plat_dat->stmmac_clk)) { + clk = devm_clk_get(&pdev->dev, "apb_pclk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "apb_pclk clock not found.\n"); - return PTR_ERR(plat_dat->stmmac_clk); + return PTR_ERR(clk); } - err = clk_prepare_enable(plat_dat->stmmac_clk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", err); return err; } - plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); - if (IS_ERR(plat_dat->pclk)) { + plat_dat->stmmac_clk = clk; + + clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); - err = PTR_ERR(plat_dat->pclk); + err = PTR_ERR(clk); goto disable; } - err = clk_prepare_enable(plat_dat->pclk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", err); goto disable; } + plat_dat->pclk = clk; + return 0; disable: clk_disable_unprepare(plat_dat->stmmac_clk); + plat_dat->stmmac_clk = NULL; + return err; } @@ -164,8 +171,15 @@ static int dwc_qos_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ clk_disable_unprepare(priv->plat->pclk); + priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->stmmac_clk); + priv->plat->stmmac_clk = NULL; return 0; } @@ -301,12 +315,12 @@ static int tegra_eqos_probe(struct platform_device *pdev, goto disable_master; } - data->stmmac_clk = eqos->clk_slave; - err = clk_prepare_enable(eqos->clk_slave); if (err < 0) goto disable_master; + data->stmmac_clk = eqos->clk_slave; + eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); if (IS_ERR(eqos->clk_rx)) { err = PTR_ERR(eqos->clk_rx); @@ -377,6 +391,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); + data->stmmac_clk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); error: @@ -385,6 +400,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, static int tegra_eqos_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct tegra_eqos *eqos = get_stmmac_bsp_priv(&pdev->dev); reset_control_assert(eqos->rst); @@ -394,6 +410,12 @@ static int tegra_eqos_remove(struct platform_device *pdev) clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ + priv->plat->stmmac_clk = NULL; + return 0; } -- 2.29.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CD90C433DB for ; Mon, 8 Feb 2021 22:40:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1DE7664EAC for ; Mon, 8 Feb 2021 22:40:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1DE7664EAC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baikalelectronics.ru Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6foRXH/pcvF+cW8Jej6XNszrb/09K4b84D5AwYBtDAQ=; b=h+14EFnDHySfZOZnpQDdb7NA8 U154Qw1Bil7Vpfuy8DDuiFMGd0eR7kdgWPLHqoaGF+L7YkMd1EDbAWplQ0eXGNgwHz3Io6nlilJ26 lOafHtGTYfUSVGFV6Xxvk4bXhfBlmolY5MgJGYfEVFenD695KuyhCAOh4OE+hAHFsmUOud3z7OIwt y4yRwfztnczi6YsjzHlHqN/et7YOBYuTf6nv9Ri7C+4N5BkJmqSpG8VChxGQGi/oON8oe1SPQFFGf SPSbL+yH5zAjR/Qk9cK1KZOJK+d9eWAgI7Lup2RVu2idglhuDNLM9GWQYisjfmpJudXLuPYhx9cHH YnbFu/U3A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97Gb-00070a-5F; Mon, 08 Feb 2021 14:11:53 +0000 Received: from mail.baikalelectronics.com ([87.245.175.226] helo=mail.baikalelectronics.ru) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l97Aq-000444-OL for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 14:05:59 +0000 From: Serge Semin To: Rob Herring , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Johan Hovold , Maxime Ripard , Joao Pinto , Lars Persson , Maxime Coquelin Subject: [PATCH v2 17/24] net: stmmac: dwc-qos: Cleanup STMMAC platform data clock pointers Date: Mon, 8 Feb 2021 16:56:01 +0300 Message-ID: <20210208135609.7685-18-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> References: <20210208135609.7685-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_090557_960216_6DFA102C X-CRM114-Status: GOOD ( 14.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin , Alexey Malahov , Serge Semin , Vyacheslav Mitrofanov , Pavel Parkhomenko , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pointers need to be nullified otherwise the stmmac_remove_config_dt() method called after them being initialized will disable the clocks. That then will cause a WARN() backtrace being printed since the clocks would be also disabled in the locally defined remove method. Signed-off-by: Serge Semin --- .../stmicro/stmmac/dwmac-dwc-qos-eth.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 27254b27d7ed..20b3696fb776 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -123,39 +123,46 @@ static int dwc_qos_probe(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat, struct stmmac_resources *stmmac_res) { + struct clk *clk; int err; - plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); - if (IS_ERR(plat_dat->stmmac_clk)) { + clk = devm_clk_get(&pdev->dev, "apb_pclk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "apb_pclk clock not found.\n"); - return PTR_ERR(plat_dat->stmmac_clk); + return PTR_ERR(clk); } - err = clk_prepare_enable(plat_dat->stmmac_clk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", err); return err; } - plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); - if (IS_ERR(plat_dat->pclk)) { + plat_dat->stmmac_clk = clk; + + clk = devm_clk_get(&pdev->dev, "phy_ref_clk"); + if (IS_ERR(clk)) { dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); - err = PTR_ERR(plat_dat->pclk); + err = PTR_ERR(clk); goto disable; } - err = clk_prepare_enable(plat_dat->pclk); + err = clk_prepare_enable(clk); if (err < 0) { dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", err); goto disable; } + plat_dat->pclk = clk; + return 0; disable: clk_disable_unprepare(plat_dat->stmmac_clk); + plat_dat->stmmac_clk = NULL; + return err; } @@ -164,8 +171,15 @@ static int dwc_qos_remove(struct platform_device *pdev) struct net_device *ndev = platform_get_drvdata(pdev); struct stmmac_priv *priv = netdev_priv(ndev); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ clk_disable_unprepare(priv->plat->pclk); + priv->plat->pclk = NULL; + clk_disable_unprepare(priv->plat->stmmac_clk); + priv->plat->stmmac_clk = NULL; return 0; } @@ -301,12 +315,12 @@ static int tegra_eqos_probe(struct platform_device *pdev, goto disable_master; } - data->stmmac_clk = eqos->clk_slave; - err = clk_prepare_enable(eqos->clk_slave); if (err < 0) goto disable_master; + data->stmmac_clk = eqos->clk_slave; + eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); if (IS_ERR(eqos->clk_rx)) { err = PTR_ERR(eqos->clk_rx); @@ -377,6 +391,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, clk_disable_unprepare(eqos->clk_rx); disable_slave: clk_disable_unprepare(eqos->clk_slave); + data->stmmac_clk = NULL; disable_master: clk_disable_unprepare(eqos->clk_master); error: @@ -385,6 +400,7 @@ static int tegra_eqos_probe(struct platform_device *pdev, static int tegra_eqos_remove(struct platform_device *pdev) { + struct stmmac_priv *priv = netdev_priv(platform_get_drvdata(pdev)); struct tegra_eqos *eqos = get_stmmac_bsp_priv(&pdev->dev); reset_control_assert(eqos->rst); @@ -394,6 +410,12 @@ static int tegra_eqos_remove(struct platform_device *pdev) clk_disable_unprepare(eqos->clk_slave); clk_disable_unprepare(eqos->clk_master); + /* Cleanup the pointers to the clock handlers hidden in the platform + * data so the stmmac_remove_config_dt() method wouldn't have disabled + * the clocks too. + */ + priv->plat->stmmac_clk = NULL; + return 0; } -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel