From patchwork Mon Nov 14 14:42:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 9427657 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 25A9E60484 for ; Mon, 14 Nov 2016 14:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A13428751 for ; Mon, 14 Nov 2016 14:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0ECE628809; Mon, 14 Nov 2016 14:43:06 +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 D039828751 for ; Mon, 14 Nov 2016 14:43:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753826AbcKNOmu (ORCPT ); Mon, 14 Nov 2016 09:42:50 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:36514 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753098AbcKNOmr (ORCPT ); Mon, 14 Nov 2016 09:42:47 -0500 Received: by mail-wm0-f53.google.com with SMTP id g23so101883810wme.1 for ; Mon, 14 Nov 2016 06:42:47 -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; bh=RU3FpcxiPdZf5xYpB/ouUj/qqD38tD9TPcgNdVwFOC8=; b=tJlQNOlkhDrwxZjFKWTXU4cM1kOQz9Da39OmRd/FvIpgw4LKNgWP7e2cymDhjqLpo9 2g2K1p9lGzbbAo/gIJUF1GCMrQt4IPmk+wABOXY9j+6BkaX39ip+EJGHcbzkSJeVp699 /qVTxVNHOVXWJZULfYO31lUpSOBTLTJdtzhb7PZyMuLNYjyvGQUYaaNnznTJOJsnfYkW XaSFfrkHsb6Vj5oO7fh7wKtDAnUSH/xRaATTESvs7xN058Z/Kv7NrdnMC/FkdjOxqwJB Z0GEGgy5xQqZQQuZ3HYpK19KGTf9aZ/hlkuG9I3nYYRL1MHq4Dh3D1IIdCVzyaydAike rF3Q== 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; bh=RU3FpcxiPdZf5xYpB/ouUj/qqD38tD9TPcgNdVwFOC8=; b=i+e4yxd/0YBlaVnr5BQ5N2m90ehnVSFf4NNc0PD0VZXamne7iNnEdjvwy6j5qiD/I4 WfSU5rWliOPbh4FGjVMLKbPa+AG15NB0KCuVYTSi22qF3CMw8rDSfJFFFOdcQZbfbL+R pkbPXpuY3iHiIwYODHcjpuL0t6ROEWhJYhfm57ELQ2siVHxSOe5d50+eWN/dORUiWwt0 ss8aVDSBPwlRYBDfPDIj9zrk87HeWSqB4Lx6uK1ZNZQwAAlP6mGaGsUh9s/ea/JZp+Z3 BnO1tWnfYhcYnE/P0iHm70vA/X6EYhwuo+fVXkvUWAlPTfJlARmi0qzqkHKrFanZuK32 7qpA== X-Gm-Message-State: ABUngvf1qbiQc/Y9JunweGILr2sK+DMEoOGBGh0HIOHqaeyHWE7FDeoKZMbGSr0TiaZE0Guz X-Received: by 10.28.136.198 with SMTP id k189mr10057759wmd.24.1479134566211; Mon, 14 Nov 2016 06:42:46 -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 l6sm9915340wmd.5.2016.11.14.06.42.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Nov 2016 06:42:45 -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 1/2] ath9k: work around AR_CFG 0xdeadbeef chip hang Date: Mon, 14 Nov 2016 15:42:25 +0100 Message-Id: <20161114144226.15748-1-sven.eckelmann@open-mesh.com> X-Mailer: git-send-email 2.10.2 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 QCA 802.11n chips (especially AR9330/AR9340) sometimes end up in a state in which a read of AR_CFG always returns 0xdeadbeef. This should not happen when when the power_mode of the device is ATH9K_PM_AWAKE. This problem is not yet detected by any other workaround in ath9k. No way is known to reproduce the problem easily. Signed-off-by: Simon Wunderlich [sven.eckelmann@open-mesh.com: port to recent ath9k, add commit message] Signed-off-by: Sven Eckelmann --- This was discussed 4 years ago on the OpenWrt mailing list. The most relevant post is https://lists.openwrt.org/pipermail/openwrt-devel/2012-September/016708.html --- 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/init.c | 1 + drivers/net/wireless/ath/ath9k/link.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/main.c | 4 ++++ 6 files changed, 43 insertions(+) diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 26fc8ec..9c6fee7 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -710,11 +710,13 @@ void ath9k_csa_update(struct ath_softc *sc); #define ATH_ANI_MAX_SKIP_COUNT 10 #define ATH_PAPRD_TIMEOUT 100 /* msecs */ #define ATH_PLL_WORK_INTERVAL 100 +#define ATH_HANG_WORK_INTERVAL 30000 void ath_tx_complete_poll_work(struct work_struct *work); void ath_reset_work(struct work_struct *work); bool ath_hw_check(struct ath_softc *sc); void ath_hw_pll_work(struct work_struct *work); +void ath_hw_hang_work(struct work_struct *work); void ath_paprd_calibrate(struct work_struct *work); void ath_ani_calibrate(unsigned long data); void ath_start_ani(struct ath_softc *sc); @@ -1014,6 +1016,7 @@ struct ath_softc { #endif struct delayed_work tx_complete_work; struct delayed_work hw_pll_work; + struct delayed_work hw_hang_work; struct timer_list sleep_timer; #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index c56e40f..608b370 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -767,6 +767,7 @@ static int read_file_reset(struct seq_file *file, void *data) [RESET_TYPE_CALIBRATION] = "Calibration error", [RESET_TX_DMA_ERROR] = "Tx DMA stop error", [RESET_RX_DMA_ERROR] = "Rx DMA stop error", + [RESET_TYPE_DEADBEEF] = "deadbeef hang", }; int i; diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index cd68c5f..0d77abbf6 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h @@ -52,6 +52,7 @@ enum ath_reset_type { RESET_TYPE_CALIBRATION, RESET_TX_DMA_ERROR, RESET_RX_DMA_ERROR, + RESET_TYPE_DEADBEEF, __RESET_TYPE_MAX }; diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 368d9b3..9bc7d1c 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -638,6 +638,7 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc, INIT_WORK(&sc->hw_reset_work, ath_reset_work); INIT_WORK(&sc->paprd_work, ath_paprd_calibrate); INIT_DELAYED_WORK(&sc->hw_pll_work, ath_hw_pll_work); + INIT_DELAYED_WORK(&sc->hw_hang_work, ath_hw_hang_work); ath9k_init_channel_context(sc); diff --git a/drivers/net/wireless/ath/ath9k/link.c b/drivers/net/wireless/ath/ath9k/link.c index 5ad0fee..ff11d85 100644 --- a/drivers/net/wireless/ath/ath9k/link.c +++ b/drivers/net/wireless/ath/ath9k/link.c @@ -138,6 +138,39 @@ void ath_hw_pll_work(struct work_struct *work) msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); } +static bool ath_hw_hang_deadbeef(struct ath_softc *sc) +{ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + u32 reg; + + /* check for stucked MAC */ + ath9k_ps_wakeup(sc); + reg = REG_READ(sc->sc_ah, AR_CFG); + ath9k_ps_restore(sc); + + if (reg != 0xdeadbeef) + return false; + + ath_dbg(common, RESET, + "0xdeadbeef hang is detected. Schedule chip reset\n"); + ath9k_queue_reset(sc, RESET_TYPE_DEADBEEF); + + return true; +} + +void ath_hw_hang_work(struct work_struct *work) +{ + struct ath_softc *sc = container_of(work, struct ath_softc, + hw_hang_work.work); + + if (ath_hw_hang_deadbeef(sc)) + goto requeue_worker; + +requeue_worker: + ieee80211_queue_delayed_work(sc->hw, &sc->hw_hang_work, + msecs_to_jiffies(ATH_HANG_WORK_INTERVAL)); +} + /* * PA Pre-distortion. */ diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index e9f32b5..4d3e216 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -183,6 +183,7 @@ static void __ath_cancel_work(struct ath_softc *sc) cancel_work_sync(&sc->paprd_work); cancel_delayed_work_sync(&sc->tx_complete_work); cancel_delayed_work_sync(&sc->hw_pll_work); + cancel_delayed_work_sync(&sc->hw_hang_work); #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT if (ath9k_hw_mci_is_enabled(sc->sc_ah)) @@ -204,6 +205,9 @@ void ath_restart_work(struct ath_softc *sc) ieee80211_queue_delayed_work(sc->hw, &sc->hw_pll_work, msecs_to_jiffies(ATH_PLL_WORK_INTERVAL)); + ieee80211_queue_delayed_work(sc->hw, &sc->hw_hang_work, + msecs_to_jiffies(ATH_HANG_WORK_INTERVAL)); + ath_start_ani(sc); }