From patchwork Fri Feb 22 17:07:39 2019 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: 10826683 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-2.web.codeaurora.org (Postfix) with ESMTP id 87CE213B5 for ; Fri, 22 Feb 2019 17:07:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E57732ADE for ; Fri, 22 Feb 2019 17:07:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6236C32AE7; Fri, 22 Feb 2019 17:07:58 +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 7935932ADD for ; Fri, 22 Feb 2019 17:07:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727361AbfBVRH4 (ORCPT ); Fri, 22 Feb 2019 12:07:56 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43688 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727337AbfBVRHz (ORCPT ); Fri, 22 Feb 2019 12:07:55 -0500 Received: by mail-lj1-f194.google.com with SMTP id z20so2243717ljj.10 for ; Fri, 22 Feb 2019 09:07:53 -0800 (PST) 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=9X+hoCf/DrAGXjknfs/pC7GI0y5CEo4O4tRaYC18Q20=; b=kK2VBCDuflrhWaBoqw5jT0MSWyLxSJ6i7zh7Y6uXGdVrvF2mL91wlpgdMHEbdoOgpO yYgH4zr46DpR5gjSTYH7dPF0wpNj0N01AZ95nzwHqSsJVvxFRuVFbTX4emubOCf/OpcT 9x1rujuKya9uq5lTmuQdGFH/zZM9RBd+KoCeGkMR0FMEZPlf8Lo34Qak+W1cfTg34mSP 77Pw1bEhD5KtCrHgKc/81Q0G+2f3Gy+cE3qZN7rYTRO7yucg+sy2/4kAAW+LLnSvsaJS 0LKg9yoyWFMrT8VX3PYv5cl7Nl2dzOg3BLYqQsznFD1VKWJ4D3np4l6LB5EfDnd+IXDL 4xmA== 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=9X+hoCf/DrAGXjknfs/pC7GI0y5CEo4O4tRaYC18Q20=; b=HbT8cV9N0jTg1StRREKYxA8Z5/gmPrzTpJQsiU49e8i/hlu4QKYsQKHtVefoJlzpmH KBxXG/Pe+iKMyeFS/sSa9hSMmv/7RfMO5ttSuMcsVaryQ64KTHRgr4vlbTmoPYI+g0io FpttXxC8yLeuqNwmj2PRUc0jFzJGlWvwhPe/gcH+vGmg2oLclct0fmhIiwgfyjo9IRZZ of1j1Pnmy0wW+8hdXfaLGOq/RSMop7NH8cEfgw6IxUYp9xT1bQWv+vO7j4BoXUK7eN00 KjMEkYgL4xH2PMOUnG0tu1+EcGbCkItHt8NzC0FP5xk2/c/5+z2+T/Ci2SWOzZHmq1hZ fAzA== X-Gm-Message-State: AHQUAuZIvOnNspGOX0yg2YQ+uKAzbLdb9SD8l2Ite9luB2LspZyMJTGV /iz6O/hc32FEuS4J5CIbgcg= X-Google-Smtp-Source: AHgI3IYJzBL+h208nWEtCwI1zIkyDOY/gzvBAfMXeABf+NbQVh0y5rrbqVfNL5O+ThBJD+EPxZAtZQ== X-Received: by 2002:a2e:99c9:: with SMTP id l9mr2987258ljj.60.1550855272578; Fri, 22 Feb 2019 09:07:52 -0800 (PST) Received: from elitebook.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id p15sm611946lfc.88.2019.02.22.09.07.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 09:07:51 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Kalle Valo Cc: Arend van Spriel , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH] brcmfmac: run firmware state watchdog on the host machine Date: Fri, 22 Feb 2019 18:07:39 +0100 Message-Id: <20190222170739.14266-1-zajec5@gmail.com> X-Mailer: git-send-email 2.20.1 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 FullMAC firmware may happen to crash due to some potential bugs exposed by e.g. a specific traffic or host-requested setup. It usually results in various timeouts & running our of resources (e.g. ring slots). Monitoring firmware state allows handling such a situation more gracefully. At this point the watchdog: 1) Prints a clear error message about a firmware crash 2) Tries to dump a crash info data That should be helpful for users & should allow providing a valuable reports for the Broadcom developers. It obviously doesn't really fix anything. This watchdog is important for USB & SDIO devices which don't have anything alike implemented yet. It's also there to complement PCIe with its FWHALT signal which does not work in all situations. It has been successfully tested with the recently released brcmfmac4366c-pcie.bin. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201853 Signed-off-by: Rafał Miłecki --- .../broadcom/brcm80211/brcmfmac/core.c | 28 +++++++++++++++++++ .../broadcom/brcm80211/brcmfmac/core.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 4fbe8791f674..ab7a54b2d831 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(1000) #define BRCMF_BSSIDX_INVALID -1 @@ -1084,6 +1085,28 @@ 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 *drvr = container_of(work, struct brcmf_pub, + fw_watchdog.work); + + if (drvr->bus_if->state == BRCMF_BUS_UP) { + struct brcmf_if *ifp = drvr->iflist[0]; + s32 ver; + int err; + + err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, &ver); + if (err) { + bphy_err(drvr, "Firmware has most likely crashed and didn't respond: %d\n", + err); + brcmf_dev_coredump(drvr->bus_if->dev); + return; + } + } + + schedule_delayed_work(&drvr->fw_watchdog, BRCMF_FW_WATCHDOG_POLL); +} + static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) { int ret = -1; @@ -1155,6 +1178,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); @@ -1284,6 +1310,8 @@ void brcmf_detach(struct device *dev) if (drvr == NULL) return; + cancel_delayed_work_sync(&drvr->fw_watchdog); + #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 d8085ce579f4..1b44d243d05f 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]; };