stmmac: Don't init ptp again when resume from suspend/hibernation
authorHuacai Chen <chenhc@lemote.com>
Fri, 19 Dec 2014 14:38:18 +0000 (22:38 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Dec 2014 20:42:13 +0000 (15:42 -0500)
commitfe13192911507c49002fc4882ef11f75f529a010
tree09eccc1243ff0f6abdb9e66fb1f31a28974303bb
parentda413eec729dae5dcb150e2eb34c5e7e5e4e1b49
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>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c