Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp839994ybl; Wed, 4 Dec 2019 11:47:00 -0800 (PST) X-Google-Smtp-Source: APXvYqyPU/4vUhCISrfjrb6qjoYbPprfh5vcZn0V8GnJ2BRRSpybkvVGtx1N++d8rVXJHjfaK8C+ X-Received: by 2002:aca:f487:: with SMTP id s129mr4121635oih.154.1575488820484; Wed, 04 Dec 2019 11:47:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575488820; cv=none; d=google.com; s=arc-20160816; b=Pv9SlXXTr6JWjQr0Fa1BRTYWFIFk/5yXpXm2pSio93IvhqCn1pv647ekgZvqY07MJU 6sCgTtFG/Y3PakQji+hKZrWthleGyMQu1l2Lp0K8s5dt16HOo39e+vHXdPdAbI8Ev21/ xvMvUINWjUjeKbhevqYBRVTMlsa/bzvQVS4hF1JvUvd2wHGSIA0Skws0+DPsUNpDieHM NbPtJ7Ty3qHILa12VjsFN5YNesgEKlrir9kHKvzmwkAC46AmMg0d4cjj9mwPTXuAkQhM C4zSymIEREpMb6QVon75vi1uyteUXvPJV16Fs4fJVgENbosr42LSHHleokhuiW0WWlsf ueyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CBPhoK57ZNFnkpeZfSdITfD0/nVr4uVcCcD2d7ffT6A=; b=FJ6RxWKvONWjiuqU+YjIc7zH0V1Zs44iHepQ8ZFXpwsgmwEACRATcFOkJV7pk5Hs+A MXCBjKJ2Uro2b1xnuS0Ae3OJLQWTAvWtWRhD3KGbAsueLphsCQ0VJSD0P+OMSffiO8QF Y8ZZGhe62Aokf+katr0FUFBtuwzGUJQbXSqKuLBhdoYuwQxwINI0/Xyvizb9q5iPHr6v yHSE3m6wiY+EynXQWqxPxShdu0ipQ83u5vr4jTpp3b75Ta6cA1EFATXA64iGDstGZG2n SDzJRYgucN2+Ih1zRWzdrklp9O/cqW5o7nWtRvKHk/BEM3qfWY5uZQPn8g4W5Al2BOFa mT8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o/ITI/fI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si3550163otk.15.2019.12.04.11.46.47; Wed, 04 Dec 2019 11:47:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="o/ITI/fI"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731589AbfLDSPN (ORCPT + 99 others); Wed, 4 Dec 2019 13:15:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:44154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730466AbfLDSOn (ORCPT ); Wed, 4 Dec 2019 13:14:43 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0010E20866; Wed, 4 Dec 2019 18:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575483282; bh=Ei5tQVIeRmqV5Most0Nt45YuJ+JcLbWOWCdSTlLFX5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o/ITI/fIx/DogVGrqv2qWMIW5rsZhbOuJlBypVIWXJvgfDTZbvzJ9mfKjMFfvxYTA 6ANEZ5rDRU8F9RQiLChhReCig2htDfLsgoUfNRVrTZ3wVkxnyR1nZSoJqIwEQyrloQ OJnaupBCdDcDwWVSj4niAdY8foR/z2t6NAq6SmWc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuhong Yuan , Fugang Duan , "David S. Miller" , Nobuhiro Iwamatsu Subject: [PATCH 4.9 125/125] net: fec: fix clock count mis-match Date: Wed, 4 Dec 2019 18:57:10 +0100 Message-Id: <20191204175327.061631078@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204175308.377746305@linuxfoundation.org> References: <20191204175308.377746305@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuhong Yuan commit a31eda65ba210741b598044d045480494d0ed52a upstream. pm_runtime_put_autosuspend in probe will call runtime suspend to disable clks automatically if CONFIG_PM is defined. (If CONFIG_PM is not defined, its implementation will be empty, then runtime suspend will not be called.) Therefore, we can call pm_runtime_get_sync to runtime resume it first to enable clks, which matches the runtime suspend. (Only when CONFIG_PM is defined, otherwise pm_runtime_get_sync will also be empty, then runtime resume will not be called.) Then it is fine to disable clks without causing clock count mis-match. Fixes: c43eab3eddb4 ("net: fec: add missed clk_disable_unprepare in remove") Signed-off-by: Chuhong Yuan Acked-by: Fugang Duan Signed-off-by: David S. Miller Cc: Nobuhiro Iwamatsu Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/fec_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3530,6 +3530,11 @@ fec_drv_remove(struct platform_device *p struct net_device *ndev = platform_get_drvdata(pdev); struct fec_enet_private *fep = netdev_priv(ndev); struct device_node *np = pdev->dev.of_node; + int ret; + + ret = pm_runtime_get_sync(&pdev->dev); + if (ret < 0) + return ret; cancel_work_sync(&fep->tx_timeout_work); fec_ptp_stop(pdev); @@ -3537,15 +3542,17 @@ fec_drv_remove(struct platform_device *p fec_enet_mii_remove(fep); if (fep->reg_phy) regulator_disable(fep->reg_phy); - pm_runtime_put(&pdev->dev); - pm_runtime_disable(&pdev->dev); - clk_disable_unprepare(fep->clk_ahb); - clk_disable_unprepare(fep->clk_ipg); + if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); of_node_put(fep->phy_node); free_netdev(ndev); + clk_disable_unprepare(fep->clk_ahb); + clk_disable_unprepare(fep->clk_ipg); + pm_runtime_put_noidle(&pdev->dev); + pm_runtime_disable(&pdev->dev); + return 0; }