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 <sherry.sun@nxp.com>
Approved-by: Tian Yang <yang.tian@nxp.com>
This commit is contained in:
Sherry Sun 2021-08-31 17:43:18 +08:00
parent 8c4e48738c
commit 3ba7550231
1 changed files with 16 additions and 0 deletions

View File

@ -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++;
}