Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp3130069lkv; Mon, 10 May 2021 08:19:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY/MP89zwLm2vKTX0Q5JuWiw5PVmv+Yh7Ovwfgq8ZeZFbiXdTDGavuqHn7BE4EAtSr/hiR X-Received: by 2002:a05:6402:284:: with SMTP id l4mr30502795edv.299.1620659981821; Mon, 10 May 2021 08:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620659981; cv=none; d=google.com; s=arc-20160816; b=Ee/McFe0pcQLN2v19c52s2Y52IcPHFBKmKVq2owU8cy0jNm0rFaxA8lD2/479wng0N xZdohnXhUibB1fHUK/CUdJy4coGFQun0VCCp2Apg6lKesdvH7KbFKl+FcGEtJGZtbJag weIz/FyRfhRtZqhzPVDq4msFQRI+iuiIEpPbuioHSO38X4CD/5e1rM4hpPT6ZwurYV7F prcA+cMGcct+2/XYF0AErxKqnh6rTi7FvkzO4rvBX59aUPaosOmMtY3WSesl7e7LwNhF elhAsc1HGHI1zx4101piPMH0YxWuZwii9nuJsUS80aa5RvqUslFgPhfNu19yOQqgSVOW AZNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=/OYQ8ASXzCYs3FRD7hwtGDc03H1l3q0+zWpagpOFfxw=; b=pWxXOcDGOaAmeQp0q+i27suthdYtJhWrQAvBXieNdW0DxvtgGLCwQuX7VnjoKKVk2d yCaG11DhMJ3tGpL4JB9TIiZpiWDYwZIfwume1s6HIT08uvLVn0B0NUUNimXP1xEfgrJp zN8xhuXPlhzpmDuqB7tAizw07+V9zOBnXSXsboZ355wx0J0AkeVh7N+2BzSPILvDIt2G mExJPn8yw0Y+Y9huZFoMjq+wk1jQjIMBA4JXEhizLhI7uPeTBTwTesgsbbZHB9zoBgAZ fqPYZX9s0KsDoL71mCJKJFl6Wx6hYC7uVsI7y1msfC/gfIEmfSSOMICMnyJWcv4tqjXo RopQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si11556097edc.498.2021.05.10.08.19.17; Mon, 10 May 2021 08:19:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234041AbhEJPSO (ORCPT + 99 others); Mon, 10 May 2021 11:18:14 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:56330 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S241770AbhEJPQg (ORCPT ); Mon, 10 May 2021 11:16:36 -0400 X-UUID: 17bf50ce860e4fe5a83cbb1ad7f46f44-20210510 X-UUID: 17bf50ce860e4fe5a83cbb1ad7f46f44-20210510 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1801878924; Mon, 10 May 2021 23:15:22 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 May 2021 23:14:59 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 10 May 2021 23:14:59 +0800 From: To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH 7/9] mt76: mt7921: consider the invalid value for to_rssi Date: Mon, 10 May 2021 23:14:55 +0800 Message-ID: <1620659697-12048-7-git-send-email-sean.wang@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1620659697-12048-1-git-send-email-sean.wang@mediatek.com> References: <1620659697-12048-1-git-send-email-sean.wang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 3C9240EF2573B67657F9ED857479D90467E4CC8D7E534F832002A2DEABEF7E0B2000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang It is possible the RCPI from the certain antenna is an invalid value, especially packets are receiving while the system is frequently entering deep sleep mode, so consider calculating RSSI with the reasonable upper bound to avoid report the wrong value to the mac80211 layer. Fixes: 163f4d22c118 ("mt76: mt7921: add MAC support") Reviewed-by: Lorenzo Bianconi Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c index 44b8918db95b..89a09381cfe4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c @@ -461,16 +461,19 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb) status->chain_signal[1] = to_rssi(MT_PRXV_RCPI1, v1); status->chain_signal[2] = to_rssi(MT_PRXV_RCPI2, v1); status->chain_signal[3] = to_rssi(MT_PRXV_RCPI3, v1); - status->signal = status->chain_signal[0]; - - for (i = 1; i < hweight8(mphy->antenna_mask); i++) { - if (!(status->chains & BIT(i))) + status->signal = -128; + for (i = 0; i < hweight8(mphy->antenna_mask); i++) { + if (!(status->chains & BIT(i)) || + status->chain_signal[i] >= 0) continue; status->signal = max(status->signal, status->chain_signal[i]); } + if (status->signal == -128) + status->flag |= RX_FLAG_NO_SIGNAL_VAL; + stbc = FIELD_GET(MT_PRXV_STBC, v0); gi = FIELD_GET(MT_PRXV_SGI, v0); cck = false; -- 2.25.1