diff options
author | Huacai Chen <chenhc@lemote.com> | 2014-12-19 09:38:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-12-22 15:42:13 -0500 |
commit | fe13192911507c49002fc4882ef11f75f529a010 (patch) | |
tree | 09eccc1243ff0f6abdb9e66fb1f31a28974303bb | |
parent | da413eec729dae5dcb150e2eb34c5e7e5e4e1b49 (diff) |
stmmac: Don't init ptp again when resume from suspend/hibernation
Both stmmac_open() and stmmac_resume() call stmmac_hw_setup(), and
stmmac_hw_setup() call stmmac_init_ptp() unconditionally. However, only
stmmac_release() calls stmmac_release_ptp(). Since stmmac_suspend()
doesn't call stmmac_release_ptp(), stmmac_resume() also needn't call
stmmac_init_ptp().
This patch also fix a "scheduling while atomic" problem when resume
from suspend/hibernation. Because stmmac_init_ptp() will trigger
scheduling while stmmac_resume() hold a spinlock.
Callgraph of "scheduling while atomic":
stmmac_resume() --> stmmac_hw_setup() --> stmmac_init_ptp() -->
stmmac_ptp_register() --> ptp_clock_register() --> device_create() -->
device_create_groups_vargs() --> device_add() --> devtmpfs_create_node()
--> wait_for_common() --> schedule_timeout() --> __schedule()
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 118a427d1942..8c6b7c1651e5 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -1671,7 +1671,7 @@ static void stmmac_init_tx_coalesce(struct stmmac_priv *priv) | |||
1671 | * 0 on success and an appropriate (-)ve integer as defined in errno.h | 1671 | * 0 on success and an appropriate (-)ve integer as defined in errno.h |
1672 | * file on failure. | 1672 | * file on failure. |
1673 | */ | 1673 | */ |
1674 | static int stmmac_hw_setup(struct net_device *dev) | 1674 | static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) |
1675 | { | 1675 | { |
1676 | struct stmmac_priv *priv = netdev_priv(dev); | 1676 | struct stmmac_priv *priv = netdev_priv(dev); |
1677 | int ret; | 1677 | int ret; |
@@ -1708,9 +1708,11 @@ static int stmmac_hw_setup(struct net_device *dev) | |||
1708 | 1708 | ||
1709 | stmmac_mmc_setup(priv); | 1709 | stmmac_mmc_setup(priv); |
1710 | 1710 | ||
1711 | ret = stmmac_init_ptp(priv); | 1711 | if (init_ptp) { |
1712 | if (ret && ret != -EOPNOTSUPP) | 1712 | ret = stmmac_init_ptp(priv); |
1713 | pr_warn("%s: failed PTP initialisation\n", __func__); | 1713 | if (ret && ret != -EOPNOTSUPP) |
1714 | pr_warn("%s: failed PTP initialisation\n", __func__); | ||
1715 | } | ||
1714 | 1716 | ||
1715 | #ifdef CONFIG_DEBUG_FS | 1717 | #ifdef CONFIG_DEBUG_FS |
1716 | ret = stmmac_init_fs(dev); | 1718 | ret = stmmac_init_fs(dev); |
@@ -1787,7 +1789,7 @@ static int stmmac_open(struct net_device *dev) | |||
1787 | goto init_error; | 1789 | goto init_error; |
1788 | } | 1790 | } |
1789 | 1791 | ||
1790 | ret = stmmac_hw_setup(dev); | 1792 | ret = stmmac_hw_setup(dev, true); |
1791 | if (ret < 0) { | 1793 | if (ret < 0) { |
1792 | pr_err("%s: Hw setup failed\n", __func__); | 1794 | pr_err("%s: Hw setup failed\n", __func__); |
1793 | goto init_error; | 1795 | goto init_error; |
@@ -3036,7 +3038,7 @@ int stmmac_resume(struct net_device *ndev) | |||
3036 | netif_device_attach(ndev); | 3038 | netif_device_attach(ndev); |
3037 | 3039 | ||
3038 | init_dma_desc_rings(ndev, GFP_ATOMIC); | 3040 | init_dma_desc_rings(ndev, GFP_ATOMIC); |
3039 | stmmac_hw_setup(ndev); | 3041 | stmmac_hw_setup(ndev, false); |
3040 | stmmac_init_tx_coalesce(priv); | 3042 | stmmac_init_tx_coalesce(priv); |
3041 | 3043 | ||
3042 | napi_enable(&priv->napi); | 3044 | napi_enable(&priv->napi); |