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
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEpeA8sTs3M8SN2hR410qiO8sPaAAFAmkDQiwACgkQ10qiO8sP
 aAD8mg//RrRLyJIrVzC/c5TtiVT/ziwyMPMe6l6aRBSN+H/15hX+QfsDt29x+BgX
 CyN9io7Tix3Szshos3XPSrWjKrRy2JYDDGQbVW1npxzAs/E4O5rhETm3SWymHkJh
 geF3W9NDbF7OQIzm6jBp7/i5Im97LU7Y6c9Pd6FxPucKBvFahvxqyDvrD2MAa6/j
 RDr9de7l7X02xymU8Z2h4qNjXQ1fbLWio1UMr+xPxPvPmXsR4aYfGb3xESryHS1y
 a2Xnui1Apzv0Bxf0j0CrsqPoZmSSMhhfB5NMclTsZluPZySRmFygoPt5fjoeaw/Q
 8Ga4nkzUW2ZMZ9CJiB8qFX8dSQ+k658AyVY0XAQkZFey4e0kPwwOG/f1xBoAeIW5
 VcvLbxIZ2Ao3K2qAg5f2bfPyjcp1t+I4iFb/WKzTzX5EcuHcxB5IfoqYfIAkLfgP
 ada9iCJzrVv0+aBCbpKvDm+BAnV/H1sQVRtPQKH09+P8Dylj/klVRYemBMzG9zH2
 zSrkllJrESKUI7Y0fDszt4G9HmWuX9+y5eKhHrLwYkUutqIJsdkW9hbe+EQGUIke
 bOL5nH5hhQDaOa5hpoTQRUKYZb+4tbttKCa9Bii+1M1NgPlQq22Ud4wBdGWqvfqF
 dFHx7vmbVAqrTl8RzXtpLj/UVbgVNhGJAIbD6IAc3DyZC4BvZJs=
 =3oN9
 -----END PGP SIGNATURE-----

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>
This commit is contained in:
Jakub Kicinski 2025-10-31 12:30:32 -07:00
commit b7904323e7
9 changed files with 209 additions and 52 deletions

View File

@ -1764,32 +1764,33 @@ void ath10k_wmi_put_wmi_channel(struct ath10k *ar, struct wmi_channel *ch,
int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
{
unsigned long timeout = jiffies + WMI_SERVICE_READY_TIMEOUT_HZ;
unsigned long time_left, i;
/* Sometimes the PCI HIF doesn't receive interrupt
* for the service ready message even if the buffer
* was completed. PCIe sniffer shows that it's
* because the corresponding CE ring doesn't fires
* it. Workaround here by polling CE rings. Since
* the message could arrive at any time, continue
* polling until timeout.
*/
do {
time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
WMI_SERVICE_READY_TIMEOUT_HZ);
if (!time_left) {
/* Sometimes the PCI HIF doesn't receive interrupt
* for the service ready message even if the buffer
* was completed. PCIe sniffer shows that it's
* because the corresponding CE ring doesn't fires
* it. Workaround here by polling CE rings once.
*/
ath10k_warn(ar, "failed to receive service ready completion, polling..\n");
for (i = 0; i < CE_COUNT; i++)
ath10k_hif_send_complete_check(ar, i, 1);
/* The 100 ms granularity is a tradeoff considering scheduler
* overhead and response latency
*/
time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
msecs_to_jiffies(100));
if (time_left)
return 0;
} while (time_before(jiffies, timeout));
WMI_SERVICE_READY_TIMEOUT_HZ);
if (!time_left) {
ath10k_warn(ar, "polling timed out\n");
return -ETIMEDOUT;
}
ath10k_warn(ar, "failed to receive service ready completion\n");
return -ETIMEDOUT;
ath10k_warn(ar, "service ready completion received, continuing normally\n");
}
return 0;
}
int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)

View File

@ -791,6 +791,7 @@ static int __zd_usb_enable_rx(struct zd_usb *usb)
if (urbs) {
for (i = 0; i < RX_URBS_COUNT; i++)
free_rx_urb(urbs[i]);
kfree(urbs);
}
return r;
}

View File

