Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2628625lqz; Wed, 3 Apr 2024 04:07:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUe8TmuQTGyfmjAm7lgzElgh0k9TMudbrpwFR+MX2cfIl0/GoSW2F0BxO/lD7XXSzm2hemoSHpX2LXAhn358EUEAyqjVtCOopXENU6hQ== X-Google-Smtp-Source: AGHT+IGIE9+wl4auFREO3h7/hxetDxUSbjYCAU0F/r6tX1amhQ9c0qY/PeBjjzUk0lfV1OUDh9Pq X-Received: by 2002:a05:6e02:1c8d:b0:368:812f:da1a with SMTP id w13-20020a056e021c8d00b00368812fda1amr18396115ill.5.1712142477763; Wed, 03 Apr 2024 04:07:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712142477; cv=pass; d=google.com; s=arc-20160816; b=Pw/hEm3T518mw3j25u949OAcI2kZiTEFtEViS4zHsd9Q+nkv50K+kgyjzjrUtlOj9l VRizTNrId1KmYgzlNQAR2bQCo1zjDtsMlHtROcwyg/gTj19ul8VYDqgbO55gRchrzyFj U9wkVrzxak7chHDhLH9KP3+l6Nvo9gAgG8fIJgUndMpVnKKUIUvUgtjc0f0oOZNnr0g6 O2jfoPdVsPR2kHDeLM5XQFbsx6hS66CCj2kHzy399Jwv6F1LSvPs3CwAn5+en/NjsFI9 B56llgmIq4py6OKjbX7E9rJ+jke6qOrcdjyKeSqYsv7zJ2Hz3+OM0OEGfHV6diLJr3Qk vc0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=oXttf9KHJqxJzjNqpvFFvl+Tzz7NR3cA/kIZ5dMzYi4=; fh=qW0phhq3fb3oiohK/Mu9j1KY1zyRNiiioKFc5anvatM=; b=W1VVldnLAtDryQV75xHDrH6QJiWzwvS2QeAds99xD3Mpmif4ZrRX7NsJ2nfYZKSjfG 7bOpvr0Ifshyql7QV31J/H6dUayMYpjZ9RA/6o7YicbPRqpYwKBuvWSJLC2nmBZz8QGz S51hf+PYe0IJ0EDiwxIg2SMCX3XyStNYeY34f0k574xd5fvKhlDgr9qIxoaxCU7gzFbU /MLgyOOqlbotvhLMVXd25hscY94Xu8lMhk6zFx7svYqp51bUYKJE9lxR5HL+fXri4qIB 5JtIRScjV3E7nI6HHebizuRQPv5xfWqqYf07cdTGAm+nsK6kU7BIChL/dqzfykERRFfv lo1w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=bR02LTfM; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-wireless+bounces-5802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5802-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q18-20020a637512000000b005e83b656261si12724146pgc.182.2024.04.03.04.07.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 04:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=bR02LTfM; arc=pass (i=1 dkim=pass dkdomain=nbd.name dmarc=pass fromdomain=nbd.name); spf=pass (google.com: domain of linux-wireless+bounces-5802-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5802-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nbd.name Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0DF32290715 for ; Wed, 3 Apr 2024 10:56:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2342136989; Wed, 3 Apr 2024 10:55:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="bR02LTfM" X-Original-To: linux-wireless@vger.kernel.org Received: from nbd.name (nbd.name [46.4.11.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08F171411F0 for ; Wed, 3 Apr 2024 10:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.4.11.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712141725; cv=none; b=DmkQdpIa0zXTMDNBho8UQrniqONfUKk3GWx9rgnlggrohiR15dyEdTr05TDQA3ejEYMKDaIesz28RTutb6EyFwXhmw0BSp/1GWuBmGpIrWIjrY4n/OGUx6h+ZK5j195eGL8g85h3zkxE2LAZTVmcGPKjQ9P3hZyYPAc4k7D57mo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712141725; c=relaxed/simple; bh=Cx46qIRZhwhYPjCcGGxM7VUI2f+02o2x+njiup04PDU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=okiXVRPiSTuCu7f6Rou11n+6KAFovAEoPhbGjGLMZPEvncRkVrGmVukcyL+iYQ4anpqGhvJTQwWnTnN7thu8LhJv8jOjt+PnHqlH9HWlKs6anY9kLaeDehPfS84gtDmFw0beNM4dQpHsZyeWHjTP9sN1p1txBQxP1SkVnlZTbPc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name; spf=none smtp.mailfrom=nbd.name; dkim=pass (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b=bR02LTfM; arc=none smtp.client-ip=46.4.11.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nbd.name Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=nbd.name DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: 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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=oXttf9KHJqxJzjNqpvFFvl+Tzz7NR3cA/kIZ5dMzYi4=; b=bR02LTfMNtGDumNiiGFQBDvlGE 72a5xMFZTVb5GFvrBJrIeGRXgQXIReay4HlzeJYQ2ncHJ3Phg4bTJyQbwJbIHDknxdqh6aZ1lAmfQ hkeGbYVjtU9PvbsYf/FfYmoq/PGygpyIetsQfAV1DIhz4yRXxqKOdldsvaJeegVh+5nU=; Received: from p54ae9c93.dip0.t-ipconnect.de ([84.174.156.147] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (Exim 4.94.2) (envelope-from ) id 1rrxt3-00CgfA-GF for linux-wireless@vger.kernel.org; Wed, 03 Apr 2024 12:30:33 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 05/13] wifi: mt76: mt7915: fix bogus Tx/Rx airtime duration values Date: Wed, 3 Apr 2024 12:30:24 +0200 Message-ID: <20240403103032.54823-5-nbd@nbd.name> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240403103032.54823-1-nbd@nbd.name> References: <20240403103032.54823-1-nbd@nbd.name> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Henry Yen Do not report measurements if the airtime counter was cleared since the last update (possibly by firmware) Signed-off-by: Henry Yen Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index e45361111f9b..f350b3f7a0bd 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -140,8 +140,15 @@ static void mt7915_mac_sta_poll(struct mt7915_dev *dev) msta->airtime_ac[i] = mt76_rr(dev, addr); msta->airtime_ac[i + 4] = mt76_rr(dev, addr + 4); - tx_time[i] = msta->airtime_ac[i] - tx_last; - rx_time[i] = msta->airtime_ac[i + 4] - rx_last; + if (msta->airtime_ac[i] <= tx_last) + tx_time[i] = 0; + else + tx_time[i] = msta->airtime_ac[i] - tx_last; + + if (msta->airtime_ac[i + 4] <= rx_last) + rx_time[i] = 0; + else + rx_time[i] = msta->airtime_ac[i + 4] - rx_last; if ((tx_last | rx_last) & BIT(30)) clear = true; -- 2.43.0