Skip to content

Commit 29e9c67

Browse files
haokexingregkh
authored andcommitted
octeontx2-pf: Fix the use of GFP_KERNEL in atomic context on rt
[ Upstream commit 55ba18d ] The commit 4af1b64 ("octeontx2-pf: Fix lmtst ID used in aura free") uses the get/put_cpu() to protect the usage of percpu pointer in ->aura_freeptr() callback, but it also unnecessarily disable the preemption for the blockable memory allocation. The commit 87b93b6 ("octeontx2-pf: Avoid use of GFP_KERNEL in atomic context") tried to fix these sleep inside atomic warnings. But it only fix the one for the non-rt kernel. For the rt kernel, we still get the similar warnings like below. BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: swapper/0 preempt_count: 1, expected: 0 RCU nest depth: 0, expected: 0 3 locks held by swapper/0/1: #0: ffff800009fc5fe8 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock+0x24/0x30 #1: ffff000100c276c0 (&mbox->lock){+.+.}-{3:3}, at: otx2_init_hw_resources+0x8c/0x3a4 #2: ffffffbfef6537e0 (&cpu_rcache->lock){+.+.}-{2:2}, at: alloc_iova_fast+0x1ac/0x2ac Preemption disabled at: [<ffff800008b1908c>] otx2_rq_aura_pool_init+0x14c/0x284 CPU: 20 PID: 1 Comm: swapper/0 Tainted: G W 6.2.0-rc3-rt1-yocto-preempt-rt #1 Hardware name: Marvell OcteonTX CN96XX board (DT) Call trace: dump_backtrace.part.0+0xe8/0xf4 show_stack+0x20/0x30 dump_stack_lvl+0x9c/0xd8 dump_stack+0x18/0x34 __might_resched+0x188/0x224 rt_spin_lock+0x64/0x110 alloc_iova_fast+0x1ac/0x2ac iommu_dma_alloc_iova+0xd4/0x110 __iommu_dma_map+0x80/0x144 iommu_dma_map_page+0xe8/0x260 dma_map_page_attrs+0xb4/0xc0 __otx2_alloc_rbuf+0x90/0x150 otx2_rq_aura_pool_init+0x1c8/0x284 otx2_init_hw_resources+0xe4/0x3a4 otx2_open+0xf0/0x610 __dev_open+0x104/0x224 __dev_change_flags+0x1e4/0x274 dev_change_flags+0x2c/0x7c ic_open_devs+0x124/0x2f8 ip_auto_config+0x180/0x42c do_one_initcall+0x90/0x4dc do_basic_setup+0x10c/0x14c kernel_init_freeable+0x10c/0x13c kernel_init+0x2c/0x140 ret_from_fork+0x10/0x20 Of course, we can shuffle the get/put_cpu() to only wrap the invocation of ->aura_freeptr() as what commit 87b93b6 does. But there are only two ->aura_freeptr() callbacks, otx2_aura_freeptr() and cn10k_aura_freeptr(). There is no usage of perpcu variable in the otx2_aura_freeptr() at all, so the get/put_cpu() seems redundant to it. We can move the get/put_cpu() into the corresponding callback which really has the percpu variable usage and avoid the sprinkling of get/put_cpu() in several places. Fixes: 4af1b64 ("octeontx2-pf: Fix lmtst ID used in aura free") Signed-off-by: Kevin Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 03bff58 commit 29e9c67

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,6 @@ static void otx2_pool_refill_task(struct work_struct *work)
962962
rbpool = cq->rbpool;
963963
free_ptrs = cq->pool_ptrs;
964964

965-
get_cpu();
966965
while (cq->pool_ptrs) {
967966
if (otx2_alloc_rbuf(pfvf, rbpool, &bufptr)) {
968967
/* Schedule a WQ if we fails to free atleast half of the
@@ -982,7 +981,6 @@ static void otx2_pool_refill_task(struct work_struct *work)
982981
pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM);
983982
cq->pool_ptrs--;
984983
}
985-
put_cpu();
986984
cq->refill_task_sched = false;
987985
}
988986

@@ -1333,9 +1331,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
13331331
err = otx2_alloc_rbuf(pfvf, pool, &bufptr);
13341332
if (err)
13351333
goto err_mem;
1336-
get_cpu();
13371334
pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr);
1338-
put_cpu();
13391335
sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr;
13401336
}
13411337
}
@@ -1381,21 +1377,18 @@ int otx2_rq_aura_pool_init(struct otx2_nic *pfvf)
13811377
if (err)
13821378
goto fail;
13831379

1384-
get_cpu();
13851380
/* Allocate pointers and free them to aura/pool */
13861381
for (pool_id = 0; pool_id < hw->rqpool_cnt; pool_id++) {
13871382
pool = &pfvf->qset.pool[pool_id];
13881383
for (ptr = 0; ptr < num_ptrs; ptr++) {
13891384
err = otx2_alloc_rbuf(pfvf, pool, &bufptr);
13901385
if (err)
1391-
goto err_mem;
1386+
return -ENOMEM;
13921387
pfvf->hw_ops->aura_freeptr(pfvf, pool_id,
13931388
bufptr + OTX2_HEAD_ROOM);
13941389
}
13951390
}
1396-
err_mem:
1397-
put_cpu();
1398-
return err ? -ENOMEM : 0;
1391+
return 0;
13991392
fail:
14001393
otx2_mbox_reset(&pfvf->mbox.mbox, 0);
14011394
otx2_aura_pool_free(pfvf);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,10 @@ static inline void cn10k_aura_freeptr(void *dev, int aura, u64 buf)
605605
u64 ptrs[2];
606606

607607
ptrs[1] = buf;
608+
get_cpu();
608609
/* Free only one buffer at time during init and teardown */
609610
__cn10k_aura_freeptr(pfvf, aura, ptrs, 2);
611+
put_cpu();
610612
}
611613

612614
/* Alloc pointer from pool/aura */

0 commit comments

Comments
 (0)