Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp271273imu; Fri, 14 Dec 2018 19:19:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ugvr388e/6A3vJu+HkPyzTv6qT+TRG+uJdY8KBP3nbxQWKkzKeDVm6CROtTn+ydj53nnX5 X-Received: by 2002:a62:7086:: with SMTP id l128mr5179290pfc.68.1544843980955; Fri, 14 Dec 2018 19:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544843980; cv=none; d=google.com; s=arc-20160816; b=CsTCDKoRqHhwTo3yl0OGmVOd6mU0j2xy5wTvUpt+/9tQG0mVw/gODqnC+Q7Wu836l7 n3trkg+pHfu33dXokQPcuxlWHWbt8uXQu4fEQzVeceFEBS1h3zp8urelCwupv6pto0+p ebjgMAETwmIrfHOff+ofYuKQD9oIDeqQg5ExngDn9tt+/Pcd+rBQttF+SAURUWPa1gCA POTK26hf4tDH1PZhKNRFkBcPC4lmCGe3tT1tx1LT0OSi07ZN715Fp3yhpmtUyRMPipo8 maWwtL87HHlxbxQEyweldG/ZUuTrppZkPBT+Y8p+J9yHw3W7AbiOhO8FtRA9xacNknpM BI1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=oxOiORIkhmRCZ9zt9/Ra4K0jZwOzUJ8knEkqHOyDvVg=; b=LcN7+74Z6AdK6QTzrZ/RL08G4+V5RMWr5vDIYEhOsBILBKjPAJIpmQjExE7CxrXa7p QABA7As7Aa3wjvui0WSNDibBY4iQ24B4p4RxdG6WJe5spcr1T2F5Ty6GsImkh1XZaWJQ ZZtRspQ9wEYxqhN0nc3w+j+NSFIV7n8LAl4wDqMJMRQJb3RZvUfz3IKC7z3FLdCF8b5O f8cl8YslI/EAkoJpC3QMzztKS9it+Nm+rZSzFRxBp3vwuk6oO/BJkU3NYELnut7v6+pJ 0ovyrRG+odtiDCFsorgPmdJwsmwAjlqRCR0pdgLHioK+ksygmIGvxhP0f2Yiqytkg/ds 4qJA== 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 r12si5484084pgl.350.2018.12.14.19.19.09; Fri, 14 Dec 2018 19:19:40 -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 S1730400AbeLODRv (ORCPT + 99 others); Fri, 14 Dec 2018 22:17:51 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:16136 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729812AbeLODRe (ORCPT ); Fri, 14 Dec 2018 22:17:34 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 00E96B0FFFE00; Sat, 15 Dec 2018 11:17:30 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.408.0; Sat, 15 Dec 2018 11:17:23 +0800 From: Peng Li To: CC: , , , , , Subject: [Patch net 04/10] net: hns: Fixed bug that netdev was opened twice Date: Sat, 15 Dec 2018 11:53:23 +0800 Message-ID: <1544846009-50276-5-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> References: <1544846009-50276-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonglong Liu After resetting dsaf to try to repair chip error such as ecc error, the net device will be open if net interface is up. But at this time if there is the users set the net device up with the command ifconfig, the net device will be opened twice consecutively. Function napi_enable was called when open device. And Kernel panic will be occurred if it was called twice consecutively. Such as follow: static inline void napi_enable(struct napi_struct *n) { BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); smp_mb__before_clear_bit(); clear_bit(NAPI_STATE_SCHED, &n->state); } [37255.571996] Kernel panic - not syncing: BUG! [37255.595234] Call trace: [37255.597694] [] dump_backtrace+0x0/0x1a0 [37255.603114] [] show_stack+0x20/0x28 [37255.608187] [] dump_stack+0x98/0xb8 [37255.613258] [] panic+0x10c/0x26c [37255.618070] [] hns_nic_net_up+0x30c/0x4e0 [37255.623664] [] hns_nic_net_open+0x94/0x12c [37255.629346] [] __dev_open+0xf4/0x168 [37255.634504] [] __dev_change_flags+0x98/0x15c [37255.640359] [] dev_change_flags+0x2c/0x68 [37255.769580] [] devinet_ioctl+0x650/0x704 [37255.775086] [] inet_ioctl+0x98/0xb4 [37255.780159] [] sock_do_ioctl+0x44/0x84 [37255.785490] [] sock_ioctl+0x248/0x30c [37255.790737] [] do_vfs_ioctl+0x480/0x618 [37255.796156] [] SyS_ioctl+0x90/0xa4 [37255.801139] SMP: stopping secondary CPUs [37255.805079] kbox: catch panic event. [37255.809586] collected_len = 128928, LOG_BUF_LEN_LOCAL = 131072 [37255.816103] flush cache 0xffff80003f000000 size 0x800000 [37255.822192] flush cache 0xffff80003f000000 size 0x800000 [37255.828289] flush cache 0xffff80003f000000 size 0x800000 [37255.834378] kbox: no notify die func register. no need to notify [37255.840413] ---[ end Kernel panic - not syncing: BUG! This patchset fix this bug according to the flag NIC_STATE_DOWN. Signed-off-by: Yonglong Liu Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns/hns_enet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index c205a0e..c9454c4 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c @@ -1333,6 +1333,9 @@ static int hns_nic_net_up(struct net_device *ndev) int i, j; int ret; + if (!test_bit(NIC_STATE_DOWN, &priv->state)) + return 0; + ret = hns_nic_init_irq(priv); if (ret != 0) { netdev_err(ndev, "hns init irq failed! ret=%d\n", ret); -- 1.9.1