From patchwork Wed Jul 18 12:13:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luciano Coelho X-Patchwork-Id: 1210801 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 08365DFFFD for ; Wed, 18 Jul 2012 12:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185Ab2GRMOV (ORCPT ); Wed, 18 Jul 2012 08:14:21 -0400 Received: from na3sys009aog111.obsmtp.com ([74.125.149.205]:36757 "EHLO na3sys009aog111.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754039Ab2GRMOC (ORCPT ); Wed, 18 Jul 2012 08:14:02 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]) (using TLSv1) by na3sys009aob111.postini.com ([74.125.148.12]) with SMTP ID DSNKUAaoiTh4QjfSP6H7+QJioIcd+U8Y7wSX@postini.com; Wed, 18 Jul 2012 05:14:01 PDT Received: by lboj14 with SMTP id j14so2871748lbo.21 for ; Wed, 18 Jul 2012 05:13:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=HKSbx75jjfRlOAtDsP8B4JTdzAVMVcABxnky8v+Kor4=; b=fISVWgR/qCr41LRd9PVOJZ/tj/Fr1YPuhOw/5F2P6R37imqKCJPPuHI+Ng0l73AHvi MrIBUVrOrrZ61P1R++aqHClSlRGYWzg4SzgKCs6v3G466qf/1Vd5hvZeEUJOqnXtKwwB ML6mXor5OnmT4vERqTO4vIG1RjxwuRIlhpQFFVHeVQQT/Ln9oz5+hMlBhhIe45Xj2qa2 3SO4UgJRNST/5LbKOe/gZJVM8ZrCIKth+szvdnPWPi1mbb21GYAWYcc/Z+tx+hYXNTbV orRg0Fh7Jz8EnWngDWVAXiTaqw2aUVnqa77tGKnPhRnKpP1pc7bok5mTVTKikTMPZNAj saJA== Received: by 10.152.48.6 with SMTP id h6mr3210970lan.30.1342613639549; Wed, 18 Jul 2012 05:13:59 -0700 (PDT) Received: from cumari.Elisa (a88-113-65-16.elisa-laajakaista.fi. [88.113.65.16]) by mx.google.com with ESMTPS id gv8sm21679270lab.14.2012.07.18.05.13.58 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 05:13:58 -0700 (PDT) From: Luciano Coelho To: linux-wireless@vger.kernel.org Cc: coelho@ti.com, arik@wizery.com Subject: [PATCH 13/14] wlcore: wait for command completion event when sending CMD_ROLE_STOP Date: Wed, 18 Jul 2012 15:13:32 +0300 Message-Id: <1342613613-917-14-git-send-email-coelho@ti.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342613613-917-1-git-send-email-coelho@ti.com> References: <1342613613-917-1-git-send-email-coelho@ti.com> X-Gm-Message-State: ALoCoQnzdaSKilBo/pVt7tHofUF3TUAwoMQpUKG3CBmpkM/yl+A3DyL2/YvVv2QnJscIYNvks9F3 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We need to wait for the command completion event when we send the CMD_ROLE_STOP event otherwise we may try to send CMD_ROLE_START too soon and get out-of-sync with the firmware. In some cases, the firmware may not send the event, so we wait for the event or for the timeout, whichever comes first. This patch is based on an earlier version by Eliad. Cc: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/ti/wlcore/cmd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c index a23949c..20e1bd9 100644 --- a/drivers/net/wireless/ti/wlcore/cmd.c +++ b/drivers/net/wireless/ti/wlcore/cmd.c @@ -497,6 +497,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; + bool timeout = false; if (WARN_ON(wlvif->sta.hlid == WL12XX_INVALID_LINK_ID)) return -EINVAL; @@ -519,6 +520,17 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } + /* + * Sometimes the firmware doesn't send this event, so we just + * time out without failing. Queue recovery for other + * failures. + */ + ret = wl1271_cmd_wait_for_event_or_timeout(wl, + ROLE_STOP_COMPLETE_EVENT_ID, + &timeout); + if (ret) + wl12xx_queue_recovery_work(wl); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: