Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5251717rwb; Mon, 31 Jul 2023 22:21:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFK1hOSLvgNNqVI6misryy2/h2niM4LyiGiIShjOgaqD5p8mE83HXk7xd7ipC7P/pR81clI X-Received: by 2002:aa7:cd0f:0:b0:522:1f34:2265 with SMTP id b15-20020aa7cd0f000000b005221f342265mr1495680edw.2.1690867313403; Mon, 31 Jul 2023 22:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690867313; cv=none; d=google.com; s=arc-20160816; b=JgLMpJ82AmbD1TmXMA32zYG2iviKIC6o+zIGbea+L3w/L6uCp7WsMzVwuejh+1PaN2 zqfb8UT6gVqwQe4eqUIrPn/780MaD7GAn7mTOvYaW/8yh20Wx8qkxNC8YCkYDrh846mJ nC1le9KRLc0zsMVZDoHBzwjN1L9Qa4g74Tl0WgLjKsjvoUxlBSw108wQFl8F2Hc+2YdH +wQJ2vEd8QKUSuAWF+8n6gzCyNJl5oWWWgoxpRg/YanQWiixaittHYOWNIoi0w5dBlpx uNzXzndTwn8mqPhZdchiPb6c+8Nxrhd/SDa+PxneB9kXalBpu9rz5T1OATNO/RIRaYir UvIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W5W7rPkOZCjf4eEXAecF+cJutWQYN7zZF7eEwmOs6zQ=; fh=B6NRqkP7H2f/6hGUq4XZ1bcu8tCBRUaRe/xed2j1WFQ=; b=Syhqj/Tm2yVeRBuaQEtLXhFqCanTc7k+PmPJQJFtwYD2GzixDFG+gbqTLnaAWvSkQc UDKvQHA8m8HosRZodmo5iZ2lQyKi6ntuGlHxKTu8i/r7KE1eiv/jUQlm0E904l3ZasZr ptLGMeRc3pArEyv65oZaOMRdmOJpq16FSiS9VWnHieb/UydVbLtDYaR/+QWwj+CinQH0 u2P7LwSnengdvNWX4bANNSOTLB4jHSnrln2IUuFwzSP8I/BPisEHr8EzTtzUf8EETIUV vXgJo9So0XJaqP02DXs6bdY6aSpCm8ktxcR/viEAIlCJKPM10HclKMiLONhy5Kc6t2O0 qxNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=jhddqpnv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020aa7d80a000000b005223a5a81d1si7922493edq.247.2023.07.31.22.21.34; Mon, 31 Jul 2023 22:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=jhddqpnv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbjHAFAM (ORCPT + 59 others); Tue, 1 Aug 2023 01:00:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjHAFAL (ORCPT ); Tue, 1 Aug 2023 01:00:11 -0400 Received: from forward101a.mail.yandex.net (forward101a.mail.yandex.net [178.154.239.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E551FC3 for ; Mon, 31 Jul 2023 22:00:09 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:170e:0:640:d60c:0]) by forward101a.mail.yandex.net (Yandex) with ESMTP id 2D5BD46C76; Tue, 1 Aug 2023 08:00:07 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 40Ji1unDfW20-Ox7efaRJ; Tue, 01 Aug 2023 08:00:06 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690866006; bh=W5W7rPkOZCjf4eEXAecF+cJutWQYN7zZF7eEwmOs6zQ=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=jhddqpnvmCXdXXllRhyORPvrF7fxbqEqlI5ksG449oHtTQKwzE5mdc6VO7RkEEKBa 1qmH3TwKqwxmoggMIIhTLU0zdOJqnAlNLN0Nxy9QbmZctyDCHuXd/jg+ERB9ESLFff xUdVjbdNhjwwIeoF8xxRX8d+qK1ZWPZOrgjLhA/o= Authentication-Results: mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Felix Fietkau Cc: Kalle Valo , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 2/4] wifi: mt76: handle possible hardware timeout in mt7603_pse_client_reset() Date: Tue, 1 Aug 2023 07:57:21 +0300 Message-ID: <20230801050000.18864-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801050000.18864-1-dmantipov@yandex.ru> References: <20230801050000.18864-1-dmantipov@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Handle possible 'mt76_poll_msec()' timeout in 'mt7603_pse_client_reset()', convert the latter from 'void' to return 'int', propagate return value to 'mt7603_dma_init()' and 'WARN_ON()' on it in 'mt7603_mac_watchdog_reset()'. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/mediatek/mt76/mt7603/dma.c | 4 +++- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 16 ++++++++++------ .../net/wireless/mediatek/mt76/mt7603/mt7603.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c index 03ba11a61c90..15c6564f212a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/dma.c @@ -169,7 +169,9 @@ int mt7603_dma_init(struct mt7603_dev *dev) MT_WPDMA_GLO_CFG_TX_WRITEBACK_DONE); mt76_wr(dev, MT_WPDMA_RST_IDX, ~0); - mt7603_pse_client_reset(dev); + ret = mt7603_pse_client_reset(dev); + if (ret) + return ret; for (i = 0; i < ARRAY_SIZE(wmm_queue_map); i++) { ret = mt76_init_tx_queue(&dev->mphy, i, wmm_queue_map[i], diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 12e0af52082a..fe38b9a8034d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c @@ -1367,7 +1367,7 @@ void mt7603_mac_stop(struct mt7603_dev *dev) mt76_clear(dev, MT_WF_ARB_RQCR, MT_WF_ARB_RQCR_RX_START); } -void mt7603_pse_client_reset(struct mt7603_dev *dev) +int mt7603_pse_client_reset(struct mt7603_dev *dev) { u32 addr; @@ -1383,20 +1383,24 @@ void mt7603_pse_client_reset(struct mt7603_dev *dev) /* Start PSE client TX abort */ mt76_set(dev, addr, MT_CLIENT_RESET_TX_R_E_1); - mt76_poll_msec(dev, addr, MT_CLIENT_RESET_TX_R_E_1_S, - MT_CLIENT_RESET_TX_R_E_1_S, 500); + if (!mt76_poll_msec(dev, addr, MT_CLIENT_RESET_TX_R_E_1_S, + MT_CLIENT_RESET_TX_R_E_1_S, 500)) + return -ETIMEDOUT; mt76_set(dev, addr, MT_CLIENT_RESET_TX_R_E_2); mt76_set(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_SW_RESET); /* Wait for PSE client to clear TX FIFO */ - mt76_poll_msec(dev, addr, MT_CLIENT_RESET_TX_R_E_2_S, - MT_CLIENT_RESET_TX_R_E_2_S, 500); + if (!mt76_poll_msec(dev, addr, MT_CLIENT_RESET_TX_R_E_2_S, + MT_CLIENT_RESET_TX_R_E_2_S, 500)) + return -ETIMEDOUT; /* Clear PSE client TX abort state */ mt76_clear(dev, addr, MT_CLIENT_RESET_TX_R_E_1 | MT_CLIENT_RESET_TX_R_E_2); + + return 0; } static void mt7603_dma_sched_reset(struct mt7603_dev *dev) @@ -1450,7 +1454,7 @@ static void mt7603_mac_watchdog_reset(struct mt7603_dev *dev) mt76_set(dev, MT_WPDMA_GLO_CFG, MT_WPDMA_GLO_CFG_FORCE_TX_EOF); - mt7603_pse_client_reset(dev); + WARN_ON(mt7603_pse_client_reset(dev) < 0); mt76_queue_tx_cleanup(dev, dev->mt76.q_mcu[MT_MCUQ_WM], true); for (i = 0; i < __MT_TXQ_MAX; i++) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h index 7c3be596da09..d651a13efe8c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mt7603.h @@ -215,7 +215,7 @@ void mt7603_mac_tx_ba_reset(struct mt7603_dev *dev, int wcid, int tid, int ba_size); void mt7603_mac_sta_poll(struct mt7603_dev *dev); -void mt7603_pse_client_reset(struct mt7603_dev *dev); +int mt7603_pse_client_reset(struct mt7603_dev *dev); int mt7603_mcu_set_channel(struct mt7603_dev *dev); int mt7603_mcu_set_eeprom(struct mt7603_dev *dev); -- 2.41.0