Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp615342rdb; Sat, 19 Aug 2023 16:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmacvh7A6msfRcWEcEBCGQA+AwWhrJtoSf7Hs5WK0vnbnCq3NR8mHZpOCqlemKp0jTNJAW X-Received: by 2002:a05:6808:221d:b0:3a7:6d64:aa68 with SMTP id bd29-20020a056808221d00b003a76d64aa68mr5523174oib.18.1692487050753; Sat, 19 Aug 2023 16:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692487050; cv=none; d=google.com; s=arc-20160816; b=foGI5jLX95vo/6r9p27m1WmFgLMS3BMRPLQrxNZb55867Lwzqw5a3/5p8P3T0fIGxC nLFiys3/BYJibMKWShz0vLKrq9cn2G/i0jTbwiSFo3RgvpifByyWctGcXtFNAcSWEzRF P/hrLxPr3ltE3hIt+AM1t8qd/e9PerxwwHqmj7yor9VOskqJI009DJq0aoGUSVE0zzbc cxCRoFoBk/Q5dgjONFM3TRsAG0+9VplwsKFUj0rBhxd1VixIhCgLs/LCOtja3VZrKFk7 Q6AU3Ru1Gj5D1vC77+CoMMIuZqhvQSKbQ80KhDHSCCV/AF1o0zXNp9mi3+Vj7pqteVDF /Lvg== 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 :message-id:date:subject:to:from:dkim-signature; bh=x+PqYStX4lkyfgaEnzOv4kbHTjqVKHbcM0snmKGoh5g=; fh=MXiEBe39BGvQr4EuIas3ehfmU9VgJUgKUy4wMy7Qjj8=; b=nmVAUdBaigmBec61CxTVVqEFuF9o20jRACZUm24+13YkB73jvWxSnSxyP4pbgrE97f GzWOVp1wFGCjmK1HYwp+ollVa18mu7O5Yo4B0y6EETErQSPB83Q9LoZSZAdEwT6QWJFI DIKCQHJB4y9QvEx4bASXJhG1bgD3FnVmkSJi2Oy4gf9Vz+2FZZfZHaYvF3G0bc6ezhzh iUxvAMxRubpYfk/lFLG7n+xyg655T139KdLRGEF41dXXUKrrioZj0+AimquJ/3FCRzaR x8f56BgJ6qiMCJiIjGrZzAqQV4K6EoFQZzQ72Z2sxbzAGJ45UeRBa/Qv2/xDGDYPdndb zPjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ayS5DYBQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q12-20020a056a00150c00b0068874d11df5si4532163pfu.307.2023.08.19.16.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 16:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ayS5DYBQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB24D66E04; Sat, 19 Aug 2023 11:04:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353378AbjHQPx1 (ORCPT + 54 others); Thu, 17 Aug 2023 11:53:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353353AbjHQPxI (ORCPT ); Thu, 17 Aug 2023 11:53:08 -0400 Received: from nbd.name (nbd.name [46.4.11.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DF4730D4 for ; Thu, 17 Aug 2023 08:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: To:From:Sender:Reply-To:Cc:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=x+PqYStX4lkyfgaEnzOv4kbHTjqVKHbcM0snmKGoh5g=; b=ayS5DYBQ8ck6M6w1sQpuwFyeFW y/rjknoCrpJJxRTW7iQbiUQsKqiaVViDFU4Ek9uhkOyKT0IXG2aTiXT9oP6rLufrqEkwUk97NnYbP QlXKSG6XETC9qdmBFF9tJjgYGAcc2KXCrwA66uxO86VV2yi9zLSjbyxG88Nci4Yfx4P4=; Received: from 134.101.185.184.dynamic-pppoe.dt.ipv4.wtnet.de ([134.101.185.184] helo=Maecks.fritz.box) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1qWfJ1-00AmKH-Q0 for linux-wireless@vger.kernel.org; Thu, 17 Aug 2023 17:53:03 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 1/5] wifi: mt76: mt7603: rework/fix rx pse hang check Date: Thu, 17 Aug 2023 17:52:54 +0200 Message-ID: <20230817155258.62636-1-nbd@nbd.name> X-Mailer: git-send-email 2.41.0 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,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE 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 It turns out that the code in mt7603_rx_pse_busy() does not detect actual hardware hangs, it only checks for busy conditions in PSE. A reset should only be performed if these conditions are true and if there is no rx activity as well. Reset the counter whenever a rx interrupt occurs. In order to also deal with a fully loaded CPU that leaves interrupts disabled with continuous NAPI polling, also check for pending rx interrupts in the function itself. Fixes: c8846e101502 ("mt76: add driver for MT7603E and MT7628/7688") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7603/core.c | 2 ++ .../net/wireless/mediatek/mt76/mt7603/mac.c | 23 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/core.c b/drivers/net/wireless/mediatek/mt76/mt7603/core.c index 60a996b63c0c..915b8349146a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/core.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/core.c @@ -42,11 +42,13 @@ irqreturn_t mt7603_irq_handler(int irq, void *dev_instance) } if (intr & MT_INT_RX_DONE(0)) { + dev->rx_pse_check = 0; mt7603_irq_disable(dev, MT_INT_RX_DONE(0)); napi_schedule(&dev->mt76.napi[0]); } if (intr & MT_INT_RX_DONE(1)) { + dev->rx_pse_check = 0; mt7603_irq_disable(dev, MT_INT_RX_DONE(1)); napi_schedule(&dev->mt76.napi[1]); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c index 99ae080502d8..7a506a0c46e2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mac.c @@ -1570,20 +1570,29 @@ static bool mt7603_rx_pse_busy(struct mt7603_dev *dev) { u32 addr, val; - if (mt76_rr(dev, MT_MCU_DEBUG_RESET) & MT_MCU_DEBUG_RESET_QUEUES) - return true; - if (mt7603_rx_fifo_busy(dev)) - return false; + goto out; addr = mt7603_reg_map(dev, MT_CLIENT_BASE_PHYS_ADDR + MT_CLIENT_STATUS); mt76_wr(dev, addr, 3); val = mt76_rr(dev, addr) >> 16; - if (is_mt7628(dev) && (val & 0x4001) == 0x4001) - return true; + if (!(val & BIT(0))) + return false; + + if (is_mt7628(dev)) + val &= 0xa000; + else + val &= 0x8000; + if (!val) + return false; + +out: + if (mt76_rr(dev, MT_INT_SOURCE_CSR) & + (MT_INT_RX_DONE(0) | MT_INT_RX_DONE(1))) + return false; - return (val & 0x8001) == 0x8001 || (val & 0xe001) == 0xe001; + return true; } static bool -- 2.41.0