mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
net: hns3: fix oops when unload drivers paralleling
[ Upstream commit 92e5995773774a3e70257e9c95ea03518268bea5 ]
When unload hclge driver, it tries to disable sriov first for each
ae_dev node from hnae3_ae_dev_list. If user unloads hns3 driver at
the time, because it removes all the ae_dev nodes, and it may cause
oops.
But we can't simply use hnae3_common_lock for this. Because in the
process flow of pci_disable_sriov(), it will trigger the remove flow
of VF, which will also take hnae3_common_lock.
To fixes it, introduce a new mutex to protect the unload process.
Fixes: 0dd8a25f35 ("net: hns3: disable sriov before unload hclge layer")
Signed-off-by: Jian Shen <shenjian15@huawei.com>
Signed-off-by: Jijie Shao <shaojijie@huawei.com>
Link: https://patch.msgid.link/20250118094741.3046663-1-shaojijie@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
c3141c17ca
commit
e876522659
@@ -40,6 +40,21 @@ EXPORT_SYMBOL(hnae3_unregister_ae_algo_prepare);
|
|||||||
*/
|
*/
|
||||||
static DEFINE_MUTEX(hnae3_common_lock);
|
static DEFINE_MUTEX(hnae3_common_lock);
|
||||||
|
|
||||||
|
/* ensure the drivers being unloaded one by one */
|
||||||
|
static DEFINE_MUTEX(hnae3_unload_lock);
|
||||||
|
|
||||||
|
void hnae3_acquire_unload_lock(void)
|
||||||
|
{
|
||||||
|
mutex_lock(&hnae3_unload_lock);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(hnae3_acquire_unload_lock);
|
||||||
|
|
||||||
|
void hnae3_release_unload_lock(void)
|
||||||
|
{
|
||||||
|
mutex_unlock(&hnae3_unload_lock);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(hnae3_release_unload_lock);
|
||||||
|
|
||||||
static bool hnae3_client_match(enum hnae3_client_type client_type)
|
static bool hnae3_client_match(enum hnae3_client_type client_type)
|
||||||
{
|
{
|
||||||
if (client_type == HNAE3_CLIENT_KNIC ||
|
if (client_type == HNAE3_CLIENT_KNIC ||
|
||||||
|
|||||||
@@ -929,4 +929,6 @@ int hnae3_register_client(struct hnae3_client *client);
|
|||||||
void hnae3_set_client_init_flag(struct hnae3_client *client,
|
void hnae3_set_client_init_flag(struct hnae3_client *client,
|
||||||
struct hnae3_ae_dev *ae_dev,
|
struct hnae3_ae_dev *ae_dev,
|
||||||
unsigned int inited);
|
unsigned int inited);
|
||||||
|
void hnae3_acquire_unload_lock(void);
|
||||||
|
void hnae3_release_unload_lock(void);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6007,9 +6007,11 @@ module_init(hns3_init_module);
|
|||||||
*/
|
*/
|
||||||
static void __exit hns3_exit_module(void)
|
static void __exit hns3_exit_module(void)
|
||||||
{
|
{
|
||||||
|
hnae3_acquire_unload_lock();
|
||||||
pci_unregister_driver(&hns3_driver);
|
pci_unregister_driver(&hns3_driver);
|
||||||
hnae3_unregister_client(&client);
|
hnae3_unregister_client(&client);
|
||||||
hns3_dbg_unregister_debugfs();
|
hns3_dbg_unregister_debugfs();
|
||||||
|
hnae3_release_unload_lock();
|
||||||
}
|
}
|
||||||
module_exit(hns3_exit_module);
|
module_exit(hns3_exit_module);
|
||||||
|
|
||||||
|
|||||||
@@ -13250,9 +13250,11 @@ static int __init hclge_init(void)
|
|||||||
|
|
||||||
static void __exit hclge_exit(void)
|
static void __exit hclge_exit(void)
|
||||||
{
|
{
|
||||||
|
hnae3_acquire_unload_lock();
|
||||||
hnae3_unregister_ae_algo_prepare(&ae_algo);
|
hnae3_unregister_ae_algo_prepare(&ae_algo);
|
||||||
hnae3_unregister_ae_algo(&ae_algo);
|
hnae3_unregister_ae_algo(&ae_algo);
|
||||||
destroy_workqueue(hclge_wq);
|
destroy_workqueue(hclge_wq);
|
||||||
|
hnae3_release_unload_lock();
|
||||||
}
|
}
|
||||||
module_init(hclge_init);
|
module_init(hclge_init);
|
||||||
module_exit(hclge_exit);
|
module_exit(hclge_exit);
|
||||||
|
|||||||
@@ -3468,8 +3468,10 @@ static int __init hclgevf_init(void)
|
|||||||
|
|
||||||
static void __exit hclgevf_exit(void)
|
static void __exit hclgevf_exit(void)
|
||||||
{
|
{
|
||||||
|
hnae3_acquire_unload_lock();
|
||||||
hnae3_unregister_ae_algo(&ae_algovf);
|
hnae3_unregister_ae_algo(&ae_algovf);
|
||||||
destroy_workqueue(hclgevf_wq);
|
destroy_workqueue(hclgevf_wq);
|
||||||
|
hnae3_release_unload_lock();
|
||||||
}
|
}
|
||||||
module_init(hclgevf_init);
|
module_init(hclgevf_init);
|
||||||
module_exit(hclgevf_exit);
|
module_exit(hclgevf_exit);
|
||||||
|
|||||||
Reference in New Issue
Block a user