On 11/25/19 2:04 PM, Stanislaw Gruszka wrote: > On Thu, Nov 21, 2019 at 07:00:01PM +0100, Markus Theil wrote: >> diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> index 90c024f12302..b9bd6bfb2a9d 100644 >> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c >> @@ -210,6 +210,12 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work) >> >> mt76x02_mac_set_beacon_prepare(dev); >> >> + mt76_csa_check(&dev->mt76); >> + if (dev->mt76.csa_complete) { >> + mt76_csa_finish(&dev->mt76); >> + goto out; >> + } > mmio counterpart setup beacons on CSA, but do not sent buffered > PS frames. Perhaps here we should do the same. However not sending > beacons on one TBTT looks ok to me as well. > > Stanislaw > If I change the order of beacon iteration and csa check, the following warning in mac80211 gets triggered: /* the counter should never reach 0 */ WARN_ON_ONCE(!beacon->csa_current_counter); Dmesg output looks like this: [ 153.829617] ------------[ cut here ]------------ [ 153.829752] WARNING: CPU: 0 PID: 224 at net/mac80211/tx.c:4318 __ieee80211_csa_update_counter.isra.0.part.0+0x5/0x10 [mac80211] [ 153.829756] Modules linked in: ccm bridge stp llc nft_masq nft_chain_nat nf_nat nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c nf_tables_set nf_tables nfnetlink ath10k_pci amd64_edac_mod mt76x2u edac_mce_amd mt76x2_common ath10k_core mt76x02_usb kvm_amd mt76_usb mt76x02_lib mt76 kvm ath mac80211 irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel cfg80211 pcengines_apuv2 gpio_keys_polled aesni_intel input_polldev crypto_simd gpio_amd_fch cryptd glue_helper igb pcspkr k10temp fam15h_power rfkill sp5100_tco i2c_piix4 libarc4 ccp i2c_algo_bit dca rng_core uio_pdrv_genirq uio leds_gpio evdev mac_hid pinctrl_amd coreboot_table acpi_cpufreq ip_tables x_tables ext4 crc32c_generic crc16 mbcache jbd2 sd_mod ahci sdhci_pci libahci cqhci libata sdhci crc32c_intel xhci_pci ehci_pci mmc_core xhci_hcd scsi_mod ehci_hcd gpio_keys [ 153.829948] CPU: 0 PID: 224 Comm: kworker/0:1H Not tainted 5.4.0-rc7-1-01110-g19b7e21c55c8 #32 [ 153.829952] Hardware name: PC Engines apu2/apu2, BIOS v4.10.0.3 11/07/2019 [ 153.829966] Workqueue: events_highpri mt76x02u_pre_tbtt_work [mt76x02_usb] [ 153.830067] RIP: 0010:__ieee80211_csa_update_counter.isra.0.part.0+0x5/0x10 [mac80211] [ 153.830077] Code: 4c 89 4a 18 c3 48 8b 47 10 4c 89 4f 10 48 89 4e 18 48 89 46 20 4c 89 08 eb a1 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 <0f> 0b c3 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 54 53 48 89 fb [ 153.830082] RSP: 0018:ffffbde8803d7c80 EFLAGS: 00010246 [ 153.830089] RAX: 0000000000000003 RBX: ffffbde8803d7d20 RCX: ffffa3b01df8f658 [ 153.830093] RDX: ffffbde8803d7d20 RSI: ffffa3b02901d450 RDI: ffffbde8803d7ce0 [ 153.830097] RBP: ffffa3b0267007a0 R08: ffffffff8d011040 R09: 0000000000000000 [ 153.830101] R10: ffffa3b029908098 R11: ffffa3b02ab2ab38 R12: 0000000000000000 [ 153.830105] R13: ffffa3b02901d450 R14: 0000000000000000 R15: ffffa3b0284eae00 [ 153.830111] FS: 0000000000000000(0000) GS:ffffa3b02aa00000(0000) knlGS:0000000000000000 [ 153.830115] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 153.830119] CR2: 00007fbb6b5c9f30 CR3: 0000000126ee2000 CR4: 00000000000406f0 [ 153.830124] Call Trace: [ 153.830203] __ieee80211_beacon_get+0x4c2/0x4d0 [mac80211] [ 153.830312] ieee80211_beacon_get_tim+0x41/0x150 [mac80211] [ 153.830336] mt76x02_update_beacon_iter+0x2d/0x40 [mt76x02_lib] [ 153.830352] ? mt76x02_add_buffered_bc+0x80/0x80 [mt76x02_lib] [ 153.830420] __iterate_interfaces+0x74/0x110 [mac80211] [ 153.830469] ? mt76x02_add_buffered_bc+0x80/0x80 [mt76x02_lib] [ 153.830566] ieee80211_iterate_interfaces+0x3a/0x50 [mac80211] [ 153.830580] mt76x02u_pre_tbtt_work+0x96/0x220 [mt76x02_usb] [ 153.830600] process_one_work+0x1e2/0x3b0 [ 153.830610] worker_thread+0x4a/0x3d0 [ 153.830623] kthread+0xfb/0x130 [ 153.830631] ? process_one_work+0x3b0/0x3b0 [ 153.830639] ? kthread_park+0x90/0x90 [ 153.830650] ret_from_fork+0x22/0x40 [ 153.830665] ---[ end trace 7a658e5cbfd0f9d1 ]--- Markus