From patchwork Fri Apr 5 23:03:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Ott X-Patchwork-Id: 234295 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 24E1A2C00F4 for ; Sat, 6 Apr 2013 10:04:01 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162966Ab3DEXD1 (ORCPT ); Fri, 5 Apr 2013 19:03:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:39583 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162833Ab3DEXD0 (ORCPT ); Fri, 5 Apr 2013 19:03:26 -0400 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 3177520901; Fri, 5 Apr 2013 19:03:26 -0400 (EDT) Received: from frontend1.nyi.mail.srv.osa ([10.202.2.160]) by compute4.internal (MEProxy); Fri, 05 Apr 2013 19:03:26 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=signal11.us; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=UYrK0WrwvyJsCrhVpT2y7NU2CgQ=; b=WrnqJBQdCTppVIVPgLPP+ Dyw2DmuXGPZ4L7yA63qVkvJB9qVHLwuQkAkqhbSf/zYSrJDuFy5PeiCsncWB4ge7 xM03biznMv2/lRwdZEh3KMxaTW++u7iJjfOgMi5MoLXOvY/Ht51VbLbBGocBzKZR hp/iWb5Y/QKAGLnGHJBxJ4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:date:message-id :in-reply-to:references; s=smtpout; bh=UYrK0WrwvyJsCrhVpT2y7NU2C gQ=; b=a8HMMqLVpCnnjMKyLUL1vsLEkhfIdzF/HPqLMAt1BC0BO5+aNoY38zAO/ 6GzbXmQPCUrm+V3DzxQK9wu76JU7HJa8b0FndlHJSNX3ZbLOP+4/sPRcAD4z5baJ lxfy8NOZszJXqWsIZbFPbzG8P7YI7GeY8lA49foEgTi/rTByE0= X-Sasl-enc: N7iSl4JisUyiDB+yM5DVuZ+d+WdQjKk9Cu99i4jYu7xQ 1365203005 Received: from ato.hsd1.fl.comcast.net. (unknown [68.62.254.211]) by mail.messagingengine.com (Postfix) with ESMTPA id 4B234C80003; Fri, 5 Apr 2013 19:03:25 -0400 (EDT) From: Alan Ott To: Alexander Smirnov , Dmitry Eremin-Solenikov , "David S. Miller" Cc: linux-zigbee-devel@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Ott Subject: [PATCH v2] mac802154: Keep track of the channel when changed Date: Fri, 5 Apr 2013 19:03:10 -0400 Message-Id: <1365202990-9006-1-git-send-email-alan@signal11.us> X-Mailer: git-send-email 1.7.11.2 In-Reply-To: <515F4017.6060404@signal11.us> References: <515F4017.6060404@signal11.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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);