Commit graph

952621 commits

Author SHA1 Message Date
Lorenzo Bianconi
6892555dbe mt76: mt7622: fix fw hang on mt7622
Set poll timeout to 3s for mt7622 devices in order to avoid fw hangs.
Swap mt7622_trigger_hif_int and doorbell configuration order in
mt7615_mcu_drv_pmctrl routine.
Introduce mt7615_mcu_lp_drv_pmctrl routine to take care of drv_own
configuration for runtime-pm.

Fixes: 08523a2a1d ("mt76: mt7615: add mt7615_pm_wake utility routine")
Fixes: 894b7767ec ("mt76: mt7615: improve mt7615_driver_own reliability")
Fixes: 757b0e7fd6 ("mt76: mt7615: avoid polling in fw_own for mt7663")
Co-developed-by: Shayne Chen <shayne.chen@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:19 +02:00
Ryder Lee
b1b7ee2f87 mt76: mt7615: fix VHT LDPC capability
The MCU field should contain a boolean 0/1, not the flag itself.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Wang Hai
3e19073a1f mt76: mt7615: Remove set but unused variable 'index'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/net/wireless/mediatek/mt76/mt7615/testmode.c: In function mt7615_tm_set_tx_power
drivers/net/wireless/mediatek/mt76/mt7615/testmode.c:83:7: warning: variable ‘index’ set but not used [-Wunused-but-set-variable]=

commit 4f0bce1c88 ("mt76: mt7615: implement testmode support")
involved this unused variable, remove it.

Signed-off-by: Wang Hai <wanghai38@huawei.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
2bffddedfc mt76: remove retry_q from struct mt76_txq and related code
Since the switch to using AQL by default, mtxq->retry_q is never filled anymore
Remove it to get rid of a few more unnecessary cycles in the tx path

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
dd57a95cfd mt76: move txwi handling code to dma.c, since it is mmio specific
This way we can make some functions static

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
ed294cede4 mt76: mt7915: fix queue/tid mapping for airtime reporting
Unlike 7615, 7915 uses the same AC index for rx and tx, which matches the
LMAC queue mapping

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
bd397a0bf8 mt76: mt7915: simplify mt7915_lmac_mapping
Compared to mac80211 ACs, MT7915 queue numbers are in reverse order
There is no need for the defensive WARN_ON_ONCE, so we can simplify
the function to avoid the array lookup

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
75d4bf1f55 mt76: dma: cache dma map address/len in struct mt76_queue_entry
Accessing them from uncached memory can be expensive, so it's cheaper to
cache them

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
2fe1a5d61f mt76: mt7915: fix HE BSS info
he_pe_duration and he_rts_thres have the same unit as the fields in the HE
operation IE

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
781eef5b34 mt76: convert from tx tasklet to tx worker thread
This improves performance by allowing the scheduler to move the tx scheduling
work to idle CPUs. Since tx scheduling work is very latency sensitive and
kept short via AQL, sched_set_fifo_low is used to keep worker priority above
normal tasks

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
30bdd69246 mt76: add utility functions for deferring work to a kernel thread
In order to avoid keeping work like tx scheduling pinned to the CPU it was
scheduled from, it makes sense to switch from tasklets to kernel threads.

Unlike a workqueue, this one only allows one fixed worker function to be
executed by the worker thread. Because of that, there is less locking
and less code for scheduling involved.
This is important because the tx worker is scheduled often in a hot path

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:18 +02:00
Felix Fietkau
9729ff4cc5 mt76: testmode: add a limit for queued tx_frames packets
This avoids running out of available tx tokens

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
0642cf4020 mt76: mt7615: fix antenna selection for testmode tx_frames
Do not alter the tx/rx chain settings during channel setup, antennas are
remapped by the testmode specific register writes already

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
f353269d59 mt76: mt7615: fix MT_ANT_SWITCH_CON register definition
This is used for testmode tx antenna selection

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Chih-Min Chen
d3c07a9e6d mt76: mt7915: fix unexpected firmware mode
Avoid firmware falling into spectrum mode since that will set
unexpected PSE/PLE thresholds which lead to Tx hang.

This mode should be cleaned before firmware download stage.

