Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2564303pxb; Thu, 3 Feb 2022 09:10:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUbkE2JTd2sLd9X7TMdlKOPxNWAD8agBRMinJrTajm8LfPODvFm7SqSJBKfh3ml5EMYb/d X-Received: by 2002:a63:594c:: with SMTP id j12mr28516278pgm.523.1643908215606; Thu, 03 Feb 2022 09:10:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643908215; cv=none; d=google.com; s=arc-20160816; b=KlTXhJ+c+fEMmKNAxlaXncf5kAbdI2UG1ofiE4cuZzPpRAWR+wsSlgbW1ji4OteRq5 1xKdXLI+wWVRxfooRZruUSdogF/iv+/wl0jBR6TwNWiMsqT+9IH0g9Iddf8Czd0KiOR1 sxiemE4HsMIsxnNc5Kt1OGLSXfDKtb9Z4F3EBiWAwRRrWSPy+eYMW9YdixLSCofnQKpz cU9zFkcpcY+r4B+sN5kKWcx75BXX2fMswU3wjGu0id6bVb4KoIIBF6poSQty69TA2dJX Xu6qsN2Hn9b5i4QfIfhLTUkeJ5kbMRkGwtZJGRq7Qvx2+Q/jVQ8y/F4672PvR1SrGoSy 048A== 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=BoSA3cWrIM0e0O1396vnvgBaXWTtieiiKblKqr9RbF4=; b=wdixLUufEOwsoRu3/ylW/oshdE/ZvFNXMahHPTgmKBTEAU9vHfF1ixtq90jCuasVtt 9zgIMoiEM6vacBCGbJbKGFzQnpP/rtEsus9U/11AWC+3uaq6vkjKSTJ6Fl5S1kpsnx2/ zofhvxRmxaPMQ1Zue9j7wBT3buW+jduPZo9wlQkVcxxsHYP3ewyBKis3CSu90UivEJ8X Zn9ngg6dXVdGCdzOhpyxU6RC0sEZGraplKYVHGOMVqwDRGrawh2u+HdeWImOH2If+PZN 0m7ocDIbNxj0FShu43dPsYZlWkYJOaK6KRqtSv3kPYFfvdxFlwEFcmjrE1pziuC191Dt blqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=P8JHz4rK; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i13si24859077pli.214.2022.02.03.09.10.03; Thu, 03 Feb 2022 09:10:15 -0800 (PST) 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=fail header.i=@nbd.name header.s=20160729 header.b=P8JHz4rK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347761AbiBCNgF (ORCPT + 72 others); Thu, 3 Feb 2022 08:36:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243939AbiBCNgE (ORCPT ); Thu, 3 Feb 2022 08:36:04 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135ABC06173D for ; Thu, 3 Feb 2022 05:36:04 -0800 (PST) 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=BoSA3cWrIM0e0O1396vnvgBaXWTtieiiKblKqr9RbF4=; b=P8JHz4rKegXZKjPCqufVBFyIWQ JZaUbK7hPUxhsrQLF15KzzjdVvBpdwHshicQ1q9XwqRLkbXX7FAKk7G6ow1j/bqay2IIiWKm7pKt4 Fe/VQKRMtEYlE8GMvSav8VLSgawk2AhUnK4rHpEkjtgUoUgL8NoVZZIRskozGMoLOyUE=; Received: from p200300daa71e0b007cedb37d167c1481.dip0.t-ipconnect.de ([2003:da:a71e:b00:7ced:b37d:167c:1481] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nFcHJ-0001Et-VJ for linux-wireless@vger.kernel.org; Thu, 03 Feb 2022 14:36:02 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 1/5] mt76x02: improve mac error check/reset reliability Date: Thu, 3 Feb 2022 14:35:56 +0100 Message-Id: <20220203133600.92211-1-nbd@nbd.name> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On AP mode devices, check beacon tx counters to detect MAC errors. When an error is detected, stop the MAC before resetting it Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt76x02.h | 1 + .../net/wireless/mediatek/mt76/mt76x02_mac.c | 25 ++++++++++++++----- .../net/wireless/mediatek/mt76/mt76x02_regs.h | 2 ++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02.h b/drivers/net/wireless/mediatek/mt76/mt76x02.h index 44d1a92d9a90..3232083e9916 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02.h @@ -104,6 +104,7 @@ struct mt76x02_dev { u32 tx_hang_reset; u8 tx_hang_check; + u8 beacon_hang_check; u8 mcu_timeout; struct mt76x02_calibration cal; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c index a404fd7ea968..dc2aeaab72ec 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.c @@ -1040,12 +1040,26 @@ EXPORT_SYMBOL_GPL(mt76x02_update_channel); static void mt76x02_check_mac_err(struct mt76x02_dev *dev) { - u32 val = mt76_rr(dev, 0x10f4); + if (dev->mt76.beacon_mask) { + if (mt76_rr(dev, MT_TX_STA_0) & MT_TX_STA_0_BEACONS) { + dev->beacon_hang_check = 0; + return; + } - if (!(val & BIT(29)) || !(val & (BIT(7) | BIT(5)))) - return; + if (++dev->beacon_hang_check < 10) + return; + + dev->beacon_hang_check = 0; + } else { + u32 val = mt76_rr(dev, 0x10f4); + if (!(val & BIT(29)) || !(val & (BIT(7) | BIT(5)))) + return; + } + + dev_err(dev->mt76.dev, "MAC error detected\n"); - dev_err(dev->mt76.dev, "mac specific condition occurred\n"); + mt76_wr(dev, MT_MAC_SYS_CTRL, 0); + mt76x02_wait_for_txrx_idle(&dev->mt76); mt76_set(dev, MT_MAC_SYS_CTRL, MT_MAC_SYS_CTRL_RESET_CSR); udelay(10); @@ -1178,8 +1192,7 @@ void mt76x02_mac_work(struct work_struct *work) dev->mt76.aggr_stats[idx++] += val >> 16; } - if (!dev->mt76.beacon_mask) - mt76x02_check_mac_err(dev); + mt76x02_check_mac_err(dev); if (dev->ed_monitor) mt76x02_edcca_check(dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h index fa7872ac22bf..fe0c5e3298bc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_regs.h @@ -571,6 +571,8 @@ #define MT_RX_STAT_2_OVERFLOW_ERRORS GENMASK(31, 16) #define MT_TX_STA_0 0x170c +#define MT_TX_STA_0_BEACONS GENMASK(31, 16) + #define MT_TX_STA_1 0x1710 #define MT_TX_STA_2 0x1714 -- 2.32.0 (Apple Git-132)