From patchwork Fri Mar 13 08:32:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fred.chou.nd@gmail.com X-Patchwork-Id: 6003151 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6C6D1BF90F for ; Fri, 13 Mar 2015 08:29:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8CA5320225 for ; Fri, 13 Mar 2015 08:29:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE788201FA for ; Fri, 13 Mar 2015 08:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753149AbbCMI3a (ORCPT ); Fri, 13 Mar 2015 04:29:30 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:46600 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752441AbbCMI30 (ORCPT ); Fri, 13 Mar 2015 04:29:26 -0400 Received: by pdev10 with SMTP id v10so27060020pde.13; Fri, 13 Mar 2015 01:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=BF2tr0149kjJjIPmA5+5W19VPRKgg5g9uNh67PG1Z04=; b=qdnrDXyRSTtJpMyfyWOXeyf0uSeuRgFmshGBvhwhrs0YW9VJbdYkj7ZVPfa+CPRAPn 2v3ibS4g3iSOjGvXTGmBKFywNIwdDP3XZy5nmDkPv4qmzWXPt1DaUNFNi1en9KBuB1KA WVBET0w9Dk1T04zeJYzcrdofr9mX3/ueMNIWXOE/daVCwSir7NDGhvgCq1jcOk5onU4P niBgMcB7gYcx76DDdlz9jyrk0JpAsWrKfZv5teDetmWiEEbgyEX/FfNp1U3mTURhAEKW b1SHdyThw6AZI1MJN4VPJ1C0sjhkq0DOohyFa+HvB0SnG4mEGUlJ+bMpS2p4p6TU2BdD j+ZQ== X-Received: by 10.66.241.36 with SMTP id wf4mr42440378pac.8.1426235365976; Fri, 13 Mar 2015 01:29:25 -0700 (PDT) Received: from fred-EP43-DS3L.a-star.edu.sg ([192.122.131.10]) by mx.google.com with ESMTPSA id or3sm2196046pdb.15.2015.03.13.01.29.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Mar 2015 01:29:24 -0700 (PDT) From: Fred Chou X-Google-Original-From: Fred Chou To: ath9k-devel@qca.qualcomm.com, kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, ath9k-devel@lists.ath9k.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Fred Chou Subject: [PATCH] ath9k_htc: check seq number instead of cmd id for timeout Date: Fri, 13 Mar 2015 16:32:38 +0800 Message-Id: <1426235558-13787-1-git-send-email-fred.chou.nd@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Fred Chou As the driver may send multiple wmi commands with identical cmd id, it is more robust to check seq number for timeout instead. Signed-off-by: Fred Chou --- drivers/net/wireless/ath/ath9k/wmi.c | 12 ++++++------ drivers/net/wireless/ath/ath9k/wmi.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c index 65c8894..aba909f 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -224,7 +224,7 @@ static void ath9k_wmi_ctrl_rx(void *priv, struct sk_buff *skb, /* Check if there has been a timeout. */ spin_lock(&wmi->wmi_lock); - if (cmd_id != wmi->last_cmd_id) { + if (be16_to_cpu(hdr->seq_no) != wmi->last_seq_id) { spin_unlock(&wmi->wmi_lock); goto free_skb; } @@ -272,11 +272,16 @@ static int ath9k_wmi_cmd_issue(struct wmi *wmi, enum wmi_cmd_id cmd, u16 len) { struct wmi_cmd_hdr *hdr; + unsigned long flags; hdr = (struct wmi_cmd_hdr *) skb_push(skb, sizeof(struct wmi_cmd_hdr)); hdr->command_id = cpu_to_be16(cmd); hdr->seq_no = cpu_to_be16(++wmi->tx_seq_id); + spin_lock_irqsave(&wmi->wmi_lock, flags); + wmi->last_seq_id = wmi->tx_seq_id; + spin_unlock_irqrestore(&wmi->wmi_lock, flags); + return htc_send_epid(wmi->htc, skb, wmi->ctrl_epid); } @@ -292,7 +297,6 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, struct sk_buff *skb; u8 *data; int time_left, ret = 0; - unsigned long flags; if (ah->ah_flags & AH_UNPLUGGED) return 0; @@ -320,10 +324,6 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, wmi->cmd_rsp_buf = rsp_buf; wmi->cmd_rsp_len = rsp_len; - spin_lock_irqsave(&wmi->wmi_lock, flags); - wmi->last_cmd_id = cmd_id; - spin_unlock_irqrestore(&wmi->wmi_lock, flags); - ret = ath9k_wmi_cmd_issue(wmi, skb, cmd_id, cmd_len); if (ret) goto out; diff --git a/drivers/net/wireless/ath/ath9k/wmi.h b/drivers/net/wireless/ath/ath9k/wmi.h index 0db37f2..2aad6dc 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.h +++ b/drivers/net/wireless/ath/ath9k/wmi.h @@ -143,7 +143,7 @@ struct wmi { enum htc_endpoint_id ctrl_epid; struct mutex op_mutex; struct completion cmd_wait; - enum wmi_cmd_id last_cmd_id; + u16 last_seq_id; struct sk_buff_head wmi_event_queue; struct tasklet_struct wmi_event_tasklet; u16 tx_seq_id;