From patchwork Thu May 26 20:31:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 822082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4QKVFG7004662 for ; Thu, 26 May 2011 20:31:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757892Ab1EZUbN (ORCPT ); Thu, 26 May 2011 16:31:13 -0400 Received: from mtaout03-winn.ispmail.ntl.com ([81.103.221.49]:39221 "EHLO mtaout03-winn.ispmail.ntl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755237Ab1EZUbN (ORCPT ); Thu, 26 May 2011 16:31:13 -0400 Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110526203111.YEQO3152.mtaout03-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com>; Thu, 26 May 2011 21:31:11 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110526203110.EZQF20122.aamtaout01-winn.ispmail.ntl.com@zog.reactivated.net>; Thu, 26 May 2011 21:31:10 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id ADEDB9D401C; Thu, 26 May 2011 21:31:08 +0100 (BST) From: Daniel Drake To: linville@tuxdriver.com To: dcbw@redhat.com Cc: linux-wireless@vger.kernel.org Cc: libertas-dev@lists.infradead.org Subject: [PATCH] libertas: Set command sequence number later to ensure consistency Message-Id: <20110526203108.ADEDB9D401C@zog.reactivated.net> Date: Thu, 26 May 2011 21:31:08 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=DR_b5neATusA:10 a=vJ1w_8FsMGIA:10 a=Op-mwl0xAAAA:8 a=LJMWY-AIvFjzyo9MmPoA:9 a=ymgiOm2cEHpdO--xNmYA:7 a=d4CUUju0HPYA:10 a=3KlYS54eFddVff9V:21 a=WwHU-g_Vl-2Uvys5:21 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 26 May 2011 20:31:15 +0000 (UTC) Before this patch, the command sequence number is being set before lbs_queue_cmd() adds the command to the queue. However, lbs_queue_cmd() sometimes forces commands to queue-jump (e.g. CMD_802_11_WAKEUP_CONFIRM). It currently does this without considering that sequence numbers might need adjusting to keep things running in order. Fix this by setting the sequence number at a later stage, just before we're actually submitting the command to the hardware. Also fixes a possible race where seqnum was being modified outside of the driver lock. Signed-off-by: Daniel Drake Acked-by: Dan Williams --- drivers/net/wireless/libertas/cmd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 84566db..71c8f3f 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c @@ -994,6 +994,8 @@ static void lbs_submit_command(struct lbs_private *priv, cmd = cmdnode->cmdbuf; spin_lock_irqsave(&priv->driver_lock, flags); + priv->seqnum++; + cmd->seqnum = cpu_to_le16(priv->seqnum); priv->cur_cmd = cmdnode; spin_unlock_irqrestore(&priv->driver_lock, flags); @@ -1621,11 +1623,9 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, /* Copy the incoming command to the buffer */ memcpy(cmdnode->cmdbuf, in_cmd, in_cmd_size); - /* Set sequence number, clean result, move to buffer */ - priv->seqnum++; + /* Set command, clean result, move to buffer */ cmdnode->cmdbuf->command = cpu_to_le16(command); cmdnode->cmdbuf->size = cpu_to_le16(in_cmd_size); - cmdnode->cmdbuf->seqnum = cpu_to_le16(priv->seqnum); cmdnode->cmdbuf->result = 0; lbs_deb_host("PREP_CMD: command 0x%04x\n", command);