Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac802154: Keep track of the channel when changed

Two sections checked whether the current channel != the new channel
without ever setting the current channel variables.

1. net/mac802154/tx.c: Prevent set_channel() from getting called every
time a packet is sent.

2. net/mac802154/mib.c: Lock (pib_lock) accesses to current_channel and
current_page and make sure they are updated when the channel has been
changed.

Signed-off-by: Alan Ott <alan@signal11.us>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Alan Ott and committed by
David S. Miller
9f7f78b4 cbde8123

+14 -1
+11 -1
net/mac802154/mib.c
··· 176 176 struct mac802154_sub_if_data *priv = netdev_priv(nw->dev); 177 177 int res; 178 178 179 + mutex_lock(&priv->hw->phy->pib_lock); 179 180 res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); 180 181 if (res) 181 182 pr_debug("set_channel failed\n"); 183 + else { 184 + priv->hw->phy->current_channel = priv->chan; 185 + priv->hw->phy->current_page = priv->page; 186 + } 187 + mutex_unlock(&priv->hw->phy->pib_lock); 182 188 183 189 kfree(nw); 184 190 } ··· 201 195 priv->chan = chan; 202 196 spin_unlock_bh(&priv->mib_lock); 203 197 198 + mutex_lock(&priv->hw->phy->pib_lock); 204 199 if (priv->hw->phy->current_channel != priv->chan || 205 200 priv->hw->phy->current_page != priv->page) { 201 + mutex_unlock(&priv->hw->phy->pib_lock); 202 + 206 203 work = kzalloc(sizeof(*work), GFP_ATOMIC); 207 204 if (!work) 208 205 return; ··· 213 204 INIT_WORK(&work->work, phy_chan_notify); 214 205 work->dev = dev; 215 206 queue_work(priv->hw->dev_workqueue, &work->work); 216 - } 207 + } else 208 + mutex_unlock(&priv->hw->phy->pib_lock); 217 209 }
+3
net/mac802154/tx.c
··· 58 58 pr_debug("set_channel failed\n"); 59 59 goto out; 60 60 } 61 + 62 + xw->priv->phy->current_channel = xw->chan; 63 + xw->priv->phy->current_page = xw->page; 61 64 } 62 65 63 66 res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);