From a78ffb5dd4699f54cd8cc56d032133d2aeff601d Mon Sep 17 00:00:00 2001 From: Vamsi Attunuru Date: Mon, 8 Jul 2019 10:17:31 +0530 Subject: [PATCH] mempool/octeontx2: fix pool populating Fix npa pool range errors observed while creating mempool, this issue happens when mempool objects are from different mem segments. During mempool creation, octeontx2 mempool driver populates pool range fields before enqueuing the buffers. If any enqueue or dequeue operation reaches npa hardware prior to the range field's HW context update, those ops result in npa range errors. Patch adds a routine to read back HW context and verify if range fields are updated or not. Fixes: e5271c507aeb ("mempool/octeontx2: add remaining slow path ops") Signed-off-by: Vamsi Attunuru Acked-by: Jerin Jacob --- drivers/mempool/octeontx2/otx2_mempool_ops.c | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/mempool/octeontx2/otx2_mempool_ops.c b/drivers/mempool/octeontx2/otx2_mempool_ops.c index e1764b0308..a60a77a4e1 100644 --- a/drivers/mempool/octeontx2/otx2_mempool_ops.c +++ b/drivers/mempool/octeontx2/otx2_mempool_ops.c @@ -599,6 +599,40 @@ npa_lf_aura_pool_pair_free(struct otx2_npa_lf *lf, uint64_t aura_handle) return rc; } +static int +npa_lf_aura_range_update_check(uint64_t aura_handle) +{ + uint64_t aura_id = npa_lf_aura_handle_to_aura(aura_handle); + struct otx2_npa_lf *lf = otx2_npa_lf_obj_get(); + struct npa_aura_lim *lim = lf->aura_lim; + struct npa_aq_enq_req *req; + struct npa_aq_enq_rsp *rsp; + struct npa_pool_s *pool; + int rc; + + req = otx2_mbox_alloc_msg_npa_aq_enq(lf->mbox); + + req->aura_id = aura_id; + req->ctype = NPA_AQ_CTYPE_POOL; + req->op = NPA_AQ_INSTOP_READ; + + rc = otx2_mbox_process_msg(lf->mbox, (void *)&rsp); + if (rc) { + otx2_err("Failed to get pool(0x%"PRIx64") context", aura_id); + return rc; + } + + pool = &rsp->pool; + + if (lim[aura_id].ptr_start != pool->ptr_start || + lim[aura_id].ptr_end != pool->ptr_end) { + otx2_err("Range update failed on pool(0x%"PRIx64")", aura_id); + return -ERANGE; + } + + return 0; +} + static int otx2_npa_alloc(struct rte_mempool *mp) { @@ -724,6 +758,9 @@ otx2_npa_populate(struct rte_mempool *mp, unsigned int max_objs, void *vaddr, npa_lf_aura_op_range_set(mp->pool_id, iova, iova + len); + if (npa_lf_aura_range_update_check(mp->pool_id) < 0) + return -EBUSY; + return rte_mempool_op_populate_default(mp, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg); } -- 2.20.1