提交 9f7f78b4 编写于 作者: A Alan Ott 提交者: David S. Miller

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: NAlan Ott <alan@signal11.us>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cbde8123
...@@ -176,9 +176,15 @@ static void phy_chan_notify(struct work_struct *work) ...@@ -176,9 +176,15 @@ static void phy_chan_notify(struct work_struct *work)
struct mac802154_sub_if_data *priv = netdev_priv(nw->dev); struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
int res; int res;
mutex_lock(&priv->hw->phy->pib_lock);
res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan); res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
if (res) if (res)
pr_debug("set_channel failed\n"); pr_debug("set_channel failed\n");
else {
priv->hw->phy->current_channel = priv->chan;
priv->hw->phy->current_page = priv->page;
}
mutex_unlock(&priv->hw->phy->pib_lock);
kfree(nw); kfree(nw);
} }
...@@ -195,8 +201,11 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) ...@@ -195,8 +201,11 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
priv->chan = chan; priv->chan = chan;
spin_unlock_bh(&priv->mib_lock); spin_unlock_bh(&priv->mib_lock);
mutex_lock(&priv->hw->phy->pib_lock);
if (priv->hw->phy->current_channel != priv->chan || if (priv->hw->phy->current_channel != priv->chan ||
priv->hw->phy->current_page != priv->page) { priv->hw->phy->current_page != priv->page) {
mutex_unlock(&priv->hw->phy->pib_lock);
work = kzalloc(sizeof(*work), GFP_ATOMIC); work = kzalloc(sizeof(*work), GFP_ATOMIC);
if (!work) if (!work)
return; return;
...@@ -204,5 +213,6 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan) ...@@ -204,5 +213,6 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
INIT_WORK(&work->work, phy_chan_notify); INIT_WORK(&work->work, phy_chan_notify);
work->dev = dev; work->dev = dev;
queue_work(priv->hw->dev_workqueue, &work->work); queue_work(priv->hw->dev_workqueue, &work->work);
} } else
mutex_unlock(&priv->hw->phy->pib_lock);
} }
...@@ -58,6 +58,9 @@ static void mac802154_xmit_worker(struct work_struct *work) ...@@ -58,6 +58,9 @@ static void mac802154_xmit_worker(struct work_struct *work)
pr_debug("set_channel failed\n"); pr_debug("set_channel failed\n");
goto out; goto out;
} }
xw->priv->phy->current_channel = xw->chan;
xw->priv->phy->current_page = xw->page;
} }
res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb); res = xw->priv->ops->xmit(&xw->priv->hw, xw->skb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册