* [PATCH] mac802154: Keep track of the channel when changed
@ 2013-04-05 20:36 Alan Ott
2013-04-05 21:05 ` [Linux-zigbee-devel] " Werner Almesberger
0 siblings, 1 reply; 5+ messages in thread
From: Alan Ott @ 2013-04-05 20:36 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
Cc: linux-zigbee-devel, netdev, linux-kernel, Alan Ott
Prevent set_channel() from getting called every time a packet is sent. This
looks like it was an oversight.
Signed-off-by: Alan Ott <alan@signal11.us>
---
net/mac802154/tx.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 3fd3e07..6d16473 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -58,6 +58,9 @@ static void mac802154_xmit_worker(struct work_struct *work)
pr_debug("set_channel failed\n");
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);
--
1.7.11.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Linux-zigbee-devel] [PATCH] mac802154: Keep track of the channel when changed
2013-04-05 20:36 [PATCH] mac802154: Keep track of the channel when changed Alan Ott
@ 2013-04-05 21:05 ` Werner Almesberger
2013-04-05 21:20 ` Alan Ott
0 siblings, 1 reply; 5+ messages in thread
From: Werner Almesberger @ 2013-04-05 21:05 UTC (permalink / raw)
To: Alan Ott
Cc: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller,
netdev, linux-kernel, linux-zigbee-devel
Alan Ott wrote:
> Prevent set_channel() from getting called every time a packet is sent. This
> looks like it was an oversight.
at86rf230.c and derivatives avoid this problem by setting
phy->current_* in the *_channel function.
But I'd agree that it's nicer to do this in one place, not in
every driver.
In case a driver had a weird failure mode in which it leaves the
original channel but only makes it halfway to the new channel, it
could still set phy->current_* and return an error. So there's no
loss of functionality with your change.
- Werner
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mac802154: Keep track of the channel when changed
2013-04-05 21:05 ` [Linux-zigbee-devel] " Werner Almesberger
@ 2013-04-05 21:20 ` Alan Ott
[not found] ` <515F4017.6060404-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Alan Ott @ 2013-04-05 21:20 UTC (permalink / raw)
To: Werner Almesberger
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
David S. Miller
On 04/05/2013 05:05 PM, Werner Almesberger wrote:
> Alan Ott wrote:
>> Prevent set_channel() from getting called every time a packet is sent. This
>> looks like it was an oversight.
> at86rf230.c and derivatives avoid this problem by setting
> phy->current_* in the *_channel function.
>
> But I'd agree that it's nicer to do this in one place, not in
> every driver.
>
> In case a driver had a weird failure mode in which it leaves the
> original channel but only makes it halfway to the new channel, it
> could still set phy->current_* and return an error. So there's no
> loss of functionality with your change.
Hmm... I just noticed that mib.c does the same thing (and doesn't set
phy->current_*). I'll need to fix that one too (and resubmit). :(
Alan.
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] mac802154: Keep track of the channel when changed
[not found] ` <515F4017.6060404-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
@ 2013-04-05 23:03 ` Alan Ott
2013-04-08 16:09 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Alan Ott @ 2013-04-05 23:03 UTC (permalink / raw)
To: Alexander Smirnov, Dmitry Eremin-Solenikov, David S. Miller
Cc: Alan Ott, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
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-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
---
net/mac802154/mib.c | 12 +++++++++++-
net/mac802154/tx.c | 3 +++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
index f03e55f..8ded97c 100644
--- a/net/mac802154/mib.c
+++ b/net/mac802154/mib.c
@@ -176,9 +176,15 @@ static void phy_chan_notify(struct work_struct *work)
struct mac802154_sub_if_data *priv = netdev_priv(nw->dev);
int res;
+ mutex_lock(&priv->hw->phy->pib_lock);
res = hw->ops->set_channel(&hw->hw, priv->page, priv->chan);
if (res)
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);
}
@@ -195,8 +201,11 @@ void mac802154_dev_set_page_channel(struct net_device *dev, u8 page, u8 chan)
priv->chan = chan;
spin_unlock_bh(&priv->mib_lock);
+ mutex_lock(&priv->hw->phy->pib_lock);
if (priv->hw->phy->current_channel != priv->chan ||
priv->hw->phy->current_page != priv->page) {
+ mutex_unlock(&priv->hw->phy->pib_lock);
+
work = kzalloc(sizeof(*work), GFP_ATOMIC);
if (!work)
return;
@@ -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);
work->dev = dev;
queue_work(priv->hw->dev_workqueue, &work->work);
- }
+ } else
+ mutex_unlock(&priv->hw->phy->pib_lock);
}
diff --git a/net/mac802154/tx.c b/net/mac802154/tx.c
index 3fd3e07..6d16473 100644
--- a/net/mac802154/tx.c
+++ b/net/mac802154/tx.c
@@ -58,6 +58,9 @@ static void mac802154_xmit_worker(struct work_struct *work)
pr_debug("set_channel failed\n");
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);
--
1.7.11.2
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mac802154: Keep track of the channel when changed
2013-04-05 23:03 ` [PATCH v2] " Alan Ott
@ 2013-04-08 16:09 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-04-08 16:09 UTC (permalink / raw)
To: alan
Cc: alex.bluesman.smirnov, dbaryshkov, linux-zigbee-devel, netdev,
linux-kernel
From: Alan Ott <alan@signal11.us>
Date: Fri, 5 Apr 2013 19:03:10 -0400
> 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>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-04-08 16:09 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-05 20:36 [PATCH] mac802154: Keep track of the channel when changed Alan Ott
2013-04-05 21:05 ` [Linux-zigbee-devel] " Werner Almesberger
2013-04-05 21:20 ` Alan Ott
[not found] ` <515F4017.6060404-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
2013-04-05 23:03 ` [PATCH v2] " Alan Ott
2013-04-08 16:09 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).