Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2622 by
re-initializing origin_qe to NULL when a buffer is allocated. This step
was omitted in the switch to ring pool allocation introduced in
commit ID c8cf1d87783d4b4c628f219803b78731b8d4ade4

Signed-off-by: Bill Fischofer <bill.fischo...@linaro.org>
---
Changes in v2:
- Review comments from Maxim. Move init to earlier loops for completeness and
  efficiency.

 platform/linux-generic/odp_pool.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/platform/linux-generic/odp_pool.c 
b/platform/linux-generic/odp_pool.c
index 4be3827..8c38c93 100644
--- a/platform/linux-generic/odp_pool.c
+++ b/platform/linux-generic/odp_pool.c
@@ -588,6 +588,7 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
        uint32_t mask, i;
        pool_cache_t *cache;
        uint32_t cache_num, num_ch, num_deq, burst;
+       odp_buffer_hdr_t *hdr;
 
        ring  = &pool->ring.hdr;
        mask  = pool->ring_mask;
@@ -608,8 +609,13 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
        }
 
        /* Get buffers from the cache */
-       for (i = 0; i < num_ch; i++)
+       for (i = 0; i < num_ch; i++) {
                buf[i] = cache->buf[cache_num - num_ch + i];
+               hdr = buf_hdl_to_hdr(buf[i]);
+               hdr->origin_qe = NULL;
+               if (buf_hdr)
+                       buf_hdr[i] = hdr;
+       }
 
        /* If needed, get more from the global pool */
        if (odp_unlikely(num_deq)) {
@@ -629,9 +635,11 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
                        uint32_t idx = num_ch + i;
 
                        buf[idx] = (odp_buffer_t)(uintptr_t)data[i];
+                       hdr = buf_hdl_to_hdr(buf[idx]);
+                       hdr->origin_qe = NULL;
 
                        if (buf_hdr) {
-                               buf_hdr[idx] = buf_hdl_to_hdr(buf[idx]);
+                               buf_hdr[idx] = hdr;
                                /* Prefetch newly allocated and soon to be used
                                 * buffer headers. */
                                odp_prefetch(buf_hdr[idx]);
@@ -648,11 +656,6 @@ int buffer_alloc_multi(pool_t *pool, odp_buffer_t buf[],
                cache->num = cache_num - num_ch;
        }
 
-       if (buf_hdr) {
-               for (i = 0; i < num_ch; i++)
-                       buf_hdr[i] = buf_hdl_to_hdr(buf[i]);
-       }
-
        return num_ch + num_deq;
 }
 
-- 
2.7.4

Reply via email to