From 3ba75502310fa5cdb5c802acd7567b272f00ce1f Mon Sep 17 00:00:00 2001 From: Sherry Sun Date: Tue, 31 Aug 2021 17:43:18 +0800 Subject: [PATCH] mxm_wifiex: fix P2P test fail on kernel higher than L5.12 P2P test will fail(deadlock) on kernel higher than L5.12, error log like below: root@imx8mmevk:~# wpa_cli -i p2p0 p2p_group_add freq=2412 [ 47.284346] Add virtual interface p2p-p2p0-0 'P2P_GROUP_ADD freq=2412' command timed out. This is because the upgarded kernel change the netdevs registration/unregistration semantics, new kernel require the drivers to call cfg80211_(un)register_netdevice() when this is happening due to a cfg80211 request. For more details, please refer to the upstream patch: https://lore.kernel.org/linux-wireless/20210122161942.cf2f4b65e4e9.Ida8234e50da13eb675b557bac52a713ad4eddf71@changeid/ Signed-off-by: Sherry Sun Approved-by: Tian Yang --- mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c b/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c index 8624d11..4f2290f 100644 --- a/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c +++ b/mxm_wifiex/wlan_src/mlinux/moal_uap_cfg80211.c @@ -1651,12 +1651,20 @@ int woal_cfg80211_add_virt_if(struct wiphy *wiphy, woal_cfg80211_init_p2p_client(new_priv); else if (type == NL80211_IFTYPE_P2P_GO) woal_cfg80211_init_p2p_go(new_priv); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) + ret = cfg80211_register_netdevice(ndev); +#else ret = register_netdevice(ndev); +#endif if (ret) { handle->priv[new_priv->bss_index] = NULL; handle->priv_num--; if (ndev->reg_state == NETREG_REGISTERED) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) + cfg80211_unregister_netdevice(ndev); +#else unregister_netdevice(ndev); +#endif free_netdev(ndev); ndev = NULL; } @@ -1837,7 +1845,11 @@ int woal_cfg80211_del_virt_if(struct wiphy *wiphy, struct net_device *dev) vir_priv->phandle->priv[vir_priv->bss_index] = NULL; priv->phandle->priv_num--; if (dev->reg_state == NETREG_REGISTERED) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) + cfg80211_unregister_netdevice(dev); +#else unregister_netdevice(dev); +#endif } return ret; } @@ -1876,7 +1888,11 @@ void woal_remove_virtual_interface(moal_handle *handle) netif_device_detach(priv->netdev); if (priv->netdev->reg_state == NETREG_REGISTERED) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0) + cfg80211_unregister_netdevice(priv->netdev); +#else unregister_netdevice(priv->netdev); +#endif handle->priv[i] = NULL; vir_intf++; }