From c4077d695e557962748c716c39b3b3228f475ead Mon Sep 17 00:00:00 2001 From: Fugang Duan Date: Thu, 14 Nov 2013 17:21:14 +0800 Subject: [PATCH] ENGR00288046: net:fec_ptp: fix WARNING caused by mutex_trylock run in interrupt context Kernel warning dump by enable kernel config "CONFIG_DEBUG_MUTEXES": ------------[ cut here ]------------ WARNING: at kernel/mutex.c:577 mutex_trylock+0x180/0x1d0() DEBUG_LOCKS_WARN_ON(in_interrupt()) Modules linked in: CPU: 0 PID: 68 Comm: kworker/0:2 Tainted: G W 3.10.17-16855-ga44de14 #1325 Workqueue: events phy_state_machine [<80014cbc>] (unwind_backtrace+0x0/0x138) from [<8001251c>] (show_stack+0x10/0x14) [<8001251c>] (show_stack+0x10/0x14) from [<80026754>] (warn_slowpath_common+0x4c/0x68) [<80026754>] (warn_slowpath_common+0x4c/0x68) from [<80026804>] (warn_slowpath_fmt+0x30/0x40) [<80026804>] (warn_slowpath_fmt+0x30/0x40) from [<8069f6b0>] (mutex_trylock+0x180/0x1d0) [<8069f6b0>] (mutex_trylock+0x180/0x1d0) from [<804dce7c>] (clk_prepare_lock+0xc/0xd8) [<804dce7c>] (clk_prepare_lock+0xc/0xd8) from [<804ddbcc>] (clk_get_rate+0xc/0x5c) [<804ddbcc>] (clk_get_rate+0xc/0x5c) from [<803b7528>] (fec_ptp_start_cyclecounter+0x1c/0x198) [<803b7528>] (fec_ptp_start_cyclecounter+0x1c/0x198) from [<803b5928>] (fec_restart+0x6e8/0x870) [<803b5928>] (fec_restart+0x6e8/0x870) from [<803b5d50>] (fec_enet_adjust_link+0x7c/0xb4) [<803b5d50>] (fec_enet_adjust_link+0x7c/0xb4) from [<803b07b8>] (phy_state_machine+0xfc/0x394) [<803b07b8>] (phy_state_machine+0xfc/0x394) from [<8003f03c>] (process_one_work+0x198/0x428) [<8003f03c>] (process_one_work+0x198/0x428) from [<8003fd24>] (worker_thread+0x144/0x3a4) [<8003fd24>] (worker_thread+0x144/0x3a4) from [<800458d8>] (kthread+0xa4/0xb0) [<800458d8>] (kthread+0xa4/0xb0) from [<8000ebd8>] (ret_from_fork+0x14/0x3c) ---[ end trace d1930b3e1c195329 ]--- Root cause: Worker thread call netif_tx_lock_bh() to diable the softirq preempt, and then call clk_get_rate() to get ptp clock rate. In fact, netif_tx_lock_bh()->local_bh_disable(), which make in_interrupt() to be ture. clk_get_rate()->clk_prepare_lock()->mutex_trylock(), and mutex_trylock() cannot use at interrupt context, otherwise there have kernel dump. So, remove the clk_get_rate() in there. Signed-off-by: Fugang Duan --- drivers/net/ethernet/freescale/fec_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 06c679ebcd9c..33f73df95b44 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -550,7 +550,7 @@ void fec_ptp_start_cyclecounter(struct net_device *ndev) unsigned long flags; int inc; - inc = FEC_T_PERIOD_ONE_SEC / clk_get_rate(fep->clk_ptp); + inc = FEC_T_PERIOD_ONE_SEC / fep->cycle_speed; /* grab the ptp lock */ spin_lock_irqsave(&fep->tmreg_lock, flags); -- 2.39.5