Skip to content

Commit 65e6af6

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: ethernet: mtk_wed: fix sleep while atomic in mtk_wed_wo_queue_refill
In order to fix the following sleep while atomic bug always alloc pages with GFP_ATOMIC in mtk_wed_wo_queue_refill since page_frag_alloc runs in spin_lock critical section. [ 9.049719] Hardware name: MediaTek MT7986a RFB (DT) [ 9.054665] Call trace: [ 9.057096] dump_backtrace+0x0/0x154 [ 9.060751] show_stack+0x14/0x1c [ 9.064052] dump_stack_lvl+0x64/0x7c [ 9.067702] dump_stack+0x14/0x2c [ 9.071001] ___might_sleep+0xec/0x120 [ 9.074736] __might_sleep+0x4c/0x9c [ 9.078296] __alloc_pages+0x184/0x2e4 [ 9.082030] page_frag_alloc_align+0x98/0x1ac [ 9.086369] mtk_wed_wo_queue_refill+0x134/0x234 [ 9.090974] mtk_wed_wo_init+0x174/0x2c0 [ 9.094881] mtk_wed_attach+0x7c8/0x7e0 [ 9.098701] mt7915_mmio_wed_init+0x1f0/0x3a0 [mt7915e] [ 9.103940] mt7915_pci_probe+0xec/0x3bc [mt7915e] [ 9.108727] pci_device_probe+0xac/0x13c [ 9.112638] really_probe.part.0+0x98/0x2f4 [ 9.116807] __driver_probe_device+0x94/0x13c [ 9.121147] driver_probe_device+0x40/0x114 [ 9.125314] __driver_attach+0x7c/0x180 [ 9.129133] bus_for_each_dev+0x5c/0x90 [ 9.132953] driver_attach+0x20/0x2c [ 9.136513] bus_add_driver+0x104/0x1fc [ 9.140333] driver_register+0x74/0x120 [ 9.144153] __pci_register_driver+0x40/0x50 [ 9.148407] mt7915_init+0x5c/0x1000 [mt7915e] [ 9.152848] do_one_initcall+0x40/0x25c [ 9.156669] do_init_module+0x44/0x230 [ 9.160403] load_module+0x1f30/0x2750 [ 9.164135] __do_sys_init_module+0x150/0x200 [ 9.168475] __arm64_sys_init_module+0x18/0x20 [ 9.172901] invoke_syscall.constprop.0+0x4c/0xe0 [ 9.177589] do_el0_svc+0x48/0xe0 [ 9.180889] el0_svc+0x14/0x50 [ 9.183929] el0t_64_sync_handler+0x9c/0x120 [ 9.188183] el0t_64_sync+0x158/0x15c Fixes: 7996844 ("net: ethernet: mtk_wed: introduce wed wo support") Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Link: https://lore.kernel.org/r/67ca94bdd3d9eaeb86e52b3050fbca0bcf7bb02f.1669908312.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 55fb80d commit 65e6af6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/net/ethernet/mediatek/mtk_wed_wo.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,18 @@ mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len,
133133

134134
static int
135135
mtk_wed_wo_queue_refill(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q,
136-
gfp_t gfp, bool rx)
136+
bool rx)
137137
{
138138
enum dma_data_direction dir = rx ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
139139
int n_buf = 0;
140140

141141
spin_lock_bh(&q->lock);
142142
while (q->queued < q->n_desc) {
143-
void *buf = page_frag_alloc(&q->cache, q->buf_size, gfp);
144143
struct mtk_wed_wo_queue_entry *entry;
145144
dma_addr_t addr;
145+
void *buf;
146146

147+
buf = page_frag_alloc(&q->cache, q->buf_size, GFP_ATOMIC);
147148
if (!buf)
148149
break;
149150

@@ -215,7 +216,7 @@ mtk_wed_wo_rx_run_queue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q)
215216
mtk_wed_mcu_rx_unsolicited_event(wo, skb);
216217
}
217218

218-
if (mtk_wed_wo_queue_refill(wo, q, GFP_ATOMIC, true)) {
219+
if (mtk_wed_wo_queue_refill(wo, q, true)) {
219220
u32 index = (q->head - 1) % q->n_desc;
220221

221222
mtk_wed_wo_queue_kick(wo, q, index);
@@ -432,7 +433,7 @@ mtk_wed_wo_hardware_init(struct mtk_wed_wo *wo)
432433
if (ret)
433434
goto error;
434435

435-
mtk_wed_wo_queue_refill(wo, &wo->q_tx, GFP_KERNEL, false);
436+
mtk_wed_wo_queue_refill(wo, &wo->q_tx, false);
436437
mtk_wed_wo_queue_reset(wo, &wo->q_tx);
437438

438439
regs.desc_base = MTK_WED_WO_CCIF_DUMMY5;
@@ -446,7 +447,7 @@ mtk_wed_wo_hardware_init(struct mtk_wed_wo *wo)
446447
if (ret)
447448
goto error;
448449

449-
mtk_wed_wo_queue_refill(wo, &wo->q_rx, GFP_KERNEL, true);
450+
mtk_wed_wo_queue_refill(wo, &wo->q_rx, true);
450451
mtk_wed_wo_queue_reset(wo, &wo->q_rx);
451452

452453
/* rx queue irqmask */

0 commit comments

Comments
 (0)