diff mbox series

[net-next,RFC,1/8] page_pool: add helper functions for DMA

Message ID 154413873204.21735.4234188123129390865.stgit@firesoul
State New
Headers show
Series [net-next,RFC,1/8] page_pool: add helper functions for DMA | expand

Commit Message

Jesper Dangaard Brouer Dec. 6, 2018, 11:25 p.m. UTC
From: Ilias Apalodimas <ilias.apalodimas@linaro.org>


Add helper functions for retreiving dma_addr_t stored in page_private and
unmapping dma addresses, mapped via the page_pool API.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>

---
 include/net/page_pool.h |    6 ++++++
 net/core/page_pool.c    |    7 +++++++
 2 files changed, 13 insertions(+)

Comments

David Miller Dec. 8, 2018, 7:06 a.m. UTC | #1
From: Jesper Dangaard Brouer <brouer@redhat.com>

Date: Fri, 07 Dec 2018 00:25:32 +0100

> From: Ilias Apalodimas <ilias.apalodimas@linaro.org>

> 

> Add helper functions for retreiving dma_addr_t stored in page_private and

> unmapping dma addresses, mapped via the page_pool API.

> 

> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>


This isn't going to work on 32-bit platforms where dma_addr_t is a u64,
because the page private is unsigned long.

Grep for PHY_ADDR_T_64BIT under arch/ to see the vast majority of the
cases where this happens, then ARCH_DMA_ADDR_T_64BIT.
Ilias Apalodimas Dec. 8, 2018, 7:55 a.m. UTC | #2
On Fri, Dec 07, 2018 at 11:06:55PM -0800, David Miller wrote:

> This isn't going to work on 32-bit platforms where dma_addr_t is a u64,

> because the page private is unsigned long.

> 

> Grep for PHY_ADDR_T_64BIT under arch/ to see the vast majority of the

> cases where this happens, then ARCH_DMA_ADDR_T_64BIT.


Noted, thanks for the heads up.

Thanks
/Ilias
diff mbox series

Patch

diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index 694d055e01ef..439f9183d4cd 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -111,6 +111,8 @@  struct page_pool *page_pool_create(const struct page_pool_params *params);
 
 void page_pool_destroy(struct page_pool *pool);
 
+void page_pool_unmap_page(struct page_pool *pool, struct page *page);
+
 /* Never call this directly, use helpers below */
 void __page_pool_put_page(struct page_pool *pool,
 			  struct page *page, bool allow_direct);
@@ -141,4 +143,8 @@  static inline bool is_page_pool_compiled_in(void)
 #endif
 }
 
+static inline dma_addr_t page_pool_get_dma_addr(struct page *page)
+{
+	return page_private(page);
+}
 #endif /* _NET_PAGE_POOL_H */
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 43a932cb609b..26e14a17a67c 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -184,6 +184,13 @@  static void __page_pool_clean_page(struct page_pool *pool,
 	set_page_private(page, 0);
 }
 
+/* unmap the page and clean our state */
+void page_pool_unmap_page(struct page_pool *pool, struct page *page)
+{
+	__page_pool_clean_page(pool, page);
+}
+EXPORT_SYMBOL(page_pool_unmap_page);
+
 /* Return a page to the page allocator, cleaning up our state */
 static void __page_pool_return_page(struct page_pool *pool, struct page *page)
 {