Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp999013pxb; Fri, 13 Aug 2021 10:58:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoxJdmm/A/ThL3blFBk6I/dzrVNQAI9PcID+HAkA+S9nfEouLUCqvW12+6J/n9DKkf4vRb X-Received: by 2002:a05:6602:3359:: with SMTP id c25mr2897797ioz.181.1628877512653; Fri, 13 Aug 2021 10:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628877512; cv=none; d=google.com; s=arc-20160816; b=TPaaKrxTv1y61NcthgHEOCxNAkDqGgzC0/oiKU2n5vVNXGN/7EYbb7UI5lAG/rp7nc HexEM84AgE3sf1u1zjdphlpoGHyGKoTSAk0GGvCBQmNKGCb0H6IrHOh9fHdZ3uhh8pjS JyZj5Qs0pGg+ZP4WHXdzkVYNiyPgHZwIQPnNpwTrioqL+qDOZvHnJOiICkk4Ot0gyQT2 W/eq/niTJ+4iFTRhWRW5qeTa50pSm5lzMOOwR9rCVdbMz/x6HOHKuW879Di6zd8bhVpL zFlrkmzix9azxiCGJ+CrQJhqQRx5F8q977YUMjYay9mUeNUUeGl1H4znd8/jmkznU8NJ 3a/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=JrFcC0I3Rqa7yM+Ueq9e3W2S/kEuirBUk6Qol19QM/s=; b=qWdVQQKj6QW6cowfkCNSKmHy9/3db9FAe70gkc1ru8lCjVzWI4bNocLZwV7dD5ynQc e0HEK+rW5rw9s4Pvb69fH9q1T3GBJ2vi0hVgD0PWY/dhsBHk1dwFvAFxxfqweyzIbLhS Y0FJYknvxooVjNghceZMciN1qnuflGOqhDSpsB1ierH1YRyvurWgYohhps75NHvNxJV9 +wvCLt3Br41oSHAH45I6r58z0GF95BLKvvN4wyQ035KsFt4SPrjCN2OxwUSBXmxK8QtN yDIwGLJCGjDvyfb0aaE5kWhMvrOI2YubYR8CA80GI29kVHAKeW37vjcfkQAlWO3UAmsL cNiw== 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 t189si2588631iof.92.2021.08.13.10.58.16; Fri, 13 Aug 2021 10:58:32 -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 S230377AbhHMR63 (ORCPT + 99 others); Fri, 13 Aug 2021 13:58:29 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:60946 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229607AbhHMR63 (ORCPT ); Fri, 13 Aug 2021 13:58:29 -0400 X-UUID: e918cf55376e4163a57db98a09de6a3b-20210814 X-UUID: e918cf55376e4163a57db98a09de6a3b-20210814 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1653128758; Sat, 14 Aug 2021 01:51:52 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 14 Aug 2021 01:51:50 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 14 Aug 2021 01:51:50 +0800 From: To: , CC: , , , , , , , , , , , , , , , Subject: [PATCH] mt76: mt7921: fix kernel warning from cfg80211_calculate_bitrate Date: Sat, 14 Aug 2021 01:51:48 +0800 Message-ID: X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Sean Wang Fix the kernel warning from cfg80211_calculate_bitrate due to the legacy rate is not parsed well in current driver. Also, zeros struct rate_info before we fill it out to avoid the old value is kept such as rate->legacy. [ 790.921560] WARNING: CPU: 7 PID: 970 at net/wireless/util.c:1298 cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 790.987738] Hardware name: MediaTek Asurada rev1 board (DT) [ 790.993298] pstate: a0400009 (NzCv daif +PAN -UAO) [ 790.998104] pc : cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 791.004295] lr : cfg80211_calculate_bitrate+0x180/0x35c [cfg80211] [ 791.010462] sp : ffffffc0129c3880 [ 791.013765] x29: ffffffc0129c3880 x28: ffffffd38305bea8 [ 791.019065] x27: ffffffc0129c3970 x26: 0000000000000013 [ 791.024364] x25: 00000000000003ca x24: 000000000000002f [ 791.029664] x23: 00000000000000d0 x22: ffffff8d108bc000 [ 791.034964] x21: ffffff8d108bc0d0 x20: ffffffc0129c39a8 [ 791.040264] x19: ffffffc0129c39a8 x18: 00000000ffff0a10 [ 791.045563] x17: 0000000000000050 x16: 00000000000000ec [ 791.050910] x15: ffffffd3f9ebed9c x14: 0000000000000006 [ 791.056211] x13: 00000000000b2eea x12: 0000000000000000 [ 791.061511] x11: 00000000ffffffff x10: 0000000000000000 [ 791.066811] x9 : 0000000000000000 x8 : 0000000000000000 [ 791.072110] x7 : 0000000000000000 x6 : ffffffd3fafa5a7b [ 791.077409] x5 : 0000000000000000 x4 : 0000000000000000 [ 791.082708] x3 : 0000000000000000 x2 : 0000000000000000 [ 791.088008] x1 : ffffff8d3f79c918 x0 : 0000000000000000 [ 791.093308] Call trace: [ 791.095770] cfg80211_calculate_bitrate+0x354/0x35c [cfg80211] [ 791.101615] nl80211_put_sta_rate+0x6c/0x2c0 [cfg80211] [ 791.106853] nl80211_send_station+0x980/0xaa4 [cfg80211] [ 791.112178] nl80211_get_station+0xb4/0x134 [cfg80211] [ 791.117308] genl_rcv_msg+0x3a0/0x440 [ 791.120960] netlink_rcv_skb+0xcc/0x118 [ 791.124785] genl_rcv+0x34/0x48 [ 791.127916] netlink_unicast+0x144/0x1dc Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support") Signed-off-by: Sean Wang --- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c index cadb633639d3..27317c121256 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c @@ -328,14 +328,15 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy, struct rate_info *rate, u16 r) { struct ieee80211_supported_band *sband; - u16 flags = 0; + u16 flags = 0, rate_idx; u8 txmode = FIELD_GET(MT_WTBL_RATE_TX_MODE, r); u8 gi = 0; u8 bw = 0; + bool cck = false; + memset(rate, 0, sizeof(*rate)); rate->mcs = FIELD_GET(MT_WTBL_RATE_MCS, r); rate->nss = FIELD_GET(MT_WTBL_RATE_NSS, r) + 1; - switch (peer->bw) { case IEEE80211_STA_RX_BW_160: gi = peer->g16; @@ -357,13 +358,18 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy, switch (txmode) { case MT_PHY_TYPE_CCK: + cck = true; + fallthrough; case MT_PHY_TYPE_OFDM: if (mphy->chandef.chan->band == NL80211_BAND_5GHZ) sband = &mphy->sband_5g.sband; else sband = &mphy->sband_2g.sband; - rate->legacy = sband->bitrates[rate->mcs].bitrate; + rate_idx = FIELD_GET(MT_TX_RATE_IDX, r); + rate_idx = mt76_get_rate(mphy->dev, sband, rate_idx, + cck); + rate->legacy = sband->bitrates[rate_idx].bitrate; break; case MT_PHY_TYPE_HT: case MT_PHY_TYPE_HT_GF: -- 2.25.1