From nobody Thu Apr 9 10:44:17 2026 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 A5AC12DCF67; Tue, 10 Mar 2026 01:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773104722; cv=none; b=AiKFSe+4d0PVvPkqAl6islxbezuxtd7OgmM/B7KDG0Y17HJWvUlg4c60/1i6hF8kPSLkkkcPyqw7bbIXpPP/ia2hYIkOcbjMzC64H+tyPv7MCAt//LiTmHabNlR4WjxIuWDikytEG0wOjrrfb+OyOXEvpiphFhQA3eunyS3hdkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773104722; c=relaxed/simple; bh=JI+zrssM2poQYt3Q/PQmB+LWGYXDv2SOXjEM5i2QT8w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ICr7VhdAfW28P3Tx0us+8tLlS3TCJZCli1JrxvTgDl40GlCH4XiyvjlpkVvzVF2ocE6OSXXPJRSubVIDkuw4eiDUtyCT5eepvb5y6tuNubGVNGz9yWE78oDzIvK8ID9tOEGyHW9lWwI+6Ikk9igeSExAyGbYy2uEFaTswgEDn/s= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=g1HAkpn/; arc=none smtp.client-ip=113.46.200.225 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="g1HAkpn/" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=IytfMJ2qVSxnwwGFOD+sjTnzoAxZ7/y0WCbSOE+d6Lw=; b=g1HAkpn/HgCZmR623CS14HsrfrxoNyBobe53az4mz1tQ3ErWBmmSQp3VWg+zwZB+Pvrrc/4Gn 5Mfx2ECwT2lMeoJdWHLWYBupRAbL8yPtAoXOzw8XezPgiy9Hukg3Fq/aHTxZclZInDkfZSQ++Jn XCjvHqCZVnX7p+T5c8RG+nc= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4fVFsy1VPDz1K9Cg; Tue, 10 Mar 2026 09:00:22 +0800 (CST) Received: from kwepemf100013.china.huawei.com (unknown [7.202.181.12]) by mail.maildlp.com (Postfix) with ESMTPS id 6636640565; Tue, 10 Mar 2026 09:05:14 +0800 (CST) Received: from DESKTOP-62GVMTR.china.huawei.com (10.174.189.124) by kwepemf100013.china.huawei.com (7.202.181.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 10 Mar 2026 09:05:13 +0800 From: Fan Gong To: Fan Gong , Zhu Yikai , , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Andrew Lunn CC: , , luosifu , Xin Guo , Zhou Shuai , Wu Like , Shi Jing , Zheng Jiezhen Subject: [PATCH net-next v03 5/9] hinic3: Add msg_send_lock for message sending concurrecy Date: Tue, 10 Mar 2026 09:04:53 +0800 Message-ID: X-Mailer: git-send-email 2.51.0.windows.1 In-Reply-To: References: 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 kwepemf100013.china.huawei.com (7.202.181.12) Content-Type: text/plain; charset="utf-8" As send_mbox_msg is invoked by 3 functions: hinic3_send_mbox_to_mgmt, hinic3_response_mbox_to_mgmt and hinic3_send_mbox_to_mgmt_no_ack, only hinic3_response_mbox_to_mgmt does not has mutex and the other two has mbox->mbox_send_lock because their send actions are mutually exclusive. As hinic3_response_mbox_to_mgmt does not conflict with them in send actions but in mailbox resources, add the new mutex(msg_send_lock) in send_mbox_msg to ensure message concurrency. Besdies, in mbox_send_seg change FIELD_PREP to FIELD_GET in MBOX_STATUS_FINISHED and MBOX_STATUS_SUCCESS to be more reasonable. Co-developed-by: Zhu Yikai Signed-off-by: Zhu Yikai Signed-off-by: Fan Gong --- drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c | 9 +++++++-- drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c b/drivers/net= /ethernet/huawei/hinic3/hinic3_mbox.c index c82370cf401d..51be726d9d2e 100644 --- a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c @@ -51,9 +51,9 @@ #define MBOX_WB_STATUS_NOT_FINISHED 0x00 =20 #define MBOX_STATUS_FINISHED(wb) \ - ((FIELD_PREP(MBOX_WB_STATUS_MASK, (wb))) !=3D MBOX_WB_STATUS_NOT_FINISHED) + ((FIELD_GET(MBOX_WB_STATUS_MASK, (wb))) !=3D MBOX_WB_STATUS_NOT_FINISHED) #define MBOX_STATUS_SUCCESS(wb) \ - ((FIELD_PREP(MBOX_WB_STATUS_MASK, (wb))) =3D=3D \ + ((FIELD_GET(MBOX_WB_STATUS_MASK, (wb))) =3D=3D \ MBOX_WB_STATUS_FINISHED_SUCCESS) #define MBOX_STATUS_ERRCODE(wb) \ ((wb) & MBOX_WB_ERROR_CODE_MASK) @@ -396,6 +396,7 @@ static int hinic3_mbox_pre_init(struct hinic3_hwdev *hw= dev, { mbox->hwdev =3D hwdev; mutex_init(&mbox->mbox_send_lock); + mutex_init(&mbox->mbox_seg_send_lock); spin_lock_init(&mbox->mbox_lock); =20 mbox->workq =3D create_singlethread_workqueue(HINIC3_MBOX_WQ_NAME); @@ -723,6 +724,8 @@ static int send_mbox_msg(struct hinic3_mbox *mbox, u8 m= od, u16 cmd, else rsp_aeq_id =3D 0; =20 + mutex_lock(&mbox->mbox_seg_send_lock); + if (dst_func =3D=3D MBOX_MGMT_FUNC_ID && !(hwdev->features[0] & MBOX_COMM_F_MBOX_SEGMENT)) { err =3D mbox_prepare_dma_msg(mbox, ack_type, &dma_msg, @@ -776,6 +779,8 @@ static int send_mbox_msg(struct hinic3_mbox *mbox, u8 m= od, u16 cmd, } =20 err_send: + mutex_unlock(&mbox->mbox_seg_send_lock); + return err; } =20 diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h b/drivers/net= /ethernet/huawei/hinic3/hinic3_mbox.h index e26f22d1d564..30de0c129503 100644 --- a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h +++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.h @@ -114,6 +114,10 @@ struct hinic3_mbox { struct hinic3_hwdev *hwdev; /* lock for send mbox message and ack message */ struct mutex mbox_send_lock; + /* lock for send message transmission. + * The lock hierarchy is mbox_send_lock -> mbox_seg_send_lock. + */ + struct mutex mbox_seg_send_lock; struct hinic3_send_mbox send_mbox; struct mbox_dma_queue sync_msg_queue; struct mbox_dma_queue async_msg_queue; --=20 2.43.0