@ -6435,6 +6435,11 @@ static inline void wiphy_delayed_work_init(struct wiphy_delayed_work *dwork,
* after wiphy_lock() was called. Therefore, wiphy_cancel_work() can
* use just cancel_work() instead of cancel_work_sync(), it requires
* being in a section protected by wiphy_lock().
*
* Note that these are scheduled with a timer where the accuracy
* becomes less the longer in the future the scheduled timer is. Use
* wiphy_hrtimer_work_queue() if the timer must be not be late by more
* than approximately 10 percent.
*/
void wiphy_delayed_work_queue(struct wiphy *wiphy,
struct wiphy_delayed_work *dwork,
@ -6506,6 +6511,79 @@ void wiphy_delayed_work_flush(struct wiphy *wiphy,
bool wiphy_delayed_work_pending(struct wiphy *wiphy,
struct wiphy_delayed_work *dwork);
struct wiphy_hrtimer_work {
struct wiphy_work work;
struct wiphy *wiphy;
struct hrtimer timer;
};
enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t);
static inline void wiphy_hrtimer_work_init(struct wiphy_hrtimer_work *hrwork,
wiphy_work_func_t func)
{
hrtimer_setup(&hrwork->timer, wiphy_hrtimer_work_timer,
CLOCK_BOOTTIME, HRTIMER_MODE_REL);
wiphy_work_init(&hrwork->work, func);
}
/**
* wiphy_hrtimer_work_queue - queue hrtimer work for the wiphy
* @wiphy: the wiphy to queue for
* @hrwork: the high resolution timer worker
* @delay: the delay given as a ktime_t
*
* Please refer to wiphy_delayed_work_queue(). The difference is that
* the hrtimer work uses a high resolution timer for scheduling. This
* may be needed if timeouts might be scheduled further in the future
* and the accuracy of the normal timer is not sufficient.
*
* Expect a delay of a few milliseconds as the timer is scheduled
* with some slack and some more time may pass between queueing the
* work and its start.
*/
void wiphy_hrtimer_work_queue(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork,
ktime_t delay);
/**
* wiphy_hrtimer_work_cancel - cancel previously queued hrtimer work
* @wiphy: the wiphy, for debug purposes
* @hrtimer: the hrtimer work to cancel
*
* Cancel the work *without* waiting for it, this assumes being
* called under the wiphy mutex acquired by wiphy_lock().
*/
void wiphy_hrtimer_work_cancel(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrtimer);
/**
* wiphy_hrtimer_work_flush - flush previously queued hrtimer work
* @wiphy: the wiphy, for debug purposes
* @hrwork: the hrtimer work to flush
*
* Flush the work (i.e. run it if pending). This must be called
* under the wiphy mutex acquired by wiphy_lock().
*/
void wiphy_hrtimer_work_flush(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork);
/**
* wiphy_hrtimer_work_pending - Find out whether a wiphy hrtimer
* work item is currently pending.
*
* @wiphy: the wiphy, for debug purposes
* @hrwork: the hrtimer work in question
*
* Return: true if timer is pending, false otherwise
*
* Please refer to the wiphy_delayed_work_pending() documentation as
* this is the equivalent function for hrtimer based delayed work
* items.
*/
bool wiphy_hrtimer_work_pending(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork);
/**
* enum ieee80211_ap_reg_power - regulatory power for an Access Point
*

View File

@ -1290,7 +1290,7 @@ ieee80211_link_chanctx_reservation_complete(struct ieee80211_link_data *link)
&link->csa.finalize_work);
break;
case NL80211_IFTYPE_STATION:
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
&link->u.mgd.csa.switch_work, 0);
break;
case NL80211_IFTYPE_UNSPECIFIED:

View File

@ -612,11 +612,11 @@ struct ieee80211_if_managed {
u8 *assoc_req_ies;
size_t assoc_req_ies_len;
struct wiphy_delayed_work ml_reconf_work;
struct wiphy_hrtimer_work ml_reconf_work;
u16 removed_links;
/* TID-to-link mapping support */
struct wiphy_delayed_work ttlm_work;
struct wiphy_hrtimer_work ttlm_work;
struct ieee80211_adv_ttlm_info ttlm_info;
struct wiphy_work teardown_ttlm_work;
@ -1017,10 +1017,10 @@ struct ieee80211_link_data_managed {
bool operating_11g_mode;
struct {
struct wiphy_delayed_work switch_work;
struct wiphy_hrtimer_work switch_work;
struct cfg80211_chan_def ap_chandef;
struct ieee80211_parsed_tpe tpe;
unsigned long time;
ktime_t time;
bool waiting_bcn;
bool ignored_same_chan;
bool blocked_tx;

View File

@ -472,10 +472,10 @@ static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata,
* from there.
*/
if (link->conf->csa_active)
wiphy_delayed_work_queue(local->hw.wiphy,
wiphy_hrtimer_work_queue(local->hw.wiphy,
&link->u.mgd.csa.switch_work,
link->u.mgd.csa.time -
jiffies);
ktime_get_boottime());
}
for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) {

View File

@ -45,7 +45,7 @@
#define IEEE80211_ASSOC_TIMEOUT_SHORT (HZ / 10)
#define IEEE80211_ASSOC_MAX_TRIES 3
#define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS msecs_to_jiffies(100)
#define IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS (100 * USEC_PER_MSEC)
#define IEEE80211_ADV_TTLM_ST_UNDERFLOW 0xff00
#define IEEE80211_NEG_TTLM_REQ_TIMEOUT (HZ / 5)
@ -2594,7 +2594,7 @@ void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success,
return;
}
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
&link->u.mgd.csa.switch_work, 0);
}
@ -2753,7 +2753,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
.timestamp = timestamp,
.device_timestamp = device_timestamp,
};
unsigned long now;
u32 csa_time_tu;
ktime_t now;
int res;
lockdep_assert_wiphy(local->hw.wiphy);
@ -2983,10 +2984,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
csa_ie.mode);
/* we may have to handle timeout for deactivated link in software */
now = jiffies;
link->u.mgd.csa.time = now +
TU_TO_JIFFIES((max_t(int, csa_ie.count, 1) - 1) *
link->conf->beacon_int);
now = ktime_get_boottime();
csa_time_tu = (max_t(int, csa_ie.count, 1) - 1) * link->conf->beacon_int;
link->u.mgd.csa.time = now + us_to_ktime(ieee80211_tu_to_usec(csa_time_tu));
if (ieee80211_vif_link_active(&sdata->vif, link->link_id) &&
local->ops->channel_switch) {
@ -3001,7 +3001,7 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,
}
/* channel switch handled in software */
wiphy_delayed_work_queue(local->hw.wiphy,
wiphy_hrtimer_work_queue(local->hw.wiphy,
&link->u.mgd.csa.switch_work,
link->u.mgd.csa.time - now);
return;
@ -4242,14 +4242,14 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
memset(&sdata->u.mgd.ttlm_info, 0,
sizeof(sdata->u.mgd.ttlm_info));
wiphy_delayed_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work);
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy, &ifmgd->ttlm_work);
memset(&sdata->vif.neg_ttlm, 0, sizeof(sdata->vif.neg_ttlm));
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
&ifmgd->neg_ttlm_timeout_work);
sdata->u.mgd.removed_links = 0;
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ml_reconf_work);
wiphy_work_cancel(sdata->local->hw.wiphy,
@ -6876,7 +6876,7 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata,
/* In case the removal was cancelled, abort it */
if (sdata->u.mgd.removed_links) {
sdata->u.mgd.removed_links = 0;
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ml_reconf_work);
}
return;
@ -6906,9 +6906,9 @@ static void ieee80211_ml_reconfiguration(struct ieee80211_sub_if_data *sdata,
}
sdata->u.mgd.removed_links = removed_links;
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
&sdata->u.mgd.ml_reconf_work,
TU_TO_JIFFIES(delay));
us_to_ktime(ieee80211_tu_to_usec(delay)));
}
static int ieee80211_ttlm_set_links(struct ieee80211_sub_if_data *sdata,
@ -7095,7 +7095,7 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
/* if a planned TID-to-link mapping was cancelled -
* abort it
*/
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ttlm_work);
} else if (sdata->u.mgd.ttlm_info.active) {
/* if no TID-to-link element, set to default mapping in
@ -7130,7 +7130,7 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
if (ttlm_info.switch_time) {
u16 beacon_ts_tu, st_tu, delay;
u32 delay_jiffies;
u64 delay_usec;
u64 mask;
/* The t2l map switch time is indicated with a partial
@ -7152,23 +7152,23 @@ static void ieee80211_process_adv_ttlm(struct ieee80211_sub_if_data *sdata,
if (delay > IEEE80211_ADV_TTLM_ST_UNDERFLOW)
return;
delay_jiffies = TU_TO_JIFFIES(delay);
delay_usec = ieee80211_tu_to_usec(delay);
/* Link switching can take time, so schedule it
* 100ms before to be ready on time
*/
if (delay_jiffies > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS)
delay_jiffies -=
if (delay_usec > IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS)
delay_usec -=
IEEE80211_ADV_TTLM_SAFETY_BUFFER_MS;
else
delay_jiffies = 0;
delay_usec = 0;
sdata->u.mgd.ttlm_info = ttlm_info;
wiphy_delayed_work_cancel(sdata->local->hw.wiphy,
wiphy_hrtimer_work_cancel(sdata->local->hw.wiphy,
&sdata->u.mgd.ttlm_work);
wiphy_delayed_work_queue(sdata->local->hw.wiphy,
wiphy_hrtimer_work_queue(sdata->local->hw.wiphy,
&sdata->u.mgd.ttlm_work,
delay_jiffies);
us_to_ktime(delay_usec));
return;
}
}
@ -8793,7 +8793,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
ieee80211_csa_connection_drop_work);
wiphy_delayed_work_init(&ifmgd->tdls_peer_del_work,
ieee80211_tdls_peer_del_work);
wiphy_delayed_work_init(&ifmgd->ml_reconf_work,
wiphy_hrtimer_work_init(&ifmgd->ml_reconf_work,
ieee80211_ml_reconf_work);
wiphy_delayed_work_init(&ifmgd->reconf.wk,
ieee80211_ml_sta_reconf_timeout);
@ -8802,7 +8802,7 @@ void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata)
timer_setup(&ifmgd->conn_mon_timer, ieee80211_sta_conn_mon_timer, 0);
wiphy_delayed_work_init(&ifmgd->tx_tspec_wk,
ieee80211_sta_handle_tspec_ac_params_wk);
wiphy_delayed_work_init(&ifmgd->ttlm_work,
wiphy_hrtimer_work_init(&ifmgd->ttlm_work,
ieee80211_tid_to_link_map_work);
wiphy_delayed_work_init(&ifmgd->neg_ttlm_timeout_work,
ieee80211_neg_ttlm_timeout_work);
@ -8849,7 +8849,7 @@ void ieee80211_mgd_setup_link(struct ieee80211_link_data *link)
else
link->u.mgd.req_smps = IEEE80211_SMPS_OFF;
wiphy_delayed_work_init(&link->u.mgd.csa.switch_work,
wiphy_hrtimer_work_init(&link->u.mgd.csa.switch_work,
ieee80211_csa_switch_work);
ieee80211_clear_tpe(&link->conf->tpe);
@ -10064,7 +10064,7 @@ void ieee80211_mgd_stop_link(struct ieee80211_link_data *link)
&link->u.mgd.request_smps_work);
wiphy_work_cancel(link->sdata->local->hw.wiphy,
&link->u.mgd.recalc_smps);
wiphy_delayed_work_cancel(link->sdata->local->hw.wiphy,
wiphy_hrtimer_work_cancel(link->sdata->local->hw.wiphy,
&link->u.mgd.csa.switch_work);
}

View File

@ -1787,6 +1787,62 @@ bool wiphy_delayed_work_pending(struct wiphy *wiphy,
}
EXPORT_SYMBOL_GPL(wiphy_delayed_work_pending);
enum hrtimer_restart wiphy_hrtimer_work_timer(struct hrtimer *t)
{
struct wiphy_hrtimer_work *hrwork =
container_of(t, struct wiphy_hrtimer_work, timer);
wiphy_work_queue(hrwork->wiphy, &hrwork->work);
return HRTIMER_NORESTART;
}
EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_timer);
void wiphy_hrtimer_work_queue(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork,
ktime_t delay)
{
trace_wiphy_hrtimer_work_queue(wiphy, &hrwork->work, delay);
if (!delay) {
hrtimer_cancel(&hrwork->timer);
wiphy_work_queue(wiphy, &hrwork->work);
return;
}
hrwork->wiphy = wiphy;
hrtimer_start_range_ns(&hrwork->timer, delay,
1000 * NSEC_PER_USEC, HRTIMER_MODE_REL);
}
EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_queue);
void wiphy_hrtimer_work_cancel(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork)
{
lockdep_assert_held(&wiphy->mtx);
hrtimer_cancel(&hrwork->timer);
wiphy_work_cancel(wiphy, &hrwork->work);
}
EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_cancel);
void wiphy_hrtimer_work_flush(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork)
{
lockdep_assert_held(&wiphy->mtx);
hrtimer_cancel(&hrwork->timer);
wiphy_work_flush(wiphy, &hrwork->work);
}
EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_flush);
bool wiphy_hrtimer_work_pending(struct wiphy *wiphy,
struct wiphy_hrtimer_work *hrwork)
{
return hrtimer_is_queued(&hrwork->timer);
}
EXPORT_SYMBOL_GPL(wiphy_hrtimer_work_pending);
static int __init cfg80211_init(void)
{
int err;

View File

@ -304,6 +304,27 @@ TRACE_EVENT(wiphy_delayed_work_queue,
__entry->delay)
);
TRACE_EVENT(wiphy_hrtimer_work_queue,
TP_PROTO(struct wiphy *wiphy, struct wiphy_work *work,
ktime_t delay),
TP_ARGS(wiphy, work, delay),
TP_STRUCT__entry(
WIPHY_ENTRY
__field(void *, instance)
__field(void *, func)
__field(ktime_t, delay)
),
TP_fast_assign(
WIPHY_ASSIGN;
__entry->instance = work;
__entry->func = work->func;
__entry->delay = delay;
),
TP_printk(WIPHY_PR_FMT " instance=%p func=%pS delay=%llu",
WIPHY_PR_ARG, __entry->instance, __entry->func,
__entry->delay)
);
TRACE_EVENT(wiphy_work_worker_start,
TP_PROTO(struct wiphy *wiphy),
TP_ARGS(wiphy),