748 Commits
Author SHA1 Message Date
Shayne ChenandFelix Fietkau 795830a99a mt76: mt7915: add debugfs knob for RF registers read/write
Add RF registers read/write support for debugging RF issues, which
should be processed by mcu commands.
The index of rf registers use the generic regidx, and are combined
with two parts: WF selection [31:28] and offset [27:0].

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
2022-04-20 13:23:48 +02:00
Colin Ian KingandFelix Fietkau db0a675820 mt76: mt7915: make read-only array ppet16_ppet8_ru3_ru0 static const
Don't populate the read-only array ppet16_ppet8_ru3_ru0 on the stack but
instead make it static const. Also makes the object code a little smaller.

Reviewed-by: AngeloGioacchino Del Regno <[email protected]>
Signed-off-by: Colin Ian King <[email protected]>
2022-04-20 13:23:48 +02:00
Ryder LeeandFelix Fietkau 64ede85f14 mt76: mt7915: remove SCS feature
SCS is obsoleted and no longer used, so remove it.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-20 13:23:48 +02:00
Lorenzo BianconiandFelix Fietkau 2a0d370cb5 mt76: mt7915: use 0xff to initialize bitrate_mask in mt7915_init_bitrate_mask
Use 0xff (GENMASK(7,0)) in mt7915_init_bitrate_mask routine in order to
initialize bitrate_mask structure in order to avoid truncating value in
memset().

Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:22:27 +02:00
Lorenzo BianconiandFelix Fietkau f3ddfe8862 mt76: mt7915: report rx mode value in mt7915_mac_fill_rx_rate
Report rx mode in mt7915_mac_fill_rx_rate routine in order to properly
add he radiotap if mode is at least HE_SU.

Fixes: 1c9db0aa23fd1 ("mt76: mt7915: update rx rate reporting for mt7916")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:22:27 +02:00
Lorenzo BianconiandFelix Fietkau fe441e5d3d mt76: mt7915: do not pass data pointer to mt7915_mcu_muru_debug_set
Fix typo in mt7915_muru_debug_set routine and pass muru_debug value to
mt7915_mcu_muru_debug_set() instead of data pointer.

