From patchwork Tue Feb 26 13:11:16 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: 10830169 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 1A9531669 for ; Tue, 26 Feb 2019 13:11:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 088C62B199 for ; Tue, 26 Feb 2019 13:11:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F09E62B139; Tue, 26 Feb 2019 13:11:55 +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 691C42B695 for ; Tue, 26 Feb 2019 13:11:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfBZNLz (ORCPT ); Tue, 26 Feb 2019 08:11:55 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37330 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726908AbfBZNLy (ORCPT ); Tue, 26 Feb 2019 08:11:54 -0500 Received: by mail-lf1-f66.google.com with SMTP id z196so8891208lff.4 for ; Tue, 26 Feb 2019 05:11:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=G1lai5VnnRFsoDItP10QXAVc95UUnO+V7zvJK9V43dI=; b=JvTTcHuJFwh2ZwW0cVQxVDfeuD77xTt6kc3xDA9gX9BD+YDu7TZbV6tGnD29eURDRM lq/+hZCpvHaOW9m3PCpo7/NZxED7oyBwvmN/pfIQss4GUyrWYzN0CDfZCxcnImCo7K+y feGq3t5dxn55wgbKAEv4eYLfaINUyrpLl0bxuw3Y/jMh/ujbn9XdtBL+C2SHXboOPscP n0yxyL2HvUTi1MBxIVPykM2QKfOhZMD6Jcmk0il4IxeyOlmmt+ss27QXtP/oqpgIGkBq 2rm1boVO6iryIEVp0+5WjBnUipXq3IPg9qoeWBu6quzN3VBajMkGOTmQ5xy0GshAhAUP 6ghg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=G1lai5VnnRFsoDItP10QXAVc95UUnO+V7zvJK9V43dI=; b=OyRSohMTuzTbVaDMv9g66Cr1etmXhEn4T6xPXVMhFmuG1He8thB1DYElmN2cM+meAT w4mTTHwghoH2VgWu6djFv1QldoFXplt7jyKrJ4599loeJEOqEa0cDGcyojvR5mBQrlLC UswvLG5wpi5OJUEza1iAX+/qhRjcV9ujDLXN6ouQoxLQCbekDPNs+o7BonOmv7o36ijc Qm3BiQX4uPZHw2KIolPCV7CAg+kNM9YpFYmfda9Uf4Kil7OS37sXT+rokVzEIINBhzcv 3QBFFkPwXL9KnX/kU8lS4bxZoAl2FnM7TQ14EnquGdleLFwB6X0sQutu2wcrFe2gcfRN BlIw== X-Gm-Message-State: AHQUAubcatMVWNCkCl2QlRDrYZmPiTGuojK/SJ/1ktuBfq4BZxQJQQhc 7w4LAARar+nmXZuRSDgPlVo= X-Google-Smtp-Source: AHgI3IZQGdQ3f2yGvMY1/MHoxqomZUEEy/Ztvos9nJvt/uGIZy2zupbM+rMKyZq8ov2Nr8ckHJ8a7w== X-Received: by 2002:ac2:555d:: with SMTP id l29mr13301420lfk.38.1551186711812; Tue, 26 Feb 2019 05:11:51 -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 f16-v6sm2952518lji.88.2019.02.26.05.11.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 05:11: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 1/4] brcmfmac: support repeated brcmf_fw_alloc_request() calls Date: Tue, 26 Feb 2019 14:11:16 +0100 Message-Id: <20190226131119.7907-2-zajec5@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226131119.7907-1-zajec5@gmail.com> References: <20190226131119.7907-1-zajec5@gmail.com> 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 During a normal brcmfmac lifetime brcmf_fw_alloc_request() is called once only during the probe. It's safe to assume provided array is clear. Further brcmfmac improvements may require calling it multiple times though. This patch allows it by fixing invalid firmware paths like: brcm/brcmfmac4366c-pcie.binbrcm/brcmfmac4366c-pcie.bin Signed-off-by: Rafał Miłecki Reviewed-by: Arend van Spriel --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c index 8209a42dea72..65098a02e1ad 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c @@ -743,6 +743,7 @@ brcmf_fw_alloc_request(u32 chip, u32 chiprev, for (j = 0; j < n_fwnames; j++) { fwreq->items[j].path = fwnames[j].path; + fwnames[j].path[0] = '\0'; /* check if firmware path is provided by module parameter */ if (brcmf_mp_global.firmware_path[0] != '\0') { strlcpy(fwnames[j].path, mp_path, From patchwork Tue Feb 26 13:11:17 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: 10830171 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 6AB821669 for ; Tue, 26 Feb 2019 13:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A00F2B19B for ; Tue, 26 Feb 2019 13:11:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EB392BCBE; Tue, 26 Feb 2019 13:11:57 +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 DC4882B19B for ; Tue, 26 Feb 2019 13:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727490AbfBZNL4 (ORCPT ); Tue, 26 Feb 2019 08:11:56 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:36354 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727467AbfBZNLz (ORCPT ); Tue, 26 Feb 2019 08:11:55 -0500 Received: by mail-lf1-f67.google.com with SMTP id x206so1574394lff.3 for ; Tue, 26 Feb 2019 05:11:54 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=fR6S6Qnno7x017ewRlWA+e9Pq5rlzJ9VOVsAW56m6BI=; b=ZXEVBJP2p7TeUNhCtmZL7y8Mpc8jp0s80fZX87q/sym+tmAiNiD3zxxb2zIs1l/rkm YUXO5nYdqczAgD59VO3tjDO2uZOcyNydqk/PgZaKYdCMk7qRZUs6zYzuVF6MXR6vjq9w e/hankF+zPTH+b7K2rNzZ2+s6GpRqcxZBAQ9ynT0XwYLhy6uvhXgXNprcj+IsYi4M7fd x4Mn/fD+nnnxoDwDRvsxiWrwKUjGlWaCaErNwDRxztyoo7XLvIwLO8mK0Yw9R4vWC2KE TiEmxanxiMQez7LW36tkNqZGlxLSm6k0uGkMUDVOetiACPzIl0rK/sHlDUWrXQy3EYGG 6bHw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=fR6S6Qnno7x017ewRlWA+e9Pq5rlzJ9VOVsAW56m6BI=; b=lFYxg7FeVwx/p3wwoHvHXORSe80xZSu44VcAejNfMhNbxht+ZTA+8ZtSLfuKykDfPH aQk543GdwUYpTZ7VCkugSc32dvJWkoJY7iltrXvnwTXtExiq31UOx2xw7guiTRjJiVzX qemGPcrtBoC5p/CIIaIzal6MMLv7g5GopTGX3yRMtMLCFdxdZEOp7sF7Z/QGHM37ZCjN KU6pL12Xey/kojFF2SyDyw3NUvvzF80OSs1fk/lRUlO08PJvViBqn6Ag0Jzksm4Q2zLH 29W7bclf468MNkxaDX2XRw+qG6S/RXcV5wD58v6tgLwTdJv1YA5Gs1qacauMCq8gyQIn vv7w== X-Gm-Message-State: AHQUAuYX3xoXowr5hYkheAOHAyAGE6bFfd0Dq7N8BprsHIsKUrzDP0h3 +kyiPH7Agxtb2dx5BAOHzTY= X-Google-Smtp-Source: AHgI3IZPBjN4V+SNwtNx9RCiCc8lrrORx5ruEilxvGIDr7EvK7rjB4SRNK38BYUjadpr4IrfkUfFuQ== X-Received: by 2002:a19:e601:: with SMTP id d1mr14441897lfh.71.1551186713824; Tue, 26 Feb 2019 05:11:53 -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 f16-v6sm2952518lji.88.2019.02.26.05.11.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 05:11:53 -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 2/4] brcmfmac: get RAM info right before downloading PCIe firmware Date: Tue, 26 Feb 2019 14:11:17 +0100 Message-Id: <20190226131119.7907-3-zajec5@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226131119.7907-1-zajec5@gmail.com> References: <20190226131119.7907-1-zajec5@gmail.com> 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's important as brcmf_chip_get_raminfo() also makes sure that memory is properly setup. Without it the firmware could report invalid RAM address like 0x04000001. During a normal brcmfmac lifetime brcmf_chip_get_raminfo() is called on probe by the brcmf_chip_recognition(). This change allows implementing further improvements like handling errors by resetting a device with the brcmf_pcie_reset_device() and redownloading a firmware afterwards. Signed-off-by: Rafał Miłecki --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 6 ++++-- drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h | 1 + drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c index 22534bf2a90c..fcaf19165891 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c @@ -707,8 +707,10 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci) return 0; } -static int brcmf_chip_get_raminfo(struct brcmf_chip_priv *ci) +int brcmf_chip_get_raminfo(struct brcmf_chip *pub) { + struct brcmf_chip_priv *ci = container_of(pub, struct brcmf_chip_priv, + pub); struct brcmf_core_priv *mem_core; struct brcmf_core *mem; @@ -990,7 +992,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci) brcmf_chip_set_passive(&ci->pub); } - return brcmf_chip_get_raminfo(ci); + return brcmf_chip_get_raminfo(&ci->pub); } static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h index 0ae3b33bab62..4794cf38b4d3 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h @@ -80,6 +80,7 @@ struct brcmf_buscore_ops { void (*activate)(void *ctx, struct brcmf_chip *chip, u32 rstvec); }; +int brcmf_chip_get_raminfo(struct brcmf_chip *pub); struct brcmf_chip *brcmf_chip_attach(void *ctx, const struct brcmf_buscore_ops *ops); void brcmf_chip_detach(struct brcmf_chip *chip); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 58a6bc379358..39f6421885f6 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1727,6 +1727,12 @@ static void brcmf_pcie_setup(struct device *dev, int ret, nvram_len = fwreq->items[BRCMF_PCIE_FW_NVRAM].nv_data.len; kfree(fwreq); + ret = brcmf_chip_get_raminfo(devinfo->ci); + if (ret) { + brcmf_err(bus, "Failed to get RAM info\n"); + goto fail; + } + /* Some of the firmwares have the size of the memory of the device * defined inside the firmware. This is because part of the memory in * the device is shared and the devision is determined by FW. Parse From patchwork Tue Feb 26 13:11:18 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: 10830173 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 39C3517EF for ; Tue, 26 Feb 2019 13:12:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 295CE2B17F for ; Tue, 26 Feb 2019 13:12:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DA382B814; Tue, 26 Feb 2019 13:12:01 +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 A91EB2BD75 for ; Tue, 26 Feb 2019 13:12:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727465AbfBZNL7 (ORCPT ); Tue, 26 Feb 2019 08:11:59 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37337 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbfBZNL6 (ORCPT ); Tue, 26 Feb 2019 08:11:58 -0500 Received: by mail-lf1-f66.google.com with SMTP id z196so8891377lff.4 for ; Tue, 26 Feb 2019 05:11:56 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=jng1uOZNBVq9j3PPM2U2Wcz60YlWQy6CcHxqFFVm1is=; b=BA6p9a7IDuq6xHPZ99C2YH4Sybfu4xhki6IgP5dDXnYHQdOB1sVkUpEuobU1b/OfBf PRRt+fE66wuJ/qwBnJKt0nnwxkwZUTxPib2X5e25qQOeC/6iQ33FSBaYpcWAXwkVkQUR SIJPvDNgjS7yr2QPTo7pz9REVK7H4a4IThiWMdXKuAAok9IvDTrtl3vSiCzjjd/BQc+z KSglo9e1fNc12RGl73bn39ImLHAI71vhGpypvg63KdXjDsYZZcrEzIeqAkTkJ5+r84F2 0QlrFa7W+aV6vzRAiFn+To9NOYhfXLxcwWZ8GI1zcemXRDv6lMdVGGHSyQ2c6w0kUikc jeZA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jng1uOZNBVq9j3PPM2U2Wcz60YlWQy6CcHxqFFVm1is=; b=fva7iGzmQGXl8NPxGPmJ4xuzg3Mmnz8kISejzsyQscxUMa1mxkKDFC7R9u2XRMB+Ay SJvIZttMcznKNCXSTrJ2ClWo9iIR9bQI/dwMjfDZuSXLgue4jktzpBzfXfTSYm3JFHld XlPf+ivRfvC5dXxUvWlSAL6qRx6SHipUeAVR1kgSllAcPCONRhvkIS7jjnodOuYDO/XQ tuGTQ9wT6K2qZLvZM+ziiULm1Kpt0NXigjfUv7sBIEJ+QD7ONTl/fw6w8g9Fisx0KTId 7tbPamdL31A46zUNNdV0Ogr2jO3Lw1naZOACnSec/DMt2GHVRib8MfwXhKdbWEjSDFbJ OwWw== X-Gm-Message-State: AHQUAuZeRj7eu+R5Nnw3q9ldMYPcDQXnif/fNjGveqIpaM5ceo6qRjxP jIMT77mfs8GmKaWzR40Ik1A= X-Google-Smtp-Source: AHgI3IZ0k1NfOGmtKf5ecCfoxUnlLLb4yVIXI7uoAuKgNQBp4jMw184aeiztB26FKw0BUTv8965E0A== X-Received: by 2002:a19:c616:: with SMTP id w22mr12775515lff.31.1551186716079; Tue, 26 Feb 2019 05:11:56 -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 f16-v6sm2952518lji.88.2019.02.26.05.11.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 05:11:55 -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 3/4] brcmfmac: add a function designated for handling firmware fails Date: Tue, 26 Feb 2019 14:11:18 +0100 Message-Id: <20190226131119.7907-4-zajec5@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226131119.7907-1-zajec5@gmail.com> References: <20190226131119.7907-1-zajec5@gmail.com> 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 This improves handling PCIe firmware halts by printing a clear error message and replaces a similar code in the SDIO bus support. It will also allow further improvements like trying to recover from a firmware crash. Signed-off-by: Rafał Miłecki Reviewed-by: Arend van Spriel --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 2 ++ .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 10 ++++++++++ .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 +- .../net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 4 ++-- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h index 3d441c5c745c..801106583ae7 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -262,6 +262,8 @@ void brcmf_detach(struct device *dev); void brcmf_dev_reset(struct device *dev); /* Request from bus module to initiate a coredump */ void brcmf_dev_coredump(struct device *dev); +/* Indication that firmware has halted or crashed */ +void brcmf_fw_crashed(struct device *dev); /* Configure the "global" bus state used by upper layers */ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 4fbe8791f674..7f4d9356b79e 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -1273,6 +1273,16 @@ void brcmf_dev_coredump(struct device *dev) brcmf_dbg(TRACE, "failed to create coredump\n"); } +void brcmf_fw_crashed(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pub *drvr = bus_if->drvr; + + bphy_err(drvr, "Firmware has halted or crashed\n"); + + brcmf_dev_coredump(dev); +} + void brcmf_detach(struct device *dev) { s32 i; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 39f6421885f6..cfa34672315f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -730,7 +730,7 @@ static void brcmf_pcie_handle_mb_data(struct brcmf_pciedev_info *devinfo) } if (dtoh_mb_data & BRCMF_D2H_DEV_FWHALT) { brcmf_dbg(PCIE, "D2H_MB_DATA: FW HALT\n"); - brcmf_dev_coredump(&devinfo->pdev->dev); + brcmf_fw_crashed(&devinfo->pdev->dev); } } diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 4d104ab80fd8..a06af0cd4a7f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -1090,8 +1090,8 @@ static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus) /* dongle indicates the firmware has halted/crashed */ if (hmb_data & HMB_DATA_FWHALT) { - brcmf_err("mailbox indicates firmware halted\n"); - brcmf_dev_coredump(&sdiod->func1->dev); + brcmf_dbg(SDIO, "mailbox indicates firmware halted\n"); + brcmf_fw_crashed(&sdiod->func1->dev); } /* Dongle recomposed rx frames, accept them again */ From patchwork Tue Feb 26 13:11:19 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: 10830175 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 303E517EF for ; Tue, 26 Feb 2019 13:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D7552B814 for ; Tue, 26 Feb 2019 13:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11A112BE1F; Tue, 26 Feb 2019 13:12:03 +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 7B5732BCBE for ; Tue, 26 Feb 2019 13:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727497AbfBZNMB (ORCPT ); Tue, 26 Feb 2019 08:12:01 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45292 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726995AbfBZNMB (ORCPT ); Tue, 26 Feb 2019 08:12:01 -0500 Received: by mail-lj1-f194.google.com with SMTP id d24so10430760ljc.12 for ; Tue, 26 Feb 2019 05:11:59 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=kcVv+XhwhadZvdGYXvwV+SiX4KJ1bsdNrTTyWe5H02A=; b=AgiYDJpElwGAuvnhTl8vgT+y2bfa/3V4MJeBeghmwyBILlo1+gMkZ66+xWT/L1LtUx 4Np2qEDzBS5s1FDlxr3PbeK1TeqJo/OzQQBOYna1MroaxSlprdCBPZU557S6eIJnCdb5 olLmv3QagqFH+mHhOLiSq93fm0Uh0rVu9I4UxIa8LXfoFPAkZi39u6oPfnbtI4crbERR Ff9bAHJ8G2/kjJ7Y3+5iOhEFMiw/W8v8dNThLyzjw/miPWcPYawmCiSu2KIFWP97qr0l FDcT5r9I0EFEBIg1qoa2vtPZYNcnrmtvKMee/Wak/qdUuMzpRoOC0uDwHG8ysEHpR63s It9g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=kcVv+XhwhadZvdGYXvwV+SiX4KJ1bsdNrTTyWe5H02A=; b=sZEf7VgMG7w3xl52unlDhU3DENGLYHGv97PNn9nEb+oH5gDTNnW1Od7VkVRvZOWChU 81kifLXr9iALmcJnlVBNSpAaEWQpxS2nPj4E+ulW09BY2nAqJM/ceP5yFmy8lgCj9kw5 /6kvy15XHneT3WalyJZfZb/tjSK/IVIipWycj4VYYftwBAqHOMjGbpelWIMvwvLZyIzJ 2Y03P6FjhWVFKD1nseqRrEvV2A3QceCT8j7KODQg/Q09RJDBi9mqJ1uGunvlZG2o27pf pD9pU58tQ/thLEDdAy467y5b2JKqml13k/T+K3gl1U7Uh9UlOnxHPCM4Wo+Zv8w+DtWw JHyw== X-Gm-Message-State: AHQUAuY9GTqa5QDov92ckvHWaL84gqXUOgYTqeSanw8wnf7t0etB7+F5 G3H/ON26OmUqEd+iB6RRg4g= X-Google-Smtp-Source: AHgI3Ia6OCG7oOrK0hNHXpxkFJ4MTa1v28XXad2gtyDiqrSZkHlBif5RIEV8bC/SkmvIvQPtXQE6fA== X-Received: by 2002:a2e:9a55:: with SMTP id k21mr13226480ljj.191.1551186718216; Tue, 26 Feb 2019 05:11:58 -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 f16-v6sm2952518lji.88.2019.02.26.05.11.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 05:11:57 -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 4/4] brcmfmac: reset PCIe bus on a firmware crash Date: Tue, 26 Feb 2019 14:11:19 +0100 Message-Id: <20190226131119.7907-5-zajec5@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226131119.7907-1-zajec5@gmail.com> References: <20190226131119.7907-1-zajec5@gmail.com> 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 This includes bus reset & reloading a firmware. It should be sufficient for a user space to (setup and) use a wireless device again. Support for reset on USB & SDIO can be added later. Signed-off-by: Rafał Miłecki Reviewed-by: Arend van Spriel --- .../broadcom/brcm80211/brcmfmac/bus.h | 10 ++++++ .../broadcom/brcm80211/brcmfmac/core.c | 12 +++++++ .../broadcom/brcm80211/brcmfmac/core.h | 2 ++ .../broadcom/brcm80211/brcmfmac/pcie.c | 35 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h index 801106583ae7..2fe167eae22c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -91,6 +91,7 @@ struct brcmf_bus_ops { int (*get_fwname)(struct device *dev, const char *ext, unsigned char *fw_name); void (*debugfs_create)(struct device *dev); + int (*reset)(struct device *dev); }; @@ -245,6 +246,15 @@ void brcmf_bus_debugfs_create(struct brcmf_bus *bus) return bus->ops->debugfs_create(bus->dev); } +static inline +int brcmf_bus_reset(struct brcmf_bus *bus) +{ + if (!bus->ops->reset) + return -EOPNOTSUPP; + + return bus->ops->reset(bus->dev); +} + /* * interface functions from common layer */ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 7f4d9356b79e..5f3548b13639 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -1084,6 +1084,14 @@ static int brcmf_revinfo_read(struct seq_file *s, void *data) return 0; } +static void brcmf_core_bus_reset(struct work_struct *work) +{ + struct brcmf_pub *drvr = container_of(work, struct brcmf_pub, + bus_reset); + + brcmf_bus_reset(drvr->bus_if); +} + static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) { int ret = -1; @@ -1155,6 +1163,8 @@ static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) #endif #endif /* CONFIG_INET */ + INIT_WORK(&drvr->bus_reset, brcmf_core_bus_reset); + /* populate debugfs */ brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read); brcmf_feat_debugfs_create(drvr); @@ -1281,6 +1291,8 @@ void brcmf_fw_crashed(struct device *dev) bphy_err(drvr, "Firmware has halted or crashed\n"); brcmf_dev_coredump(dev); + + schedule_work(&drvr->bus_reset); } void brcmf_detach(struct device *dev) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h index d8085ce579f4..9f09aa31eeda 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 work_struct bus_reset; + u8 clmver[BRCMF_DCMD_SMLEN]; }; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index cfa34672315f..e941039ee1c3 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -345,6 +345,10 @@ static const u32 brcmf_ring_itemsize[BRCMF_NROF_COMMON_MSGRINGS] = { BRCMF_D2H_MSGRING_RX_COMPLETE_ITEMSIZE }; +static void brcmf_pcie_setup(struct device *dev, int ret, + struct brcmf_fw_request *fwreq); +static struct brcmf_fw_request * +brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo); static u32 brcmf_pcie_read_reg32(struct brcmf_pciedev_info *devinfo, u32 reg_offset) @@ -1409,6 +1413,36 @@ int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name) return 0; } +static int brcmf_pcie_reset(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie; + struct brcmf_pciedev_info *devinfo = buspub->devinfo; + struct brcmf_fw_request *fwreq; + int err; + + brcmf_detach(dev); + + brcmf_pcie_release_irq(devinfo); + brcmf_pcie_release_scratchbuffers(devinfo); + brcmf_pcie_release_ringbuffers(devinfo); + brcmf_pcie_reset_device(devinfo); + + fwreq = brcmf_pcie_prepare_fw_request(devinfo); + if (!fwreq) { + dev_err(dev, "Failed to prepare FW request\n"); + return -ENOMEM; + } + + err = brcmf_fw_get_firmwares(dev, fwreq, brcmf_pcie_setup); + if (err) { + dev_err(dev, "Failed to prepare FW request\n"); + kfree(fwreq); + } + + return err; +} + static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { .txdata = brcmf_pcie_tx, .stop = brcmf_pcie_down, @@ -1418,6 +1452,7 @@ static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { .get_ramsize = brcmf_pcie_get_ramsize, .get_memdump = brcmf_pcie_get_memdump, .get_fwname = brcmf_pcie_get_fwname, + .reset = brcmf_pcie_reset, };