From patchwork Mon Jul 20 13:48:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Stach X-Patchwork-Id: 497730 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id DB6B914076E for ; Mon, 20 Jul 2015 23:48:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754509AbbGTNsX (ORCPT ); Mon, 20 Jul 2015 09:48:23 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:53447 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbbGTNsW (ORCPT ); Mon, 20 Jul 2015 09:48:22 -0400 Received: from dude.hi.4.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1ZH9Yu-0005cx-Q6; Mon, 20 Jul 2015 13:48:48 +0200 From: Lucas Stach To: "David S. Miller" Cc: Duan Andy , Frank Li , Andrew Lunn , netdev@vger.kernel.org, kernel@pengutronix.de, patchwork-lst@pengutronix.de Subject: [PATCH] net: fec: fix runtime PM when probing MII bus Date: Mon, 20 Jul 2015 15:48:14 +0200 Message-Id: <1437400094-11453-1-git-send-email-l.stach@pengutronix.de> X-Mailer: git-send-email 2.1.4 X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In the case where there is no "mdio" bus specified in the devicetree a plain mdiobus_register() will be called, which tries to probe the connected PHY by doing mdio_read() on the bus. Since 6c3e921b18ed (net: fec: Ensure clocks are enabled while using mdio bus) this needs runtime PM to be available, but as RPM is only later set up in the FEC probe function those calls will fail, which in turn prevents the FEC driver to be registered successfully. Fix this by moving the RPM setup calls before the MII bus probing. Also move autosuspend init calls before runtime_pm_enable() so that the RPM callbacks aren't invoked several times during the probe function. Signed-off-by: Lucas Stach --- The offending commit got in with v4.2-rc3, so this should be applied as a fix for 4.2. --- drivers/net/ethernet/freescale/fec_main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 42e20e5385ac..349365d85b92 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3431,6 +3431,11 @@ fec_probe(struct platform_device *pdev) fep->reg_phy = NULL; } + pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT); + pm_runtime_use_autosuspend(&pdev->dev); + pm_runtime_set_active(&pdev->dev); + pm_runtime_enable(&pdev->dev); + fec_reset_phy(pdev); if (fep->bufdesc_ex) @@ -3465,8 +3470,6 @@ fec_probe(struct platform_device *pdev) netif_carrier_off(ndev); fec_enet_clk_enable(ndev, false); pinctrl_pm_select_sleep_state(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); ret = register_netdev(ndev); if (ret) @@ -3481,8 +3484,6 @@ fec_probe(struct platform_device *pdev) fep->rx_copybreak = COPYBREAK_DEFAULT; INIT_WORK(&fep->tx_timeout_work, fec_enet_timeout_work); - pm_runtime_set_autosuspend_delay(&pdev->dev, FEC_MDIO_PM_TIMEOUT); - pm_runtime_use_autosuspend(&pdev->dev); pm_runtime_mark_last_busy(&pdev->dev); pm_runtime_put_autosuspend(&pdev->dev);