Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'wireless-2025-10-30' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless

Johannes Berg says:

====================
Couple of new fixes:

- ath10k: revert a patch that had caused issues on some devices
- cfg80211/mac80211: use hrtimers for some things where the
precise timing matters
- zd1211rw: fix a long-standing potential leak

* tag 'wireless-2025-10-30' of https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless:
wifi: zd1211rw: fix potential memory leak in __zd_usb_enable_rx()
wifi: mac80211: use wiphy_hrtimer_work for csa.switch_work
wifi: mac80211: use wiphy_hrtimer_work for ml_reconf_work
wifi: mac80211: use wiphy_hrtimer_work for ttlm_work
wifi: cfg80211: add an hrtimer based delayed work item
Revert "wifi: ath10k: avoid unnecessary wait for service ready message"
====================

Link: https://patch.msgid.link/20251030104919.12871-3-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+209 -52
+20 -19
drivers/net/wireless/ath/ath10k/wmi.c
··· 1764 1764 1765 1765 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar) 1766 1766 { 1767 - unsigned long timeout = jiffies + WMI_SERVICE_READY_TIMEOUT_HZ; 1768 1767 unsigned long time_left, i; 1769 1768 1770 - /* Sometimes the PCI HIF doesn't receive interrupt 1771 - * for the service ready message even if the buffer 1772 - * was completed. PCIe sniffer shows that it's 1773 - * because the corresponding CE ring doesn't fires 1774 - * it. Workaround here by polling CE rings. Since 1775 - * the message could arrive at any time, continue 1776 - * polling until timeout. 1777 - */ 1778 - do { 1769 + time_left = wait_for_completion_timeout(&ar->wmi.service_ready, 1770 + WMI_SERVICE_READY_TIMEOUT_HZ); 1771 + if (!time_left) { 1772 + /* Sometimes the PCI HIF doesn't receive interrupt 1773 + * for the service ready message even if the buffer 1774 + * was completed. PCIe sniffer shows that it's 1775 + * because the corresponding CE ring doesn't fires 1776 + * it. Workaround here by polling CE rings once. 1777 + */ 1778 + ath10k_warn(ar, "failed to receive service ready completion, polling..\n"); 1779 + 1779 1780 for (i = 0; i < CE_COUNT; i++) 1780 1781 ath10k_hif_send_complete_check(ar, i, 1); 1781 1782 1782 - /* The 100 ms granularity is a tradeoff considering scheduler 1783 - * overhead and response latency 1784 - */ 1785 1783 time_left = wait_for_completion_timeout(&ar->wmi.service_ready, 1786 - msecs_to_jiffies(100)); 1787 - if (time_left) 1788 - return 0; 1789 - } while (time_before(jiffies, timeout)); 1784 + WMI_SERVICE_READY_TIMEOUT_HZ); 1785 + if (!time_left) { 1786 + ath10k_warn(ar, "polling timed out\n"); 1787 + return -ETIMEDOUT; 1788 + } 1790 1789 1791 - ath10k_warn(ar, "failed to receive service ready completion\n"); 1792 - return -ETIMEDOUT; 1790 + ath10k_warn(ar, "service ready completion received, continuing normally\n"); 1791 + } 1792 + 1793 + return 0; 1793 1794 } 1794 1795 1795 1796 int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
+1
drivers/net/wireless/zydas/zd1211rw/zd_usb.c
··· 791 791 if (urbs) { 792 792 for (i = 0; i < RX_URBS_COUNT; i++) 793 793 free_rx_urb(urbs[i]); 794 + kfree(urbs); 794 795 } 795 796 return r; 796 797 }
+78
include/net/cfg80211.h
··· 6435 6435 * after wiphy_lock() was called. Therefore, wiphy_cancel_work() can 6436 6436 * use just cancel_work() instead of cancel_work_sync(), it requires 6437 6437 * being in a section protected by wiphy_lock(). 6438 + * 6439 + * Note that these are scheduled with a timer where the accuracy 6440 + * becomes less the longer in the future the scheduled timer is. Use 6441 + * wiphy_hrtimer_work_queue() if the timer must be not be late by more 6442 + * than approximately 10 percent. 6438 6443 */ 6439 6444 void wiphy_delayed_work_queue(struct wiphy *wiphy, 6440 6445 struct wiphy_delayed_work *dwork, ··· 6510 6505 */ 6511 6506 bool wiphy_delayed_work_pending(struct wiphy *wiphy, 6512 6507 struct wiphy_delayed_work *dwork); 6508 + 6509 + struct wiphy_hrtimer_work { 6510 + struct wiphy_work work; 6511 + struct wiphy *wiphy; 6512 + struct hrtimer timer; 6513 + }; 6514 + 6515 + enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t); 6516 + 6517 + static inline void wiphy_hrtimer_work_init(struct wiphy_hrtimer_work *hrwork, 6518 + wiphy_work_func_t func) 6519 + { 6520 + hrtimer_setup(&hrwork->timer, wiphy_hrtimer_work_timer, 6521 + CLOCK_BOOTTIME, HRTIMER_MODE_REL); 6522 + wiphy_work_init(&hrwork->work, func); 6523 + } 6524 + 6525 + /** 6526 + * wiphy_hrtimer_work_queue - queue hrtimer work for the wiphy 6527 + * @wiphy: the wiphy to queue for 6528 + * @hrwork: the high resolution timer worker 6529 + * @delay: the delay given as a ktime_t 6530 + * 6531 + * Please refer to wiphy_delayed_work_queue(). The difference is that 6532 + * the hrtimer work uses a high resolution timer for scheduling. This 6533 + * may be needed if timeouts might be scheduled further in the future 6534 + * and the accuracy of the normal timer is not sufficient. 6535 + * 6536 + * Expect a delay of a few milliseconds as the timer is scheduled 6537 + * with some slack and some more time may pass between queueing the 6538 + * work and its start. 6539 + */ 6540 + void wiphy_hrtimer_work_queue(struct wiphy *wiphy, 6541 + struct wiphy_hrtimer_work *hrwork, 6542 + ktime_t delay); 6543 + 6544 + /** 6545 + * wiphy_hrtimer_work_cancel - cancel previously queued hrtimer work 6546 + * @wiphy: the wiphy, for debug purposes 6547 + * @hrtimer: the hrtimer work to cancel 6548 + * 6549 + * Cancel the work *without* waiting for it, this assumes being 6550 + * called under the wiphy mutex acquired by wiphy_lock(). 6551 + */ 6552 + void wiphy_hrtimer_work_cancel(struct wiphy *wiphy, 6553 + struct wiphy_hrtimer_work *hrtimer); 6554 + 6555 + /** 6556 + * wiphy_hrtimer_work_flush - flush previously queued hrtimer work 6557 + * @wiphy: the wiphy, for debug purposes 6558 + * @hrwork: the hrtimer work to flush 6559 + * 6560 + * Flush the work (i.e. run it if pending). This must be called 6561 + * under the wiphy mutex acquired by wiphy_lock(). 6562 + */ 6563 + void wiphy_hrtimer_work_flush(struct wiphy *wiphy, 6564 + struct wiphy_hrtimer_work *hrwork); 6565 + 6566 + /** 6567 + * wiphy_hrtimer_work_pending - Find out whether a wiphy hrtimer 6568 + * work item is currently pending. 6569 + * 6570 + * @wiphy: the wiphy, for debug purposes 6571 + * @hrwork: the hrtimer work in question 6572 + * 6573 + * Return: true if timer is pending, false otherwise 6574 + * 6575 + * Please refer to the wiphy_delayed_work_pending() documentation as 6576 + * this is the equivalent function for hrtimer based delayed work 6577 + * items. 6578 + */ 6579 + bool wiphy_hrtimer_work_pending(struct wiphy *wiphy, 6580 + struct wiphy_hrtimer_work *hrwork); 6513 6581 6514 6582 /** 6515 6583 * enum ieee80211_ap_reg_power - regulatory power for an Access Point
+1 -1
net/mac80211/chan.c
··· 1290 1290 &link->csa.finalize_work); 1291 1291 break; 1292 1292 case NL80211_IFTYPE_STATION: 1293 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 1293 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 1294 1294 &link->u.mgd.csa.switch_work, 0); 1295 1295 break; 1296 1296 case NL80211_IFTYPE_UNSPECIFIED:
+4 -4
net/mac80211/ieee80211_i.h
··· 612 612 u8 *assoc_req_ies; 613 613 size_t assoc_req_ies_len; 614 614 615 - struct wiphy_delayed_work ml_reconf_work; 615 + struct wiphy_hrtimer_work ml_reconf_work; 616 616 u16 removed_links; 617 617 618 618 /* TID-to-link mapping support */ 619 - struct wiphy_delayed_work ttlm_work; 619 + struct wiphy_hrtimer_work ttlm_work; 620 620 struct ieee80211_adv_ttlm_info ttlm_info; 621 621 struct wiphy_work teardown_ttlm_work; 622 622 ··· 1017 1017 bool operating_11g_mode; 1018 1018 1019 1019 struct { 1020 - struct wiphy_delayed_work switch_work; 1020 + struct wiphy_hrtimer_work switch_work; 1021 1021 struct cfg80211_chan_def ap_chandef; 1022 1022 struct ieee80211_parsed_tpe tpe; 1023 - unsigned long time; 1023 + ktime_t time; 1024 1024 bool waiting_bcn; 1025 1025 bool ignored_same_chan; 1026 1026 bool blocked_tx;
+2 -2
net/mac80211/link.c
··· 472 472 * from there. 473 473 */ 474 474 if (link->conf->csa_active) 475 - wiphy_delayed_work_queue(local->hw.wiphy, 475 + wiphy_hrtimer_work_queue(local->hw.wiphy, 476 476 &link->u.mgd.csa.switch_work, 477 477 link->u.mgd.csa.time - 478 - jiffies); 478 + ktime_get_boottime()); 479 479 } 480 480 481 481 for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {
+26 -26
net/mac80211/mlme.c
··· 45 45 #define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10) 46 46 #define IEEE80211_ASSOC_MAX_TRIES 3 47 47 48 - #define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS msecs_to_jiffies(100) 48 + #define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS (100 * USEC_PER_MSEC) 49 49 #define IEEE80211_ADV_TTLM_ST_UNDERFLOW 0xff00 50 50 51 51 #define IEEE80211_NEG_TTLM_REQ_TIMEOUT (HZ / 5) ··· 2594 2594 return; 2595 2595 } 2596 2596 2597 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 2597 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 2598 2598 &link->u.mgd.csa.switch_work, 0); 2599 2599 } 2600 2600 ··· 2753 2753 .timestamp = timestamp, 2754 2754 .device_timestamp = device_timestamp, 2755 2755 }; 2756 - unsigned long now; 2756 + u32 csa_time_tu; 2757 + ktime_t now; 2757 2758 int res; 2758 2759 2759 2760 lockdep_assert_wiphy(local->hw.wiphy); ··· 2984 2983 csa_ie.mode); 2985 2984 2986 2985 /* we may have to handle timeout for deactivated link in software */ 2987 - now = jiffies; 2988 - link->u.mgd.csa.time = now + 2989 - TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) * 2990 - link->conf->beacon_int); 2986 + now = ktime_get_boottime(); 2987 + csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int; 2988 + link->u.mgd.csa.time = now + us_to_ktime(ieee80211_tu_to_usec(csa_time_tu)); 2991 2989 2992 2990 if (ieee80211_vif_link_active(&sdata->vif, link->link_id) && 2993 2991 local->ops->channel_switch) { ··· 3001 3001 } 3002 3002 3003 3003 /* channel switch handled in software */ 3004 - wiphy_delayed_work_queue(local->hw.wiphy, 3004 + wiphy_hrtimer_work_queue(local->hw.wiphy, 3005 3005 &link->u.mgd.csa.switch_work, 3006 3006 link->u.mgd.csa.time - now); 3007 3007 return; ··· 4242 4242 4243 4243 memset(&sdata->u.mgd.ttlm_info, 0, 4244 4244 sizeof(sdata->u.mgd.ttlm_info)); 4245 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work); 4245 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work); 4246 4246 4247 4247 memset(&sdata->vif.neg_ttlm, 0, sizeof(sdata->vif.neg_ttlm)); 4248 4248 wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 4249 4249 &ifmgd->neg_ttlm_timeout_work); 4250 4250 4251 4251 sdata->u.mgd.removed_links = 0; 4252 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 4252 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 4253 4253 &sdata->u.mgd.ml_reconf_work); 4254 4254 4255 4255 wiphy_work_cancel(sdata->local->hw.wiphy, ··· 6876 6876 /* In case the removal was cancelled, abort it */ 6877 6877 if (sdata->u.mgd.removed_links) { 6878 6878 sdata->u.mgd.removed_links = 0; 6879 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 6879 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 6880 6880 &sdata->u.mgd.ml_reconf_work); 6881 6881 } 6882 6882 return; ··· 6906 6906 } 6907 6907 6908 6908 sdata->u.mgd.removed_links = removed_links; 6909 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 6909 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 6910 6910 &sdata->u.mgd.ml_reconf_work, 6911 - TU_TO_JIFFIES(delay)); 6911 + us_to_ktime(ieee80211_tu_to_usec(delay))); 6912 6912 } 6913 6913 6914 6914 static int ieee80211_ttlm_set_links(struct ieee80211_sub_if_data *sdata, ··· 7095 7095 /* if a planned TID-to-link mapping was cancelled - 7096 7096 * abort it 7097 7097 */ 7098 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 7098 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 7099 7099 &sdata->u.mgd.ttlm_work); 7100 7100 } else if (sdata->u.mgd.ttlm_info.active) { 7101 7101 /* if no TID-to-link element, set to default mapping in ··· 7130 7130 7131 7131 if (ttlm_info.switch_time) { 7132 7132 u16 beacon_ts_tu, st_tu, delay; 7133 - u32 delay_jiffies; 7133 + u64 delay_usec; 7134 7134 u64 mask; 7135 7135 7136 7136 /* The t2l map switch time is indicated with a partial ··· 7152 7152 if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW) 7153 7153 return; 7154 7154 7155 - delay_jiffies = TU_TO_JIFFIES(delay); 7155 + delay_usec = ieee80211_tu_to_usec(delay); 7156 7156 7157 7157 /* Link switching can take time, so schedule it 7158 7158 * 100ms before to be ready on time 7159 7159 */ 7160 - if (delay_jiffies > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS) 7161 - delay_jiffies -= 7160 + if (delay_usec > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS) 7161 + delay_usec -= 7162 7162 IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS; 7163 7163 else 7164 - delay_jiffies = 0; 7164 + delay_usec = 0; 7165 7165 7166 7166 sdata->u.mgd.ttlm_info = ttlm_info; 7167 - wiphy_delayed_work_cancel(sdata->local->hw.wiphy, 7167 + wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, 7168 7168 &sdata->u.mgd.ttlm_work); 7169 - wiphy_delayed_work_queue(sdata->local->hw.wiphy, 7169 + wiphy_hrtimer_work_queue(sdata->local->hw.wiphy, 7170 7170 &sdata->u.mgd.ttlm_work, 7171 - delay_jiffies); 7171 + us_to_ktime(delay_usec)); 7172 7172 return; 7173 7173 } 7174 7174 } ··· 8793 8793 ieee80211_csa_connection_drop_work); 8794 8794 wiphy_delayed_work_init(&ifmgd->tdls_peer_del_work, 8795 8795 ieee80211_tdls_peer_del_work); 8796 - wiphy_delayed_work_init(&ifmgd->ml_reconf_work, 8796 + wiphy_hrtimer_work_init(&ifmgd->ml_reconf_work, 8797 8797 ieee80211_ml_reconf_work); 8798 8798 wiphy_delayed_work_init(&ifmgd->reconf.wk, 8799 8799 ieee80211_ml_sta_reconf_timeout); ··· 8802 8802 timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0); 8803 8803 wiphy_delayed_work_init(&ifmgd->tx_tspec_wk, 8804 8804 ieee80211_sta_handle_tspec_ac_params_wk); 8805 - wiphy_delayed_work_init(&ifmgd->ttlm_work, 8805 + wiphy_hrtimer_work_init(&ifmgd->ttlm_work, 8806 8806 ieee80211_tid_to_link_map_work); 8807 8807 wiphy_delayed_work_init(&ifmgd->neg_ttlm_timeout_work, 8808 8808 ieee80211_neg_ttlm_timeout_work); ··· 8849 8849 else 8850 8850 link->u.mgd.req_smps = IEEE80211_SMPS_OFF; 8851 8851 8852 - wiphy_delayed_work_init(&link->u.mgd.csa.switch_work, 8852 + wiphy_hrtimer_work_init(&link->u.mgd.csa.switch_work, 8853 8853 ieee80211_csa_switch_work); 8854 8854 8855 8855 ieee80211_clear_tpe(&link->conf->tpe); ··· 10064 10064 &link->u.mgd.request_smps_work); 10065 10065 wiphy_work_cancel(link->sdata->local->hw.wiphy, 10066 10066 &link->u.mgd.recalc_smps); 10067 - wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy, 10067 + wiphy_hrtimer_work_cancel(link->sdata->local->hw.wiphy, 10068 10068 &link->u.mgd.csa.switch_work); 10069 10069 } 10070 10070
+56
net/wireless/core.c
··· 1787 1787 } 1788 1788 EXPORT_SYMBOL_GPL(wiphy_delayed_work_pending); 1789 1789 1790 + enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t) 1791 + { 1792 + struct wiphy_hrtimer_work *hrwork = 1793 + container_of(t, struct wiphy_hrtimer_work, timer); 1794 + 1795 + wiphy_work_queue(hrwork->wiphy, &hrwork->work); 1796 + 1797 + return HRTIMER_NORESTART; 1798 + } 1799 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_timer); 1800 + 1801 + void wiphy_hrtimer_work_queue(struct wiphy *wiphy, 1802 + struct wiphy_hrtimer_work *hrwork, 1803 + ktime_t delay) 1804 + { 1805 + trace_wiphy_hrtimer_work_queue(wiphy, &hrwork->work, delay); 1806 + 1807 + if (!delay) { 1808 + hrtimer_cancel(&hrwork->timer); 1809 + wiphy_work_queue(wiphy, &hrwork->work); 1810 + return; 1811 + } 1812 + 1813 + hrwork->wiphy = wiphy; 1814 + hrtimer_start_range_ns(&hrwork->timer, delay, 1815 + 1000 * NSEC_PER_USEC, HRTIMER_MODE_REL); 1816 + } 1817 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_queue); 1818 + 1819 + void wiphy_hrtimer_work_cancel(struct wiphy *wiphy, 1820 + struct wiphy_hrtimer_work *hrwork) 1821 + { 1822 + lockdep_assert_held(&wiphy->mtx); 1823 + 1824 + hrtimer_cancel(&hrwork->timer); 1825 + wiphy_work_cancel(wiphy, &hrwork->work); 1826 + } 1827 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_cancel); 1828 + 1829 + void wiphy_hrtimer_work_flush(struct wiphy *wiphy, 1830 + struct wiphy_hrtimer_work *hrwork) 1831 + { 1832 + lockdep_assert_held(&wiphy->mtx); 1833 + 1834 + hrtimer_cancel(&hrwork->timer); 1835 + wiphy_work_flush(wiphy, &hrwork->work); 1836 + } 1837 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_flush); 1838 + 1839 + bool wiphy_hrtimer_work_pending(struct wiphy *wiphy, 1840 + struct wiphy_hrtimer_work *hrwork) 1841 + { 1842 + return hrtimer_is_queued(&hrwork->timer); 1843 + } 1844 + EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_pending); 1845 + 1790 1846 static int __init cfg80211_init(void) 1791 1847 { 1792 1848 int err;
+21
net/wireless/trace.h
··· 304 304 __entry->delay) 305 305 ); 306 306 307 + TRACE_EVENT(wiphy_hrtimer_work_queue, 308 + TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work, 309 + ktime_t delay), 310 + TP_ARGS(wiphy, work, delay), 311 + TP_STRUCT__entry( 312 + WIPHY_ENTRY 313 + __field(void *, instance) 314 + __field(void *, func) 315 + __field(ktime_t, delay) 316 + ), 317 + TP_fast_assign( 318 + WIPHY_ASSIGN; 319 + __entry->instance = work; 320 + __entry->func = work->func; 321 + __entry->delay = delay; 322 + ), 323 + TP_printk(WIPHY_PR_FMT " instance=%p func=%pS delay=%llu", 324 + WIPHY_PR_ARG, __entry->instance, __entry->func, 325 + __entry->delay) 326 + ); 327 + 307 328 TRACE_EVENT(wiphy_work_worker_start, 308 329 TP_PROTO(struct wiphy *wiphy), 309 330 TP_ARGS(wiphy),