Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp168557ybg; Mon, 27 Jul 2020 19:19:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGBoIrXKZgDlZijl9yb/Diw2p0LMtdPWESVLQ8+7iKV0fOf+GbqW/mNpkYV/LzNrXYmugy X-Received: by 2002:a17:906:444e:: with SMTP id i14mr22762289ejp.418.1595902796021; Mon, 27 Jul 2020 19:19:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595902796; cv=none; d=google.com; s=arc-20160816; b=ghreZngUekQPqXb7fLGHgFAx9Ot+TvRFYeeTTcWnXhRq9EYcTuj7mY32zuH1E8e3dy +yoPG8t6Bay24a9Jzj7t1spLZH4tvVMmvtf/OlSfEp28A9J/R+MZzOu0/xQ4I0VNhWJH DnnAt1Y3ARk902GPMtI3EqhNA3Z1KCk9XP3jVu/EPF85gINs682RSoFePdXEe7ZF21eC UhPr9hA5vXVc/1evt5PJuHKmeiAab+ybyQp7yW2Mpo1hv0ZVZ4C847KdwUw70Nlu9av+ +vwc54eV2InfI5KYYhahiFGLixAKsP/bH+fiVF2Zhy6GyP4SN7oSFbzPJVkHuJk84Hko NFUg== 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=Rwx3YHXKfdKei+ZQ+p6iZHv07hrRDBWORDYnjKBhlRw=; b=lCgbCjztkxFuUzrqoBkS4Bn+Hwb0ppKgcP/pqhsD6V5M7YsOy1P8bCZnbnT19PGDrJ GLEOyZUdNZsh8gwIjXwrEQHfq3Y6RqCmI8W5umrACljC4h1IpPfMDL96VvQCGSVLq63A GpHZZL/7y/BIZP3rhrMu5jiwFKlIUexLAF/OdLRoQscOYt+rPHmn+WcIyGMoSm01fON6 PERHOk1p7S5Tk7rvckY4JWERE6kzLkodzFMhaFpsuSZ7s4rY3QW5ox1A38HNo16zb+4q HNrByjnfxkS4x+WDVLJbBEogP1lzkn/7G/1aaXaVJ2Pn42TUh9B92zW9DDEgSgtT/oHQ B+fg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u21si6646010edi.143.2020.07.27.19.19.34; Mon, 27 Jul 2020 19:19:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726975AbgG1CTS (ORCPT + 99 others); Mon, 27 Jul 2020 22:19:18 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8282 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726357AbgG1CTP (ORCPT ); Mon, 27 Jul 2020 22:19:15 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7887DCF508FBD69A4FE7; Tue, 28 Jul 2020 10:19:07 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Tue, 28 Jul 2020 10:19:00 +0800 From: Huazhong Tan To: CC: , , , , , , Jian Shen , Huazhong Tan Subject: [PATCH net 3/5] net: hns3: add reset check for VF updating port based VLAN Date: Tue, 28 Jul 2020 10:16:50 +0800 Message-ID: <1595902612-12880-4-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595902612-12880-1-git-send-email-tanhuazhong@huawei.com> References: <1595902612-12880-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen Currently hclgevf_update_port_base_vlan_info() may be called when VF is resetting, which may cause hns3_nic_net_open() being called twice unexpectedly. So fix it by adding a reset check for it, and extend critical region for rntl_lock in hclgevf_update_port_base_vlan_info(). Fixes: 92f11ea177cd ("net: hns3: fix set port based VLAN issue for VF") Signed-off-by: Jian Shen Signed-off-by: Huazhong Tan --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index a10b022..b8b72ac 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -3439,23 +3439,35 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state, { struct hnae3_handle *nic = &hdev->nic; struct hclge_vf_to_pf_msg send_msg; + int ret; rtnl_lock(); - hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); - rtnl_unlock(); + + if (test_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) { + dev_warn(&hdev->pdev->dev, + "is resetting when updating port based vlan info\n"); + rtnl_unlock(); + return; + } + + ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); + if (ret) { + rtnl_unlock(); + return; + } /* send msg to PF and wait update port based vlan info */ hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_VLAN, HCLGE_MBX_PORT_BASE_VLAN_CFG); memcpy(send_msg.data, port_base_vlan_info, data_size); - hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); - - if (state == HNAE3_PORT_BASE_VLAN_DISABLE) - nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_DISABLE; - else - nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE; + ret = hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); + if (!ret) { + if (state == HNAE3_PORT_BASE_VLAN_DISABLE) + nic->port_base_vlan_state = state; + else + nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE; + } - rtnl_lock(); hclgevf_notify_client(hdev, HNAE3_UP_CLIENT); rtnl_unlock(); } -- 2.7.4