Skip to content

Commit 4af1b64

Browse files
Geetha sowjanyadavem330
authored andcommitted
octeontx2-pf: Fix lmtst ID used in aura free
Current code uses per_cpu pointer to get the lmtst_id mapped to the core on which aura_free() is executed. Using per_cpu pointer without preemption disable causing mismatch between lmtst_id and core on which pointer gets freed. This patch fixes the issue by disabling preemption around aura_free. Fixes: ef6c8da ("octeontx2-pf: cn10K: Reserve LMTST lines per core") Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9c80796 commit 4af1b64

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ static void otx2_pool_refill_task(struct work_struct *work)
10121012
rbpool = cq->rbpool;
10131013
free_ptrs = cq->pool_ptrs;
10141014

1015+
get_cpu();
10151016
while (cq->pool_ptrs) {
10161017
if (otx2_alloc_rbuf(pfvf, rbpool, &bufptr)) {
10171018
/* Schedule a WQ if we fails to free atleast half of the
@@ -1031,6 +1032,7 @@ static void otx2_pool_refill_task(struct work_struct *work)
10311032
pfvf->hw_ops->aura_freeptr(pfvf, qidx, bufptr + OTX2_HEAD_ROOM);
10321033
cq->pool_ptrs--;
10331034
}
1035+
put_cpu();
10341036
cq->refill_task_sched = false;
10351037
}
10361038

@@ -1368,6 +1370,7 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
13681370
if (err)
13691371
goto fail;
13701372

1373+
get_cpu();
13711374
/* Allocate pointers and free them to aura/pool */
13721375
for (qidx = 0; qidx < hw->tot_tx_queues; qidx++) {
13731376
pool_id = otx2_get_pool_idx(pfvf, AURA_NIX_SQ, qidx);
@@ -1376,18 +1379,24 @@ int otx2_sq_aura_pool_init(struct otx2_nic *pfvf)
13761379
sq = &qset->sq[qidx];
13771380
sq->sqb_count = 0;
13781381
sq->sqb_ptrs = kcalloc(num_sqbs, sizeof(*sq->sqb_ptrs), GFP_KERNEL);
1379-
if (!sq->sqb_ptrs)
1380-
return -ENOMEM;
1382+
if (!sq->sqb_ptrs) {
1383+
err = -ENOMEM;
1384+
goto err_mem;
1385+
}
13811386

13821387
for (ptr = 0; ptr < num_sqbs; ptr++) {
1383-
if (otx2_alloc_rbuf(pfvf, pool, &bufptr))
1384-
return -ENOMEM;
1388+
err = otx2_alloc_rbuf(pfvf, pool, &bufptr);
1389+
if (err)
1390+
goto err_mem;
13851391
pfvf->hw_ops->aura_freeptr(pfvf, pool_id, bufptr);
13861392
sq->sqb_ptrs[sq->sqb_count++] = (u64)bufptr;
13871393
}
13881394
}
13891395

1390-
return 0;
1396+
err_mem:
1397+
put_cpu();
1398+
return err ? -ENOMEM : 0;
1399+
13911400
fail:
13921401
otx2_mbox_reset(&pfvf->mbox.mbox, 0);
13931402
otx2_aura_pool_free(pfvf);
@@ -1426,18 +1435,21 @@ int otx2_rq_aura_pool_init(struct otx2_nic *pfvf)
14261435
if (err)
14271436
goto fail;
14281437

1438+
get_cpu();
14291439
/* Allocate pointers and free them to aura/pool */
14301440
for (pool_id = 0; pool_id < hw->rqpool_cnt; pool_id++) {
14311441
pool = &pfvf->qset.pool[pool_id];
14321442
for (ptr = 0; ptr < num_ptrs; ptr++) {
1433-
if (otx2_alloc_rbuf(pfvf, pool, &bufptr))
1434-
return -ENOMEM;
1443+
err = otx2_alloc_rbuf(pfvf, pool, &bufptr);
1444+
if (err)
1445+
goto err_mem;
14351446
pfvf->hw_ops->aura_freeptr(pfvf, pool_id,
14361447
bufptr + OTX2_HEAD_ROOM);
14371448
}
14381449
}
1439-
1440-
return 0;
1450+
err_mem:
1451+
put_cpu();
1452+
return err ? -ENOMEM : 0;
14411453
fail:
14421454
otx2_mbox_reset(&pfvf->mbox.mbox, 0);
14431455
otx2_aura_pool_free(pfvf);

0 commit comments

Comments
 (0)