From nobody Wed Oct 8 05:52:19 2025 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 645A5276028; Wed, 2 Jul 2025 13:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751462157; cv=none; b=kqq83WC257QNQrRB8cM06b+agmumHUHo+zxwGVSnOTYVGm4+/0ouWm+l/6xDTXfwnY7YAYhUAfwAjWdRAuX0gt54A95zEvLDnrGfkQFlX/5j0fPGp29mUd8z4VJvTQqqvjrgCbxMphlotIeyH9+ww7Y7HbtQ0A4AbVqSfUqGSd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751462157; c=relaxed/simple; bh=i3pdO3f4mFgCs60KoFqZ7DoLzg2LmIvNWHCvQ+5g4Dw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nk3B8C5HU+7pWVl7MC4dBHzUW1sNTvY+lEk+9rQvUhTagl64Ui2CNBeeHNxlu7WXUUfwltGsTDcd5D8M7agqv95opMR9im/Eu2SXiYg8r3TrbUkI7V/wX2NsFoxmPrnwG90WUECZwLDU+clTaP0N6gLvuZY0JxVVo7QXdPg7VUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4bXKzQ43D3zWfvF; Wed, 2 Jul 2025 21:11:30 +0800 (CST) Received: from kwepemk100013.china.huawei.com (unknown [7.202.194.61]) by mail.maildlp.com (Postfix) with ESMTPS id 44BD91402C1; Wed, 2 Jul 2025 21:15:53 +0800 (CST) Received: from localhost.localdomain (10.90.31.46) by kwepemk100013.china.huawei.com (7.202.194.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 2 Jul 2025 21:15:52 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , , Subject: [PATCH net 1/4] net: hns3: fix concurrent setting vlan filter issue Date: Wed, 2 Jul 2025 21:08:58 +0800 Message-ID: <20250702130901.2879031-2-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20250702130901.2879031-1-shaojijie@huawei.com> References: <20250702130901.2879031-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemk100013.china.huawei.com (7.202.194.61) Content-Type: text/plain; charset="utf-8" From: Jian Shen The vport->req_vlan_fltr_en may be changed concurrently by function hclge_sync_vlan_fltr_state() called in periodic work task and function hclge_enable_vport_vlan_filter() called by user configuration. It may cause the user configuration inoperative. Fixes it by protect the vport->req_vlan_fltr by vport_lock. Fixes: fa6a262a2550 ("net: hns3: add support for VF modify VLAN filter stat= e") Signed-off-by: Jian Shen Signed-off-by: Jijie Shao Reviewed-by: Simon Horman --- .../hisilicon/hns3/hns3pf/hclge_main.c | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/driv= ers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 35c984a256ab..a485fc53807d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -9576,33 +9576,36 @@ static bool hclge_need_enable_vport_vlan_filter(str= uct hclge_vport *vport) return false; } =20 -int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request= _en) +static int __hclge_enable_vport_vlan_filter(struct hclge_vport *vport, + bool request_en) { - struct hclge_dev *hdev =3D vport->back; bool need_en; int ret; =20 - mutex_lock(&hdev->vport_lock); - - vport->req_vlan_fltr_en =3D request_en; - need_en =3D hclge_need_enable_vport_vlan_filter(vport); - if (need_en =3D=3D vport->cur_vlan_fltr_en) { - mutex_unlock(&hdev->vport_lock); + if (need_en =3D=3D vport->cur_vlan_fltr_en) return 0; - } =20 ret =3D hclge_set_vport_vlan_filter(vport, need_en); - if (ret) { - mutex_unlock(&hdev->vport_lock); + if (ret) return ret; - } =20 vport->cur_vlan_fltr_en =3D need_en; =20 + return 0; +} + +int hclge_enable_vport_vlan_filter(struct hclge_vport *vport, bool request= _en) +{ + struct hclge_dev *hdev =3D vport->back; + int ret; + + mutex_lock(&hdev->vport_lock); + vport->req_vlan_fltr_en =3D request_en; + ret =3D __hclge_enable_vport_vlan_filter(vport, request_en); mutex_unlock(&hdev->vport_lock); =20 - return 0; + return ret; } =20 static int hclge_enable_vlan_filter(struct hnae3_handle *handle, bool enab= le) @@ -10623,16 +10626,19 @@ static void hclge_sync_vlan_fltr_state(struct hcl= ge_dev *hdev) &vport->state)) continue; =20 - ret =3D hclge_enable_vport_vlan_filter(vport, - vport->req_vlan_fltr_en); + mutex_lock(&hdev->vport_lock); + ret =3D __hclge_enable_vport_vlan_filter(vport, + vport->req_vlan_fltr_en); if (ret) { dev_err(&hdev->pdev->dev, "failed to sync vlan filter state for vport%u, ret =3D %d\n", vport->vport_id, ret); set_bit(HCLGE_VPORT_STATE_VLAN_FLTR_CHANGE, &vport->state); + mutex_unlock(&hdev->vport_lock); return; } + mutex_unlock(&hdev->vport_lock); } } =20 --=20 2.33.0