From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753658AbbFCIU3 (ORCPT ); Wed, 3 Jun 2015 04:20:29 -0400 Received: from mx12-out5.antispamcloud.com ([46.165.232.175]:56840 "EHLO mx12-out5.antispamcloud.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752960AbbFCIUY convert rfc822-to-8bit (ORCPT ); Wed, 3 Jun 2015 04:20:24 -0400 X-Greylist: delayed 1673 seconds by postgrey-1.27 at vger.kernel.org; Wed, 03 Jun 2015 04:20:23 EDT Message-ID: <556EB229.1060409@topic.nl> Date: Wed, 3 Jun 2015 09:52:09 +0200 From: Mike Looijmans Organization: TOPIC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: , CC: , Subject: Re: [PATCH v3] arm/mm/dma-mapping.c: Add arm_coherent_dma_mmap References: <1431003257-7794-1-git-send-email-mike.looijmans@topic.nl> In-Reply-To: <1431003257-7794-1-git-send-email-mike.looijmans@topic.nl> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8BIT X-Originating-IP: [192.168.80.121] X-EXCLAIMER-MD-CONFIG: 9833cda7-5b21-4d34-9a38-8d025ddc3664 X-EXCLAIMER-MD-BIFURCATION-INSTANCE: 0 X-Filter-ID: s0sct1PQhAABKnZB5plbIbbvfIHzQjPVmPLZeVYSu3xU9luQrU+8/8qthi+0Jd/W6KAUC/fjyuDn NXFr4uarw1HLdaqPQEXQbVxseDCsCCuAv7TlYyOHVsk7300Fxo0/mhHwuZkwbQpbZ8u+YNzCrnS0 YRLDDZrQ3mo3oJvKsFEkJLVEICBPkQzcYhyd6CAC2wvHbfwld3xCwVQvwEuT76LI4OY9HO9H+Fx9 YIm3grMCYhCx4jjoS9B9Db5aGUukpoUzM/D3rDCLyj73WFrf3KIkqoPlWAiba+QlSvJ1KdV0f61g tzhUSGdn+0jlSPUS9/yh5FqdXSItk8kl+EYz39lkiNYDhrKg6iciDr+4QvoZZGEguk4zUQ/Gt9tH mlzPPd0rEuGjFyZoidhtHm+WoaljTiJbOE14mzcsdj2IkgyJiZTPLlrVLJWwphIjvwbr9R/2gMGq 0KWAzmMf+ibVDuTUaj8AfOKPjyzq5JIgJ6iFHGGshDptiwLpJ2ejTRx0JIGwxVnFOWVlZE2rSvjy Y6R9Sm8ZZj3WwN4q40J+sX/QR1wHhJ68m2AHzli/8iF0Hu6iKjziKwNkC+aQcixt2GUVrBsPGnNi J83AD/4JscAbL2JnZdIooCHNGp9X4OJ892nj+Rw7neU1JqRjpg2S1boa3gWHj8Z0FXcCDR+j/aqN tT4cvsJLiU+BMQ/n95+pVgW9/bktU41htiJ8fk7NkKB8lTw+8BlajhHdQsU8wHc30zpO3I50xYlT IV7B+RXOlzKKnB7nLxLWhY3bervOdGaJcpyjJlL6r+ZuA7RgvH49lo9n5nr2gCQ+mfzihyAS X-Report-Abuse-To: spam@mx99.antispamcloud.com X-Filter-Fingerprint: IFrWXGses7OKB5S5G8/dJcFIkh7yuznlTeFPLSNUgKbJUWjZ8+qhjyB23tbDuyLOYL8Ff78gYsez 4Rl08xudmXi4esCQ0R1MchVjt7wblGlvhFgW0MjUMRkF5sMCDfftTXNFDzN17hnrWeZYOJvLq0Ic WjZ+XcEjj/7Pkld0zkmvziDInX9WdMov2kn2yXjdwv61T+KDYyYtREgszdyFwv8IxCB3p/oCKvxr eyISh3JGb7OS5oVgiO+kDxZrVPLz3MmEGC2PrUKqLq5WmHK+Nw== X-Originating-IP: 88.159.208.100 X-Spampanel-Domain: topic.nl X-Spampanel-Username: 88.159.208.100 Authentication-Results: antispamcloud.com; auth=pass smtp.auth=88.159.208.100@topic.nl X-Spampanel-Outgoing-Class: ham X-Spampanel-Outgoing-Evidence: SB/global_tokens (0.00151968156377) X-Recommended-Action: accept Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping! Just curious, any further feedback or comment after Arnd Bergmann's ack? It fixes a bug that took quite some time to discover and analyze, we should save other people going through that same trouble. On 07-05-15 14:54, Mike Looijmans wrote: > When dma-coherent transfers are enabled, the mmap call must > not change the pg_prot flags in the vma struct. > > Split the arm_dma_mmap into a common and specific parts, > and add a "arm_coherent_dma_mmap" implementation that does > not alter the page protection flags. > > Tested on a topic-miami board (Zynq) using the ACP port > to transfer data between FPGA and CPU using the Dyplo > framework. Without this patch, byte-wise access to mmapped > coherent DMA memory was about 20x slower because of the > memory being marked as non-cacheable, and transfer speeds > would not exceed 240MB/s. > > After this patch, the mapped memory is cacheable and the > transfer speed is again 600MB/s (limited by the FPGA) when > the data is in the L2 cache, while data integrity is being > maintained. > > The patch has no effect on non-coherent DMA. > > Signed-off-by: Mike Looijmans > --- > v2: Mistakenly sent the wrong patch which included a devicetree file, removed it from the patch. > v3: Rebased on current linux master because the patch was made on 3.19 and did not apply cleanly. > > arch/arm/mm/dma-mapping.c | 32 +++++++++++++++++++++++++------- > 1 file changed, 25 insertions(+), 7 deletions(-) > > diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c > index 09c5fe3..d6f5256 100644 > --- a/arch/arm/mm/dma-mapping.c > +++ b/arch/arm/mm/dma-mapping.c > @@ -148,11 +148,14 @@ static void *arm_coherent_dma_alloc(struct device *dev, size_t size, > dma_addr_t *handle, gfp_t gfp, struct dma_attrs *attrs); > static void arm_coherent_dma_free(struct device *dev, size_t size, void *cpu_addr, > dma_addr_t handle, struct dma_attrs *attrs); > +static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma, > + void *cpu_addr, dma_addr_t dma_addr, size_t size, > + struct dma_attrs *attrs); > > struct dma_map_ops arm_coherent_dma_ops = { > .alloc = arm_coherent_dma_alloc, > .free = arm_coherent_dma_free, > - .mmap = arm_dma_mmap, > + .mmap = arm_coherent_dma_mmap, > .get_sgtable = arm_dma_get_sgtable, > .map_page = arm_coherent_dma_map_page, > .map_sg = arm_dma_map_sg, > @@ -690,10 +693,7 @@ static void *arm_coherent_dma_alloc(struct device *dev, size_t size, > attrs, __builtin_return_address(0)); > } > > -/* > - * Create userspace mapping for the DMA-coherent memory. > - */ > -int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, > +static int __arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, > void *cpu_addr, dma_addr_t dma_addr, size_t size, > struct dma_attrs *attrs) > { > @@ -704,8 +704,6 @@ int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, > unsigned long pfn = dma_to_pfn(dev, dma_addr); > unsigned long off = vma->vm_pgoff; > > - vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); > - > if (dma_mmap_from_coherent(dev, vma, cpu_addr, size, &ret)) > return ret; > > @@ -721,6 +719,26 @@ int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, > } > > /* > + * Create userspace mapping for the DMA-coherent memory. > + */ > +static int arm_coherent_dma_mmap(struct device *dev, struct vm_area_struct *vma, > + void *cpu_addr, dma_addr_t dma_addr, size_t size, > + struct dma_attrs *attrs) > +{ > + return __arm_dma_mmap(dev, vma, cpu_addr, dma_addr, size, attrs); > +} > + > +int arm_dma_mmap(struct device *dev, struct vm_area_struct *vma, > + void *cpu_addr, dma_addr_t dma_addr, size_t size, > + struct dma_attrs *attrs) > +{ > +#ifdef CONFIG_MMU > + vma->vm_page_prot = __get_dma_pgprot(attrs, vma->vm_page_prot); > +#endif /* CONFIG_MMU */ > + return __arm_dma_mmap(dev, vma, cpu_addr, dma_addr, size, attrs); > +} > + > +/* > * Free a buffer as defined by the above mapping. > */ > static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr, > Kind regards, Mike Looijmans System Expert TOPIC Embedded Products Eindhovenseweg 32-C, NL-5683 KH Best Postbus 440, NL-5680 AK Best Telefoon: +31 (0) 499 33 69 79 Telefax: +31 (0) 499 33 69 70 E-mail: mike.looijmans@topicproducts.com Website: www.topicproducts.com Please consider the environment before printing this e-mail