Signed-off-by: Chih-Min Chen <chih-min.chen@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
9e47a683e9 mt76: mt76x02: tune tx ring size
Increase data queue size to improve performance.
Reduce PS/mgmt queue size

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
21fd4bb7dd mt76: mt7603: tune tx ring size
Stop relying on global tx ring size, reduce size for PS/mgmt queue

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
f099c2e5de mt76: remove struct mt76_sw_queue
All members except for the struct mt76_queue pointer have been removed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
e1378e5228 mt76: rely on AQL for burst size limits on tx queueing
Now that AQL works well on all mt76 drivers, completely replace the arbitrary
burst sizing and number of bursts logic for tx scheduling.
For the short period of time in which AQL does not work well yet, limit each
stations to 16 in-flight packets that have no estimated tx time.
This should avoid filling the queue if a station connects and queues up a
large number of packets before rate control information is available, especially
with hardware rate control

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
513d6acb97 mt76: remove swq from struct mt76_sw_queue
Since txq selection was moved to mac80211, it is no longer used

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
d80e52c7b6 mt76: remove qid argument to drv->tx_complete_skb
It is not needed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:17 +02:00
Felix Fietkau
fe5b5ab52e mt76: unify queue tx cleanup code
Cleanup and preparation for changing tx scheduling behavior

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
16254fc51f mt76: sdio: fix use of q->head and q->tail
Their use is reversed compared to DMA. The order for DMA makes more sense,
so let's use that

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
95f61e17ef mt76: usb: fix use of q->head and q->tail
Their use is reversed compared to DMA. The order for DMA makes more sense,
so let's use that

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
d407afcbd6 mt76: mt7603: check for single-stream EEPROM configuration
Some devices using MT7628 or MT7603 have only one antenna chain connected.
Detect these using the EEPROM rx/tx path settings

Reported-by: Qin Wei <me@vonger.cn>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
2d68104742 mt76: add memory barrier to DMA queue kick
Ensure that descriptor memory has been fully written before letting the
hardware read it

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
c32011bbde mt76: mt7915: add support for accessing mapped registers via bus ops
Makes it possible to read/write them via debugfs, similar to mt7615/7603

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
e17d794587 mt76: mt7615: significantly reduce interrupt load
On 7615 and newer, DMA completion only triggers unmap, but not free of queued
skbs, since pointers to packets are queued internally.
Because of that, there is no need to process the main data queue immediately
on DMA completion.
To improve performance, mask out the DMA data queue completion interrupt and
process the queue only when we receive a txfree event.
This brings the number of interrupts under load down to a small fraction.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
f8a667a9af mt76: mt7915: significantly reduce interrupt load
On 7615 and newer, DMA completion only triggers unmap, but not free of queued
skbs, since pointers to packets are queued internally.
Because of that, there is no need to process the main data queue immediately
on DMA completion.
To improve performance, mask out the DMA data queue completion interrupt and
process the queue only when we receive a txfree event.
This brings the number of interrupts under load down to a small fraction.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
250944596c mt76: mt7915: schedule tx tasklet in mt7915_mac_tx_free
The previous scheduling round may have been limited by AQL.
More frames might be available after the tx free run.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
0b51f18653 mt76: dma: update q->queued immediately on cleanup
Tx cleanup and tx enqueuing can run in parallel. In order to avoid queue
starvation issues under load, update q->queued immediately.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
0f1c443ca9 mt76: mt7915: optimize mt7915_mac_sta_poll
Since DMA completion does not imply tx completion, it makes more sense to
poll for airtime from mt7915_mac_tx_free.
Reduce the runtime of the function by moving all items from dev->sta_poll_list
to a local list once and process any stations that were added afterwards
on the next run

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:16 +02:00
Felix Fietkau
68e6644bbd mt76: mt7615: fix reading airtime statistics
- change the WTBL LMAC access function to set the mapping window only once
- use ac * 2 as offset, since each AC has separate words for rx and tx

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
8da40d6981 mt76: mt7663u: fix dma header initialization
Fix length field corruption in usb dma header introduced adding sdio
support

Fixes: 75b10f0cbd ("mt76: mt76u: add mt76_skb_adjust_pad utility routine")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
ce8463a726 mt76: fix a possible NULL pointer dereference in mt76_testmode_dump
Fix a possible NULL pointer dereference in mt76_testmode_dump() since
nla_nest_start returns NULL in case of error

