aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2015-01-15 17:45:10 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-16 01:00:03 -0500
commitb5133e7a988b2cf8e1cd2b23231f36aff35ceffc (patch)
treec0cbd927df3fcb143af99b5d62c8666785943cfe
parentcd2d6d33e2c5be653d10cdc8fcd7dcf0be28de50 (diff)
net: davinci_emac: Fix runtime pm calls for davinci_emac
Commit 3ba97381343b ("net: ethernet: davinci_emac: add pm_runtime support") added support for runtime PM, but it causes issues on omap3 related devices that actually gate the clocks: Unhandled fault: external abort on non-linefetch (0x1008) ... [<c04160f0>] (emac_dev_getnetstats) from [<c04d6a3c>] (dev_get_stats+0x78/0xc8) [<c04d6a3c>] (dev_get_stats) from [<c04e9ccc>] (rtnl_fill_ifinfo+0x3b8/0x938) [<c04e9ccc>] (rtnl_fill_ifinfo) from [<c04eade4>] (rtmsg_ifinfo+0x68/0xd8) [<c04eade4>] (rtmsg_ifinfo) from [<c04dd35c>] (register_netdevice+0x3a0/0x4ec) [<c04dd35c>] (register_netdevice) from [<c04dd4bc>] (register_netdev+0x14/0x24) [<c04dd4bc>] (register_netdev) from [<c041755c>] (davinci_emac_probe+0x408/0x5c8) [<c041755c>] (davinci_emac_probe) from [<c0396d78>] (platform_drv_probe+0x48/0xa4) Let's fix it by moving the pm_runtime_get() call earlier, and also add it to the emac_dev_getnetstats(). Also note that we want to use pm_runtime_get_sync() as we don't want to have deferred_resume happen. And let's also check the return value for pm_runtime_get_sync() as noted by Felipe Balbi <balbi@ti.com>. Cc: Brian Hutchinson <b.hutchman@gmail.com> Acked-by: Mark A. Greer <mgreer@animalcreek.com> Reviewed-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 383ed527dad9..5df339e9f67c 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1538,7 +1538,13 @@ static int emac_dev_open(struct net_device *ndev)
1538 int i = 0; 1538 int i = 0;
1539 struct emac_priv *priv = netdev_priv(ndev); 1539 struct emac_priv *priv = netdev_priv(ndev);
1540 1540
1541 pm_runtime_get(&priv->pdev->dev); 1541 ret = pm_runtime_get_sync(&priv->pdev->dev);
1542 if (ret < 0) {
1543 pm_runtime_put_noidle(&priv->pdev->dev);
1544 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1545 __func__, ret);
1546 return ret;
1547 }
1542 1548
1543 netif_carrier_off(ndev); 1549 netif_carrier_off(ndev);
1544 for (cnt = 0; cnt < ETH_ALEN; cnt++) 1550 for (cnt = 0; cnt < ETH_ALEN; cnt++)
@@ -1725,6 +1731,15 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1725 struct emac_priv *priv = netdev_priv(ndev); 1731 struct emac_priv *priv = netdev_priv(ndev);
1726 u32 mac_control; 1732 u32 mac_control;
1727 u32 stats_clear_mask; 1733 u32 stats_clear_mask;
1734 int err;
1735
1736 err = pm_runtime_get_sync(&priv->pdev->dev);
1737 if (err < 0) {
1738 pm_runtime_put_noidle(&priv->pdev->dev);
1739 dev_err(&priv->pdev->dev, "%s: failed to get_sync(%d)\n",
1740 __func__, err);
1741 return &ndev->stats;
1742 }
1728 1743
1729 /* update emac hardware stats and reset the registers*/ 1744 /* update emac hardware stats and reset the registers*/
1730 1745
@@ -1767,6 +1782,8 @@ static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
1767 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN); 1782 ndev->stats.tx_fifo_errors += emac_read(EMAC_TXUNDERRUN);
1768 emac_write(EMAC_TXUNDERRUN, stats_clear_mask); 1783 emac_write(EMAC_TXUNDERRUN, stats_clear_mask);
1769 1784
1785 pm_runtime_put(&priv->pdev->dev);
1786
1770 return &ndev->stats; 1787 return &ndev->stats;
1771} 1788}
1772 1789
@@ -1981,12 +1998,22 @@ static int davinci_emac_probe(struct platform_device *pdev)
1981 ndev->ethtool_ops = &ethtool_ops; 1998 ndev->ethtool_ops = &ethtool_ops;
1982 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT); 1999 netif_napi_add(ndev, &priv->napi, emac_poll, EMAC_POLL_WEIGHT);
1983 2000
2001 pm_runtime_enable(&pdev->dev);
2002 rc = pm_runtime_get_sync(&pdev->dev);
2003 if (rc < 0) {
2004 pm_runtime_put_noidle(&pdev->dev);
2005 dev_err(&pdev->dev, "%s: failed to get_sync(%d)\n",
2006 __func__, rc);
2007 goto no_cpdma_chan;
2008 }
2009
1984 /* register the network device */ 2010 /* register the network device */
1985 SET_NETDEV_DEV(ndev, &pdev->dev); 2011 SET_NETDEV_DEV(ndev, &pdev->dev);
1986 rc = register_netdev(ndev); 2012 rc = register_netdev(ndev);
1987 if (rc) { 2013 if (rc) {
1988 dev_err(&pdev->dev, "error in register_netdev\n"); 2014 dev_err(&pdev->dev, "error in register_netdev\n");
1989 rc = -ENODEV; 2015 rc = -ENODEV;
2016 pm_runtime_put(&pdev->dev);
1990 goto no_cpdma_chan; 2017 goto no_cpdma_chan;
1991 } 2018 }
1992 2019
@@ -1996,9 +2023,7 @@ static int davinci_emac_probe(struct platform_device *pdev)
1996 "(regs: %p, irq: %d)\n", 2023 "(regs: %p, irq: %d)\n",
1997 (void *)priv->emac_base_phys, ndev->irq); 2024 (void *)priv->emac_base_phys, ndev->irq);
1998 } 2025 }
1999 2026 pm_runtime_put(&pdev->dev);
2000 pm_runtime_enable(&pdev->dev);
2001 pm_runtime_resume(&pdev->dev);
2002 2027
2003 return 0; 2028 return 0;
2004 2029