common/cnxk: fix NPA pool RANGE interrupt handling
PATCH 1/1 common/cnxk: fix NPA pool RANGE interrupt handling
NPA_POOL_ERR_INT_RANGE fires spuriously between pool creation (ptr_start/ptr_end default to 0/~0) and the actual range install via roc_npa_pool_op_range_set(). On CN10K this drains the pool stack and makes the pool unusable.
Fix by masking NPA_POOL_ERR_INT_RANGE at pool creation time, then re-enabling it (along with OVFLS and PERR) after the valid range is installed. Add roc_npa_pool_range_int_enable() for this and call it from both cnxk_mempool_populate() (regular mempools) and sqb_pool_populate() (NIX SQ buffer pools).
--- drivers/common/cnxk/roc_nix_queue.c | 5 +++ drivers/common/cnxk/roc_npa.c | 46 ++++++++++++++++++++++++- drivers/common/cnxk/roc_npa.h | 1 + drivers/mempool/cnxk/cnxk_mempool_ops.c | 5 +++ 4 files changed, 56 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_nix_queue.c +5 -0
@@ -1666,6 +1666,11 @@ sqb_pool_populate(struct roc_nix *roc_nix, struct roc_nix_sq *sq) }roc_npa_pool_op_range_set (sq->aura_handle, (uint64_t )sq->sqe_mem, iova); + + rc =roc_npa_pool_range_int_enable (sq->aura_handle); +if (rc) + goto npa_fail; +roc_npa_aura_limit_modify (sq->aura_handle, nb_sqb_bufs); sq->aura_sqb_bufs = nb_sqb_bufs;
drivers/common/cnxk/roc_npa.c +45 -1
58 lines not on this page · raw message
drivers/common/cnxk/roc_npa.h +1 -0
@@ -852,6 +852,7 @@ int __roc_api roc_npa_aura_limit_modify(uint64_t aura_handle, uint16_t aura_limit); int __roc_api roc_npa_pool_destroy(uint64_t aura_handle); int __roc_api roc_npa_pool_range_update_check(uint64_t aura_handle); +int __roc_api roc_npa_pool_range_int_enable(uint64_t aura_handle); void __roc_api roc_npa_aura_op_range_set(uint64_t aura_handle,uint64_t start_iova,uint64_t end_iova);
drivers/mempool/cnxk/cnxk_mempool_ops.c +5 -0
@@ -2,6 +2,7 @@* Copyright(C) 2021 Marvell. */ +#include <rte_eal.h> #include <rte_mbuf_pool_ops.h> #include <rte_mempool.h>
@@ -180,6 +181,10 @@ cnxk_mempool_populate(struct rte_mempool *mp, unsigned int max_objs,if (roc_npa_pool_range_update_check (mp->pool_id) <0 )return -EBUSY ; +if (rte_eal_iova_mode () ==RTE_IOVA_VA && +roc_npa_pool_range_int_enable (mp->pool_id) <0 ) +return -EBUSY ; +return rte_mempool_op_populate_helper ( mp,RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ , max_objs, vaddr, iova, len, obj_cb, obj_cb_arg);
Signature · 1 line
2.39.5 (Apple Git-154)
PATCH v2 1/1 common/cnxk: fix NPA pool RANGE interrupt handling
NPA_POOL_ERR_INT_RANGE fires spuriously between pool creation (ptr_start/ptr_end default to 0/~0) and the actual range install via roc_npa_pool_op_range_set(). On CN10K this drains the pool stack and makes the pool unusable.
Fix by masking NPA_POOL_ERR_INT_RANGE at pool creation time, then re-enabling it (along with OVFLS and PERR) after the valid range is installed. Add roc_npa_pool_range_int_enable() for this and call it from both cnxk_mempool_populate() (regular mempools) and sqb_pool_populate() (NIX SQ buffer pools).
--- drivers/common/cnxk/roc_nix_queue.c | 5 ++ drivers/common/cnxk/roc_npa.c | 46 ++++++++++++++++++- drivers/common/cnxk/roc_npa.h | 1 + .../common/cnxk/roc_platform_base_symbols.c | 1 + drivers/mempool/cnxk/cnxk_mempool_ops.c | 5 ++ 5 files changed, 57 insertions(+), 1 deletion(-)
drivers/common/cnxk/roc_nix_queue.c +5 -0
@@ -1666,6 +1666,11 @@ sqb_pool_populate(struct roc_nix *roc_nix, struct roc_nix_sq *sq) }roc_npa_pool_op_range_set (sq->aura_handle, (uint64_t )sq->sqe_mem, iova); + + rc =roc_npa_pool_range_int_enable (sq->aura_handle); +if (rc) + goto npa_fail; +roc_npa_aura_limit_modify (sq->aura_handle, nb_sqb_bufs); sq->aura_sqb_bufs = nb_sqb_bufs;
drivers/common/cnxk/roc_npa.c +45 -1
58 lines not on this page · raw message
drivers/common/cnxk/roc_npa.h +1 -0
@@ -852,6 +852,7 @@ int __roc_api roc_npa_aura_limit_modify(uint64_t aura_handle, uint16_t aura_limit); int __roc_api roc_npa_pool_destroy(uint64_t aura_handle); int __roc_api roc_npa_pool_range_update_check(uint64_t aura_handle); +int __roc_api roc_npa_pool_range_int_enable(uint64_t aura_handle); void __roc_api roc_npa_aura_op_range_set(uint64_t aura_handle,uint64_t start_iova,uint64_t end_iova);
drivers/common/cnxk/roc_platform_base_symbols.c +1 -0
@@ -447,6 +447,7 @@ RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_aura_create) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_aura_limit_modify) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_pool_destroy) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_aura_destroy) +RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_pool_range_int_enable) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_pool_range_update_check) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_zero_aura_handle) RTE_EXPORT_INTERNAL_SYMBOL(roc_npa_aura_bp_configure)
drivers/mempool/cnxk/cnxk_mempool_ops.c +5 -0
@@ -2,6 +2,7 @@* Copyright(C) 2021 Marvell. */ +#include <rte_eal.h> #include <rte_mbuf_pool_ops.h> #include <rte_mempool.h>
@@ -180,6 +181,10 @@ cnxk_mempool_populate(struct rte_mempool *mp, unsigned int max_objs,if (roc_npa_pool_range_update_check (mp->pool_id) <0 )return -EBUSY ; +if (rte_eal_iova_mode () ==RTE_IOVA_VA && +roc_npa_pool_range_int_enable (mp->pool_id) <0 ) +return -EBUSY ; +return rte_mempool_op_populate_helper ( mp,RTE_MEMPOOL_POPULATE_F_ALIGN_OBJ , max_objs, vaddr, iova, len, obj_cb, obj_cb_arg);
Signature · 1 line
2.39.5 (Apple Git-154)
Hi Amiya,
Quoted 3 lines
NPA_POOL_ERR_INT_RANGEfires spuriously between pool creation (ptr_start/ptr_end default to 0/~0) and the actual range install viaroc_npa_pool_op_range_set().
ERR_INT_RANGE is not supposed to fire spuriously. Did you root cause why this is happening ?
Quoted 2 lines
On CN10K this drains the pool
stack and makes the pool unusable.
Didn't quite understand this part. Could you please elaborate.
Thanks
Ashwin
Hi Ashwin
*> NPA_POOL_ERR_INT_RANGE fires spuriously between pool creation > (ptr_start/ptr_end default to 0/~0) and the actual range install > via roc_npa_pool_op_range_set(). >>ERR_INT_RANGE is not supposed to fire spuriously. Did you root cause why this is happening ?*
Yes — the root cause is NDC staleness. The AQ INIT writes pool context (including ptr_start=0, ptr_end=~0) directly to RAM, bypassing NDC. When the MMIO data path (aura_op_free) reads pool context, it goes through NDC which can still have stale zeros from a previous init/teardown cycle — including ptr_end=0. Against that stale range [0, 0], any buffer IOVA triggers RANGE.
The NDC sync patch [
https://patches.dpdk.org/project/dpdk/patch/[email protected]/]
addresses this root cause by invalidating NDC after AQ INIT. This RANGE patch adds defense-in-depth: mask RANGE during the init→range_set window and re-enable only after the real range is installed.
I also acknowledge that this fix is no longer required if we force-sync the NDC as in
https://patches.dpdk.org/project/dpdk/patch/[email protected]/.
We can drop this patch completely.
*> On CN10K this drains the pool > stack and makes the pool unusable.>>Didn't quite understand this part. Could you please elaborate.*
Sorry for my poor wordings. on my part. The pool stack does not get drained — it never gets populated.During cnxk_mempool_populate(), each roc_npa_aura_op_free()
call silently drops the buffer (NPA sees stale context with ena=0 or ptr_end=0 via NDC). After populate completes, the pool has 0 available buffers despite no error being returned. Subsequent roc_npa_aura_op_alloc() returns NULL, causing port start failures.
All this will be taken care of via NDC sync. So it's safe to drop this patch.
I initially made this fix and later fixed the NDC sync issue, so somehow, I forgot to mark this patch as dropped.
Thanks
Amiya
Quoted 18 lines · Ashwin Sekhar T K
Hi Amiya,
Quoted 3 lines
NPA_POOL_ERR_INT_RANGEfires spuriously between pool creation (ptr_start/ptr_end default to 0/~0) and the actual range install viaroc_npa_pool_op_range_set().
ERR_INT_RANGEis not supposed to fire spuriously. Did you root cause why this is happening ?Quoted 2 lines
On CN10K this drains the pool
stack and makes the pool unusable.Didn't quite understand this part. Could you please elaborate.
Thanks
Ashwin
Hi Amiya,
Quoted 1 line
Yes — the root cause is NDC staleness. The AQ INIT writes pool context (including ptr_start=0, ptr_end=~0) directly to RAM, bypassing NDC.
The AQ INIT does not bypass NDC. May I know how you arrived at this conclusion?
Even your other NDC sync patch is not required. The only time NDC sync is required is at teardown time because at this point, we free the stack memory. So, after this, NPA should not evict any stale stack pages back to memory (which is already freed).
Quoted 2 lines
Sorry for my poor wordings. on my part. The pool stack does not get drained — it never gets populated.During
cnxk_mempool_populate(), eachroc_npa_aura_op_free()call silently drops the buffer (NPA sees stale context with ena=0 or ptr_end=0 via NDC). After populate completes, the pool has 0 available buffers despite no error being returned. Subsequentroc_npa_aura_op_alloc()returns NULL, causing port start failures.
It will not silently drop. You should be getting AURA DISABLED interrupts.
Could you please explain the exact use case and issue that you are facing?
Thanks
Ashwin
Hi Ashwin - I have raised a ticket
https://bugs.dpdk.org/show_bug.cgi?id=2031 with details. Pls check if it helps.
Thanks
Amiya
Quoted 25 lines · Ashwin Sekhar T K
Hi Amiya,
Quoted 1 line
Yes — the root cause is NDC staleness. The AQ INIT writes pool context
(including ptr_start=0, ptr_end=~0) directly to RAM, bypassing NDC. The AQ INIT does not bypass NDC. May I know how you arrived at this conclusion?
Even your other NDC sync patch is not required. The only time NDC sync is required is at teardown time because at this point, we free the stack memory. So, after this, NPA should not evict any stale stack pages back to memory (which is already freed).Quoted 1 line
Sorry for my poor wordings. on my part. The pool stack does not get
drained — it never gets populated.During
cnxk_mempool_populate(), eachroc_npa_aura_op_free()call silently drops the buffer (NPA sees stale context with ena=0 or ptr_end=0 via NDC). After populate completes, the pool has 0Quoted 1 line
available buffers despite no error being returned. Subsequent
roc_npa_aura_op_alloc()returns NULL, causing port start failures. It will not silently drop. You should be getting AURA DISABLED interrupts.Could you please explain the exact use case and issue that you are facing?
Thanks
Ashwin
Hi Ashwin
*The AQ INIT does not bypass NDC. May I know how you arrived at this conclusion?*
* Even your other NDC sync patch is not required. The only time NDC sync is required is at teardown time because at this point, we free the stack memory. So, after this, NPA should not evict any stale stack pages back to memory (which is already freed).*
*>> *I don't see any ndc_sync calls during pool_init, So the NDC is not updated at pool_init time, whereas it's getting called for all termination paths. Could you explain how this is taken care of then without an ndc sync? I need to test without NDC sync changes multiple times and confirm. BUt if you could explain how it'll work without NDC sync or how it's a side effect of IOVA as PA, it would be great.
Thanks
Amiya
Quoted 36 lines · Amiya Ranjan Mohakud
Hi Ashwin - I have raised a ticket
https://bugs.dpdk.org/show_bug.cgi?id=2031 with details. Pls check if it helps.Thanks
AmiyaQuoted 25 lines · Ashwin Sekhar T K
Hi Amiya,
Quoted 1 line
Yes — the root cause is NDC staleness. The AQ INIT writes pool context
(including ptr_start=0, ptr_end=~0) directly to RAM, bypassing NDC. The AQ INIT does not bypass NDC. May I know how you arrived at this conclusion?
Even your other NDC sync patch is not required. The only time NDC sync is required is at teardown time because at this point, we free the stack memory. So, after this, NPA should not evict any stale stack pages back to memory (which is already freed).Quoted 1 line
Sorry for my poor wordings. on my part. The pool stack does not get
drained — it never gets populated.During
cnxk_mempool_populate(), eachroc_npa_aura_op_free()call silently drops the buffer (NPA sees stale context with ena=0 or ptr_end=0 via NDC). After populate completes, the pool has 0Quoted 1 line
available buffers despite no error being returned. Subsequent
roc_npa_aura_op_alloc()returns NULL, causing port start failures. It will not silently drop. You should be getting AURA DISABLED interrupts.Could you please explain the exact use case and issue that you are facing?
Thanks
Ashwin
Hi Amiya,
NDC is a cache that NPA uses to cache frequently accessed contexts and stack pages. All accesses to contexts/stack pages go via this cache only. There is NO direct access to backing memory in NPA operations.
On AQ Init, the context is first allocated in the cache. Whenever NPA must access this context (for subsequent alloc/frees or AQ reads/writes), it will read/write directly from the cache. The context/stack pages never gets evicted out of the cache (unless there are more contexts/stack pages active at the same time than the NDC can hold).
Doing an NDC sync will write back the dirty entries in the cache to the backing memory. This does not affect the normal operation of NPA in anyway. Even after you do a sync, the entries remain in the cache and further NPA operations still read/write from the cache. The backing memory is NEVER accessed directly.
Why we need it at teardown is to avoid corruption. We free stack pages when we destroy the pool. If there are stale entries for these stack pages remaining in the cache, then at a later point of time, these entries can become candidates for eviction and can cause writes to memory which was already freed causing corruption/translation faults etc.
Quoted 1 line
Quoted 1 line
how it's a side effect of IOVA as PA
IOVA as PA is NOT a supported mode. We have not studied what kind of errors will pop up in this mode. Explaining the side effects in this mode will require deeper study which we don't think is necessary for an unsupported mode.
Thanks
Ashwin
Thanks Ashwin for the explanation.
*On AQ Init, the context is first allocated in the cache.* -> Does the hardware take care of it? Before writing to memory, it writes to NDC first?
Thanks
Amiya
Quoted 34 lines · Ashwin Sekhar
Hi Amiya,
NDC is a cache that NPA uses to cache frequently accessed contexts and stack pages. All accesses to contexts/stack pages go via this cache only. There is NO direct access to backing memory in NPA operations.
On AQ Init, the context is first allocated in the cache. Whenever NPA must access this context (for subsequent alloc/frees or AQ reads/writes), it will read/write directly from the cache. The context/stack pages never gets evicted out of the cache (unless there are more contexts/stack pages active at the same time than the NDC can hold).
Doing an NDC sync will write back the dirty entries in the cache to the backing memory. This does not affect the normal operation of NPA in anyway. Even after you do a sync, the entries remain in the cache and further NPA operations still read/write from the cache. The backing memory is NEVER accessed directly.
Why we need it at teardown is to avoid corruption. We free stack pages when we destroy the pool. If there are stale entries for these stack pages remaining in the cache, then at a later point of time, these entries can become candidates for eviction and can cause writes to memory which was already freed causing corruption/translation faults etc.
Quoted 1 line
Quoted 1 line
how it's a side effect of IOVA as PA
IOVA as PA is NOT a supported mode. We have not studied what kind of errors will pop up in this mode. Explaining the side effects in this mode will require deeper study which we don't think is necessary for an unsupported mode.
Thanks
Ashwin
Quoted 2 lines
On AQ Init, the context is first allocated in the cache. -> Does the hardware take care of it? Before writing to memory, it writes to NDC first?
Yes. The hardware takes care.