From patchwork Wed Jun 14 07:58:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 693640 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 D21BEEB64DA for ; Wed, 14 Jun 2023 07:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242786AbjFNH7J (ORCPT ); Wed, 14 Jun 2023 03:59:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233669AbjFNH7E (ORCPT ); Wed, 14 Jun 2023 03:59:04 -0400 Received: from forward103c.mail.yandex.net (forward103c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F44D10E6 for ; Wed, 14 Jun 2023 00:59:03 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2d23:0:640:2dd6:0]) by forward103c.mail.yandex.net (Yandex) with ESMTP id 4BB516003B; Wed, 14 Jun 2023 10:59:01 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id owVk0cNWxSw0-1VSHv1yR; Wed, 14 Jun 2023 10:59:00 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1686729540; bh=+WR/c4jPrbplUAvIWrC+3q2lfmmDjDlJYI7FptCT3B8=; h=Message-Id:Date:Cc:Subject:To:From; b=rNVuiAMg9H25S1G/7l3kXoQX7bMQJYXbaDRXv/1xjhqCdgWJuB75w9sxRmKoXVR+5 r2UKKeLC8cEGjfihSnxJhDJbE5/P4UDycwdlol7l4yll5FqZseCWgS2N/vIsVGX2XK QI0szW7za+auaTxtdzcxB54vrz1EGB4M0PbNCyzo= Authentication-Results: mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Hante Meuleman Cc: brcm80211-dev-list.pdl@broadcom.com, linux-wireless@vger.kernel.org, Kalle Valo , lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 1/2] [v2] wifi: brcmfmac: handle possible completion timeouts Date: Wed, 14 Jun 2023 10:58:47 +0300 Message-Id: <20230614075848.80536-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 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 Reviewed-by: Arend van Spriel --- v2: rebase against wireless-next tree --- .../broadcom/brcm80211/brcmfmac/p2p.c | 31 +++++++++++++------ 1 file changed, 21 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..e43dabdaeb0b 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c @@ -1151,6 +1151,7 @@ static s32 brcmf_p2p_af_searching_channel(struct brcmf_p2p_info *p2p) { struct afx_hdl *afx_hdl = &p2p->afx_hdl; struct brcmf_cfg80211_vif *pri_vif; + bool timeout = false; s32 retry; brcmf_dbg(TRACE, "Enter\n"); @@ -1173,8 +1174,11 @@ 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)) { + timeout = true; + break; + } if ((afx_hdl->peer_chan != P2P_INVALID_CHANNEL) || (!test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status))) @@ -1186,8 +1190,11 @@ 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)) { + timeout = true; + break; + } } if ((afx_hdl->peer_chan != P2P_INVALID_CHANNEL) || (!test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, @@ -1209,7 +1216,7 @@ static s32 brcmf_p2p_af_searching_channel(struct brcmf_p2p_info *p2p) clear_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL, &p2p->status); - return afx_hdl->peer_chan; + return timeout ? P2P_INVALID_CHANNEL : afx_hdl->peer_chan; } @@ -1580,14 +1587,18 @@ 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"); } 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 +2415,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 14 07:58:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 692992 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 787E1EB64DC for ; Wed, 14 Jun 2023 07:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238659AbjFNH7K (ORCPT ); Wed, 14 Jun 2023 03:59:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238643AbjFNH7G (ORCPT ); Wed, 14 Jun 2023 03:59:06 -0400 Received: from forward103b.mail.yandex.net (forward103b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:d103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2C65CD for ; Wed, 14 Jun 2023 00:59:04 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2d23:0:640:2dd6:0]) by forward103b.mail.yandex.net (Yandex) with ESMTP id 2F9D460137; Wed, 14 Jun 2023 10:59:03 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id owVk0cNWxSw0-mdOT1Vws; Wed, 14 Jun 2023 10:59:02 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1686729542; bh=T3af1EX5TOSDHmdi4O+2cmbHadtXfJLEHnRUhWJsa24=; h=Message-Id:Date:In-Reply-To:Cc:Subject:References:To:From; b=ZFoB2mbmlE7TtWVsb9OF2bBPJPsLSzMql9u60S8IYwhVWNPEAtD7Sr7kjWbyLTMwG +kYOBRcPeL388jaN9SilUgIXR3Az8XaYJdFht31twrVZuajjhneL2dSglmJEiy/b12 vjF2ynM1ersQ0hhAMvEKdnrzBYgio6pcLhBQbcn8= Authentication-Results: mail-nwsmtp-smtp-production-main-45.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Hante Meuleman Cc: brcm80211-dev-list.pdl@broadcom.com, linux-wireless@vger.kernel.org, Kalle Valo , lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 2/2] [v2] wifi: brcmfmac: handle possible MSI enabling error Date: Wed, 14 Jun 2023 10:58:48 +0300 Message-Id: <20230614075848.80536-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230614075848.80536-1-dmantipov@yandex.ru> References: <20230614075848.80536-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 Reviewed-by: Arend van Spriel --- v2: rebase against wireless-next tree --- .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 12 ++++++++---- 1 file changed, 8 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..f7d9f2cbd60b 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,19 @@ 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; } - devinfo->irq_allocated = true; - return 0; + return ret; }