2021-02-09 11:02:23

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 0/6] mt76: mt7921: multiple fixes

Align mt7921 driver to fw APIs available in linux-firmware.
Fix uninitialized pointer access.

Sean Wang (6):
mt76: mt7921: switch to new api for hardware beacon filter
mt76: connac: fix up the setting for ht40 mode in
mt76_connac_mcu_uni_add_bss
mt76: mt7921: fixup rx bitrate statistics
mt76: mt7921: add flush operation
mt76: mt7921: fix uninitialized pointer access in mt7921_get_wtbl_info
mt76: connac: update sched_scan cmd usage

.../wireless/mediatek/mt76/mt7615/mt7615.h | 5 -
.../net/wireless/mediatek/mt76/mt76_connac.h | 5 +
.../wireless/mediatek/mt76/mt76_connac_mcu.c | 9 +-
.../wireless/mediatek/mt76/mt76_connac_mcu.h | 14 +-
.../net/wireless/mediatek/mt76/mt7921/mac.c | 152 +++++++++---------
.../net/wireless/mediatek/mt76/mt7921/mac.h | 10 +-
.../net/wireless/mediatek/mt76/mt7921/main.c | 12 +-
.../net/wireless/mediatek/mt76/mt7921/mcu.c | 13 +-
8 files changed, 128 insertions(+), 92 deletions(-)

--
2.29.2


2021-02-09 11:03:21

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 6/6] mt76: connac: update sched_scan cmd usage

From: Sean Wang <[email protected]>

Update sched_scan command usage according to the current firmware
submitted into linux-firmware.git.

Fixes: 80fc1e37c0eb ("mt76: mt7921: rely on mt76_connac_mcu module for sched_scan and hw_scan")
Co-developed-by: Soul Huang <[email protected]>
Signed-off-by: Soul Huang <[email protected]>
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h | 5 -----
drivers/net/wireless/mediatek/mt76/mt76_connac.h | 5 +++++
.../net/wireless/mediatek/mt76/mt76_connac_mcu.c | 7 +++++--
.../net/wireless/mediatek/mt76/mt76_connac_mcu.h | 14 +++++++++++---
4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
index 491841bc6291..5ef19fbee6bd 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h
@@ -408,11 +408,6 @@ static inline bool is_mt7615(struct mt76_dev *dev)
return mt76_chip(dev) == 0x7615 || mt76_chip(dev) == 0x7611;
}

-static inline bool is_mt7663(struct mt76_dev *dev)
-{
- return mt76_chip(dev) == 0x7663;
-}
-
static inline bool is_mt7611(struct mt76_dev *dev)
{
return mt76_chip(dev) == 0x7611;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
index 0d58606391b0..b811f3c410a1 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
@@ -73,6 +73,11 @@ static inline bool is_mt7921(struct mt76_dev *dev)
return mt76_chip(dev) == 0x7961;
}

