[linux-yocto] [PATCH 06/26] net: nemac: cannot sleep in get_stats
Daniel Dragomir
daniel.dragomir at windriver.com
Wed Nov 16 08:56:42 PST 2016
From: Per Hallsmark <per.hallsmark at windriver.com>
root at axxiaarm64:~# ifconfig eth0
[ 2377.952102] BUG: sleeping function called from invalid context at
kernel/sched/completion.c:90
[ 2378.005347] in_atomic(): 0, irqs_disabled(): 0, pid: 1140, name: ifconfig
[ 2378.046970] INFO: lockdep is turned off.
[ 2378.070992] Preemption disabled at:[<ffffffc00010c658>] vprintk_default+0x48/0x58
[ 2378.116906]
[ 2378.125998] CPU: 0 PID: 1140 Comm: ifconfig Tainted: G W 4.1.21-rt13-wrl800.6_
2.38_1-yocto-standard+ #25
[ 2378.191071] Hardware name: AXM56xx Victoria (DT)
[ 2378.219344] Call trace:
[ 2378.234287] [<ffffffc00008ac38>] dump_backtrace+0x0/0x128
[ 2378.267363] [<ffffffc00008ad84>] show_stack+0x24/0x30
[ 2378.298304] [<ffffffc00072cd64>] dump_stack+0xb0/0x10c
[ 2378.329780] [<ffffffc0000d44a0>] ___might_sleep+0x258/0x270
[ 2378.363919] [<ffffffc0000d4518>] __might_sleep+0x60/0xa0
[ 2378.396460] [<ffffffc00072fab0>] wait_for_common+0x48/0x150
[ 2378.430599] [<ffffffc00072fc1c>] wait_for_completion_timeout+0x2c/0x38
[ 2378.470607] [<ffffffc0004f2c1c>] nemac_stats_snapshot+0x44/0x50
[ 2378.506880] [<ffffffc0004f3a40>] nemac_get_stats64+0x28/0x138
[ 2378.542088] [<ffffffc0005a6478>] dev_get_stats+0x68/0xd8
[ 2378.574628] [<ffffffc0005d0834>] dev_seq_printf_stats+0x2c/0xf0
[ 2378.610900] [<ffffffc0005d0928>] dev_seq_show+0x30/0x60
[ 2378.642908] [<ffffffc000260dcc>] seq_read+0x32c/0x420
[ 2378.673851] [<ffffffc0002a751c>] proc_reg_read+0x84/0xc0
[ 2378.706391] [<ffffffc0002358e8>] __vfs_read+0x48/0x90
[ 2378.737331] [<ffffffc000236334>] vfs_read+0x84/0x170
[ 2378.767737] [<ffffffc00023702c>] SyS_read+0x54/0xb0
eth0 Link encap:Ethernet HWaddr 98:4f:ee:10:e4:39
inet addr:128.224.95.149 Bcast:128.224.95.255 Mask:255.255.255.128
inet6 addr: fe80::9a4f:eeff:fe10:e439/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15928 errors:0 dropped:2 overruns:0 frame:15928
TX packets:5301 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11134123 (10.6 MiB) TX bytes:982220 (959.1 KiB)
root at axxiaarm64:~#
According to documentation:
ndo_get_stats:
Synchronization: dev_base_lock rwlock.
Context: nominally process, but don't sleep inside an rwlock
So we need to poll for completion instead of possibly sleep.
Signed-off-by: Per Hallsmark <per.hallsmark at windriver.com>
---
drivers/net/ethernet/intel/axxia/nemac.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/axxia/nemac.c b/drivers/net/ethernet/intel/axxia/nemac.c
index 2eead12..ce57258 100644
--- a/drivers/net/ethernet/intel/axxia/nemac.c
+++ b/drivers/net/ethernet/intel/axxia/nemac.c
@@ -376,14 +376,20 @@ nemac_tx_stat_counter(struct nemac_priv *priv, int counter)
static int
nemac_stats_snapshot(struct nemac_priv *priv)
{
- const unsigned long tmo = msecs_to_jiffies(20);
+ const unsigned long tmo = jiffies + msecs_to_jiffies(20);
+ int ret;
/* Request a snapshot of the counters and wait for the interrupt
* handler to signal completion.
*/
reinit_completion(&priv->stats_rdy);
writel(MAC(0), priv->reg + NEM_STATS_SNAPSHOT_R);
- return wait_for_completion_interruptible_timeout(&priv->stats_rdy, tmo);
+
+ /* need to poll for completion */
+ do {
+ ret = try_wait_for_completion(&priv->stats_rdy);
+ } while (!ret && time_before(jiffies, tmo));
+ return ret;
}
static const char * const tx_stat_names[] = {
--
2.7.4
More information about the linux-yocto
mailing list