Fixes: 1966a5078f2d2 (mt76: mt7915: add mu-mimo and ofdma debugfs knobs")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:22:27 +02:00
Lorenzo BianconiandFelix Fietkau 5a87be892b mt76: mt7915: fix possible NULL pointer dereference in mt7915_mac_fill_rx_vector
Fix possible NULL pointer dereference in mt7915_mac_fill_rx_vector
routine if the chip does not support dbdc and the hw reports band_idx
set to 1.

Fixes: 78fc30a21cf11 ("mt76: mt7915: move testmode data from dev to phy")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:22:27 +02:00
Lorenzo BianconiandFelix Fietkau ec0e9f4da3 mt76: mt7915: fix possible uninitialized pointer dereference in mt7986_wmac_gpio_setup
Add default case for type switch in mt7986_wmac_gpio_setup routine in
order to avoid a possible uninitialized pointer dereference.

Fixes: 99ad32a4ca3a2 ("mt76: mt7915: add support for MT7986")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:22:27 +02:00
Peter ChiuandFelix Fietkau 2accb74e6b mt76: mt7915: fix using null pointer when wfsys on
Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 12:11:11 +02:00
Felix Fietkau 87a962e060 mt76: mt7915: add Wireless Ethernet Dispatch support
This is used to support hardware flow offloading from Ethernet to WLAN

Signed-off-by: Felix Fietkau <[email protected]>
2022-04-07 11:56:24 +02:00
Felix Fietkau 376ea8152b mt76: mt7915: add missing chunk from wfsys reset fix
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-28 10:21:42 +02:00
Felix Fietkau 6b1efcd729 mt76: mt7915: fix wfsys reset regression
Reset needs to be performed before hif2 initialization

Signed-off-by: Felix Fietkau <[email protected]>
2022-03-27 21:18:58 +02:00
Lorenzo BianconiandFelix Fietkau ec4d9b9e8b mt76: mt7915: fix unbounded shift in mt7915_mcu_beacon_mbss
Fix the following smatch static checker warning:
	drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1872 mt7915_mcu_beacon_mbss()
	error: undefined (user controlled) shift '(((1))) << (data[2])'

Rely on mac80211 definitions for ieee80211_bssid_index subelement.

Fixes: 6b7f9aff7c67 ("mt76: mt7915: introduce 802.11ax multi-bss support")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-25 22:17:32 +01:00
Ryder LeeandFelix Fietkau 1442710d79 mt76: mt7915: always call mt7915_wfsys_reset() during init
Soft reboot might not clear certain condition, so always call
mt7915_wfsys_reset() during init.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-25 22:17:32 +01:00
Evelyn TsaiandFelix Fietkau c692aacb9b mt76: fix MBSS index condition in DBDC mode
MT7915_MAX_INTERFACES is per-band declaration in MT7915/MT7986/MT7916.
Enlarge vif_mask to 64 bits wide, including the bit operation.

Reviewed-by: Shayne Chen <[email protected]>
Signed-off-by: Evelyn Tsai <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
2022-03-25 22:13:38 +01:00
Felix Fietkau 5b7dd093c8 mt76: fix use-after-free by removing a non-RCU wcid pointer
Fixes an issue caught by KASAN about use-after-free in mt76_txq_schedule
by protecting mtxq->wcid with rcu_lock between mt76_txq_schedule and
sta_info_[alloc, free].

[18853.876689] ==================================================================
[18853.876751] BUG: KASAN: use-after-free in mt76_txq_schedule+0x204/0xaf8 [mt76]
[18853.876773] Read of size 8 at addr ffffffaf989a2138 by task mt76-tx phy0/883
[18853.876786]
[18853.876810] CPU: 5 PID: 883 Comm: mt76-tx phy0 Not tainted 5.10.100-fix-510-56778d365941-kasan #5 0b01fbbcf41a530f52043508fec2e31a4215

[18853.876840] Call trace:
[18853.876861]  dump_backtrace+0x0/0x3ec
[18853.876878]  show_stack+0x20/0x2c
[18853.876899]  dump_stack+0x11c/0x1ac
[18853.876918]  print_address_description+0x74/0x514
[18853.876934]  kasan_report+0x134/0x174
[18853.876948]  __asan_report_load8_noabort+0x44/0x50
[18853.876976]  mt76_txq_schedule+0x204/0xaf8 [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2]
[18853.877002]  mt76_txq_schedule_all+0x2c/0x48 [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2]
[18853.877030]  mt7921_tx_worker+0xa0/0x1cc [mt7921_common f0875ebac9d7b4754e1010549e7db50fbd90a047]
[18853.877054]  __mt76_worker_fn+0x190/0x22c [mt76 074e03e4640e97fe7405ee1fab547b81c4fa45d2]
[18853.877071]  kthread+0x2f8/0x3b8
[18853.877087]  ret_from_fork+0x10/0x30
[18853.877098]
[18853.877112] Allocated by task 941:
[18853.877131]  kasan_save_stack+0x38/0x68
[18853.877147]  __kasan_kmalloc+0xd4/0xfc
[18853.877163]  kasan_kmalloc+0x10/0x1c
[18853.877177]  __kmalloc+0x264/0x3c4
[18853.877294]  sta_info_alloc+0x460/0xf88 [mac80211]
[18853.877410]  ieee80211_prep_connection+0x204/0x1ee0 [mac80211]
[18853.877523]  ieee80211_mgd_auth+0x6c4/0xa4c [mac80211]
[18853.877635]  ieee80211_auth+0x20/0x2c [mac80211]
[18853.877733]  rdev_auth+0x7c/0x438 [cfg80211]
[18853.877826]  cfg80211_mlme_auth+0x26c/0x390 [cfg80211]
[18853.877919]  nl80211_authenticate+0x6d4/0x904 [cfg80211]
[18853.877938]  genl_rcv_msg+0x748/0x93c
[18853.877954]  netlink_rcv_skb+0x160/0x2a8
[18853.877969]  genl_rcv+0x3c/0x54
[18853.877985]  netlink_unicast_kernel+0x104/0x1ec
[18853.877999]  netlink_unicast+0x178/0x268
[18853.878015]  netlink_sendmsg+0x3cc/0x5f0
[18853.878030]  sock_sendmsg+0xb4/0xd8
[18853.878043]  ____sys_sendmsg+0x2f8/0x53c
[18853.878058]  ___sys_sendmsg+0xe8/0x150
[18853.878071]  __sys_sendmsg+0xc4/0x1f4
[18853.878087]  __arm64_compat_sys_sendmsg+0x88/0x9c
[18853.878101]  el0_svc_common+0x1b4/0x390
[18853.878115]  do_el0_svc_compat+0x8c/0xdc
[18853.878131]  el0_svc_compat+0x10/0x1c
[18853.878146]  el0_sync_compat_handler+0xa8/0xcc
[18853.878161]  el0_sync_compat+0x188/0x1c0
[18853.878171]
[18853.878183] Freed by task 10927:
[18853.878200]  kasan_save_stack+0x38/0x68
[18853.878215]  kasan_set_track+0x28/0x3c
[18853.878228]  kasan_set_free_info+0x24/0x48
[18853.878244]  __kasan_slab_free+0x11c/0x154
[18853.878259]  kasan_slab_free+0x14/0x24
[18853.878273]  slab_free_freelist_hook+0xac/0x1b0
[18853.878287]  kfree+0x104/0x390
[18853.878402]  sta_info_free+0x198/0x210 [mac80211]
[18853.878515]  __sta_info_destroy_part2+0x230/0x2d4 [mac80211]
[18853.878628]  __sta_info_flush+0x300/0x37c [mac80211]
[18853.878740]  ieee80211_set_disassoc+0x2cc/0xa7c [mac80211]
[18853.878851]  ieee80211_mgd_deauth+0x4a4/0x10a0 [mac80211]
[18853.878962]  ieee80211_deauth+0x20/0x2c [mac80211]
[18853.879057]  rdev_deauth+0x7c/0x438 [cfg80211]
[18853.879150]  cfg80211_mlme_deauth+0x274/0x414 [cfg80211]
[18853.879243]  cfg80211_mlme_down+0xe4/0x118 [cfg80211]
[18853.879335]  cfg80211_disconnect+0x218/0x2d8 [cfg80211]
[18853.879427]  __cfg80211_leave+0x17c/0x240 [cfg80211]
[18853.879519]  cfg80211_leave+0x3c/0x58 [cfg80211]
[18853.879611]  wiphy_suspend+0xdc/0x200 [cfg80211]
[18853.879628]  dpm_run_callback+0x58/0x408
[18853.879642]  __device_suspend+0x4cc/0x864
[18853.879658]  async_suspend+0x34/0xf4
[18853.879673]  async_run_entry_fn+0xe0/0x37c
[18853.879689]  process_one_work+0x508/0xb98
[18853.879702]  worker_thread+0x7f4/0xcd4
[18853.879717]  kthread+0x2f8/0x3b8
[18853.879731]  ret_from_fork+0x10/0x30
[18853.879741]
[18853.879757] The buggy address belongs to the object at ffffffaf989a2000
[18853.879757]  which belongs to the cache kmalloc-8k of size 8192
[18853.879774] The buggy address is located 312 bytes inside of
[18853.879774]  8192-byte region [ffffffaf989a2000, ffffffaf989a4000)
[18853.879787] The buggy address belongs to the page:
[18853.879807] page:000000004bda2a59 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1d89a0
[18853.879823] head:000000004bda2a59 order:3 compound_mapcount:0 compound_pincount:0
[18853.879839] flags: 0x8000000000010200(slab|head)
[18853.879857] raw: 8000000000010200 ffffffffbc89e208 ffffffffb7fb5208 ffffffaec000cc80
[18853.879873] raw: 0000000000000000 0000000000010001 00000001ffffffff 0000000000000000
[18853.879885] page dumped because: kasan: bad access detected
[18853.879896]
[18853.879907] Memory state around the buggy address:
[18853.879922]  ffffffaf989a2000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[18853.879935]  ffffffaf989a2080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[18853.879948] >ffffffaf989a2100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[18853.879961]                                         ^
[18853.879973]  ffffffaf989a2180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[18853.879986]  ffffffaf989a2200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
[18853.879998] ==================================================================

Cc: [email protected]
Reported-by: Sean Wang <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-25 22:08:28 +01:00
Felix Fietkau c2bb44cab5 mt76: mt7915: accept rx frames with non-standard VHT MCS10-11
The hardware receives them properly, they should not be dropped

Signed-off-by: Felix Fietkau <[email protected]>
2022-03-25 21:14:29 +01:00
Felix Fietkau c96fbb86f7 mt76: mt7915: rework hardware/phy initialization
Clean up and fix error paths in mt7915_register_device
Initialize second DBDC tx queue in mt7915_dma_init

Signed-off-by: Felix Fietkau <[email protected]>
2022-03-25 20:35:20 +01:00
Felix Fietkau 104dd5cb0a mt76: mt7915: fix DBDC default band selection on MT7915D
This code was accidentally dropped while adding 6 GHz support

Signed-off-by: Felix Fietkau <[email protected]>
2022-03-19 08:08:29 +01:00
Deren WuandFelix Fietkau 7a05f4628e mt76: fix monitor rx FCS error in DFS channel
When setup monitor mode in DFS channel, mt76 send CH_SWITCH_DFS to
fw for channel config. This would cause rx performance bad while
monitoring frames. Settings CH_SWITCH_NORMAL in monitor mode would
get the same performance as normal channels.

Reviewed-by: Shayne Chen <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-16 21:15:45 +01:00
Deren WuandFelix Fietkau e756ea3bd0 mt76: fix wrong HE data rate in sniffer tool
Due to the missing IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN in
status report, the HE rate in wirehsark/tcpdump always shows wrong value.
Applications will refer to IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC
when the flag is set and shows the correct data rate.

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Deren Wu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-16 21:15:13 +01:00
Lorenzo BianconiandFelix Fietkau 65042bfd75 mt76: mt7915: introduce 802.11ax multi-bss support
Introduce mbss mcu APIs to enable 802.11ax multi-bss AP support for
mt7915 devices

Tested-by: Money Wang <[email protected]>
Co-developed-by: Ryder Lee <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Co-developed-by: Money Wang <[email protected]>
Signed-off-by: Money Wang <[email protected]>
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-16 21:13:11 +01:00
Julia LawallandFelix Fietkau c6780c85cf mt76: mt7915: fix typos in comments
Various spelling mistakes in comments.
Detected with the help of Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Peter ChiuandFelix Fietkau 6e899abec8 mt76: mt7915: fix phy cap in mt7915_set_stream_he_txbf_caps()
This patch fixes performance issue of beamforming tx on
bandwidth 160MHz.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Shayne ChenandFelix Fietkau 67ce2708dc mt76: mt7915: fix beamforming mib stats
Some of beamforming mib counters are moved to different offsets
or registers in newer chipsets.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Shayne ChenandFelix Fietkau f16fc9d961 mt76: mt7915: set band1 TGID field in tx descriptor
Set proper group index of tx descriptor for band1.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Ryder LeeandFelix Fietkau e49af7036b mt76: use le32/16_get_bits() whenever possible
Switch to use le32/16_get_bits() to simplfy codes and specify
the size explicitly to avoid potential issues.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Dan CarpenterandFelix Fietkau 9fee1faf60 mt76: mt7915: check for devm_pinctrl_get() failure
If devm_pinctrl_get() fails then it leads to an error pointer
dereference.  Add a check to prevent that.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:53:26 +01:00
Shayne ChenandFelix Fietkau d4b226cc15 mt76: mt7915: add txpower init for 6GHz
Add support to init txpower values of 6GHz band.

Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:24 +01:00
Shayne ChenandFelix Fietkau 28ff1bddc7 mt76: mt7915: fix eeprom fields of txpower init values
A-die 7976 has different offset and uses different channel group
definition on txpower init values.

Fixes: 99ad32a4ca3a ("mt76: mt7915: add support for MT7986")
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:24 +01:00
MeiChia ChiuandFelix Fietkau 630384cb32 mt76: mt7915: add 6 GHz support
Basic 6 GHz support is added to mt76.
Modification includes:
1. Add 6 GHz E2P definition
2. Register 6 GHz HE cap
3. Refactor existing code of adding a STA

This adds support for Wi-Fi 6E on MT7986/MT7916.
Detailed link:
https://www.mediatek.com/products/mediatek-filogic-830
Detailed link:
https://www.mediatek.com/products/products/broadband-wifi/mediatek-filogic-630

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Money Wang <[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:24 +01:00
Ryder LeeandFelix Fietkau c374559eae mt76: mt7915: allow beaconing on all chains
This improves rate reach performance on units with polarized antennas.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:13 +01:00
MeiChia ChiuandFelix Fietkau d8d2b383a2 mt76: split single ldpc cap bit into bits
The original single LDPC cap bit cannot be used to
differentiate LDPC cap in each PHY mode.
This modification split the single bit into 3 bits,
ht_ldpc, vht_ldpc, and he_ldpc.

Reviewed-by: Ryder Lee <[email protected]>
Suggested-by: Money Wang <[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:13 +01:00
Evelyn TsaiandFelix Fietkau 594ee03d5a mt76: mt7915: fix DFS no radar detection event
Driver needs to carry region definition when radar detection starts.
Need to remap nl80211 DFS regions to chip region definition.

Signed-off-by: Evelyn Tsai <[email protected]>
Signed-off-by: Rubio Lu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-03-14 15:23:13 +01:00
Felix Fietkau 64c74dc93f mt76: fix dfs state issue with 160 MHz channels
When operating on a mix of DFS and non-DFS channels, the driver only checks
the CAC status of the control channel. This causes beacons/tx to fail if the
control channel is on a non-DFS channel.
Fix this by calling cfg80211_reg_can_beacon to determine the DFS status of
all affected channels

Signed-off-by: Felix Fietkau <[email protected]>
2022-02-24 14:34:35 +01:00
Wan JiabingandFelix Fietkau c007ba3ec7 mt76: mt7915: simplify conditional
Fix following coccicheck warning:
./drivers/net/wireless/mediatek/mt76/mt7915/mac.c:768:29-31:
WARNING !A || A && B is equivalent to !A || B

Signed-off-by: Wan Jiabing <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-23 11:36:54 +01:00
Felix Fietkau 4f43095428 mt76: mt7915: only use u32_get_bits with constant value
Fixes invalid unresolved symbols when built on ARM and avoids unnecessary
divisions

Signed-off-by: Felix Fietkau <[email protected]>
2022-02-23 11:33:24 +01:00
Felix Fietkau 378b638c70 mt76: mt7915: fix unused variable with testmode disabled
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-23 11:31:05 +01:00
Nicolas CavallariandFelix Fietkau c67df0d313 mt76: mt7915e: Enable thermal management by default
By default, mt7915e does not enable thermal management until the default
thermal zone does not reach a trip point.  If the rest of the system
have better cooling than the wireless hardware, then it is possible that
the wireless chip can overheat while the rest of the system is fine.

Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 14:20:01 +01:00
Nicolas CavallariandFelix Fietkau f2e1a62cf0 mt76: mt7915e: Add a hwmon attribute to get the actual throttle state.
The firmware-controlled actual throttle state was previously available
by reading the cooling_device, but this confused the thermal subsystem.
Add a hwmon attribute to get it instead.

Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 14:20:01 +01:00
Nicolas CavallariandFelix Fietkau 9fee8f3736 mt76: mt7915e: Fix degraded performance after temporary overheat
mt7915e registers a cooling_device with wrong semantics:

1. cooling_device expect that higher states values should cool more, but
   mt7915e did the opposite...  with the exception of state == 0, which
   should "disable thermal management", but does not seem to have any
   effect since the previous state is kept.

The result is that when the thermal zone heats up a bit and bumps the
cooling_device state from 0 to 1 to cool a bit, the performance is
destroyed, and when going back from 1 to 0, the performance stays bad.

2. Reading the cooling_device state does not always return the last
   written state, but can return the actual hardware throttle state,
   which is different.

This is a problem because the mt7915 firmware actually implement the
equivalent of a thermal zone with trip points.  Setting the cooling
device state actually changes the throttles at each trip point, so the
following could occur if the first issue is fixed:

- thermal subsystem set state to 100% power (state=0)
- mt7915e driver set trip throttles to [100%, 50%, 25%, 12%]
- hardware heats up and decides to switch to 50% power
- thermal subsystem see that power is 50% (state=50), decide to increase
  it to 60% (state=40) because the rest of the system is cool.
- mt7915e driver set trip throttle to [60%, 30%, 15%, 7%]
- hardware thus switches to 30% power
[race to the bottom continues...]

This patch corrects the semantics of the cooling_device to the one that
the thermal subsystem expect it.

Signed-off-by: Nicolas Cavallari <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 14:20:01 +01:00
Changcheng DengandFelix Fietkau a050c14b56 mt76: mt7915: use min_t() to make code cleaner
Use min_t() in order to make code cleaner.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Changcheng Deng <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 13:56:25 +01:00
MeiChia ChiuandFelix Fietkau abd80cf68d mt76: mt7915: fix the muru tlv issue
The muru enable/disable are only set after the first station connection.
Without this patch, the firmware couldn't enable muru
if the first connected station is non-HE type.

Fixes: 16bff457dd33a ("mt76: mt7915: rework mt7915_mcu_sta_muru_tlv()")

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: MeiChia Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 13:56:25 +01:00
Bo JiaoandFelix Fietkau bbbbafb67b mt76: mt7915: fix compiler warning
fix warning: variable 'temp' set but not used and
cast from pointer to integer of different size

Fixes: 91eeaef2523f ("mt76: mt7915: add support for MT7986")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 13:56:25 +01:00
Bo JiaoandFelix Fietkau 98ee3e2889 mt76: mt7915: fix logic error and remove the unused member of mt7915_dev
fix logic error and remove the unused member 'adie' of mt7915_dev.

Fixes: 91eeaef2523f ("mt76: mt7915: add support for MT7986")
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-15 13:56:25 +01:00
Ryder LeeandFelix Fietkau d4fc42889a mt76: mt7915: check band idx for bcc event
Add missing band idx check for DBDC cases.

Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-14 15:15:48 +01:00
Lorenzo BianconiandFelix Fietkau d0ab636cb6 mt76: mt7915: fix endianness warnings in mt7915_mac_tx_free()
Fix the following sparse warning in mt7915_mac_tx_free routine:
warning: incorrect type in assignment (different base types)
   expected unsigned int [usertype] *cur_info
   got restricted __le32 *
   warning: cast to restricted __le32

Fixes: c17780e7b21ec ("mt76: mt7915: add txfree event v3")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-14 15:08:04 +01:00
Lorenzo BianconiandFelix Fietkau d60f335e78 mt76: mt7915: fix endianness warnings in mt7915_debugfs_rx_fw_monitor
Fix the following sparse warnings:
warning: incorrect type in initializer (different base types)
   expected restricted __le16 [usertype] msg_type
   got int
warning: incorrect type in assignment (different base types)
   expected restricted __le32 [usertype] timestamp
   got unsigned int

Fixes: 988845c9361a0 ("mt76: mt7915: add support for passing chip/firmware debug data to user space")
Signed-off-by: Lorenzo Bianconi <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-14 15:08:04 +01:00
Peter ChiuandFelix Fietkau 1d57a0d506 mt76: mt7915: initialize smps mode in mt7915_mcu_sta_rate_ctrl_tlv()
Initialize smps mode to prevent firmware rate adaptation issue.

Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Peter Chiu <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-14 15:08:04 +01:00
Bo JiaoandFelix Fietkau 7f1818cd8f mt76: mt7915: introduce band_idx in mt7915_phy
The wfsys of MT7986 has only single adie chip for non-dbdc devices,
and it binds to band1 by default. Hence this patch adds band_idx to
explicitly configure phy accordingly.

Co-developed-by: Sujuan Chen <[email protected]>
Signed-off-by: Sujuan Chen <[email protected]>
Co-developed-by: Shayne Chen <[email protected]>
Signed-off-by: Shayne Chen <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Reviewed-by: Ryder Lee <[email protected]>
Signed-off-by: Bo Jiao <[email protected]>
Signed-off-by: Felix Fietkau <[email protected]>
2022-02-14 15:08:04 +01:00