From: Jiri Pirko <jiri@resnulli.us>
To: Jijie Shao <shaojijie@huawei.com>
Cc: yisen.zhuang@huawei.com, salil.mehta@huawei.com,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, shenjian15@huawei.com, wangjie125@huawei.com,
liuyonglong@huawei.com, chenhao418@huawei.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 7/7] net: hns3: fix kernel crash when devlink reload during vf initialization
Date: Mon, 22 Apr 2024 16:18:56 +0200 [thread overview]
Message-ID: <ZiZx0E5NlSL7nuLE@nanopsycho> (raw)
In-Reply-To: <20240422134327.3160587-8-shaojijie@huawei.com>
Mon, Apr 22, 2024 at 03:43:27PM CEST, shaojijie@huawei.com wrote:
>From: Yonglong Liu <liuyonglong@huawei.com>
>
>The devlink reload process will access the hardware resources,
>but the register operation is done before the hardware is initialized.
>So, processing the devlink reload during initialization may lead to kernel
>crash. This patch fixes this by taking devl_lock during initialization.
>
>Fixes: cd6242991d2e ("net: hns3: add support for registering devlink for VF")
>Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
>Signed-off-by: Jijie Shao <shaojijie@huawei.com>
>---
> drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
>index 08db8e84be4e..3ee41943d15f 100644
>--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
>+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
>@@ -2849,6 +2849,8 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
> if (ret)
> goto err_devlink_init;
>
Hmm, what if reload happens here? I think that you don't fix the issue,
rather just narrowing the race window.
Why don't you rather calle devlink_register at the end of this function?
Also, parallel to this patch, why don't you register devlink port of
flavour "virtual" for this VF?
>+ devl_lock(hdev->devlink);
>+
> ret = hclge_comm_cmd_queue_init(hdev->pdev, &hdev->hw.hw);
> if (ret)
> goto err_cmd_queue_init;
>@@ -2950,6 +2952,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
> hclgevf_task_schedule(hdev, round_jiffies_relative(HZ));
> timer_setup(&hdev->reset_timer, hclgevf_reset_timer, 0);
>
>+ devl_unlock(hdev->devlink);
> return 0;
>
> err_config:
>@@ -2960,6 +2963,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
> err_cmd_init:
> hclge_comm_cmd_uninit(hdev->ae_dev, &hdev->hw.hw);
> err_cmd_queue_init:
>+ devl_unlock(hdev->devlink);
> hclgevf_devlink_uninit(hdev);
> err_devlink_init:
> hclgevf_pci_uninit(hdev);
>--
>2.30.0
>
>
next prev parent reply other threads:[~2024-04-22 14:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-22 13:43 [PATCH net 0/7] There are some bugfix for the HNS3 ethernet driver Jijie Shao
2024-04-22 13:43 ` [PATCH net 1/7] net: hns3: direct return when receive a unknown mailbox message Jijie Shao
2024-04-22 13:43 ` [PATCH net 2/7] net: hns3: change type of numa_node_mask as nodemask_t Jijie Shao
2024-04-22 13:43 ` [PATCH net 3/7] net: hns3: release PTP resources if pf initialization failed Jijie Shao
2024-04-22 13:43 ` [PATCH net 4/7] net: hns3: use appropriate barrier function after setting a bit value Jijie Shao
2024-04-22 13:43 ` [PATCH net 5/7] net: hns3: using user configure after hardware reset Jijie Shao
2024-04-22 13:43 ` [PATCH net 6/7] net: hns3: fix port vlan filter not disabled issue Jijie Shao
2024-04-22 13:43 ` [PATCH net 7/7] net: hns3: fix kernel crash when devlink reload during vf initialization Jijie Shao
2024-04-22 14:18 ` Jiri Pirko [this message]
[not found] ` <2ada3cd6-ed7d-432f-8aa4-cbeafa820590@huawei.com>
2024-04-23 13:00 ` Jiri Pirko
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=ZiZx0E5NlSL7nuLE@nanopsycho \
--to=jiri@resnulli.us \
--cc=chenhao418@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyonglong@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=salil.mehta@huawei.com \
--cc=shaojijie@huawei.com \
--cc=shenjian15@huawei.com \
--cc=wangjie125@huawei.com \
--cc=yisen.zhuang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.