From patchwork Tue May 11 10:54:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sujith X-Patchwork-Id: 98694 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4BAsSWa013464 for ; Tue, 11 May 2010 10:54:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757445Ab0EKKy0 (ORCPT ); Tue, 11 May 2010 06:54:26 -0400 Received: from mail.atheros.com ([12.36.123.2]:47728 "EHLO mail.atheros.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757030Ab0EKKyY (ORCPT ); Tue, 11 May 2010 06:54:24 -0400 Received: from mail.atheros.com ([10.10.20.105]) by sidewinder.atheros.com for ; Tue, 11 May 2010 03:54:24 -0700 Received: from CHEXHC-01.global.atheros.com (10.12.0.100) by SC1EXHC-01.global.atheros.com (10.10.20.104) with Microsoft SMTP Server (TLS) id 8.2.213.0; Tue, 11 May 2010 03:54:24 -0700 Received: from kamboji (10.12.0.31) by CHEXHC-01.global.atheros.com (10.12.0.100) with Microsoft SMTP Server (TLS) id 8.2.176.0; Tue, 11 May 2010 16:24:20 +0530 MIME-Version: 1.0 Message-ID: <19433.14195.321284.643261@gargle.gargle.HOWL> Date: Tue, 11 May 2010 16:24:43 +0530 To: X-Mailer: VM 8.1.0 under 23.2.1 (x86_64-unknown-linux-gnu) CC: Subject: [PATCH 4/5] ath9k_htc: Fix target ready race condition From: 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 11 May 2010 10:54:29 +0000 (UTC) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index 17111fc..dc01507 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -81,6 +81,11 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv) { int time_left; + if (atomic_read(&priv->htc->tgt_ready) > 0) { + atomic_dec(&priv->htc->tgt_ready); + return 0; + } + /* Firmware can take up to 50ms to get ready, to be safe use 1 second */ time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ); if (!time_left) { @@ -88,6 +93,8 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv) return -ETIMEDOUT; } + atomic_dec(&priv->htc->tgt_ready); + return 0; } diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c index 2c8006a..e86e172 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.c +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c @@ -95,6 +95,7 @@ static void htc_process_target_rdy(struct htc_target *target, endpoint = &target->endpoint[ENDPOINT0]; endpoint->service_id = HTC_CTRL_RSVD_SVC; endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH; + atomic_inc(&target->tgt_ready); complete(&target->target_wait); } @@ -451,6 +452,8 @@ struct htc_target *ath9k_htc_hw_alloc(void *hif_handle, endpoint->ul_pipeid = hif->control_ul_pipe; endpoint->dl_pipeid = hif->control_dl_pipe; + atomic_set(&target->tgt_ready, 0); + return target; } diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h index d216c0f..4f1cdb0 100644 --- a/drivers/net/wireless/ath/ath9k/htc_hst.h +++ b/drivers/net/wireless/ath/ath9k/htc_hst.h @@ -147,6 +147,7 @@ struct htc_target { u16 credits; u16 credit_size; u8 htc_flags; + atomic_t tgt_ready; }; enum htc_msg_id {