From patchwork Tue Sep 3 04:29:26 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: 11127163 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EB1D1920 for ; Tue, 3 Sep 2019 04:29:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C74222D6D for ; Tue, 3 Sep 2019 04:29:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TyqjPEzT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726053AbfICE3w (ORCPT ); Tue, 3 Sep 2019 00:29:52 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46024 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725839AbfICE3w (ORCPT ); Tue, 3 Sep 2019 00:29:52 -0400 Received: by mail-lj1-f193.google.com with SMTP id l1so14554407lji.12 for ; Mon, 02 Sep 2019 21:29:50 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=qCmsP82DTk01w6Xx+SSAdpGpTOCXTc/9JdvifjcdZ1Q=; b=TyqjPEzTRaJkmoTpWNr0WBxF7PPvmZD+XCfcsWTiaBMvdhnbEBlRhp8EuoWbGOM/0d piov/Tl7c4ksILB2RB7oZk/0BJ+q0mnpmHaFE0ED2i808fepf1dKKebDY7192T9glnCB 0Pk7aPD2feLD1m0uvPcU1i+T+DYhXE3K9ct+lcw9lVbKAPXZqJo2NbnY0t3cou77ippm lWOz5d8EoMenFwJSLv7qRWlob54gQKAwna/UffHW7toFY/AFQUgeI3h5Z1uAviRbW/JY 5cCzAD4f7KOoXnDRz4YnKXrfMYaP1jc3+h3u+iAvcChMQfOyw52ZFqm+0DNx0mC0Bkp0 64Sg== 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=qCmsP82DTk01w6Xx+SSAdpGpTOCXTc/9JdvifjcdZ1Q=; b=A2FtbixYinB0C8UsdbE8tb4byJQ4yD5sTLoynXazyp3EvYGkyO4/5Zd/2UK0rAjj/L CkJgJR28G9RlEjm7hxDZMVSb65gpvQxyHP4h/Cfk3OaboL46Aio2+ufvDMXCvWJ7szky 9rV0LeKAtYQLo7cXKog17qe5FAKPMFZFbGC1g793kdMUGveb+oT49ByIcq6zjFd919r3 iZEP+CLBx4U9ZqXOrgmrszCA/JxYcv6kZEroqfnnE3HoiI0Xkl/s6ib1YzExQKTpxh9A EPJaVlxAN7HdailIS3q3DbddcRcmQE7YZgTkG575iad2EtiT6K6b9UWmjLNInIVE+7D+ SaiA== X-Gm-Message-State: APjAAAUYBFrz7YVpQh0w1YoY7PVZ7el/P9Xa6SmJVL0NcoA1SPiQO/da 2DHfDPRmuS1BR0JLxBA4GCQ= X-Google-Smtp-Source: APXvYqx6Hy6ZToqyhfxi3ILsirSd9XiH/1IasKG57bGpYK4saIqFLVKbqxymeBQznB7AM6J3cHTDEA== X-Received: by 2002:a2e:974f:: with SMTP id f15mr1307378ljj.114.1567484989911; Mon, 02 Sep 2019 21:29:49 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id d25sm2265125lfj.15.2019.09.02.21.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Sep 2019 21:29:49 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Kalle Valo Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , Winnie Chang , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 1/3] brcmfmac: move "cfg80211_ops" pointer to another struct Date: Tue, 3 Sep 2019 06:29:26 +0200 Message-Id: <20190903042928.18621-2-zajec5@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903042928.18621-1-zajec5@gmail.com> References: <20190903042928.18621-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 From: Rafał Miłecki This moves "ops" pointer from "struct brcmf_cfg80211_info" to the "struct brcmf_pub". This movement makes it possible to allocate wiphy without attaching cfg80211 (brcmf_cfg80211_attach()). It's required for later separation of wiphy allocation and driver initialization. While at it fix also an unlikely memory leak in the brcmf_attach(). Signed-off-by: Rafał Miłecki --- .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 1 - .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h | 1 - drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 9 ++++++--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 581d0013f33e..c476f854f3ae 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -7210,7 +7210,6 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg) brcmf_pno_detach(cfg); brcmf_btcoex_detach(cfg); wiphy_unregister(cfg->wiphy); - kfree(cfg->ops); wl_deinit_priv(cfg); brcmf_free_wiphy(cfg->wiphy); kfree(cfg); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h index b7b50b07f776..14d5bbad1db1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h @@ -292,7 +292,6 @@ struct brcmf_cfg80211_wowl { */ struct brcmf_cfg80211_info { struct wiphy *wiphy; - struct cfg80211_ops *ops; struct brcmf_cfg80211_conf *conf; struct brcmf_p2p_info p2p; struct brcmf_btcoex_info *btcoex; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index 21e07d1ceeae..e8c488376ff9 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -1224,12 +1224,15 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) return -ENOMEM; wiphy = wiphy_new(ops, sizeof(*drvr)); - if (!wiphy) + if (!wiphy) { + kfree(ops); return -ENOMEM; + } set_wiphy_dev(wiphy, dev); drvr = wiphy_priv(wiphy); drvr->wiphy = wiphy; + drvr->ops = ops; for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++) drvr->if2bss[i] = BRCMF_BSSIDX_INVALID; @@ -1262,12 +1265,10 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) goto fail; } - drvr->config->ops = ops; return 0; fail: brcmf_detach(dev); - kfree(ops); return ret; } @@ -1353,6 +1354,8 @@ void brcmf_detach(struct device *dev) bus_if->drvr = NULL; + kfree(drvr->ops); + wiphy_free(drvr->wiphy); } diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h index 86517a3d74b1..6699637d3bf8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h @@ -97,6 +97,7 @@ struct brcmf_pub { struct brcmf_bus *bus_if; struct brcmf_proto *proto; struct wiphy *wiphy; + struct cfg80211_ops *ops; struct brcmf_cfg80211_info *config; /* Internal brcmf items */ From patchwork Tue Sep 3 04:29:27 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: 11127165 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D29713B1 for ; Tue, 3 Sep 2019 04:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0AC3721897 for ; Tue, 3 Sep 2019 04:29:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hDrJSzrg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbfICE3z (ORCPT ); Tue, 3 Sep 2019 00:29:55 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35984 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726142AbfICE3y (ORCPT ); Tue, 3 Sep 2019 00:29:54 -0400 Received: by mail-lj1-f194.google.com with SMTP id l20so139096ljj.3 for ; Mon, 02 Sep 2019 21:29:52 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=xd1Alt9j2r8DmeeHg4iVBf4lvIDi1nSctRfRervr+Wo=; b=hDrJSzrght0RtbDsgKpQzwdf8zXtvFc7siniMrTbkKoARcQwl6hhivgpVfKew2nQaQ lWSNZkkiK4E2OoqbdngLNg8BpklKxDDcex6sKgJ78zcc2CMiFI7mRk/4yKWJqJq3qzi/ P4VYA/PMtqvbOVTWVrPLu1fuh30BGLH1tuNfvxQRJaGD2fBk1oYAmOxmS4IQpNRVuz0Y tzK5gX3ZtzSxrrcafasmYEBQsVLPhfQyNCC6TMBqLyoqQ4Ea8SrTOZdqEDxXOHKqaGcK GBFtvcTkvKFyGFXuj7uDlUpsIV9D127Uzafc/uVe/6UlOwYbJxnJ2fXxdQ89jBe9KlFi 4W0w== 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=xd1Alt9j2r8DmeeHg4iVBf4lvIDi1nSctRfRervr+Wo=; b=tvC1FFFq2UuTV6Nap8Q024CMCSnlQZu2Nv85jrcLo2ZZCdgvoaRrxQaOg+RTZ06TuB zo6yv3Du0DLHztI1ZK6PUbDGb70RVZZSVCbxb0Hh2D9TKnkIlQFzvFRhO9Yvu5/XymaR KYkJZIvs+iAoQ1iNsSLQXnGPN4FZiSL9edg0SDbDxuf9+9kOS8Mb3td7KySw6KT+ZOlT 8wQuTYCS30Mq674zK0xaBJs+YeqhztIWgxA7S7htwzOBSvjgJGbMdsf2PQ3irWnx3m++ +W5YTVIl4TeGGplHeX6JCS/QE6YyxPTtnKgX8JBRVciqyWzdjZZTeEOT1ttiTb3brejS WWCg== X-Gm-Message-State: APjAAAWjI5xbmgsNVnBzOtR9k/NarOZ6a8teYjPqDWxv5Tk94f1NpiJB +dkz97zU2QT/sJ7wGV8qjiw= X-Google-Smtp-Source: APXvYqx33LDjbOavO2kg95NmURJDE1aNNjon2FMZZ9alALL6Rkp+EF69u3QxjEYuRDwPxhyAOwS7Lg== X-Received: by 2002:a05:651c:292:: with SMTP id b18mr2035149ljo.131.1567484992191; Mon, 02 Sep 2019 21:29:52 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id d25sm2265125lfj.15.2019.09.02.21.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Sep 2019 21:29:51 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Kalle Valo Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , Winnie Chang , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 2/3] brcmfmac: split brcmf_attach() and brcmf_detach() functions Date: Tue, 3 Sep 2019 06:29:27 +0200 Message-Id: <20190903042928.18621-3-zajec5@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903042928.18621-1-zajec5@gmail.com> References: <20190903042928.18621-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 From: Rafał Miłecki Move code allocating/freeing wiphy out of above functions. This will allow reinitializing the driver (e.g. on some error) without allocating a new wiphy. Signed-off-by: Rafał Miłecki Acked-by: Arend van Spriel --- .../broadcom/brcm80211/brcmfmac/bus.h | 4 ++- .../broadcom/brcm80211/brcmfmac/core.c | 33 ++++++++++++++---- .../broadcom/brcm80211/brcmfmac/pcie.c | 13 +++++-- .../broadcom/brcm80211/brcmfmac/sdio.c | 15 ++++++-- .../broadcom/brcm80211/brcmfmac/usb.c | 34 +++++++++++++++---- 5 files changed, 80 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h index 0988a166a785..623c0168da79 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h @@ -253,10 +253,12 @@ void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event); /* Receive async event packet from firmware. Callee disposes of rxp. */ void brcmf_rx_event(struct device *dev, struct sk_buff *rxp); +int brcmf_alloc(struct device *dev, struct brcmf_mp_device *settings); /* Indication from bus module regarding presence/insertion of dongle. */ -int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings); +int brcmf_attach(struct device *dev); /* Indication from bus module regarding removal/absence of dongle */ void brcmf_detach(struct device *dev); +void brcmf_free(struct device *dev); /* Indication from bus module that dongle should be reset */ void brcmf_dev_reset(struct device *dev); /* Request from bus module to initiate a coredump */ diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index e8c488376ff9..406b367c284c 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -1209,13 +1209,11 @@ static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops) return ret; } -int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) +int brcmf_alloc(struct device *dev, struct brcmf_mp_device *settings) { struct wiphy *wiphy; struct cfg80211_ops *ops; struct brcmf_pub *drvr = NULL; - int ret = 0; - int i; brcmf_dbg(TRACE, "Enter\n"); @@ -1233,6 +1231,21 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) drvr = wiphy_priv(wiphy); drvr->wiphy = wiphy; drvr->ops = ops; + drvr->bus_if = dev_get_drvdata(dev); + drvr->bus_if->drvr = drvr; + drvr->settings = settings; + + return 0; +} + +int brcmf_attach(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pub *drvr = bus_if->drvr; + int ret = 0; + int i; + + brcmf_dbg(TRACE, "Enter\n"); for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++) drvr->if2bss[i] = BRCMF_BSSIDX_INVALID; @@ -1241,9 +1254,6 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) /* Link to bus module */ drvr->hdrlen = 0; - drvr->bus_if = dev_get_drvdata(dev); - drvr->bus_if->drvr = drvr; - drvr->settings = settings; /* Attach and link in the protocol */ ret = brcmf_proto_attach(drvr); @@ -1259,7 +1269,7 @@ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings) /* attach firmware event handler */ brcmf_fweh_attach(drvr); - ret = brcmf_bus_started(drvr, ops); + ret = brcmf_bus_started(drvr, drvr->ops); if (ret != 0) { bphy_err(drvr, "dongle is not responding: err=%d\n", ret); goto fail; @@ -1351,6 +1361,15 @@ void brcmf_detach(struct device *dev) brcmf_cfg80211_detach(drvr->config); drvr->config = NULL; } +} + +void brcmf_free(struct device *dev) +{ + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_pub *drvr = bus_if->drvr; + + if (!drvr) + return; bus_if->drvr = NULL; diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 7ac945369762..b01b33e99c14 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1430,6 +1430,7 @@ static int brcmf_pcie_reset(struct device *dev) brcmf_pcie_bus_console_read(devinfo, true); brcmf_detach(dev); + brcmf_free(dev); brcmf_pcie_release_irq(devinfo); brcmf_pcie_release_scratchbuffers(devinfo); @@ -1824,11 +1825,18 @@ static void brcmf_pcie_setup(struct device *dev, int ret, brcmf_pcie_intr_enable(devinfo); brcmf_pcie_hostready(devinfo); - if (brcmf_attach(&devinfo->pdev->dev, devinfo->settings) == 0) - return; + + ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings); + if (ret) + goto fail; + ret = brcmf_attach(&devinfo->pdev->dev); + if (ret) + goto fail; brcmf_pcie_bus_console_read(devinfo, false); + return; + fail: device_release_driver(dev); } @@ -1971,6 +1979,7 @@ brcmf_pcie_remove(struct pci_dev *pdev) brcmf_pcie_intr_disable(devinfo); brcmf_detach(&pdev->dev); + brcmf_free(&pdev->dev); kfree(bus->bus_priv.pcie); kfree(bus->msgbuf->flowrings); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c index 629140b6d7e2..264ad63232f8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c @@ -4247,17 +4247,26 @@ static void brcmf_sdio_firmware_callback(struct device *dev, int err, sdiod->bus_if->chip = bus->ci->chip; sdiod->bus_if->chiprev = bus->ci->chiprev; + err = brcmf_alloc(sdiod->dev, sdiod->settings); + if (err) { + brcmf_err("brcmf_alloc failed\n"); + goto claim; + } + /* Attach to the common layer, reserve hdr space */ - err = brcmf_attach(sdiod->dev, sdiod->settings); + err = brcmf_attach(sdiod->dev); if (err != 0) { brcmf_err("brcmf_attach failed\n"); - sdio_claim_host(sdiod->func1); - goto checkdied; + goto free; } /* ready */ return; +free: + brcmf_free(sdiod->dev); +claim: + sdio_claim_host(sdiod->func1); checkdied: brcmf_sdio_checkdied(bus); release: diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c index d33628b79a3a..06f3c01f10b3 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c @@ -1178,8 +1178,12 @@ static void brcmf_usb_probe_phase2(struct device *dev, int ret, if (ret) goto error; + ret = brcmf_alloc(devinfo->dev, devinfo->settings); + if (ret) + goto error; + /* Attach to the common driver interface */ - ret = brcmf_attach(devinfo->dev, devinfo->settings); + ret = brcmf_attach(devinfo->dev); if (ret) goto error; @@ -1251,7 +1255,10 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) } if (!brcmf_usb_dlneeded(devinfo)) { - ret = brcmf_attach(devinfo->dev, devinfo->settings); + ret = brcmf_alloc(devinfo->dev, devinfo->settings); + if (ret) + goto fail; + ret = brcmf_attach(devinfo->dev); if (ret) goto fail; /* we are done */ @@ -1279,6 +1286,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) fail: /* Release resources in reverse order */ + brcmf_free(devinfo->dev); kfree(bus); brcmf_usb_detach(devinfo); return ret; @@ -1292,6 +1300,7 @@ brcmf_usb_disconnect_cb(struct brcmf_usbdev_info *devinfo) brcmf_dbg(USB, "Enter, bus_pub %p\n", devinfo); brcmf_detach(devinfo->dev); + brcmf_free(devinfo->dev); kfree(devinfo->bus_pub.bus); brcmf_usb_detach(devinfo); } @@ -1435,10 +1444,12 @@ static int brcmf_usb_suspend(struct usb_interface *intf, pm_message_t state) brcmf_dbg(USB, "Enter\n"); devinfo->bus_pub.state = BRCMFMAC_USB_STATE_SLEEP; - if (devinfo->wowl_enabled) + if (devinfo->wowl_enabled) { brcmf_cancel_all_urbs(devinfo); - else + } else { brcmf_detach(&usb->dev); + brcmf_free(&usb->dev); + } return 0; } @@ -1451,8 +1462,19 @@ static int brcmf_usb_resume(struct usb_interface *intf) struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(&usb->dev); brcmf_dbg(USB, "Enter\n"); - if (!devinfo->wowl_enabled) - return brcmf_attach(devinfo->dev, devinfo->settings); + if (!devinfo->wowl_enabled) { + int err; + + err = brcmf_alloc(&usb->dev, devinfo->settings); + if (err) + return err; + + err = brcmf_attach(devinfo->dev); + if (err) { + brcmf_free(devinfo->dev); + return err; + } + } devinfo->bus_pub.state = BRCMFMAC_USB_STATE_UP; brcmf_usb_rx_fill_all(devinfo); From patchwork Tue Sep 3 04:29:28 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: 11127167 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80E8F14DE for ; Tue, 3 Sep 2019 04:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57AB422D6D for ; Tue, 3 Sep 2019 04:29:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kS0CeNGq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbfICE34 (ORCPT ); Tue, 3 Sep 2019 00:29:56 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35529 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbfICE34 (ORCPT ); Tue, 3 Sep 2019 00:29:56 -0400 Received: by mail-lj1-f194.google.com with SMTP id l14so14607357lje.2 for ; Mon, 02 Sep 2019 21:29:55 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=FGsNyS9+7uW1WVXEB7vhNVK26nLysHjh5G+batUF3LQ=; b=kS0CeNGq2940wPbthAV5JxtvXyrpYKrifw5/gkcmzAsVUiJO0Ntv/eBYkSotbprSSK 5n5cfuUyGP+RjI6NR5PPRsRCauQDZYoRLKfunP3rLXeCA75lJS6jfKxUKObhShRqEsUR VjaQ5XxaNKcfFPH33Pgm1Yl8kTXb7HkIeHXIBe/sirRYlLVs9Xr62UVRorlrjvVl7hCH O++XDia9w49ivxJhurP3HzUHY6aqskFA4GyOY6TnZRi5Psu5f31CijEQhVSKtN+p9wsv ll/qn+ewvliql9c2NliLJsdFd/mRrz/IpVljFRt3CeBT6otUqHVkS5gNn7vRIvS1Pg4S QURg== 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=FGsNyS9+7uW1WVXEB7vhNVK26nLysHjh5G+batUF3LQ=; b=XM0Kx+0lju+SXPJhTlBps8rI3MhlRsHqCnICgF/qwDJnsfFOkRbWRGtFbFVcVeqF5N fpmuj2qomYuAPb8nkDvhTCWmw7tbn0mSLzS6oEI5hEXI4FMLa7cIKGuDpl6s2UFt3lbc lhyTXVyCN8SVwBHAnaMKjOJSbjHh9Bx6TlojfuVBe2wHI5PXzgObl823txv6VUoUSh29 cd4XdEWPxog6tqHnA95mNWX5lGqpFcs9rcTaH9WlFB8yj86qpe6cbVtHSj0HFSQ9rql8 YuvaYRmesT2hrQf0J06eRnz5Lia+GkKPbU1TXX70ar9cjH2t0W3lM/W6WN+sYord1+Wl fvPg== X-Gm-Message-State: APjAAAUx+wl4qSvqdMhW8RSN57cPuWthub6DfD6LqxJU1cB7wwEKCRU+ 2oLVjHVIwgUamXOaeh0DA0g= X-Google-Smtp-Source: APXvYqyn3Rd78qwyyF3ZMpacdRgXLflX9aXoOh8s8CA9W0GyEPXWqoPsyVbDzWQFl2Lg1cGvfC8n6A== X-Received: by 2002:a2e:7604:: with SMTP id r4mr18358076ljc.225.1567484994377; Mon, 02 Sep 2019 21:29:54 -0700 (PDT) Received: from localhost.localdomain (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id d25sm2265125lfj.15.2019.09.02.21.29.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Sep 2019 21:29:53 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Kalle Valo Cc: Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , Winnie Chang , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 3/3] brcmfmac: don't realloc wiphy during PCIe reset Date: Tue, 3 Sep 2019 06:29:28 +0200 Message-Id: <20190903042928.18621-4-zajec5@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190903042928.18621-1-zajec5@gmail.com> References: <20190903042928.18621-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 From: Rafał Miłecki Providing a new wiphy on every PCIe reset was confusing and was causing configuration problems for some users (supplicant and authenticators). Sticking to the existing wiphy should make error recovery much simpler and more reliable. Signed-off-by: Rafał Miłecki Acked-by: Arend van Spriel --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index b01b33e99c14..6c463475e90b 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1430,7 +1430,6 @@ static int brcmf_pcie_reset(struct device *dev) brcmf_pcie_bus_console_read(devinfo, true); brcmf_detach(dev); - brcmf_free(dev); brcmf_pcie_release_irq(devinfo); brcmf_pcie_release_scratchbuffers(devinfo); @@ -1826,9 +1825,6 @@ static void brcmf_pcie_setup(struct device *dev, int ret, brcmf_pcie_intr_enable(devinfo); brcmf_pcie_hostready(devinfo); - ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings); - if (ret) - goto fail; ret = brcmf_attach(&devinfo->pdev->dev); if (ret) goto fail; @@ -1931,6 +1927,10 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) bus->wowl_supported = pci_pme_capable(pdev, PCI_D3hot); dev_set_drvdata(&pdev->dev, bus); + ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings); + if (ret) + goto fail_bus; + fwreq = brcmf_pcie_prepare_fw_request(devinfo); if (!fwreq) { ret = -ENOMEM;