mac80211: add tx dequeue function for process context
Subsystems (2)
PATCH 1/2 mac80211: add tx dequeue function for process context
Since ieee80211_tx_dequeue() must not be called with softirqs enabled (i.e. from process context without proper disable of bottom halves), we add a wrapper that disables bottom halves before calling ieee80211_tx_dequeue()
The new function is named ieee80211_tx_dequeue_ni() just as all other from-process-context versions found in mac80211.
The documentation of ieee80211_tx_dequeue() is also updated so it mentions that the function should not be called from process context.
--- include/net/mac80211.h | 26 ++++++++++++++++++++++++++ net/mac80211/tx.c | 2 ++ 2 files changed, 28 insertions(+)
include/net/mac80211.h +26 -0
@@ -6251,10 +6251,36 @@ void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);* but for the duration of the frame handling. * However, also note that while in the wake_tx_queue() method, * rcu_read_lock() is already held. +* +* softirqs must also be disabled when this function is called. +* In process context, use ieee80211_tx_dequeue_ni() instead. */ struct sk_buff *ieee80211_tx_dequeue (struct ieee80211_hw *hw,struct ieee80211_txq *txq); +/** +* ieee80211_tx_dequeue_ni - dequeue a packet from a software tx queue +* (in process context) +* +* Like ieee80211_tx_dequeue() but can be called in process context +* (internally disables bottom halves). +* +* @hw: pointer as obtained from ieee80211_alloc_hw() +* @txq: pointer obtained from station or virtual interface, or from +* ieee80211_next_txq() +*/ +static inline struct sk_buff *ieee80211_tx_dequeue_ni (struct ieee80211_hw *hw, +struct ieee80211_txq *txq) +{ +struct sk_buff *skb; + +local_bh_disable (); + skb =ieee80211_tx_dequeue (hw, txq); +local_bh_enable (); + +return skb; +} +/** * ieee80211_next_txq - get next tx queue to pull packets from *
net/mac80211/tx.c +2 -0
@@ -3550,6 +3550,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,ieee80211_tx_result r;struct ieee80211_vif *vif = txq->vif; +WARN_ON_ONCE (softirq_count () ==0 ); + begin:spin_lock_bh (&fq->lock);
Signature · 7 lines
2.22.0 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
PATCH 2/2 ath10k: switch to ieee80211_tx_dequeue_ni
Since ath10k_mac_tx_push_txq() can be called from process context, we must explicitly disable softirqs before the call into mac80211.
By calling ieee80211_tx_dequeue_ni() instead of ieee80211_tx_dequeue() we make sure softirqs are always disabled even in the case when ath10k_mac_tx_push_txq() is called from process context.
Calling ieee80211_tx_dequeue_ni() with softirq's already disabled (e.g., from softirq context) should be safe as the local_bh_disable() and local_bh_enable() functions (called from ieee80211_tx_dequeue_ni) are fully reentrant.
--- drivers/net/wireless/ath/ath10k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/mac.c +1 -1
@@ -4033,7 +4033,7 @@ int ath10k_mac_tx_push_txq(struct ieee80211_hw *hw,if (ret)return ret; - skb =ieee80211_tx_dequeue (hw, txq); + skb =ieee80211_tx_dequeue_ni (hw, txq);if (!skb) {spin_lock_bh (&ar->htt.tx_lock);ath10k_htt_tx_dec_pending (htt);
Signature · 7 lines
2.22.0 _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
Quoted 7 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.
Quoted 7 lines
Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.Signed-off-by Erik Stromdahl <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
306547608c84 ath10k: switch to ieee80211_tx_dequeue_ni
Signature · 9 lines
https://patchwork.kernel.org/patch/11000363/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
In reply to Erik StromdahlQuoted 7 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.
Quoted 7 lines
Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.Signed-off-by Erik Stromdahl <[email protected]>Signed-off-by Kalle Valo <[email protected]>
Patch applied to ath-next branch of ath.git, thanks.
306547608c84 ath10k: switch to ieee80211_tx_dequeue_ni
Signature · 3 lines
https://patchwork.kernel.org/patch/11000363/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
In reply to Erik StromdahlQuoted 7 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.
Quoted 6 lines
Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.Signed-off-by Erik Stromdahl <[email protected]>
I already applied this, but I still want to check _why_ you are changing this? Is it that you want to call ath10k_mac_tx_push_pending() from a workqueue in sdio.c in a future patch, or what? Because at the moment me and Johannes were not able to find where this is called in process context.
Signature · 6 lines
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches _______________________________________________ ath10k mailing list [email protected] http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.
Quoted 7 lines
Quoted 1 line
Signed-off-by Erik Stromdahl <[email protected]>I already applied this, but I still want to check _why_ you are changing this? Is it that you want to call
ath10k_mac_tx_push_pending()from a workqueue insdio.cin a future patch, or what? Because at the moment me and Johannes were not able to find where this is called in process context.
It seems Johannes wants to fix it in mac80211.
[PATCH v2] mac80211: keep BHs disabled while calling drv_tx_wake_queue()
Drivers typically expect this, as it's the case for almost all cases where this is called (i.e. from the TX path). Also, the code in mac80211 itself (if the driver calls ieee80211_tx_dequeue()) expects this as it uses this_cpu_ptr() without additional protection.
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
Quoted 16 lines · Peter Oh
Quoted 14 lines · Kalle Valo
Quoted 12 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Signed-off-by Erik Stromdahl <[email protected]>I already applied this, but I still want to check _why_ you are changing this? Is it that you want to call
ath10k_mac_tx_push_pending()from a workqueue insdio.cin a future patch, or what? Because at the moment me and Johannes were not able to find where this is called in process context.
SDIO irqs are threaded irqs (at least on my iMX6 board) and hence process context. I will see if I can find a trace that shows the call chain more exactly.
Quoted 9 lines
It seems Johannes wants to fix it in mac80211.
[PATCH v2] mac80211: keep BHs disabled while calling
drv_tx_wake_queue()Drivers typically expect this, as it's the case for almost all cases where this is called (i.e. from the TX path). Also, the code in mac80211 itself (if the driver calls
ieee80211_tx_dequeue()) expects this as it usesthis_cpu_ptr()without additional protection.
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
Re: [PATCH 2/2] ath10k: switch to ieee80211_tx_dequeue_ni
Quoted 20 lines · Erik Stromdahl
Quoted 17 lines · Peter Oh
Quoted 15 lines · Kalle Valo
Quoted 13 lines · Erik Stromdahl
Since
ath10k_mac_tx_push_txq()can be called from process context, we must explicitly disable softirqs before the call into mac80211.By calling
ieee80211_tx_dequeue_ni()instead ofieee80211_tx_dequeue()we make sure softirqs are always disabled even in the case whenath10k_mac_tx_push_txq()is called from process context.Calling
ieee80211_tx_dequeue_ni()with softirq's already disabled (e.g., from softirq context) should be safe as thelocal_bh_disable()andlocal_bh_enable()functions (called fromieee80211_tx_dequeue_ni) are fully reentrant.Signed-off-by Erik Stromdahl <[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
I already applied this, but I still want to check _why_ you are changing this? Is it that you want to call
ath10k_mac_tx_push_pending()from a workqueue insdio.cin a future patch, or what? Because at the moment me and Johannes were not able to find where this is called in process context.SDIO irqs are threaded irqs (at least on my iMX6 board) and hence process context. I will see if I can find a trace that shows the call chain more exactly.
I found this backtrace in a log file:
(it does not show the call to ieee80211_tx_dequeue_ni(), but it shows that ath10k_sdio_irq_handler() is called from process context)
irq/62-mmc1-65 [000] .... 785.261081: ath10k_mac_op_wake_tx_queue <-ieee80211_queue_skb
irq/62-mmc1-65 [000] .... 785.261090: <stack trace>
=> ieee80211_queue_skb
=> __ieee80211_subif_start_xmit
=> ieee80211_subif_start_xmit
=> dev_hard_start_xmit
=> __dev_queue_xmit
=> dev_queue_xmit
=> ip_finish_output2
=> ip_finish_output
=> ip_output
=> ip_local_out
=> ip_queue_xmit
=> tcp_transmit_skb
=> tcp_write_xmit
=> __tcp_push_pending_frames
=> tcp_rcv_established
=> tcp_v4_do_rcv
=> tcp_v4_rcv
=> ip_local_deliver_finish
=> ip_local_deliver
=> ip_rcv_finish
=> ip_rcv
=> __netif_receive_skb_core
=> __netif_receive_skb
=> netif_receive_skb_internal
=> netif_receive_skb
=> ieee80211_deliver_skb
=> ieee80211_rx_handlers
=> ieee80211_prepare_and_rx_handle
=> ieee80211_rx_napi
=> ath10k_htt_t2h_msg_handler
=> ath10k_htt_htc_t2h_msg_handler
=> ath10k_sdio_mbox_rxmsg_pending_handler
=> ath10k_sdio_irq_handler <- ath10k_mac_tx_push_pending() is called from here
=> process_sdio_pending_irqs
=> sdio_run_irqs
=> sdhci_thread_irq
=> irq_thread_fn
=> irq_thread
=> kthread
=> ret_from_fork
=> 0From ath10k_sdio_irq_handler(), the call chain down to ieee80211_tx_dequeue_ni() looks like this:
ath10k_sdio_irq_handler() =>
ath10k_mac_tx_push_pending() =>
ath10k_mac_schedule_txq() =>
ath10k_mac_tx_push_txq() =>
ieee80211_tx_dequeue_ni()Quoted 10 lines
Quoted 10 lines
It seems Johannes wants to fix it in mac80211.
[PATCH v2] mac80211: keep BHs disabled while calling
drv_tx_wake_queue()Drivers typically expect this, as it's the case for almost all cases where this is called (i.e. from the TX path). Also, the code in mac80211 itself (if the driver calls
ieee80211_tx_dequeue()) expects this as it usesthis_cpu_ptr()without additional protection.
_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k