aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/page_pool.c
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2019-02-12 20:55:45 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-14 01:00:16 -0500
commit1567b85eb8ad2d0fe8d77e50118e876df565d9c7 (patch)
treed7357f5cf9befd591a7fc17bf120a4210d040eac /net/core/page_pool.c
parentc25fff7171bebb76243ccc77f0f04aafa3db87be (diff)
net: page_pool: don't use page->private to store dma_addr_t
As pointed out by David Miller the current page_pool implementation stores dma_addr_t in page->private. This won't work on 32-bit platforms with 64-bit DMA addresses since the page->private is an unsigned long and the dma_addr_t a u64. A previous patch is adding dma_addr_t on struct page to accommodate this. This patch adapts the page_pool related functions to use the newly added struct for storing and retrieving DMA addresses from network drivers. Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/page_pool.c')
-rw-r--r--net/core/page_pool.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 43a932cb609b..897a69a1477e 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -136,7 +136,9 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,
136 if (!(pool->p.flags & PP_FLAG_DMA_MAP)) 136 if (!(pool->p.flags & PP_FLAG_DMA_MAP))
137 goto skip_dma_map; 137 goto skip_dma_map;
138 138
139 /* Setup DMA mapping: use page->private for DMA-addr 139 /* Setup DMA mapping: use 'struct page' area for storing DMA-addr
140 * since dma_addr_t can be either 32 or 64 bits and does not always fit
141 * into page private data (i.e 32bit cpu with 64bit DMA caps)
140 * This mapping is kept for lifetime of page, until leaving pool. 142 * This mapping is kept for lifetime of page, until leaving pool.
141 */ 143 */
142 dma = dma_map_page(pool->p.dev, page, 0, 144 dma = dma_map_page(pool->p.dev, page, 0,
@@ -146,7 +148,7 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,
146 put_page(page); 148 put_page(page);
147 return NULL; 149 return NULL;
148 } 150 }
149 set_page_private(page, dma); /* page->private = dma; */ 151 page->dma_addr = dma;
150 152
151skip_dma_map: 153skip_dma_map:
152 /* When page just alloc'ed is should/must have refcnt 1. */ 154 /* When page just alloc'ed is should/must have refcnt 1. */
@@ -175,13 +177,16 @@ EXPORT_SYMBOL(page_pool_alloc_pages);
175static void __page_pool_clean_page(struct page_pool *pool, 177static void __page_pool_clean_page(struct page_pool *pool,
176 struct page *page) 178 struct page *page)
177{ 179{
180 dma_addr_t dma;
181
178 if (!(pool->p.flags & PP_FLAG_DMA_MAP)) 182 if (!(pool->p.flags & PP_FLAG_DMA_MAP))
179 return; 183 return;
180 184
185 dma = page->dma_addr;
181 /* DMA unmap */ 186 /* DMA unmap */
182 dma_unmap_page(pool->p.dev, page_private(page), 187 dma_unmap_page(pool->p.dev, dma,
183 PAGE_SIZE << pool->p.order, pool->p.dma_dir); 188 PAGE_SIZE << pool->p.order, pool->p.dma_dir);
184 set_page_private(page, 0); 189 page->dma_addr = 0;
185} 190}
186 191
187/* Return a page to the page allocator, cleaning up our state */ 192/* Return a page to the page allocator, cleaning up our state */