From patchwork Mon Nov 14 14:42:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 9427655 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D35BB60484 for ; Mon, 14 Nov 2016 14:43:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C772D28795 for ; Mon, 14 Nov 2016 14:43:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BBF8D2881A; Mon, 14 Nov 2016 14:43:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B0EF28795 for ; Mon, 14 Nov 2016 14:43:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932858AbcKNOm5 (ORCPT ); Mon, 14 Nov 2016 09:42:57 -0500 Received: from mail-wm0-f52.google.com ([74.125.82.52]:38575 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932334AbcKNOmx (ORCPT ); Mon, 14 Nov 2016 09:42:53 -0500 Received: by mail-wm0-f52.google.com with SMTP id f82so102295489wmf.1 for ; Mon, 14 Nov 2016 06:42:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=open-mesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SkznC0nmwDAVr0wscqVm0WyyrA0eUZEjx42TMSoVb/s=; b=wI9m2i71JRj0P3g85DmaZdCtZ/jBoneMjYEp2VAIBRVkSYJCgUuwHPxTPfasFWybPk hfRjDLi2anLxB6KYt8jidZIk3JV3prX1eAcFyECKoFKJoRZqnKLVk6toSSqx3qCh9Q4E /5oVBh9Ofs2KcIC8k67kVu/gPsMjZhCbQePgDqOU3IqXsbXLaiUFa7i6sa0gDESDDEqf ITRx7RVnQVcZBY9xyn6Bckp/JOwLwVJklACxxf2r+Qot/hGv40i8jT9kEDfcHjEI5e3b iDqBA8SkJZyTy31fl9WUrMIYGJ/K+umX4zTf6vdewKwYuwESKyc/kS+OqoBMvOjFl3la HuyA== 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=SkznC0nmwDAVr0wscqVm0WyyrA0eUZEjx42TMSoVb/s=; b=aLsD/g/bxnL3IcmePucufnNR10lXhSHz3xshly/GS4XomUxsnZeeBhgV3KuXQ6eudj POsLf58HjpPoSSqlvRNpHpsR5fv0uByYO5rKdODsgtz545nKz8ep+jgRsIx/BPgpc4GT 9R4lNKz8Nzuq3TgB8myXuRmBt3ye4d+zgwpLmrca1UthA217P27gIYGWb78T1XGWcssC 0+qPEYjutdBqnYPdoCWBy/SFxto9FJ9fAr9LoEpGRTlQ8cFaN8gOFhAUHx7xmDC4Sbnw PozuU/S+0Ui1RZv8Yca3pfqexh6xcIqg3aTz3wViNDXMA5vIjZCQWgZIu9A8Ye0GCFqi s/KQ== X-Gm-Message-State: ABUngvf8kWHs895H1QJrtQr8gm2+KlaWG7kevezkr8eZuhkqJF3xKv+7k5WKklmzs69CwRNl X-Received: by 10.28.18.129 with SMTP id 123mr10069703wms.2.1479134571413; Mon, 14 Nov 2016 06:42:51 -0800 (PST) Received: from sven-desktop.home.narfation.org (p2003007C6F5D6EFE500C7BD707C41E3B.dip0.t-ipconnect.de. [2003:7c:6f5d:6efe:500c:7bd7:7c4:1e3b]) by smtp.gmail.com with ESMTPSA id cl10sm29155426wjb.4.2016.11.14.06.42.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Nov 2016 06:42:50 -0800 (PST) From: Sven Eckelmann To: ath9k-devel@lists.ath9k.org Cc: linux-wireless@vger.kernel.org, ath9k-devel@qca.qualcomm.com, Simon Wunderlich , Sven Eckelmann Subject: [RFC 2/2] ath9k: Reset chip on potential deaf state Date: Mon, 14 Nov 2016 15:42:26 +0100 Message-Id: <20161114144226.15748-2-sven.eckelmann@open-mesh.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161114144226.15748-1-sven.eckelmann@open-mesh.com> References: <20161114144226.15748-1-sven.eckelmann@open-mesh.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Simon Wunderlich The chip is switching seemingly random into a state which can be described as "deaf". No or nearly no interrupts are generated anymore for incoming packets. Existing links either break down after a while and new links will not be established. The driver doesn't know if there is no other device available or if it ended up in an "deaf" state. Resetting the chip proactively avoids permanent problems in case the chip really was in its "deaf" state but maybe causes unnecessary resets in case it wasn't "deaf". Signed-off-by: Simon Wunderlich [sven.eckelmann@open-mesh.com: port to recent ath9k, add commit message] Signed-off-by: Sven Eckelmann --- This problem was discovered in mesh setups. It was noticed that some nodes were not able to see their neighbors (mostly after running for a while) - even when those neighbors received data from them via IBSS. A simple `iw dev wlan0 scan` fixed the problem for them. But the problem seems to reappear after while(tm) in a large enough(tm) mesh. This patch is a little bit obscure because it requires CONFIG_ATH9K_DEBUGFS to actually work. But there still seems to be potential interest in Freifunk communities or Freifunk meta-projects (e.g. freifunk-gluon). It is currently not known if it helps them but publishing this to allow them to test and play around with it will not hurt :) --- drivers/net/wireless/ath/ath9k/ath9k.h | 3 +++ drivers/net/wireless/ath/ath9k/debug.c | 1 + drivers/net/wireless/ath/ath9k/debug.h | 1 + drivers/net/wireless/ath/ath9k/link.c | 45 ++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 9c6fee7..3987ad5 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -996,6 +996,9 @@ struct ath_softc { short nbcnvifs; unsigned long ps_usecount; + unsigned long last_check_time; + u32 last_check_interrupts; + struct ath_rx rx; struct ath_tx tx; struct ath_beacon beacon; diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 608b370..6d5c253 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -768,6 +768,7 @@ static int read_file_reset(struct seq_file *file, void *data) [RESET_TX_DMA_ERROR] = "Tx DMA stop error", [RESET_RX_DMA_ERROR] = "Rx DMA stop error", [RESET_TYPE_DEADBEEF] = "deadbeef hang", + [RESET_TYPE_DEAF] = "deaf hang", }; int i; diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 0d77abbf6..6f186bd 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h @@ -53,6 +53,7 @@ enum ath_reset_type { RESET_TX_DMA_ERROR, RESET_RX_DMA_ERROR, RESET_TYPE_DEADBEEF, + RESET_TYPE_DEAF, __RESET_TYPE_MAX }; diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c index ff11d85..f4b74b7 100644 --- a/drivers/net/wireless/ath/ath9k/link.c +++ b/drivers/net/wireless/ath/ath9k/link.c @@ -158,6 +158,48 @@ static bool ath_hw_hang_deadbeef(struct ath_softc *sc) return true; } +static bool ath_hw_hang_deaf(struct ath_softc *sc) +{ +#ifndef CONFIG_ATH9K_DEBUGFS + return false; +#else + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + u32 interrupts, interrupt_per_s; + unsigned int interval; + + /* get historic data */ + interval = jiffies_to_msecs(jiffies - sc->last_check_time); + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) + interrupts = sc->debug.stats.istats.rxlp; + else + interrupts = sc->debug.stats.istats.rxok; + + interrupts -= sc->last_check_interrupts; + + /* save current data */ + sc->last_check_time = jiffies; + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) + sc->last_check_interrupts = sc->debug.stats.istats.rxlp; + else + sc->last_check_interrupts = sc->debug.stats.istats.rxok; + + /* sanity check, should be 30 seconds */ + if (interval > 40000 || interval < 20000) + return false; + + /* should be at least one interrupt per second */ + interrupt_per_s = interrupts / (interval / 1000); + if (interrupt_per_s >= 1) + return false; + + ath_dbg(common, RESET, + "RX deaf hang is detected. Schedule chip reset\n"); + ath9k_queue_reset(sc, RESET_TYPE_DEAF); + + return true; +#endif +} + void ath_hw_hang_work(struct work_struct *work) { struct ath_softc *sc = container_of(work, struct ath_softc, @@ -166,6 +208,9 @@ void ath_hw_hang_work(struct work_struct *work) if (ath_hw_hang_deadbeef(sc)) goto requeue_worker; + if (ath_hw_hang_deaf(sc)) + goto requeue_worker; + requeue_worker: ieee80211_queue_delayed_work(sc->hw, &sc->hw_hang_work, msecs_to_jiffies(ATH_HANG_WORK_INTERVAL));