From patchwork Wed Jun 7 16:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 691151 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F6EDC77B7A for ; Wed, 7 Jun 2023 16:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233336AbjFGQQh (ORCPT ); Wed, 7 Jun 2023 12:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238363AbjFGQQf (ORCPT ); Wed, 7 Jun 2023 12:16:35 -0400 Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F86199D for ; Wed, 7 Jun 2023 09:16:33 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:6e01:0:640:627f:0]) by forward100b.mail.yandex.net (Yandex) with ESMTP id C7A466004A; Wed, 7 Jun 2023 19:16:31 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id KGX7fTADXSw0-Z7GhDIYG; Wed, 07 Jun 2023 19:16:31 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1686154591; bh=FKy9jnvA+7Y7SWCGMGxUppexL6ZNvSWKfqcugwV1E6E=; h=Message-Id:Date:Cc:Subject:To:From; b=EjkbO0+btHmbhSYVMA1decB98dITHjccXiYIUAh9h/+3ontgIQ7s4/trnCtOTQsEM JQ2luVvdMEVSnjn67Je5C5kNZQY/6+kJvE9+i11ql6R6IlItWDrimOnLZ3z02PjzlQ HlWpRz9p8HDDcQZppfs9cnc16uAxhpTH1QxiypJ0= Authentication-Results: mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Franky Lin Cc: brcm80211-dev-list.pdl@broadcom.com, linux-wireless@vger.kernel.org, Kalle Valo , lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 1/3] wifi: brcmfmac: handle possible WOWL configuration error Date: Wed, 7 Jun 2023 19:16:08 +0300 Message-Id: <20230607161611.85106-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Convert 'brcmf_configure_wowl()' to return 's32' which may be an error raised by 'brcmf_fil_iovar_data_set()', pass the value to 'brcmf_cfg80211_suspend()' and adjust related code. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov --- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index de8a2e27f49c..5a0b32322b4f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -4175,12 +4175,13 @@ static s32 brcmf_cfg80211_resume(struct wiphy *wiphy) return 0; } -static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg, - struct brcmf_if *ifp, - struct cfg80211_wowlan *wowl) +static s32 brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg, + struct brcmf_if *ifp, + struct cfg80211_wowlan *wowl) { u32 wowl_config; struct brcmf_wowl_wakeind_le wowl_wakeind; + s32 err = 0; u32 i; brcmf_dbg(TRACE, "Suspend, wowl config.\n"); @@ -4223,12 +4224,15 @@ static void brcmf_configure_wowl(struct brcmf_cfg80211_info *cfg, wowl_config |= BRCMF_WOWL_UNASSOC; memcpy(&wowl_wakeind, "clear", 6); - brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind, - sizeof(wowl_wakeind)); - brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config); - brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1); - brcmf_bus_wowl_config(cfg->pub->bus_if, true); - cfg->wowl.active = true; + err = brcmf_fil_iovar_data_set(ifp, "wowl_wakeind", &wowl_wakeind, + sizeof(wowl_wakeind)); + if (err == 0) { + brcmf_fil_iovar_int_set(ifp, "wowl", wowl_config); + brcmf_fil_iovar_int_set(ifp, "wowl_activate", 1); + brcmf_bus_wowl_config(cfg->pub->bus_if, true); + cfg->wowl.active = true; + } + return err; } static int brcmf_keepalive_start(struct brcmf_if *ifp, unsigned int interval) @@ -4256,6 +4260,7 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, struct net_device *ndev = cfg_to_ndev(cfg); struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_cfg80211_vif *vif; + s32 err = 0; brcmf_dbg(TRACE, "Enter\n"); @@ -4293,18 +4298,19 @@ static s32 brcmf_cfg80211_suspend(struct wiphy *wiphy, brcmf_set_mpc(ifp, 1); } else { - /* Configure WOWL paramaters */ - brcmf_configure_wowl(cfg, ifp, wowl); + /* Configure WOWL parameters */ + err = brcmf_configure_wowl(cfg, ifp, wowl); /* Prevent disassociation due to inactivity with keep-alive */ - brcmf_keepalive_start(ifp, 30); + if (err == 0) + brcmf_keepalive_start(ifp, 30); } exit: brcmf_dbg(TRACE, "Exit\n"); /* clear any scanning activity */ cfg->scan_status = 0; - return 0; + return err; } static s32 From patchwork Wed Jun 7 16:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 690500 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56829C7EE2F for ; Wed, 7 Jun 2023 16:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239899AbjFGQQk (ORCPT ); Wed, 7 Jun 2023 12:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238577AbjFGQQh (ORCPT ); Wed, 7 Jun 2023 12:16:37 -0400 Received: from forward102b.mail.yandex.net (forward102b.mail.yandex.net [178.154.239.149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58EA199D for ; Wed, 7 Jun 2023 09:16:35 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:6e01:0:640:627f:0]) by forward102b.mail.yandex.net (Yandex) with ESMTP id 500C860031; Wed, 7 Jun 2023 19:16:34 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id KGX7fTADXSw0-pr1UYybQ; Wed, 07 Jun 2023 19:16:34 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1686154594; bh=fnlyunCbB9cj/57wkDEeWYriIa21VhOlUzGg1mysQ7Y=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=h0M4h+cX0bidSyHBzqwLZMkqXKOrILm2veHWkN0/zMb6qCSKeXz/xDzgKwOmaLYZ/ c6APFv+c8H1EQMNp1/Hb9sFalXTfNjdtaLECjvrgy6Q0ftKr+mDc9rHUrh/5FxLkXo 19+ea8ihzRNshtyn2PE72twN8JIoDX0hGqR7A3J4= Authentication-Results: mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Franky Lin Cc: brcm80211-dev-list.pdl@broadcom.com, linux-wireless@vger.kernel.org, Kalle Valo , lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 2/3] wifi: brcmfmac: handle possible completion timeouts Date: Wed, 7 Jun 2023 19:16:09 +0300 Message-Id: <20230607161611.85106-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607161611.85106-1-dmantipov@yandex.ru> References: <20230607161611.85106-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Handle possible 'wait_for_completion_timeout()' errors in 'brcmf_p2p_af_searching_channel()', ' brcmf_p2p_tx_action_frame()' and 'brcmf_p2p_del_vif()', adjust related code. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov --- .../broadcom/brcm80211/brcmfmac/p2p.c | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index d4492d02e4ea..9e383e6cab21 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c @@ -1173,8 +1173,10 @@ static s32 brcmf_p2p_af_searching_channel(struct brcmf_p2p_info *p2p) retry); /* search peer on peer's listen channel */ schedule_work(&afx_hdl->afx_work); - wait_for_completion_timeout(&afx_hdl->act_frm_scan, - P2P_AF_FRM_SCAN_MAX_WAIT); + if (!wait_for_completion_timeout(&afx_hdl->act_frm_scan, + P2P_AF_FRM_SCAN_MAX_WAIT)) + /* timed out */ + afx_hdl->peer_chan = P2P_INVALID_CHANNEL; if ((afx_hdl->peer_chan != P2P_INVALID_CHANNEL) || (!test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status))) @@ -1186,8 +1188,10 @@ static s32 brcmf_p2p_af_searching_channel(struct brcmf_p2p_info *p2p) /* listen on my listen channel */ afx_hdl->is_listen = true; schedule_work(&afx_hdl->afx_work); - wait_for_completion_timeout(&afx_hdl->act_frm_scan, - P2P_AF_FRM_SCAN_MAX_WAIT); + if (!wait_for_completion_timeout + (&afx_hdl->act_frm_scan, P2P_AF_FRM_SCAN_MAX_WAIT)) + /* timed out */ + afx_hdl->peer_chan = P2P_INVALID_CHANNEL; } if ((afx_hdl->peer_chan != P2P_INVALID_CHANNEL) || (!test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, @@ -1580,14 +1584,20 @@ static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p, (p2p->wait_for_offchan_complete) ? "off-channel" : "on-channel"); - wait_for_completion_timeout(&p2p->send_af_done, P2P_AF_MAX_WAIT_TIME); - + if (!wait_for_completion_timeout(&p2p->send_af_done, + P2P_AF_MAX_WAIT_TIME)) { + err = -ETIMEDOUT; + goto clear; + } if (test_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status)) { - brcmf_dbg(TRACE, "TX action frame operation is success\n"); + err = 0; + brcmf_dbg(TRACE, "TX action frame operation has succeeded\n"); } else { err = -EIO; brcmf_dbg(TRACE, "TX action frame operation has failed\n"); } + +clear: /* clear status bit for action tx */ clear_bit(BRCMF_P2P_STATUS_ACTION_TX_COMPLETED, &p2p->status); clear_bit(BRCMF_P2P_STATUS_ACTION_TX_NOACK, &p2p->status); @@ -2404,10 +2414,10 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) brcmf_dbg(INFO, "P2P: GO_NEG_PHASE status cleared\n"); if (wait_for_disable) - wait_for_completion_timeout(&cfg->vif_disabled, - BRCMF_P2P_DISABLE_TIMEOUT); + err = (wait_for_completion_timeout(&cfg->vif_disabled, + BRCMF_P2P_DISABLE_TIMEOUT) + ? 0 : -ETIMEDOUT); - err = 0; if (iftype != NL80211_IFTYPE_P2P_DEVICE) { brcmf_vif_clear_mgmt_ies(vif); err = brcmf_p2p_release_p2p_if(vif); From patchwork Wed Jun 7 16:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 691150 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 928DEC7EE23 for ; Wed, 7 Jun 2023 16:16:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234874AbjFGQQo (ORCPT ); Wed, 7 Jun 2023 12:16:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjFGQQm (ORCPT ); Wed, 7 Jun 2023 12:16:42 -0400 Received: from forward101c.mail.yandex.net (forward101c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DE6F1BF8 for ; Wed, 7 Jun 2023 09:16:40 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net [IPv6:2a02:6b8:c14:6e01:0:640:627f:0]) by forward101c.mail.yandex.net (Yandex) with ESMTP id EF1C560045; Wed, 7 Jun 2023 19:16:38 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id KGX7fTADXSw0-rF2zrjxU; Wed, 07 Jun 2023 19:16:38 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1686154598; bh=cZjh3SNsHicEetTbgG/03B9ec8uS3ctpisatKaG6ePU=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=DOnLbSusrLhFJEVU5kDThvzwHvORI6dNFMvXebkKbRRwOcxwk2rl4jM4lKEuf3eVo R29AWfvczFYFdEebw4lXfAgI8TAcmu29LjUbbo0ZJvlPoPLOhcJysA8DWn9ZTmsbZ1 feaghkCzE9/NhW4358TirOt//QOc1cUp6+dKnfrk= Authentication-Results: mail-nwsmtp-smtp-production-main-63.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Franky Lin Cc: brcm80211-dev-list.pdl@broadcom.com, linux-wireless@vger.kernel.org, Kalle Valo , lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 3/3] wifi: brcmfmac: handle possible MSI enabling error Date: Wed, 7 Jun 2023 19:16:10 +0300 Message-Id: <20230607161611.85106-3-dmantipov@yandex.ru> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607161611.85106-1-dmantipov@yandex.ru> References: <20230607161611.85106-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Handle possible 'pci_enable_msi()' error in 'brcmf_pcie_request_irq()', adjust related code. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov --- .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 80220685f5e4..4d61f241cfaf 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -965,6 +965,7 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) { + int ret; struct pci_dev *pdev = devinfo->pdev; struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev); @@ -972,16 +973,20 @@ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) brcmf_dbg(PCIE, "Enter\n"); - pci_enable_msi(pdev); + ret = pci_enable_msi(pdev); + if (ret) + return ret; if (request_threaded_irq(pdev->irq, brcmf_pcie_quick_check_isr, brcmf_pcie_isr_thread, IRQF_SHARED, "brcmf_pcie_intr", devinfo)) { pci_disable_msi(pdev); brcmf_err(bus, "Failed to request IRQ %d\n", pdev->irq); - return -EIO; + ret = -EIO; + } else { + devinfo->irq_allocated = true; + ret = 0; } - devinfo->irq_allocated = true; - return 0; + return ret; }