Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1392742ybl; Wed, 18 Dec 2019 18:09:16 -0800 (PST) X-Google-Smtp-Source: APXvYqwXDdhdC8Tk5FSCvUBB2YA6J4MWGW+sIBciwvfhpkPz0hKMObUcVO9I3fNzPSPJDuN31zSV X-Received: by 2002:a05:6830:1715:: with SMTP id 21mr6184664otk.67.1576721356260; Wed, 18 Dec 2019 18:09:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576721356; cv=none; d=google.com; s=arc-20160816; b=mGJ2SaRlWDIs1S7JIGkLk6EafMsihXTe5wUlLJUNtYt/R8iuFF3qOPhmCLRMFfmBlk LlUlqFhYWwmaGsgF7if7QnV3+Op8bywQKFE2kr//O6IwGyZTpbHseDpCFs6CGSmI9nxB NLa5n3vIBfn/9WgbTWAZXFq5RLMpfxa2geMiigRY5YG5nQSUsDLG7wstXIsSQK7bzgBb Y0wFRop3qsk/2/yH9n5ZZLVsxKGRN1AMHnqV2eTo/gVK24HmPKefHJLoa1qK6SoBFMAA 5j6RbKqmfVi55ISJkO0XOSvkVeYYyJW9D9rj0qAvPHITi5HtJk7+MyNz+MxjlL4QUrr6 UFLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=MWsNP+Ep1nLtLRxBfEbI/dJ7rVpjkz6yVXwHxJIbGjg=; b=oUwicq1hPNIzOl2tIkT2/WDcQ9bsBDs33NHCRV6f87evdVPVXdYPybFaHDmLOzoYI3 SHOr2fJZpupsJziPCUoVfZ7OSAH1Rss4E1kCOWogpy+gIaQYjLqnkVGnNNjzzXadbNM1 cMPlyeCffX/8su39zApHGIQ27u9PTilu+Kw8J+m2GCFRpkRmM21PrP9siy2OKzQ6/mn7 JBt5/phBckR1KsAjHJpXKgM7c7bxMfEgsPLpt1eXFsMogIDRiu1CzJ1b1308n7PvUGPJ 9Gl6OAB7FpycWPGSl5P1SGOLUeRB/cjLRIkDTw1DXBTOuL2EdG0xrzjWZZb27O6TvVt5 jbNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si2394719otn.216.2019.12.18.18.09.04; Wed, 18 Dec 2019 18:09:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbfLSCIZ (ORCPT + 99 others); Wed, 18 Dec 2019 21:08:25 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7713 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726700AbfLSCIY (ORCPT ); Wed, 18 Dec 2019 21:08:24 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CA88C46F6798D21DA4B5; Thu, 19 Dec 2019 10:08:22 +0800 (CST) Received: from huawei.com (10.67.189.167) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Thu, 19 Dec 2019 10:08:13 +0800 From: Jiangfeng Xiao To: , , , , , , CC: , , , , Subject: [PATCH v4] net: hisilicon: Fix a BUG trigered by wrong bytes_compl Date: Thu, 19 Dec 2019 10:08:07 +0800 Message-ID: <1576721287-68102-1-git-send-email-xiaojiangfeng@huawei.com> X-Mailer: git-send-email 1.8.5.6 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.189.167] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When doing stress test, we get the following trace: kernel BUG at lib/dynamic_queue_limits.c:26! Internal error: Oops - BUG: 0 [#1] SMP ARM Modules linked in: hip04_eth CPU: 0 PID: 2003 Comm: tDblStackPcap0 Tainted: G O L 4.4.197 #1 Hardware name: Hisilicon A15 task: c3637668 task.stack: de3bc000 PC is at dql_completed+0x18/0x154 LR is at hip04_tx_reclaim+0x110/0x174 [hip04_eth] pc : [] lr : [] psr: 800f0313 sp : de3bdc2c ip : 00000000 fp : c020fb10 r10: 00000000 r9 : c39b4224 r8 : 00000001 r7 : 00000046 r6 : c39b4000 r5 : 0078f392 r4 : 0078f392 r3 : 00000047 r2 : 00000000 r1 : 00000046 r0 : df5d5c80 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user Control: 32c5387d Table: 1e189b80 DAC: 55555555 Process tDblStackPcap0 (pid: 2003, stack limit = 0xde3bc190) Stack: (0xde3bdc2c to 0xde3be000) [] (dql_completed) from [] (hip04_tx_reclaim+0x110/0x174 [hip04_eth]) [] (hip04_tx_reclaim [hip04_eth]) from [] (hip04_rx_poll+0x20/0x388 [hip04_eth]) [] (hip04_rx_poll [hip04_eth]) from [] (net_rx_action+0x120/0x374) [] (net_rx_action) from [] (__do_softirq+0x218/0x318) [] (__do_softirq) from [] (irq_exit+0x88/0xac) [] (irq_exit) from [] (msa_irq_exit+0x11c/0x1d4) [] (msa_irq_exit) from [] (__handle_domain_irq+0x110/0x148) [] (__handle_domain_irq) from [] (gic_handle_irq+0xd4/0x118) [] (gic_handle_irq) from [] (__irq_svc+0x40/0x58) Exception stack(0xde3bdde0 to 0xde3bde28) dde0: 00000000 00008001 c3637668 00000000 00000000 a00f0213 dd3627a0 c0af6380 de00: c086d380 a00f0213 c0a22a50 de3bde6c 00000002 de3bde30 c0558138 c055813c de20: 600f0213 ffffffff [] (__irq_svc) from [] (_raw_spin_unlock_irqrestore+0x44/0x54) Kernel panic - not syncing: Fatal exception in interrupt Pre-modification code: int hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) { [...] [1] priv->tx_head = TX_NEXT(tx_head); [2] count++; [3] netdev_sent_queue(ndev, skb->len); [...] } An rx interrupt occurs if hip04_mac_start_xmit just executes to the line 2, tx_head has been updated, but corresponding 'skb->len' has not been added to dql_queue. And then hip04_mac_interrupt->__napi_schedule->hip04_rx_poll->hip04_tx_reclaim In hip04_tx_reclaim, because tx_head has been updated, bytes_compl will plus an additional "skb-> len" which has not been added to dql_queue. And then trigger the BUG_ON(bytes_compl > num_queued - dql->num_completed). To solve the problem described above, we put "netdev_sent_queue(ndev, skb->len);" before "priv->tx_head = TX_NEXT(tx_head);" Fixes: a41ea46a9a12 ("net: hisilicon: new hip04 ethernet driver") Signed-off-by: Jiangfeng Xiao --- ChangeLog v1->v2 - Provide an appropriate Fixes: tag ChangeLog v2->v3 - Remove unrelated cleanup ChangeLog v3->v4 - Use Fixes: tag with 12 characters of the hash --- drivers/net/ethernet/hisilicon/hip04_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index 3e9b6d5..150a8cc 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -543,9 +543,9 @@ static void hip04_start_tx_timer(struct hip04_priv *priv) skb_tx_timestamp(skb); hip04_set_xmit_desc(priv, phys); - priv->tx_head = TX_NEXT(tx_head); count++; netdev_sent_queue(ndev, skb->len); + priv->tx_head = TX_NEXT(tx_head); stats->tx_bytes += skb->len; stats->tx_packets++; -- 1.8.5.6