Fixes: f0efa86215 ("mt76: add API for testmode support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
a081de174d mt76: mt7615: fix a possible NULL pointer dereference in mt7615_pm_wake_work
Initialize wcid to global_wcid if msta is NULL in mt7615_pm_wake_work
routine since wcid will be dereferenced running mt76_tx()

Fixes: 2b8cdfb28d ("mt76: mt7615: wake device before pushing frames in mt7615_tx")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
e862825dcf mt76: mt7615: fix possible memory leak in mt7615_tm_set_tx_power
Fix a memory leak in mt7615_tm_set_tx_power routine if
mt7615_eeprom_get_target_power_index fails.
Moreover do not account req_header twice in mcu skb allocation.

Fixes: 4f0bce1c88 ("mt76: mt7615: implement testmode support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Sean Wang
b496490886 mt76: mt7663s: fix unable to handle kernel paging request
Use buffer allocated with kmalloc instead of with stack to fix kernel
crash due to Unable to handle kernel paging request at virtual address
ffffffc0095cbce8.

[  156.977349] Unable to handle kernel paging request at virtual address ffffffc0095cbce8
[  156.985270] Mem abort info:
[  156.988059]   ESR = 0x96000045
[  156.991104]   Exception class = DABT (current EL), IL = 32 bits
[  156.997013]   SET = 0, FnV = 0
[  157.000057]   EA = 0, S1PTW = 0
[  157.003190] Data abort info:
[  157.006061]   ISV = 0, ISS = 0x00000045
[  157.009887]   CM = 0, WnR = 1
[  157.012850] swapper pgtable: 4k pages, 39-bit VAs, pgdp = 0000000042adcba2
[  157.019715] [ffffffc0095cbce8] pgd=0000000000000000, pud=0000000000000000
[  157.026499] Internal error: Oops: 96000045 [#1] PREEMPT SMP
[  157.032065] Modules linked in: mt7663s mt7663_usb_sdio_common mt7615_common

...

[  157.073007] Process CompositorTileW (pid: 1625, stack limit = 0x000000003f2389fc)
[  157.080484] CPU: 0 PID: 1625 Comm: CompositorTileW Not tainted 4.19.137 #36
[  157.092219] pstate: 80000085 (Nzcv daIf -PAN -UAO)
[  157.097012] pc : __memcpy+0xc0/0x180
[  157.100585] lr : swiotlb_tbl_unmap_single+0x84/0x14c
[  157.105540] sp : ffffff8008003cb0
[  157.108845] x29: ffffff8008003cb0 x28: ffffff9c1a211f60
[  157.114149] x27: ffffff9c19ecc018 x26: 0000000000001000
[  157.119452] x25: ffffff9c1a378000 x24: 0000000000000001
[  157.124755] x23: ffffff9c1a378000 x22: 00000000000001ff
[  157.130058] x21: 0000000000000000 x20: 00000000fbefe800
[  157.135360] x19: 0000000000000070 x18: 0000000000000000
[  157.140663] x17: 0000000000000000 x16: 0000000000000000
[  157.145965] x15: 0000000000000000 x14: 0000000000000000
[  157.151267] x13: 0000000000000000 x12: 000000000000000d
[  157.156569] x11: 000000000000000c x10: 0000000a7befe800
[  157.161873] x9 : fffffff680000000 x8 : 0000000000000000
[  157.167175] x7 : 0000000100000003 x6 : ffffffc0095cbce8
[  157.172479] x5 : 0000000000000000 x4 : 0000000000000000
[  157.177781] x3 : 0000000000000002 x2 : fffffffffffffff0
[  157.183085] x1 : ffffffca7befe810 x0 : ffffffc0095cbce8
[  157.188389] Call trace:
[  157.190832]  __memcpy+0xc0/0x180
[  157.194053]  swiotlb_unmap_sg_attrs+0xa8/0xb0
[  157.198406]  __swiotlb_unmap_sg_attrs+0x8c/0xa4
[  157.202931]  msdc_unprepare_data+0x6c/0x84
[  157.207019]  msdc_request_done+0x58/0x98
[  157.210934]  msdc_data_xfer_done+0x1a8/0x1d0
[  157.215195]  msdc_irq+0x12c/0x17c
[  157.218505]  __handle_irq_event_percpu+0xd8/0x298
[  157.223202]  handle_irq_event+0x60/0xdc
[  157.227031]  handle_fasteoi_irq+0xa4/0x1d4
[  157.231120]  __handle_domain_irq+0x84/0xc4
[  157.235210]  gic_handle_irq+0x124/0x1a4
[  157.239038]  el0_irq_naked+0x4c/0x54
[  157.242608] Code: 14000028 f1020042 5400024a a8c12027 (a88120c7)
[  157.248693] ---[ end trace 28b8090135b0a2e1 ]---
[  157.265589] Kernel panic - not syncing: Fatal exception in interrupt
[  157.271944] SMP: stopping secondary CPUs
[  157.275865] Kernel Offset: 0x1c10e00000 from 0xffffff8008000000
[  157.281779] CPU features: 0x0,2188200c
[  157.285519] Memory Limit: none

Fixes: a66cbdd657 ("mt76: mt7615: introduce mt7663s support")
Co-developed-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Sean Wang
8b7c6e1cb2 mt76: mt7663s: fix resume failure
MT7663s have to rely on MMC_PM_KEEP_POWER in pm_flags for to avoid SDIO
power is being shut off.

To fix sdio access failure like "mt7663s mmc1:0001:1: sdio write failed:
-22" for the first sdio command to access the bus in the resume handler.

Fixes: a66cbdd657 ("mt76: mt7615: introduce mt7663s support")
Co-developed-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: YN Chen <YN.Chen@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
673d7764c4 mt76: mt7663s: use NULL instead of 0 in sdio code
Fix the following sparse warnings in mt7663s driver:

drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c:78:62: warning:
Using plain integer as NULL pointer
drivers/net/wireless/mediatek/mt76/mt7615/sdio_mcu.c:110:62: warning:
Using plain integer as NULL pointer
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c:229:64: warning:
Using plain integer as NULL pointer
drivers/net/wireless/mediatek/mt76/mt7615/sdio_txrx.c:263:64: warning:
Using plain integer as NULL pointer

Fixes: a66cbdd657 ("mt76: mt7615: introduce mt7663s support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Lorenzo Bianconi
346f810e22 mt76: mt7615: release mutex in mt7615_reset_test_set
Reduce scope of mutex_acquire/mutex_release in mt7615_reset_test_set
routine in order to fix the following static checker warning:

drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c:179
mt7615_reset_test_set()
warn: inconsistent returns 'dev->mt76.mutex'.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: ea4906c4be ("mt76: mt7615: wake device before accessing regmap in debugfs")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Ryder Lee
b443e55fb5 mt76: mt7915: add Tx A-MSDU offloading support
This disables the software A-MSDU aggregation in mac80211 and enables hardware
offloading

Suggested-by: Yiwei Chung <yiwei.chung@mediatek.com>
Suggested-by: YF Luo <yf.luo@mediatek.com>
Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Shayne Chen <shayne.chen@mediatek.com>
Co-developed-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Felix Fietkau
2a3412061a mt76: mt7915: add missing flags in WMM parameter settings
Indicate the filled parameter to the firmware

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:15 +02:00
Felix Fietkau
481e34a702 mt76: mt7915: simplify aggregation session check
Use the txwi data as primary source information to avoid touching skb data
Use bitfield instead of state variable + spinlock

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
5c4b29fd9a mt76: mt7615: remove mtxq->agg_ssn assignment
It is not used anywhere for this driver

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
c50d105aa7 mt76: move mt76_check_agg_ssn to driver tx_prepare calls
mt7615 and newer drivers do not need this, since they use sequence number offload
Moving this code also reduces the number of callsites to make it easier to review

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
577dbc6c65 mt76: mt7915: enable offloading of sequence number assignment
Preparation for supporting more offload features

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
3dff191800 mt76: mt7915: increase tx retry count
Set it to 15 to match reference driver

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
1daf2522fa mt76: mt7915: clean up station stats polling and rate control update
Queueing a per-sta work item from the tx free path can become very expensive
under load. This work is only supposed to pull rate control stats every
second and deal with rate control changes.

Additionally, the rate control update code was wrong, because it was
confusing bit masks and bit numbers in test_bit.

Fix this by introducing a dedicated device work item for rate control
updates, and by polling station stats from the phy mac work.
Stations requiring polling or rate control updates are added to lists
protected by dev->sta_poll_lock.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00
Felix Fietkau
38b04398c5 mt76: mt7915: do not do any work in napi poll after calling napi_complete_done()
Fixes a race condition where multiple tx cleanup or sta poll tasks could run
in parallel.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2020-09-24 18:10:14 +02:00