From patchwork Tue Sep 25 10:38:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 1503671 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 49816DF28C for ; Tue, 25 Sep 2012 10:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754766Ab2IYKjJ (ORCPT ); Tue, 25 Sep 2012 06:39:09 -0400 Received: from moutng.kundenserver.de ([212.227.126.171]:61942 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752503Ab2IYKjH (ORCPT ); Tue, 25 Sep 2012 06:39:07 -0400 Received: from axis700.grange (dslb-178-001-231-044.pools.arcor-ip.net [178.1.231.44]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0Lla4p-1Tqtox0kBb-00bKcu; Tue, 25 Sep 2012 12:39:00 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 9B819E6AAB; Tue, 25 Sep 2012 12:38:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 913ED10675B; Tue, 25 Sep 2012 12:38:59 +0200 (CEST) Date: Tue, 25 Sep 2012 12:38:59 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: linux-sh@vger.kernel.org cc: Paul Mundt , netdev@vger.kernel.org Subject: [PATCH] net: sh-eth: fix sleeping in atomic context Message-ID: MIME-Version: 1.0 X-Provags-ID: V02:K0:AgsFnKE5Yr5+JkPuNfbVrphGLl7WlfOoK5UH+ooqJwC BfOzGpbRikyR+k8fqLTH8/qgfqgQX5lgQR5gniCyxCSI23S0Om QynxPJ6Yqrg9K6uXh8IpzXNejZozjNdL79sqUWNJwKVVAOqPe8 l1Kxu8V+N43KMe7+ek5MUZ44eUC+nZuIe1Ob7mT6tewusOiQwN PWVe/ZC97HlpAIC6uoFEpiWDKaoxGBc3UorViG/9RA2fM9xBl/ Gltby37XjvTYinqLMAxXhXleALNNzqp5PqLwORpUH+fSOjdC0H BQaxvlHIh/ShAHyHeHJ4chtdbGiA/uXfoH5xVSMLD8dK/j5dy/ ZSenl1Q0NYV45IA/PHv0mQFplAx1gAd/5Pa79o4d3CX+LgSkDb gLmFuuo7b+jwg== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org The .ndo_get_stats() net-device operation can sleep, which leads on sh_eth to the following BUG on the armadillo800eva board: BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:867 in_atomic(): 1, irqs_disabled(): 0, pid: 561, name: rpc.statd Backtrace: [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c) r6:c0294118 r5:00000004 r4:c035e898 r3:60000013 [] (dump_stack+0x0/0x1c) from [] (__might_sleep+0xec/0x10c) [] (__might_sleep+0x0/0x10c) from [] (__pm_runtime_resume+0x3c/0xac) [] (__pm_runtime_resume+0x0/0xac) from [] (sh_eth_get_stats+0x24/0x180) r6:c0294118 r5:de0c6400 r4:de0c6000 r3:c01b59ec [] (sh_eth_get_stats+0x0/0x180) from [] (dev_get_stats+0x5c/0x84) r6:c0294118 r5:de0c6000 r4:de1efad0 r3:c01b59ec [] (dev_get_stats+0x0/0x84) from [] (rtnl_fill_ifinfo+0x354/0x76c) r6:00000000 r5:de0c6000 r4:de3df980 r3:00000334 [] (rtnl_fill_ifinfo+0x0/0x76c) from [] (rtnl_dump_ifinfo+0xf8/0x1a8) [] (rtnl_dump_ifinfo+0x0/0x1a8) from [] (netlink_dump+0x58/0x1c0) [] (netlink_dump+0x0/0x1c0) from [] (netlink_dump_start+0x108/0x144) r7:de3a9e30 r6:de3bcd80 r5:de04f200 r4:de3a9e00 [] (netlink_dump_start+0x0/0x144) from [] (rtnetlink_rcv_msg+0x160/0x2a0) r8:c020245c r7:00000f40 r6:de1efd00 r5:de3de180 r4:de3da680 r3:de1efd00 [] (rtnetlink_rcv_msg+0x0/0x2a0) from [] (netlink_rcv_skb+0x54/0xb8) [] (netlink_rcv_skb+0x0/0xb8) from [] (rtnetlink_rcv+0x20/0x2c) r6:de3a9e00 r5:de3de180 r4:de3de180 r3:c0203558 [] (rtnetlink_rcv+0x0/0x2c) from [] (netlink_unicast+0x14c/0x21c) r4:de04f200 r3:c0203558 [] (netlink_unicast+0x0/0x21c) from [] (netlink_sendmsg+0x210/0x288) r8:00000000 r7:de1efe78 r6:de1eff54 r5:de3a9e00 r4:de3de180 [] (netlink_sendmsg+0x0/0x288) from [] (sock_sendmsg+0x9c/0xb8) [] (sock_sendmsg+0x0/0xb8) from [] (sys_sendto+0xb8/0xdc) r5:00000014 r4:de1efed4 [] (sys_sendto+0x0/0xdc) from [] (ret_fast_syscall+0x0/0x30) Remove sleeping functions from sh_eth_get_stats() to fix it. Signed-off-by: Guennadi Liakhovetski --- I'm not sure, whether this is the correct fix, i.e., whether this function is guaranteed to be called on a resumed device, but at least this fixes this specific issue in 3.6-rc7, but leaves another BUG open: BUG: sleeping function called from invalid context at include/linux/kernel.h:207 in_atomic(): 1, irqs_disabled(): 0, pid: 0, name: swapper Backtrace: [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c) r6:c03a7cf8 r5:00000000 r4:00000000 r3:60000113 [] (dump_stack+0x0/0x1c) from [] (__might_sleep+0xec/0x10c) [] (__might_sleep+0x0/0x10c) from [] (do_alignment+0x29c/0x700) [] (do_alignment+0x0/0x700) from [] (do_DataAbort+0x3c/0xa0) [] (do_DataAbort+0x0/0xa0) from [] (__dabt_svc+0x38/0x60) Exception stack(0xc03a7cf8 to 0xc03a7d40) 7ce0: dd385cc0 dd2937c2 7d00: 00000000 dd385cc0 dd385cc0 c03cf8c8 dd23c7c0 00000000 00000001 00000000 7d20: 00000001 c03a7db4 c03a7d50 c03a7d40 c027832c c0277eb8 60000113 ffffffff r7:c03a7d2c r6:ffffffff r5:60000113 r4:c0277eb8 [] (icmp_echo+0x0/0x70) from [] (icmp_rcv+0x144/0x16c) [] (icmp_rcv+0x0/0x16c) from [] (ip_local_deliver+0x104/0x1b8) r6:c03cf8c8 r5:00000001 r4:dd385cc0 r3:c02781e8 [] (ip_local_deliver+0x0/0x1b8) from [] (ip_rcv+0x4c0/0x504) r7:00000000 r6:0125010d r5:dd2937ae r4:dd385cc0 [] (ip_rcv+0x0/0x504) from [] (__netif_receive_skb+0x4cc/0x560) r9:00200000 r8:00000000 r7:00000008 r6:c03af040 r5:dd0e2000 r4:c03ae5e0 [] (__netif_receive_skb+0x0/0x560) from [] (process_backlog+0x78/0x12c) [] (process_backlog+0x0/0x12c) from [] (net_rx_action+0x58/0x148) [] (net_rx_action+0x0/0x148) from [] (__do_softirq+0x88/0x140) [] (__do_softirq+0x0/0x140) from [] (irq_exit+0x4c/0x70) [] (irq_exit+0x0/0x70) from [] (handle_IRQ+0x6c/0x8c) [] (handle_IRQ+0x0/0x8c) from [] (asm_do_IRQ+0x10/0x14) r5:60000013 r4:c000e8c0 [] (asm_do_IRQ+0x0/0x14) from [] (shmobile_handle_irq_intc+0x8/0x40) Exception stack(0xc03a7f38 to 0xc03a7f80) 7f20: 00000000 00000000 7f40: 00000000 00000000 c03a6000 ffffffff c039d3d0 7fffffff 40004059 412fc093 7f60: 00000000 c03a7f8c c03a7f90 c03a7f80 c000e8bc c000e8c0 60000013 ffffffff [] (default_idle+0x0/0x34) from [] (cpu_idle+0x58/0x9c) [] (cpu_idle+0x0/0x9c) from [] (rest_init+0x78/0x90) r4:c03a6000 r3:c02bac68 [] (rest_init+0x0/0x90) from [] (start_kernel+0x248/0x288) r4:c03ae0ec r3:c03bff40 [] (start_kernel+0x0/0x288) from [<40008040>] (0x40008040) drivers/net/ethernet/renesas/sh_eth.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index bad8f2e..512c7cb 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -1809,8 +1809,6 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) { struct sh_eth_private *mdp = netdev_priv(ndev); - pm_runtime_get_sync(&mdp->pdev->dev); - ndev->stats.tx_dropped += sh_eth_read(ndev, TROCR); sh_eth_write(ndev, 0, TROCR); /* (write clear) */ ndev->stats.collisions += sh_eth_read(ndev, CDCR); @@ -1826,7 +1824,6 @@ static struct net_device_stats *sh_eth_get_stats(struct net_device *ndev) ndev->stats.tx_carrier_errors += sh_eth_read(ndev, CNDCR); sh_eth_write(ndev, 0, CNDCR); /* (write clear) */ } - pm_runtime_put_sync(&mdp->pdev->dev); return &ndev->stats; }