From patchwork Wed Jan 28 10:22:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 5734661 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 418F0BF440 for ; Thu, 29 Jan 2015 02:15:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43721201BB for ; Thu, 29 Jan 2015 02:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 294EF20160 for ; Thu, 29 Jan 2015 02:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757095AbbA2CP0 (ORCPT ); Wed, 28 Jan 2015 21:15:26 -0500 Received: from mail-wi0-f175.google.com ([209.85.212.175]:49779 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755684AbbA2BzS (ORCPT ); Wed, 28 Jan 2015 20:55:18 -0500 Received: by mail-wi0-f175.google.com with SMTP id fb4so18546727wid.2 for ; Wed, 28 Jan 2015 17:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+wCI3yUVYRFd1ZYUSUm54bGRkEmL4i7NbUacDtfNd7M=; b=XKr16pIEjOadY7/0PcEqs4bV/QyJ/zLp7r6QpEJA37UiwmoscfjjGhicqJ9ecIvdUo b2mHjiu0G0/+zcxSkLEwtY3XX8l0dSI+0R2nZ4oLrKQxVDUnZAYn0A880yN/CUzXgot2 Faad3VHHOd6wsjNtxCAjCqQJ4a1VzQQvrObBg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+wCI3yUVYRFd1ZYUSUm54bGRkEmL4i7NbUacDtfNd7M=; b=QWihioYIVUNlIKInz40NO+57dxFbTVgFrsjTmcHggdObURpCmgXchHF5eIPyffwfzR 753vNPdR3f3WD/uT35OvM27yggQI0qMsvQy19WlxO27lQK8JXO7mHrAKMElVxKozuZWX r4NJh0TlD81XYGqAX2JIZRMlJAeAUovB5xKAClB8jTqCQYnMQqNdBVZwbmV+F2a70Lli NZyKiS9r3ABmazdqFaY+8aguKidm9Zm3KGArKDr/BJFVe3ADWzACdXrkJr7lLHE7rQYz jR6q+pzOKyMXEhLDiE8HcYweOUZonHU4i0hruu5iZW/FlI6PlY1YJOvM0t+eRhosuxuQ n66g== X-Gm-Message-State: ALoCoQk646S2bD80Mfbk/IY9/X3nBKttB8xL9A66eyAVlvA0RJDwpx9RiwYBij8XRQe9FAotnZPppUjYlRN8666KgCmpPZuYd8E++o3KM3HJsGDOG+tx7uSFI6+TY+c4qWJiGCFLf/F6 X-Received: by 10.180.35.42 with SMTP id e10mr5416995wij.11.1422440581719; Wed, 28 Jan 2015 02:23:01 -0800 (PST) Received: from bob.homerouter.cpe (apn-31-1-134-151.dynamic.gprs.plus.pl. [31.1.134.151]) by mx.google.com with ESMTPSA id x18sm2140166wia.12.2015.01.28.02.23.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jan 2015 02:23:01 -0800 (PST) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Michal Kazior Subject: [PATCH v2 2/2] ath10k: fix beacon deadlock Date: Wed, 28 Jan 2015 11:22:05 +0100 Message-Id: <1422440525-11115-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.8.5.3 In-Reply-To: <1422440525-11115-1-git-send-email-michal.kazior@tieto.com> References: <1421412811-6387-1-git-send-email-michal.kazior@tieto.com> <1422440525-11115-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com 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_SIGNED, 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 This should fix a very rare occurrence of the following deadlock: [] ath10k_wmi_tx_beacons_nowait+0x1e/0x50 [ath10k_core] [] ath10k_wmi_op_ep_tx_credits+0x16/0x40 [ath10k_core] [] ath10k_htc_send+0x285/0x3d0 [ath10k_core] [] ath10k_wmi_cmd_send_nowait+0x81/0x110 [ath10k_core] [] ath10k_wmi_tx_beacon_nowait.part.33+0x51/0x90 [ath10k_core] [] ath10k_wmi_tx_beacons_iter+0x30/0x40 [ath10k_core] [] __iterate_active_interfaces+0xa6/0x100 [] ? ath10k_wmi_tx_beacon_nowait.part.33+0x90/0x90 [ath10k_core] [] ieee80211_iterate_active_interfaces_atomic+0xe/0x10 [] ath10k_wmi_tx_beacons_nowait+0x36/0x50 [ath10k_core] [] ath10k_wmi_op_ep_tx_credits+0x16/0x40 [ath10k_core] [] ath10k_htc_rx+0x280/0x410 [ath10k_core] [] ? ath10k_ce_completed_recv_next+0x60/0x80 [ath10k_pci] [] ath10k_pci_ce_recv_data+0x11b/0x1d0 [ath10k_pci] [] ath10k_ce_per_engine_service+0x64/0xc0 [ath10k_pci] [] ath10k_ce_per_engine_service_any+0x22/0x50 [ath10k_pci] [] ath10k_pci_tasklet+0x30/0x90 [ath10k_pci] [] tasklet_action+0xc5/0x100 To prevent this make sure to release ar->data_lock while calling to ath10k_wmi_beacon_send_ref_nowait(). Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/core.h | 8 +++- drivers/net/wireless/ath/ath10k/mac.c | 6 ++- drivers/net/wireless/ath/ath10k/wmi.c | 68 +++++++++++++++++++++++----------- 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 2d9f871..67e6b46 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -262,6 +262,12 @@ struct ath10k_sta { #define ATH10K_VDEV_SETUP_TIMEOUT_HZ (5*HZ) +enum ath10k_beacon_state { + ATH10K_BEACON_SCHEDULED = 0, + ATH10K_BEACON_SENDING, + ATH10K_BEACON_SENT, +}; + struct ath10k_vif { struct list_head list; @@ -272,7 +278,7 @@ struct ath10k_vif { u32 dtim_period; struct sk_buff *beacon; /* protected by data_lock */ - bool beacon_sent; + enum ath10k_beacon_state beacon_state; void *beacon_buf; dma_addr_t beacon_paddr; diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 4ff6dd0..2a51f0e 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -521,10 +521,14 @@ void ath10k_mac_vif_beacon_free(struct ath10k_vif *arvif) dma_unmap_single(ar->dev, ATH10K_SKB_CB(arvif->beacon)->paddr, arvif->beacon->len, DMA_TO_DEVICE); + if (WARN_ON(arvif->beacon_state != ATH10K_BEACON_SCHEDULED && + arvif->beacon_state != ATH10K_BEACON_SENT)) + return; + dev_kfree_skb_any(arvif->beacon); arvif->beacon = NULL; - arvif->beacon_sent = false; + arvif->beacon_state = ATH10K_BEACON_SCHEDULED; } static void ath10k_mac_vif_beacon_cleanup(struct ath10k_vif *arvif) diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c index 459b203..a398193 100644 --- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -956,30 +956,45 @@ err_pull: static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif) { - struct sk_buff *bcn; + struct ath10k *ar = arvif->ar; struct ath10k_skb_cb *cb; + struct sk_buff *bcn; int ret; - lockdep_assert_held(&arvif->ar->data_lock); + spin_lock_bh(&ar->data_lock); - if (arvif->beacon == NULL) - return; + bcn = arvif->beacon; - if (arvif->beacon_sent) - return; + if (!bcn) + goto unlock; - bcn = arvif->beacon; cb = ATH10K_SKB_CB(bcn); - ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar, arvif->vdev_id, - bcn->data, bcn->len, cb->paddr, - cb->bcn.dtim_zero, - cb->bcn.deliver_cab); - if (ret) - return; - /* We need to retain the arvif->beacon reference for DMA unmapping and - * freeing the skbuff later. */ - arvif->beacon_sent = true; + switch (arvif->beacon_state) { + case ATH10K_BEACON_SENDING: + case ATH10K_BEACON_SENT: + break; + case ATH10K_BEACON_SCHEDULED: + arvif->beacon_state = ATH10K_BEACON_SENDING; + spin_unlock_bh(&ar->data_lock); + + ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar, + arvif->vdev_id, + bcn->data, bcn->len, + cb->paddr, + cb->bcn.dtim_zero, + cb->bcn.deliver_cab); + + spin_lock_bh(&ar->data_lock); + + if (ret == 0) + arvif->beacon_state = ATH10K_BEACON_SENT; + else + arvif->beacon_state = ATH10K_BEACON_SCHEDULED; + } + +unlock: + spin_unlock_bh(&ar->data_lock); } static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac, @@ -992,12 +1007,10 @@ static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac, static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar) { - spin_lock_bh(&ar->data_lock); ieee80211_iterate_active_interfaces_atomic(ar->hw, IEEE80211_IFACE_ITER_NORMAL, ath10k_wmi_tx_beacons_iter, NULL); - spin_unlock_bh(&ar->data_lock); } static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar) @@ -2459,9 +2472,19 @@ void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb) spin_lock_bh(&ar->data_lock); if (arvif->beacon) { - if (!arvif->beacon_sent) - ath10k_warn(ar, "SWBA overrun on vdev %d\n", + switch (arvif->beacon_state) { + case ATH10K_BEACON_SENT: + break; + case ATH10K_BEACON_SCHEDULED: + ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n", + arvif->vdev_id); + break; + case ATH10K_BEACON_SENDING: + ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n", arvif->vdev_id); + dev_kfree_skb(bcn); + goto skip; + } ath10k_mac_vif_beacon_free(arvif); } @@ -2489,15 +2512,16 @@ void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb) } arvif->beacon = bcn; - arvif->beacon_sent = false; + arvif->beacon_state = ATH10K_BEACON_SCHEDULED; trace_ath10k_tx_hdr(ar, bcn->data, bcn->len); trace_ath10k_tx_payload(ar, bcn->data, bcn->len); - ath10k_wmi_tx_beacon_nowait(arvif); skip: spin_unlock_bh(&ar->data_lock); } + + ath10k_wmi_tx_beacons_nowait(ar); } void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)