Commit ebfb5e8f authored by Alexis Lothoré's avatar Alexis Lothoré Committed by Kalle Valo

Revert "wifi: wilc1000: convert list management to RCU"

This reverts commit f236464f

Commit f236464f ("wifi: wilc1000: convert list management to RCU")
replaced SRCU with RCU, aiming to simplify RCU usage in the driver. No
documentation or commit history hinted about why SRCU has been preferred
in original design, so it has been assumed to be safe to do this
conversion.
Unfortunately, some static analyzers raised warnings, confirmed by runtime
checker, not long after the merge. At least three different issues arose
when switching to RCU:
- wilc_wlan_txq_filter_dup_tcp_ack is executed in a RCU read critical
  section yet calls wait_for_completion_timeout
- wilc_wfi_init_mon_interface calls kmalloc and register_netdevice while
  manipulating a vif retrieved from vif list
- set_channel sends command to chip (and so, also waits for a completion)
  while holding a vif retrieved from vif list (so, in RCU read critical
  section)

Some of those issues are not trivial to fix and would need bigger driver
rework. Fix those issues by reverting the SRCU to RCU conversion commit
Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-wireless/3b46ec7c-baee-49fd-b760-3bc12fb12eaf@moroto.mountain/
Fixes: f236464f ("wifi: wilc1000: convert list management to RCU")
Signed-off-by: default avatarAlexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240528-wilc_revert_srcu_to_rcu-v1-1-bce096e0798c@bootlin.com
parent 10bc8558
...@@ -237,11 +237,12 @@ static int set_channel(struct wiphy *wiphy, ...@@ -237,11 +237,12 @@ static int set_channel(struct wiphy *wiphy,
struct wilc_vif *vif; struct wilc_vif *vif;
u32 channelnum; u32 channelnum;
int result; int result;
int srcu_idx;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
vif = wilc_get_wl_to_vif(wl); vif = wilc_get_wl_to_vif(wl);
if (IS_ERR(vif)) { if (IS_ERR(vif)) {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return PTR_ERR(vif); return PTR_ERR(vif);
} }
...@@ -252,7 +253,7 @@ static int set_channel(struct wiphy *wiphy, ...@@ -252,7 +253,7 @@ static int set_channel(struct wiphy *wiphy,
if (result) if (result)
netdev_err(vif->ndev, "Error in setting channel\n"); netdev_err(vif->ndev, "Error in setting channel\n");
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return result; return result;
} }
...@@ -805,8 +806,9 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) ...@@ -805,8 +806,9 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
struct wilc *wl = wiphy_priv(wiphy); struct wilc *wl = wiphy_priv(wiphy);
struct wilc_vif *vif; struct wilc_vif *vif;
struct wilc_priv *priv; struct wilc_priv *priv;
int srcu_idx;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
vif = wilc_get_wl_to_vif(wl); vif = wilc_get_wl_to_vif(wl);
if (IS_ERR(vif)) if (IS_ERR(vif))
goto out; goto out;
...@@ -861,7 +863,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) ...@@ -861,7 +863,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed)
netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n");
out: out:
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return ret; return ret;
} }
...@@ -1537,19 +1539,20 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, ...@@ -1537,19 +1539,20 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
if (type == NL80211_IFTYPE_MONITOR) { if (type == NL80211_IFTYPE_MONITOR) {
struct net_device *ndev; struct net_device *ndev;
int srcu_idx;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
vif = wilc_get_vif_from_type(wl, WILC_AP_MODE); vif = wilc_get_vif_from_type(wl, WILC_AP_MODE);
if (!vif) { if (!vif) {
vif = wilc_get_vif_from_type(wl, WILC_GO_MODE); vif = wilc_get_vif_from_type(wl, WILC_GO_MODE);
if (!vif) { if (!vif) {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
goto validate_interface; goto validate_interface;
} }
} }
if (vif->monitor_flag) { if (vif->monitor_flag) {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
goto validate_interface; goto validate_interface;
} }
...@@ -1557,12 +1560,12 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, ...@@ -1557,12 +1560,12 @@ static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
if (ndev) { if (ndev) {
vif->monitor_flag = 1; vif->monitor_flag = 1;
} else { } else {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
wdev = &vif->priv.wdev; wdev = &vif->priv.wdev;
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return wdev; return wdev;
} }
...@@ -1610,7 +1613,7 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) ...@@ -1610,7 +1613,7 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev)
list_del_rcu(&vif->list); list_del_rcu(&vif->list);
wl->vif_num--; wl->vif_num--;
mutex_unlock(&wl->vif_mutex); mutex_unlock(&wl->vif_mutex);
synchronize_rcu(); synchronize_srcu(&wl->srcu);
return 0; return 0;
} }
...@@ -1635,23 +1638,25 @@ static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) ...@@ -1635,23 +1638,25 @@ static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled)
{ {
struct wilc *wl = wiphy_priv(wiphy); struct wilc *wl = wiphy_priv(wiphy);
struct wilc_vif *vif; struct wilc_vif *vif;
int srcu_idx;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
vif = wilc_get_wl_to_vif(wl); vif = wilc_get_wl_to_vif(wl);
if (IS_ERR(vif)) { if (IS_ERR(vif)) {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return; return;
} }
netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled);
wilc_set_wowlan_trigger(vif, enabled); wilc_set_wowlan_trigger(vif, enabled);
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
} }
static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
enum nl80211_tx_power_setting type, int mbm) enum nl80211_tx_power_setting type, int mbm)
{ {
int ret; int ret;
int srcu_idx;
s32 tx_power = MBM_TO_DBM(mbm); s32 tx_power = MBM_TO_DBM(mbm);
struct wilc *wl = wiphy_priv(wiphy); struct wilc *wl = wiphy_priv(wiphy);
struct wilc_vif *vif; struct wilc_vif *vif;
...@@ -1659,10 +1664,10 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -1659,10 +1664,10 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
if (!wl->initialized) if (!wl->initialized)
return -EIO; return -EIO;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
vif = wilc_get_wl_to_vif(wl); vif = wilc_get_wl_to_vif(wl);
if (IS_ERR(vif)) { if (IS_ERR(vif)) {
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return -EINVAL; return -EINVAL;
} }
...@@ -1674,7 +1679,7 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, ...@@ -1674,7 +1679,7 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
ret = wilc_set_tx_power(vif, tx_power); ret = wilc_set_tx_power(vif, tx_power);
if (ret) if (ret)
netdev_err(vif->ndev, "Failed to set tx power\n"); netdev_err(vif->ndev, "Failed to set tx power\n");
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return ret; return ret;
} }
...@@ -1757,6 +1762,7 @@ static void wlan_init_locks(struct wilc *wl) ...@@ -1757,6 +1762,7 @@ static void wlan_init_locks(struct wilc *wl)
init_completion(&wl->cfg_event); init_completion(&wl->cfg_event);
init_completion(&wl->sync_event); init_completion(&wl->sync_event);
init_completion(&wl->txq_thread_started); init_completion(&wl->txq_thread_started);
init_srcu_struct(&wl->srcu);
} }
void wlan_deinit_locks(struct wilc *wilc) void wlan_deinit_locks(struct wilc *wilc)
...@@ -1767,6 +1773,7 @@ void wlan_deinit_locks(struct wilc *wilc) ...@@ -1767,6 +1773,7 @@ void wlan_deinit_locks(struct wilc *wilc)
mutex_destroy(&wilc->txq_add_to_head_cs); mutex_destroy(&wilc->txq_add_to_head_cs);
mutex_destroy(&wilc->vif_mutex); mutex_destroy(&wilc->vif_mutex);
mutex_destroy(&wilc->deinit_lock); mutex_destroy(&wilc->deinit_lock);
cleanup_srcu_struct(&wilc->srcu);
} }
int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type,
......
...@@ -1570,11 +1570,12 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1570,11 +1570,12 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
struct host_if_drv *hif_drv; struct host_if_drv *hif_drv;
struct host_if_msg *msg; struct host_if_msg *msg;
struct wilc_vif *vif; struct wilc_vif *vif;
int srcu_idx;
int result; int result;
int id; int id;
id = get_unaligned_le32(&buffer[length - 4]); id = get_unaligned_le32(&buffer[length - 4]);
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
vif = wilc_get_vif_from_idx(wilc, id); vif = wilc_get_vif_from_idx(wilc, id);
if (!vif) if (!vif)
goto out; goto out;
...@@ -1606,7 +1607,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1606,7 +1607,7 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
kfree(msg); kfree(msg);
} }
out: out:
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
} }
void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
...@@ -1614,13 +1615,14 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1614,13 +1615,14 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
struct host_if_drv *hif_drv; struct host_if_drv *hif_drv;
struct host_if_msg *msg; struct host_if_msg *msg;
struct wilc_vif *vif; struct wilc_vif *vif;
int srcu_idx;
int result; int result;
int id; int id;
mutex_lock(&wilc->deinit_lock); mutex_lock(&wilc->deinit_lock);
id = get_unaligned_le32(&buffer[length - 4]); id = get_unaligned_le32(&buffer[length - 4]);
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
vif = wilc_get_vif_from_idx(wilc, id); vif = wilc_get_vif_from_idx(wilc, id);
if (!vif) if (!vif)
goto out; goto out;
...@@ -1647,7 +1649,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1647,7 +1649,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
kfree(msg); kfree(msg);
} }
out: out:
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
mutex_unlock(&wilc->deinit_lock); mutex_unlock(&wilc->deinit_lock);
} }
...@@ -1655,11 +1657,12 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1655,11 +1657,12 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
{ {
struct host_if_drv *hif_drv; struct host_if_drv *hif_drv;
struct wilc_vif *vif; struct wilc_vif *vif;
int srcu_idx;
int result; int result;
int id; int id;
id = get_unaligned_le32(&buffer[length - 4]); id = get_unaligned_le32(&buffer[length - 4]);
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
vif = wilc_get_vif_from_idx(wilc, id); vif = wilc_get_vif_from_idx(wilc, id);
if (!vif) if (!vif)
goto out; goto out;
...@@ -1684,7 +1687,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -1684,7 +1687,7 @@ void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
} }
} }
out: out:
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
} }
int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan, int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, u16 chan,
......
...@@ -127,28 +127,30 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, const u8 *bssid, ...@@ -127,28 +127,30 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, const u8 *bssid,
int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
{ {
int srcu_idx;
u8 ret_val = 0; u8 ret_val = 0;
struct wilc_vif *vif; struct wilc_vif *vif;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_for_each_vif(wilc, vif) { wilc_for_each_vif(wilc, vif) {
if (!is_zero_ether_addr(vif->bssid)) if (!is_zero_ether_addr(vif->bssid))
ret_val++; ret_val++;
} }
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
return ret_val; return ret_val;
} }
static void wilc_wake_tx_queues(struct wilc *wl) static void wilc_wake_tx_queues(struct wilc *wl)
{ {
int srcu_idx;
struct wilc_vif *ifc; struct wilc_vif *ifc;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
wilc_for_each_vif(wl, ifc) { wilc_for_each_vif(wl, ifc) {
if (ifc->mac_opened && netif_queue_stopped(ifc->ndev)) if (ifc->mac_opened && netif_queue_stopped(ifc->ndev))
netif_wake_queue(ifc->ndev); netif_wake_queue(ifc->ndev);
} }
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
} }
static int wilc_txq_task(void *vp) static int wilc_txq_task(void *vp)
...@@ -653,6 +655,7 @@ static int wilc_set_mac_addr(struct net_device *dev, void *p) ...@@ -653,6 +655,7 @@ static int wilc_set_mac_addr(struct net_device *dev, void *p)
struct sockaddr *addr = (struct sockaddr *)p; struct sockaddr *addr = (struct sockaddr *)p;
unsigned char mac_addr[ETH_ALEN]; unsigned char mac_addr[ETH_ALEN];
struct wilc_vif *tmp_vif; struct wilc_vif *tmp_vif;
int srcu_idx;
if (!is_valid_ether_addr(addr->sa_data)) if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
...@@ -664,19 +667,19 @@ static int wilc_set_mac_addr(struct net_device *dev, void *p) ...@@ -664,19 +667,19 @@ static int wilc_set_mac_addr(struct net_device *dev, void *p)
/* Verify MAC Address is not already in use: */ /* Verify MAC Address is not already in use: */
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_for_each_vif(wilc, tmp_vif) { wilc_for_each_vif(wilc, tmp_vif) {
wilc_get_mac_address(tmp_vif, mac_addr); wilc_get_mac_address(tmp_vif, mac_addr);
if (ether_addr_equal(addr->sa_data, mac_addr)) { if (ether_addr_equal(addr->sa_data, mac_addr)) {
if (vif != tmp_vif) { if (vif != tmp_vif) {
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
} }
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
return 0; return 0;
} }
} }
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
result = wilc_set_mac_address(vif, (u8 *)addr->sa_data); result = wilc_set_mac_address(vif, (u8 *)addr->sa_data);
if (result) if (result)
...@@ -764,14 +767,15 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -764,14 +767,15 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
wilc_tx_complete); wilc_tx_complete);
if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
int srcu_idx;
struct wilc_vif *vif; struct wilc_vif *vif;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_for_each_vif(wilc, vif) { wilc_for_each_vif(wilc, vif) {
if (vif->mac_opened) if (vif->mac_opened)
netif_stop_queue(vif->ndev); netif_stop_queue(vif->ndev);
} }
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
} }
return NETDEV_TX_OK; return NETDEV_TX_OK;
...@@ -815,12 +819,13 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, ...@@ -815,12 +819,13 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size,
unsigned int frame_len = 0; unsigned int frame_len = 0;
struct wilc_vif *vif; struct wilc_vif *vif;
struct sk_buff *skb; struct sk_buff *skb;
int srcu_idx;
int stats; int stats;
if (!wilc) if (!wilc)
return; return;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_netdev = get_if_handler(wilc, buff); wilc_netdev = get_if_handler(wilc, buff);
if (!wilc_netdev) if (!wilc_netdev)
goto out; goto out;
...@@ -848,14 +853,15 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, ...@@ -848,14 +853,15 @@ void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size,
netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats); netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats);
} }
out: out:
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
} }
void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth) void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth)
{ {
int srcu_idx;
struct wilc_vif *vif; struct wilc_vif *vif;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_for_each_vif(wilc, vif) { wilc_for_each_vif(wilc, vif) {
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buff; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buff;
u16 type = le16_to_cpup((__le16 *)buff); u16 type = le16_to_cpup((__le16 *)buff);
...@@ -876,7 +882,7 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth) ...@@ -876,7 +882,7 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size, bool is_auth)
if (vif->monitor_flag) if (vif->monitor_flag)
wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size);
} }
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
} }
static const struct net_device_ops wilc_netdev_ops = { static const struct net_device_ops wilc_netdev_ops = {
...@@ -906,7 +912,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) ...@@ -906,7 +912,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)
list_del_rcu(&vif->list); list_del_rcu(&vif->list);
wilc->vif_num--; wilc->vif_num--;
mutex_unlock(&wilc->vif_mutex); mutex_unlock(&wilc->vif_mutex);
synchronize_rcu(); synchronize_srcu(&wilc->srcu);
if (vif->ndev) if (vif->ndev)
unregister_netdev(vif->ndev); unregister_netdev(vif->ndev);
} }
...@@ -925,15 +931,16 @@ static u8 wilc_get_available_idx(struct wilc *wl) ...@@ -925,15 +931,16 @@ static u8 wilc_get_available_idx(struct wilc *wl)
{ {
int idx = 0; int idx = 0;
struct wilc_vif *vif; struct wilc_vif *vif;
int srcu_idx;
rcu_read_lock(); srcu_idx = srcu_read_lock(&wl->srcu);
wilc_for_each_vif(wl, vif) { wilc_for_each_vif(wl, vif) {
if (vif->idx == 0) if (vif->idx == 0)
idx = 1; idx = 1;
else else
idx = 0; idx = 0;
} }
rcu_read_unlock(); srcu_read_unlock(&wl->srcu, srcu_idx);
return idx; return idx;
} }
...@@ -983,7 +990,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, ...@@ -983,7 +990,7 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
list_add_tail_rcu(&vif->list, &wl->vif_list); list_add_tail_rcu(&vif->list, &wl->vif_list);
wl->vif_num += 1; wl->vif_num += 1;
mutex_unlock(&wl->vif_mutex); mutex_unlock(&wl->vif_mutex);
synchronize_rcu(); synchronize_srcu(&wl->srcu);
return vif; return vif;
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#define wilc_for_each_vif(w, v) \ #define wilc_for_each_vif(w, v) \
struct wilc *_w = w; \ struct wilc *_w = w; \
list_for_each_entry_rcu(v, &_w->vif_list, list, \ list_for_each_entry_srcu(v, &_w->vif_list, list, \
rcu_read_lock_held()) srcu_read_lock_held(&_w->srcu))
struct wilc_wfi_stats { struct wilc_wfi_stats {
unsigned long rx_packets; unsigned long rx_packets;
...@@ -220,6 +220,7 @@ struct wilc { ...@@ -220,6 +220,7 @@ struct wilc {
/* protect vif list */ /* protect vif list */
struct mutex vif_mutex; struct mutex vif_mutex;
struct srcu_struct srcu;
u8 open_ifcs; u8 open_ifcs;
/* protect head of transmit queue */ /* protect head of transmit queue */
......
...@@ -712,6 +712,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) ...@@ -712,6 +712,7 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
u32 *vmm_table = wilc->vmm_table; u32 *vmm_table = wilc->vmm_table;
u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0}; u8 ac_pkt_num_to_chip[NQUEUES] = {0, 0, 0, 0};
const struct wilc_hif_func *func; const struct wilc_hif_func *func;
int srcu_idx;
u8 *txb = wilc->tx_buffer; u8 *txb = wilc->tx_buffer;
struct wilc_vif *vif; struct wilc_vif *vif;
...@@ -723,10 +724,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) ...@@ -723,10 +724,10 @@ int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count)
mutex_lock(&wilc->txq_add_to_head_cs); mutex_lock(&wilc->txq_add_to_head_cs);
rcu_read_lock(); srcu_idx = srcu_read_lock(&wilc->srcu);
wilc_for_each_vif(wilc, vif) wilc_for_each_vif(wilc, vif)
wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev); wilc_wlan_txq_filter_dup_tcp_ack(vif->ndev);
rcu_read_unlock(); srcu_read_unlock(&wilc->srcu, srcu_idx);
for (ac = 0; ac < NQUEUES; ac++) for (ac = 0; ac < NQUEUES; ac++)
tqe_q[ac] = wilc_wlan_txq_get_first(wilc, ac); tqe_q[ac] = wilc_wlan_txq_get_first(wilc, ac);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment