From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Fan Gong <gongfan1@huawei.com>
Cc: andrew+netdev@lunn.ch, christophe.jaillet@wanadoo.fr,
corbet@lwn.net, davem@davemloft.net, edumazet@google.com,
guoxin09@huawei.com, gur.stavi@huawei.com, helgaas@kernel.org,
horms@kernel.org, jdamato@fastly.com, kuba@kernel.org,
lee@trager.us, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, luosifu@huawei.com,
meny.yossefi@huawei.com, mpe@ellerman.id.au,
netdev@vger.kernel.org, pabeni@redhat.com,
przemyslaw.kitszel@intel.com, shenchenyang1@hisilicon.com,
shijing34@huawei.com, sumang@marvell.com, wulike1@huawei.com,
zhoushuai28@huawei.com, zhuyikai1@h-partners.com
Subject: Re: [PATCH net-next v07 7/8] hinic3: Mailbox management interfaces
Date: Wed, 9 Jul 2025 14:15:27 +0100 [thread overview]
Message-ID: <b6b78ea8-4235-4fd5-ab19-133bc04e4188@linux.dev> (raw)
In-Reply-To: <20250709083233.27344-1-gongfan1@huawei.com>
On 09/07/2025 09:32, Fan Gong wrote:
> Thanks for your reviewing.
>
>>> +static int send_mbox_msg(struct hinic3_mbox *mbox, u8 mod, u16 cmd,
>>> + const void *msg, u32 msg_len, u16 dst_func,
>>> + enum mbox_msg_direction_type direction,
>>> + enum mbox_msg_ack_type ack_type,
>>> + struct mbox_msg_info *msg_info)
>>> +{
>>> + enum mbox_msg_data_type data_type = MBOX_MSG_DATA_INLINE;
>>> + struct hinic3_hwdev *hwdev = mbox->hwdev;
>>> + struct mbox_dma_msg dma_msg;
>>> + u32 seg_len = MBOX_SEG_LEN;
>>> + u64 header = 0;
>>> + u32 seq_id = 0;
>>> + u16 rsp_aeq_id;
>>> + u8 *msg_seg;
>>> + int err = 0;
>>> + u32 left;
>>> +
>>> + if (hwdev->hwif->attr.num_aeqs > MBOX_MSG_AEQ_FOR_MBOX)
>>> + rsp_aeq_id = MBOX_MSG_AEQ_FOR_MBOX;
>>> + else
>>> + rsp_aeq_id = 0;
>>> +
>>> + mutex_lock(&mbox->msg_send_lock);
>>
>> this function is always called under mbox->mbox_send_lock, why do you
>> need another mutex? From the experience, a double-locking schema usually
>> brings more troubles than benefits...
>
> In the current patch, send_mbox_msg is only used in mbox sending process.
> But send_mbox_msg will be used in other functions like mbox response in the
> future patch, so msg_send_lock is necessary to cover the remaining scenes.
I would still suggest you to implement it with one locking primitive as
it will be safer and easier to maintain in the future
>
>>> int hinic3_send_mbox_to_mgmt(struct hinic3_hwdev *hwdev, u8 mod, u16 cmd,
>>> const struct mgmt_msg_params *msg_params)
>>> {
>>> - /* Completed by later submission due to LoC limit. */
>>> - return -EFAULT;
>>> + struct hinic3_mbox *mbox = hwdev->mbox;
>>> + struct mbox_msg_info msg_info = {};
>>> + struct hinic3_msg_desc *msg_desc;
>>> + int err;
>>> +
>>> + /* expect response message */
>>> + msg_desc = get_mbox_msg_desc(mbox, MBOX_MSG_RESP, MBOX_MGMT_FUNC_ID);
>>> + mutex_lock(&mbox->mbox_send_lock);
>>> + msg_info.msg_id = (msg_info.msg_id + 1) & 0xF;
>>
>> msg_id is constant 1 here as msg_info is initialized to all zeroes a
>> couple of lines above. It looks like a mistake to me and
>> mbox->send_msg_id should be used instead.
>
> This is our mistake. We will fix this error in the next version's patch.
next prev parent reply other threads:[~2025-07-09 13:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-04 6:22 [PATCH net-next v07 0/8] net: hinic3: Add a driver for Huawei 3rd gen NIC - management interfaces Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 1/8] hinic3: Async Event Queue interfaces Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 2/8] hinic3: Complete " Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 3/8] hinic3: Command Queue framework Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 4/8] hinic3: Command Queue interfaces Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 5/8] hinic3: TX & RX Queue coalesce interfaces Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 6/8] hinic3: Mailbox framework Fan Gong
2025-07-04 6:22 ` [PATCH net-next v07 7/8] hinic3: Mailbox management interfaces Fan Gong
2025-07-07 13:22 ` Vadim Fedorenko
2025-07-09 8:32 ` Fan Gong
2025-07-09 13:15 ` Vadim Fedorenko [this message]
2025-07-04 6:22 ` [PATCH net-next v07 8/8] hinic3: Interrupt request configuration Fan Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6b78ea8-4235-4fd5-ab19-133bc04e4188@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrew+netdev@lunn.ch \
--cc=christophe.jaillet@wanadoo.fr \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gongfan1@huawei.com \
--cc=guoxin09@huawei.com \
--cc=gur.stavi@huawei.com \
--cc=helgaas@kernel.org \
--cc=horms@kernel.org \
--cc=jdamato@fastly.com \
--cc=kuba@kernel.org \
--cc=lee@trager.us \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luosifu@huawei.com \
--cc=meny.yossefi@huawei.com \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=shenchenyang1@hisilicon.com \
--cc=shijing34@huawei.com \
--cc=sumang@marvell.com \
--cc=wulike1@huawei.com \
--cc=zhoushuai28@huawei.com \
--cc=zhuyikai1@h-partners.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).