Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1262140ybc; Tue, 19 Nov 2019 17:27:16 -0800 (PST) X-Google-Smtp-Source: APXvYqz6f4s2wPqezfbShgwv/ZmD8O8AUGfFaATy8pzuXrO2EPi4LSyTdzGtyl67mE2TFobYrf5q X-Received: by 2002:a17:906:1fd5:: with SMTP id e21mr1191126ejt.320.1574213236146; Tue, 19 Nov 2019 17:27:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574213236; cv=none; d=google.com; s=arc-20160816; b=H5G8SZa6Zmq6aaInI3L361DHqNmLY0wri66IAVfQoKz1a+MfALb4xykkks7HWgk9sv biVplEVxf9V1X6n/AgDKLzDPndxITENYejb+YaYNc9J11UhRIGKx3PUhDqj+1GKtkAQU zbRqOrHLc8y/FZpS38QEwvPSlSaTiJSRCKipIthxUzJmyiOVIAyhMk1bZZKm0v2MDYlZ DTOrapVxDP8RKiLDd+xyyvn66YZJtTmDaExftCozPUa3fTJ8kOoc2dMl7B1Uf1DDHihl tYNcZVfoTPhpMd6KlcSTh7EZjFPb1fpyjwstbvSgHwBXKVFWawTPq1Wj/WCfdvaU7PGU x0tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=ldarti2Cil2jWS7BGbU10AooRxN+DMj3yEli61ye9Eg=; b=KmTxvE32h7BhlU8iSlmOh499++e+54IRVekyJOs60gy8fWfxbSJW+Tj0+jx61zIE8h 6CHozLVHeIp99/6EQomMispAt0eyDY5hvahywKXeziWNVHzFOv9rSfQqbMes8s4cDntZ GJD+bskeu37Y6XXMe5hPBY0BAOKQrr9DV3pSypysy2JoxWajKU6YDlCQXmSuGwcrp3V8 /o3p0aHaXw6OdbyEVBNe+oLVVIWCJgBfmVSo6odaD4S36IqHYX8TArLLwUngH+Y4w6k2 EHqvAI69jwA2uw5Rx/mNwKdzeqUMnZaV0c8EyHw2LVToLFCjKsvwARLnhuqFbM4EhkOR u1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t93ZFRP9; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g17si16624483edh.379.2019.11.19.17.26.52; Tue, 19 Nov 2019 17:27:16 -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=fail header.i=@gmail.com header.s=20161025 header.b=t93ZFRP9; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbfKTBZZ (ORCPT + 99 others); Tue, 19 Nov 2019 20:25:25 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:34387 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727500AbfKTBZY (ORCPT ); Tue, 19 Nov 2019 20:25:24 -0500 Received: by mail-pf1-f193.google.com with SMTP id n13so13353747pff.1; Tue, 19 Nov 2019 17:25:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ldarti2Cil2jWS7BGbU10AooRxN+DMj3yEli61ye9Eg=; b=t93ZFRP9GLj9YVftWBZdfJypyw06kXZPfvo/rvRybO9zmhH6Q70fVzrxUoSNqP+Tfo s9JHJqrVXxK14gHQ1JkImEFe9RhnsDTdkdOFAjhhj6+TT35yyEHnpvgO+ocL5NrYIPdn CF+L7MbbcXPpfvxmdYPzYfDcSsUp19KmyWBqP9wL871edNo6P53oyWElyON/PwSTZKxy SSx3mVbDiwm0eKqd/6UIL9H1spD9Wt+PO409v6NURuI2fjCY81n96aAucal3l7Vy5Zhx L2GzC/oAbsaYZRs0HYlrTzs+DC8u3837hK5aNsiKvEmgkkozfaPLEOvvJE66yGuH92tX wWKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ldarti2Cil2jWS7BGbU10AooRxN+DMj3yEli61ye9Eg=; b=MxkxLerf3EB0f7SER9yKIxwn8mIk2Dp0f5uGhafPGRfOpIm6LmV/tHCx875/2q8aw0 u9Db3e+VyLQGX9GpeLnPpDYKV++3PZLs3K1jhDWlbJkAaTp5MXf/HbeopR20RQM6q72G yfxk0cC3kxvKNaaZj7PQhJ7HoiqbFQHi2fCwWOWFJwaPxoMnUNax3UbGTGoD8kzX5FqK /HeA+pDKbQWaIfmQftasYfDjaz34v29iM1zV6dQdpGZTbhOQIQ5w47WlFQ6x072D64Hf EQ5RuywjxajDo/DT6hSjbcVLlIPYD1ENM/Y6LrYnkDDJhMmaEOoSrUvVFyb2NQX4xpEc GDfg== X-Gm-Message-State: APjAAAXyAdHgoAelEv37KtV2isFz4mu1+xr+Mefcjkev7rijWQZe/pxe rf7pyLlJd+U/QBAvHo4zScU= X-Received: by 2002:a63:a502:: with SMTP id n2mr172176pgf.158.1574213123850; Tue, 19 Nov 2019 17:25:23 -0800 (PST) Received: from suzukaze.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.gmail.com with ESMTPSA id o129sm30343553pfg.75.2019.11.19.17.25.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 17:25:22 -0800 (PST) From: Chuhong Yuan Cc: Fugang Duan , "David S . Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chuhong Yuan Subject: [PATCH net v4] net: fec: fix clock count mis-match Date: Wed, 20 Nov 2019 09:25:13 +0800 Message-Id: <20191120012513.11161-1-hslester96@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v4: - Fix some typos. drivers/net/ethernet/freescale/fec_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index a9c386b63581..4bb30761abfc 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3636,6 +3636,11 @@ fec_drv_remove(struct platform_device *pdev) 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); @@ -3643,15 +3648,17 @@ fec_drv_remove(struct platform_device *pdev) 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; } -- 2.24.0