Skip to content

Commit 10a54d8

Browse files
lucacoelhoKalle Valo
authored andcommitted
iwlwifi: pcie: move rx workqueue initialization to iwl_trans_pcie_alloc()
Work queues cannot be allocated when a mutex is held because the mutex may be in use and that would make it sleep. Doing so generates the following splat with 4.13+: [ 19.513298] ====================================================== [ 19.513429] WARNING: possible circular locking dependency detected [ 19.513557] 4.13.0-rc5+ #6 Not tainted [ 19.513638] ------------------------------------------------------ [ 19.513767] cpuhp/0/12 is trying to acquire lock: [ 19.513867] (&tz->lock){+.+.+.}, at: [<ffffffff924afebb>] thermal_zone_get_temp+0x5b/0xb0 [ 19.514047] [ 19.514047] but task is already holding lock: [ 19.514166] (cpuhp_state){+.+.+.}, at: [<ffffffff91cc4baa>] cpuhp_thread_fun+0x3a/0x210 [ 19.514338] [ 19.514338] which lock already depends on the new lock. This lock dependency already existed with previous kernel versions, but it was not detected until commit 49dfe2a ("cpuhotplug: Link lock stacks for hotplug callbacks") was introduced. Reported-by: David Weinehall <[email protected]> Reported-by: Jiri Kosina <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent e9bf53a commit 10a54d8

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

drivers/net/wireless/intel/iwlwifi/pcie/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,8 @@ int iwl_pci_fw_enter_d0i3(struct iwl_trans *trans);
787787

788788
void iwl_pcie_enable_rx_wake(struct iwl_trans *trans, bool enable);
789789

790+
void iwl_pcie_rx_allocator_work(struct work_struct *data);
791+
790792
/* common functions that are used by gen2 transport */
791793
void iwl_pcie_apm_config(struct iwl_trans *trans);
792794
int iwl_pcie_prepare_card_hw(struct iwl_trans *trans);

drivers/net/wireless/intel/iwlwifi/pcie/rx.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static void iwl_pcie_rx_allocator_get(struct iwl_trans *trans,
597597
rxq->free_count += RX_CLAIM_REQ_ALLOC;
598598
}
599599

600-
static void iwl_pcie_rx_allocator_work(struct work_struct *data)
600+
void iwl_pcie_rx_allocator_work(struct work_struct *data)
601601
{
602602
struct iwl_rb_allocator *rba_p =
603603
container_of(data, struct iwl_rb_allocator, rx_alloc);
@@ -900,10 +900,6 @@ static int _iwl_pcie_rx_init(struct iwl_trans *trans)
900900
return err;
901901
}
902902
def_rxq = trans_pcie->rxq;
903-
if (!rba->alloc_wq)
904-
rba->alloc_wq = alloc_workqueue("rb_allocator",
905-
WQ_HIGHPRI | WQ_UNBOUND, 1);
906-
INIT_WORK(&rba->rx_alloc, iwl_pcie_rx_allocator_work);
907903

908904
spin_lock(&rba->lock);
909905
atomic_set(&rba->req_pending, 0);
@@ -1017,10 +1013,6 @@ void iwl_pcie_rx_free(struct iwl_trans *trans)
10171013
}
10181014

10191015
cancel_work_sync(&rba->rx_alloc);
1020-
if (rba->alloc_wq) {
1021-
destroy_workqueue(rba->alloc_wq);
1022-
rba->alloc_wq = NULL;
1023-
}
10241016

10251017
iwl_pcie_free_rbs_pool(trans);
10261018

drivers/net/wireless/intel/iwlwifi/pcie/trans.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,11 @@ void iwl_trans_pcie_free(struct iwl_trans *trans)
17861786
iwl_pcie_tx_free(trans);
17871787
iwl_pcie_rx_free(trans);
17881788

1789+
if (trans_pcie->rba.alloc_wq) {
1790+
destroy_workqueue(trans_pcie->rba.alloc_wq);
1791+
trans_pcie->rba.alloc_wq = NULL;
1792+
}
1793+
17891794
if (trans_pcie->msix_enabled) {
17901795
for (i = 0; i < trans_pcie->alloc_vecs; i++) {
17911796
irq_set_affinity_hint(
@@ -3169,6 +3174,10 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
31693174
trans_pcie->inta_mask = CSR_INI_SET_MASK;
31703175
}
31713176

3177+
trans_pcie->rba.alloc_wq = alloc_workqueue("rb_allocator",
3178+
WQ_HIGHPRI | WQ_UNBOUND, 1);
3179+
INIT_WORK(&trans_pcie->rba.rx_alloc, iwl_pcie_rx_allocator_work);
3180+
31723181
#ifdef CONFIG_IWLWIFI_PCIE_RTPM
31733182
trans->runtime_pm_mode = IWL_PLAT_PM_MODE_D0I3;
31743183
#else

0 commit comments

Comments
 (0)