diff mbox series

[net-next,V2,3/3] page_pool: use DMA_ATTR_SKIP_CPU_SYNC for DMA mappings

Message ID 154998295338.8783.14384429687417240826.stgit@firesoul (mailing list archive)
State New, archived
Headers show
Series Fix page_pool API and dma address storage | expand

Commit Message

Jesper Dangaard Brouer Feb. 12, 2019, 2:49 p.m. UTC
As pointed out by Alexander Duyck, the DMA mapping done in page_pool needs
to use the DMA attribute DMA_ATTR_SKIP_CPU_SYNC.

As the principle behind page_pool keeping the pages mapped is that the
driver takes over the DMA-sync steps.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 net/core/page_pool.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

kernel test robot Feb. 12, 2019, 5:12 p.m. UTC | #1
Hi Jesper,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jesper-Dangaard-Brouer/mm-add-dma_addr_t-to-struct-page/20190213-002150
config: ia64-allyesconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   net/core/page_pool.c: In function '__page_pool_clean_page':
>> net/core/page_pool.c:187:2: error: implicit declaration of function 'dma_unmap_page_attr'; did you mean 'dma_unmap_page_attrs'? [-Werror=implicit-function-declaration]
     dma_unmap_page_attr(pool->p.dev, dma,
     ^~~~~~~~~~~~~~~~~~~
     dma_unmap_page_attrs
   cc1: some warnings being treated as errors

vim +187 net/core/page_pool.c

   175	
   176	/* Cleanup page_pool state from page */
   177	static void __page_pool_clean_page(struct page_pool *pool,
   178					   struct page *page)
   179	{
   180		dma_addr_t dma;
   181	
   182		if (!(pool->p.flags & PP_FLAG_DMA_MAP))
   183			return;
   184	
   185		dma = page->dma_addr;
   186		/* DMA unmap */
 > 187		dma_unmap_page_attr(pool->p.dev, dma,
   188				    PAGE_SIZE << pool->p.order, pool->p.dma_dir,
   189				    DMA_ATTR_SKIP_CPU_SYNC);
   190		page->dma_addr = 0;
   191	}
   192	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Jesper Dangaard Brouer Feb. 12, 2019, 5:58 p.m. UTC | #2
On Wed, 13 Feb 2019 01:12:59 +0800
kbuild test robot <lkp@intel.com> wrote:

>    net/core/page_pool.c: In function '__page_pool_clean_page':
> >> net/core/page_pool.c:187:2: error: implicit declaration of function 'dma_unmap_page_attr'; did you mean 'dma_unmap_page_attrs'? [-Werror=implicit-function-declaration]  
>      dma_unmap_page_attr(pool->p.dev, dma,
>      ^~~~~~~~~~~~~~~~~~~
>      dma_unmap_page_attrs
>    cc1: some warnings being treated as errors

Ups, in my compile test I didn't have CONFIG_PAGE_POOL defined.
Will respin a V3.
diff mbox series

Patch

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index 897a69a1477e..7e624c2cd709 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -141,9 +141,9 @@  static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,
 	 * into page private data (i.e 32bit cpu with 64bit DMA caps)
 	 * This mapping is kept for lifetime of page, until leaving pool.
 	 */
-	dma = dma_map_page(pool->p.dev, page, 0,
-			   (PAGE_SIZE << pool->p.order),
-			   pool->p.dma_dir);
+	dma = dma_map_page_attrs(pool->p.dev, page, 0,
+				 (PAGE_SIZE << pool->p.order),
+				 pool->p.dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
 	if (dma_mapping_error(pool->p.dev, dma)) {
 		put_page(page);
 		return NULL;
@@ -184,8 +184,9 @@  static void __page_pool_clean_page(struct page_pool *pool,
 
 	dma = page->dma_addr;
 	/* DMA unmap */
-	dma_unmap_page(pool->p.dev, dma,
-		       PAGE_SIZE << pool->p.order, pool->p.dma_dir);
+	dma_unmap_page_attr(pool->p.dev, dma,
+			    PAGE_SIZE << pool->p.order, pool->p.dma_dir,
+			    DMA_ATTR_SKIP_CPU_SYNC);
 	page->dma_addr = 0;
 }