From patchwork Fri May 6 12:19:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caesar Wang X-Patchwork-Id: 9032581 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B470BF29F for ; Fri, 6 May 2016 12:19:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F01620389 for ; Fri, 6 May 2016 12:19:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E23420390 for ; Fri, 6 May 2016 12:19:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ayejU-0001Q8-2S; Fri, 06 May 2016 12:19:48 +0000 Received: from mail-pf0-f195.google.com ([209.85.192.195]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ayejQ-0001Mj-Pm for linux-rockchip@lists.infradead.org; Fri, 06 May 2016 12:19:46 +0000 Received: by mail-pf0-f195.google.com with SMTP id p185so12137936pfb.3 for ; Fri, 06 May 2016 05:19:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=sEucd+/Q6f4Xj4ELugjLOat0uQRKeIULCfQsycPgRII=; b=EpKOxiOsjsc3oLhszfYDpw4TsIV8o5Xm45MUSj85qXdfV7fYcelFs7aNmROhnI8z0D /L6av1vkpGY4TqLmLjX3eZBciwaZ4vuKFlqZZJFjGCQ8jV+g9vWk6hwmpbmbg+2gh+kq KU+A2D1x6Kk7rPBvczKq/6z/5p0jEocivL7xWtS/R0fatKgFijHcYiYLk5hvbTLo3Ey8 HOnBW92v6qGKB2EMcEL6srbQdjYJiz1bti2l7NIuYbk7QBEYx0g0EzWJQ12djFjNSomu RqPjx1q7FAkf2owa4D19BruJihbvih6Jl7FUJ08OuwfdvJPiaYWZxcMfbJ+wdWdklcHu ufTw== X-Gm-Message-State: AOPr4FW4yhl9+dZVyVntp859GCmwHEzmaUiCWPwd/UY3s/BOaWFLPLSPbpWduSFTOFUyCw== X-Received: by 10.98.28.84 with SMTP id c81mr28340989pfc.131.1462537163718; Fri, 06 May 2016 05:19:23 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id lz5sm20887258pab.34.2016.05.06.05.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 May 2016 05:19:22 -0700 (PDT) From: Caesar Wang To: davem@davemloft.net Subject: [PATCH v2] net: arc/emac: Move arc_emac_tx_clean() into arc_emac_tx() and disable tx interrut Date: Fri, 6 May 2016 20:19:16 +0800 Message-Id: <1462537156-10489-1-git-send-email-wxt@rock-chips.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160506_051944_872391_54EB1DEA X-CRM114-Status: GOOD ( 13.86 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heiko@sntech.de, Alexander Kochetkov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Shuyu Wei , Caesar Wang MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shuyu Wei Doing tx_clean() inside poll() may scramble the tx ring buffer if tx() is running. This will cause tx to stop working, which can be reproduced by simultaneously downloading two large files at high speed. Moving tx_clean() into tx() will prevent this. And tx interrupt is no longer needed now. Picked the Shuyu's patch up, the patch is sent on https://patchwork.kernel.org/patch/8356821/, since that make sense for rockchip platform. Note: Many people feedback the cransh problems with rk3036/rk3188 emac when download the heavy loading and this patch is indeed can fix the crash. The crash log as the followings: ... [ 2191.996127 ] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.0-rc6 #114 [ 2192.002475 ] Hardware name: Rockchip (Device Tree) [ 2192.007174 ] Backtrace: [ 2192.009658 ] [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [ 2192.017220 ] r7:c051c4f8 r6:ef463180 r5:c05b7000 r4:00000000 [ 2192.022948 ] [] (show_stack) from [] (dump_stack+0x90/0xa0) [ 2192.030176 ] [] (dump_stack) from [] (bad_page+0xdc/0x12c) [ 2192.037302 ] r5:c059a100 r4:c05f430c [ 2192.040913 ] [] (bad_page) from [] (get_page_from_freelist+0x388/0x95c) [ 2192.049166 ] r9:00000008 r8:ef463180 r7:c051c4d0 r6:00000000 r5:00000000 r4:c051c4e4 [ 2192.056982 ] [] (get_page_from_freelist) from [] (__alloc_pages_nodemask+0xd8/0x8e8) [ 2192.066362 ] r10:c001b068 r9:00000000 r8:ee0b02b0 r7:60000113 r6:00000003 r5:02095220 [ 2192.074254 ] r4:c05ca1c0 [ 2192.076809 ] [] (__alloc_pages_nodemask) from [] (__alloc_page_frag+0xb0/0x160) [ 2192.085757 ] r10:c001b068 r9:00000000 r8:ee0b02b0 r7:60000113 r6:02080020 r5:00000740 [ 2192.093650 ] r4:eedbc884 [ 2192.096207 ] [] (__alloc_page_frag) from [] (__netdev_alloc_skb+0xa0/0x104) [ 2192.104806 ] r7:60000113 r6:eedbc884 r5:ee0b0000 r4:00000740 [ 2192.110525 ] [] (__netdev_alloc_skb) from [] (arc_emac_poll+0x318/0x57c) [ 2192.118865 ] r9:00000000 r8:ee0b02b0 r7:0000019c r6:ee163780 r5:00000670 r4:ee0b0000 [ 2192.126683 ] [] (arc_emac_poll) from [] (net_rx_action+0x1f0/0x2ec) [ 2192.134590 ] r10:c0599df8 r9:c059a100 r8:00073760 r7:0000012c r6:00000028 r5:c02aa8e8 [ 2192.142483 ] r4:ee0b04e0 [ 2192.145040 ] [] (net_rx_action) from [] (__do_softirq+0x134/0x258) [ 2192.152860 ] r10:c059a080 r9:40000003 r8:00000003 r7:00000100 r6:c0598000 r5:c059a08c [ 2192.160751 ] r4:00000000 ... Signed-off-by: Shuyu Wei Tested-by: Michael Niewoehner Tested-by: Xing Zheng Cc: "David S. Miller" Cc: Alexander Kochetkov Cc: netdev@vger.kernel.org Signed-off-by: Caesar Wang --- drivers/net/ethernet/arc/emac_main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index a3a9392..4f4e25e 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -311,12 +311,10 @@ static int arc_emac_poll(struct napi_struct *napi, int budget) struct arc_emac_priv *priv = netdev_priv(ndev); unsigned int work_done; - arc_emac_tx_clean(ndev); - work_done = arc_emac_rx(ndev, budget); if (work_done < budget) { napi_complete(napi); - arc_reg_or(priv, R_ENABLE, RXINT_MASK | TXINT_MASK); + arc_reg_or(priv, R_ENABLE, RXINT_MASK); } return work_done; @@ -345,9 +343,9 @@ static irqreturn_t arc_emac_intr(int irq, void *dev_instance) /* Reset all flags except "MDIO complete" */ arc_reg_set(priv, R_STATUS, status); - if (status & (RXINT_MASK | TXINT_MASK)) { + if (status & RXINT_MASK) { if (likely(napi_schedule_prep(&priv->napi))) { - arc_reg_clr(priv, R_ENABLE, RXINT_MASK | TXINT_MASK); + arc_reg_clr(priv, R_ENABLE, RXINT_MASK); __napi_schedule(&priv->napi); } } @@ -461,7 +459,7 @@ static int arc_emac_open(struct net_device *ndev) arc_reg_set(priv, R_TX_RING, (unsigned int)priv->txbd_dma); /* Enable interrupts */ - arc_reg_set(priv, R_ENABLE, RXINT_MASK | TXINT_MASK | ERR_MASK); + arc_reg_set(priv, R_ENABLE, RXINT_MASK | ERR_MASK); /* Set CONTROL */ arc_reg_set(priv, R_CTRL, @@ -594,7 +592,7 @@ static int arc_emac_stop(struct net_device *ndev) netif_stop_queue(ndev); /* Disable interrupts */ - arc_reg_clr(priv, R_ENABLE, RXINT_MASK | TXINT_MASK | ERR_MASK); + arc_reg_clr(priv, R_ENABLE, RXINT_MASK | ERR_MASK); /* Disable EMAC */ arc_reg_clr(priv, R_CTRL, EN_MASK); @@ -656,6 +654,8 @@ static int arc_emac_tx(struct sk_buff *skb, struct net_device *ndev) __le32 *info = &priv->txbd[*txbd_curr].info; dma_addr_t addr; + arc_emac_tx_clean(ndev); + if (skb_padto(skb, ETH_ZLEN)) return NETDEV_TX_OK;