@@ -486,6 +486,8 @@ static inline void page_pool_nid_changed(struct page_pool *pool, int new_nid)
#if defined(CONFIG_PAGE_POOL)
void page_pool_set_pp_info(struct page_pool *pool, netmem_ref netmem);
void page_pool_clear_pp_info(netmem_ref netmem);
+
+void page_pool_mp_return_in_cache(struct page_pool *pool, netmem_ref netmem);
#else
static inline void page_pool_set_pp_info(struct page_pool *pool,
netmem_ref netmem)
@@ -1195,3 +1195,18 @@ void page_pool_update_nid(struct page_pool *pool, int new_nid)
}
}
EXPORT_SYMBOL(page_pool_update_nid);
+
+/*
+ * page_pool_mp_return_in_cache() - return a netmem to the allocation cache.
+ * @pool: pool from which pages were allocated
+ * @netmem: netmem to return
+ *
+ * Return already allocated and accounted netmem to the page pool's allocation
+ * cache. The function doesn't provide synchronisation and can only be called
+ * off the mp_ops->alloc_netmems() path.
+ */
+void page_pool_mp_return_in_cache(struct page_pool *pool, netmem_ref netmem)
+{
+ page_pool_dma_sync_for_device(pool, netmem, -1);
+ pool->alloc.cache[pool->alloc.count++] = netmem;
+}