Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756777AbcKETjh (ORCPT ); Sat, 5 Nov 2016 15:39:37 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:33960 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755581AbcKETje (ORCPT ); Sat, 5 Nov 2016 15:39:34 -0400 Date: Sat, 5 Nov 2016 15:39:30 -0400 From: Konrad Rzeszutek Wilk To: Alexander Duyck Cc: linux-mm@kvack.org, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Konrad Rzeszutek Wilk Subject: Re: [mm PATCH v2 03/26] swiotlb: Add support for DMA_ATTR_SKIP_CPU_SYNC Message-ID: <20161105193929.GA26349@localhost.localdomain> References: <20161102111031.79519.14741.stgit@ahduyck-blue-test.jf.intel.com> <20161102111252.79519.21950.stgit@ahduyck-blue-test.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161102111252.79519.21950.stgit@ahduyck-blue-test.jf.intel.com> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1832 Lines: 45 .. snip.. > @@ -561,6 +565,7 @@ void swiotlb_tbl_unmap_single(struct device *hwdev, phys_addr_t tlb_addr, > * First, sync the memory before unmapping the entry > */ > if (orig_addr != INVALID_PHYS_ADDR && > + !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && > ((dir == DMA_FROM_DEVICE) || (dir == DMA_BIDIRECTIONAL))) > swiotlb_bounce(orig_addr, tlb_addr, size, DMA_FROM_DEVICE); > > @@ -654,7 +659,8 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr, > * GFP_DMA memory; fall back on map_single(), which > * will grab memory from the lowest available address range. > */ > - phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE); > + phys_addr_t paddr = map_single(hwdev, 0, size, > + DMA_FROM_DEVICE, 0); > if (paddr == SWIOTLB_MAP_ERROR) > goto err_warn; > > @@ -669,7 +675,8 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr, > > /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ > swiotlb_tbl_unmap_single(hwdev, paddr, > - size, DMA_TO_DEVICE); > + size, DMA_TO_DEVICE, > + DMA_ATTR_SKIP_CPU_SYNC); This I believe is redundant. That is swiotlb_tbl_unmap_single only does an bounce if the dir is DMA_FROM_DEVICE or DMA_BIDIRECTIONAL. I added /* optional. */ > goto err_warn; > } > } > @@ -699,7 +706,7 @@ void swiotlb_tbl_sync_single(struct device *hwdev, phys_addr_t tlb_addr, > free_pages((unsigned long)vaddr, get_order(size)); > else > /* DMA_TO_DEVICE to avoid memcpy in swiotlb_tbl_unmap_single */ > - swiotlb_tbl_unmap_single(hwdev, paddr, size, DMA_TO_DEVICE); > + swiotlb_tbl_unmap_single(hwdev, paddr, size, DMA_TO_DEVICE, 0); .. but here you choose to put 0? I changed that to DMA_ATTR_SKIP_CPU_SYNC and expanded the comment above. Time to test the patches.