From patchwork Wed Aug 15 18:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 10566735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1165C1390 for ; Wed, 15 Aug 2018 18:01:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA0C92AD76 for ; Wed, 15 Aug 2018 18:01:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE3062AD5E; Wed, 15 Aug 2018 18:01:22 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 3934C2AD5E for ; Wed, 15 Aug 2018 18:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729464AbeHOUya (ORCPT ); Wed, 15 Aug 2018 16:54:30 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44014 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729363AbeHOUya (ORCPT ); Wed, 15 Aug 2018 16:54:30 -0400 Received: by mail-lf1-f66.google.com with SMTP id f135-v6so1469806lfg.10 for ; Wed, 15 Aug 2018 11:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K+RwFkGf821QUo3iOV22wBQJmZAbAvQt16MyIdVCYAI=; b=ZFGA0PNUull1+YwpFqcbRprQZHhNFOcJWPg5U1JicLoZwjMr3P/z/14sNLth15aN+z DUA7l+EskhqGSCZinjDDjKmzgF+TyM6BzL1O7BNZM2z6VMFgnaFsW+TDzuwH7KT19bs2 TTf0ScF21WJU63m+eKRR1+30hky4M8x8bHbfY+4DqkGqnGjKf0OuevBJzGbaJERBeP/l P/9HBf6O4duAUR2bhc4wNNFk21OJ517tJb7zMCnSLrg3nKnufTvevESC1UJjMR3XReE3 o+QLKtRQ9OHVV6aj+R6EeMmWqa1IaLVqMLgRTPKxl1GHkJ0jtOVq48vJkaxYw5njEJRD x/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K+RwFkGf821QUo3iOV22wBQJmZAbAvQt16MyIdVCYAI=; b=IKXACSvvkZbfBxcXTMAbZ2a65uo7wbd5WKmMhjniGI5wZ3bRGLCSpY1FAXuK7zUPJt ausVR2TjOEzf9QJgR+ELO/tvktKyt7PzKbMzS1gDpdNV4yn5MjTFUo2+iSFakJB6K2i9 84sUm+HgB/6stCMYpaqeHADiFVEpmAycJWv2Ua7kI62rf578OhWjTPxvCwEon2/2/tUi sF5gIKmT4hsDlRCUlGTkt89jtd32KXVVwK/RuTPE2Es4EzIyYy67I8wQAJWEsgKOgdQS MJleCXD5Q2esPM9jGMZI43F6sJsK7/hyDakn5QfJGlHpM1yXltvuYPBPmLK4EfB/vMwW fdow== X-Gm-Message-State: AOUpUlEk6SvSbY4Gn/GloSxOjtjbZRXAqoc/hGBi3pxmcIYN4bF9Ozy7 h/D9UwgPufoW8RdX0IX5T0dphzIt X-Google-Smtp-Source: AA+uWPx5WzVaefRX8rEc4S3WXTcJDvs7ZwfZB/46kC+eam+gSLsp4R6iLkRTk91djOMlV7ChZls9DA== X-Received: by 2002:a19:c403:: with SMTP id u3-v6mr16543734lff.87.1534356078194; Wed, 15 Aug 2018 11:01:18 -0700 (PDT) Received: from linux-veee.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id o13-v6sm4129095lja.23.2018.08.15.11.01.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Aug 2018 11:01:17 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: linux-wireless@vger.kernel.org Cc: brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [DEBUG PATCH] brcmfmac: add firmware watchdog running on host machine Date: Wed, 15 Aug 2018 20:01:01 +0200 Message-Id: <20180815180101.15087-1-zajec5@gmail.com> X-Mailer: git-send-email 2.13.7 MIME-Version: 1.0 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: Rafał Miłecki It may happen for FullMAC firmware to crash. It should be detected and ideally somehow handled by a driver. Since commit ff4445a8502c ("brcmfmac: expose device memory to devcoredump subsystem") brcmfmac has BRCMF_E_PSM_WATCHDOG event handler but it wasn't enough to detect all kind of crashes. E.g. Netgear R8000 (BCM4709A0 + 3 x BCM43602) user was exepriencing firmware crashes that never resulted in passing BRCMF_E_PSM_WATCHDOG to the host driver. That made me implement this trivial software watchdog that simply checks periodically if firmware still replies to the commands. Luckily this patch DOES NOT seem to be needed anymore since the commit 8a3ab2f38f16 ("brcmfmac: trigger memory dump upon firmware halt signal"). That change allows brcmfmac to detect firmware crashes successfully. This patch is being posted for research/debugging purposes only. It SHOULD NOT be applied until someone notices a firmware crash that doesn't trigger the BRCMF_D2H_DEV_FWHALT signal. Signed-off-by: Rafał Miłecki --- .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 21 +++++++++++++++++++++ .../net/wireless/broadcom/brcm80211/brcmfmac/core.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 03bfbcc3ca6e..4d928ca795b1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -40,6 +40,7 @@ #include "common.h" #define MAX_WAIT_FOR_8021X_TX msecs_to_jiffies(950) +#define BRCMF_FW_WATCHDOG_POLL msecs_to_jiffies(3000) #define BRCMF_BSSIDX_INVALID -1 @@ -1088,6 +1089,20 @@ static int brcmf_revinfo_read(struct seq_file *s, void *data) return 0; } +static void brcmf_fw_watchdog(struct work_struct *work) +{ + struct brcmf_pub *pub = container_of(work, struct brcmf_pub, fw_watchdog.work); + struct brcmf_if *ifp = pub->iflist[0]; + s32 ver; + int err; + + err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, &ver); + if (err) + brcmf_err("Firmware didn't respond: %d (firmware crash?)\n", err); + + schedule_delayed_work(&pub->fw_watchdog, BRCMF_FW_WATCHDOG_POLL); +} + static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) { int ret = -1; @@ -1159,6 +1174,9 @@ static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) #endif #endif /* CONFIG_INET */ + INIT_DELAYED_WORK(&drvr->fw_watchdog, brcmf_fw_watchdog); + schedule_delayed_work(&drvr->fw_watchdog, BRCMF_FW_WATCHDOG_POLL); + /* populate debugfs */ brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read); brcmf_feat_debugfs_create(drvr); @@ -1287,6 +1305,9 @@ void brcmf_detach(struct device *dev) if (drvr == NULL) return; + cancel_delayed_work(&drvr->fw_watchdog); + flush_scheduled_work(); + #ifdef CONFIG_INET unregister_inetaddr_notifier(&drvr->inetaddr_notifier); #endif diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h index 2d37a2fc6a6f..1afb3f0ca585 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h @@ -143,6 +143,8 @@ struct brcmf_pub { struct notifier_block inet6addr_notifier; struct brcmf_mp_device *settings; + struct delayed_work fw_watchdog; + u8 clmver[BRCMF_DCMD_SMLEN]; };