+static inline bool is_mt7663(struct mt76_dev *dev)
+{
+ return mt76_chip(dev) == 0x7663;
+}
+
int mt76_connac_pm_wake(struct mt76_phy *phy, struct mt76_connac_pm *pm);
void mt76_connac_power_save_sched(struct mt76_phy *phy,
struct mt76_connac_pm *pm);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
index 4356bf130dbd..1ee4e627ea00 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
@@ -1435,10 +1435,13 @@ int mt76_connac_mcu_sched_scan_req(struct mt76_phy *phy,
req->version = 1;
req->seq_num = mvif->scan_seq_num | ext_phy << 7;

- if (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
- get_random_mask_addr(req->random_mac, sreq->mac_addr,
+ if (is_mt7663(phy->dev) &&
+ (sreq->flags & NL80211_SCAN_FLAG_RANDOM_ADDR)) {
+ get_random_mask_addr(req->mt7663.random_mac, sreq->mac_addr,
sreq->mac_addr_mask);
req->scan_func = 1;
+ } else if (is_mt7921(phy->dev)) {
+ req->mt7921.bss_idx = mvif->idx;
}

req->ssids_num = sreq->n_ssids;
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
index c1e1df5f7cd7..4dca07e4e8aa 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
@@ -759,11 +759,19 @@ struct mt76_connac_sched_scan_req {
u8 channel_type;
u8 channels_num;
u8 intervals_num;
- u8 scan_func; /* BIT(0) eable random mac address */
+ u8 scan_func; /* MT7663: BIT(0) eable random mac address */
struct mt76_connac_mcu_scan_channel channels[64];
__le16 intervals[MT76_CONNAC_MAX_SCHED_SCAN_INTERVAL];
- u8 random_mac[ETH_ALEN]; /* valid when BIT(0) in scan_func is set */
- u8 pad2[58];
+ union {
+ struct {
+ u8 random_mac[ETH_ALEN];
+ u8 pad2[58];
+ } mt7663;
+ struct {
+ u8 bss_idx;
+ u8 pad2[63];
+ } mt7921;
+ };
} __packed;

struct mt76_connac_sched_scan_done {
--
2.29.2

2021-02-09 11:04:57

by Lorenzo Bianconi

[permalink] [raw]
Subject: [PATCH 5/6] mt76: mt7921: fix uninitialized pointer access in mt7921_get_wtbl_info

From: Sean Wang <[email protected]>

fix possible uninitialized pointer access in mt7921_get_wtbl_info
routine

[ 270.073205] wlp1s0: deauthenticating from 9c:5c:8e:c9:93:14 by local choice (Reason: 3=DEAUTH_LEAVING)
[ 270.094918] 8<--- cut here ---
[ 270.097988] Unable to handle kernel NULL pointer dereference at virtual address 0000000a
[ 270.106120] pgd = 7ac68838
[ 270.108842] [0000000a] *pgd=00000000
[ 270.112426] Internal error: Oops: 805 [#1] SMP ARM
[ 270.117216] Modules linked in: mt7921e mt76_connac_lib mt76
[ 270.122803] CPU: 0 PID: 7 Comm: kworker/u8:0 Tainted: G W 5.11.0-rc2+ #67
[ 270.130891] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 270.136459] Workqueue: phy0 mt7921_mac_work [mt7921e]
[ 270.141557] PC is at mt7921_get_wtbl_info+0x224/0x2d8 [mt7921e]
[ 270.147498] LR is at 0x0
[ 270.150026] pc : [<bf030398>] lr : [<00000000>] psr: 60000013

...

[ 270.317696] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 270.325869] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[ 270.334043] [<bf030398>] (mt7921_get_wtbl_info [mt7921e]) from [<bf02ea9c>] (mt7921_mac_work+0x298/0x2c0 [mt7921e])
[ 270.344529] [<bf02ea9c>] (mt7921_mac_work [mt7921e]) from [<c013cde8>] (process_one_work+0x1f0/0x538)
[ 270.353780] [<c013cde8>] (process_one_work) from [<c013d17c>] (worker_thread+0x4c/0x55c)
[ 270.361874] [<c013d17c>] (worker_thread) from [<c01447a8>] (kthread+0x124/0x150)
[ 270.369275] [<c01447a8>] (kthread) from [<c0100150>] (ret_from_fork+0x14/0x24)
[ 270.376501] Exception stack(0xc19c7fb0 to 0xc19c7ff8)
[ 270.381550] 7fa0: 00000000 00000000 00000000 00000000
[ 270.389724] 7fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 270.397896] 7fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[ 270.404509] Code: e59de012 e1cdc1b6 e1cdc1b8 e59dc016 (e582e00a)

Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support")
Signed-off-by: Sean Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
index d784c75d47bf..58de7f32a625 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
@@ -404,11 +404,10 @@ mt7921_mcu_tx_rate_report(struct mt7921_dev *dev, struct sk_buff *skb,

if (wlan_idx >= MT76_N_WCIDS)
return;
+
wcid = rcu_dereference(dev->mt76.wcid[wlan_idx]);
- if (!wcid) {
- stats->tx_rate = rate;
+ if (!wcid)
return;
- }

msta = container_of(wcid, struct mt7921_sta, wcid);
stats = &msta->stats;
--
2.29.2