From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [Linaro-mm-sig] [PATCH/RFC 0/8] ARM: DMA-mapping =?iso-8859-1?q?framework=09redesign?= Date: Fri, 24 Jun 2011 17:20:15 +0200 Message-ID: <201106241720.15385.arnd@arndb.de> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <002701cc30be$ab296cc0$017c4640$%szyprowski@samsung.com> <4E02119F.4000901@codeaurora.org> Mime-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4E02119F.4000901@codeaurora.org> Sender: owner-linux-mm@kvack.org To: Jordan Crouse Cc: Marek Szyprowski , 'Subash Patel' , linux-arch@vger.kernel.org, 'Russell King - ARM Linux' , 'Joerg Roedel' , linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, 'Kyungmin Park' , linux-arm-kernel@lists.infradead.org List-Id: linux-arch.vger.kernel.org On Wednesday 22 June 2011, Jordan Crouse wrote: > >> I have a query in similar lines, but related to user virtual address > >> space. Is it feasible to extend these DMA interfaces(and IOMMU), to map > >> a user allocated buffer into the hardware? > > > > This can be done with the current API, although it may not look so > > straightforward. You just need to create a scatter list of user pages > > (these can be gathered with get_user_pages function) and use dma_map_sg() > > function. If the dma-mapping support iommu, it can map all these pages > > into a single contiguous buffer on device (DMA) address space. > > > > Some additional 'magic' might be required to get access to pages that are > > mapped with pure PFN (VM_PFNMAP flag), but imho it still can be done. > > > > I will try to implement this feature in videobuf2-dma-config allocator > > together with the next version of my patches for dma-mapping&iommu. > > With luck DMA_ATTRIB_NO_KERNEL_MAPPING should remove any lingering arguments > for trying to map user pages. Given that our ultimate goal here is buffer > sharing, user allocated pages have limited value and appeal. If anything, I > vote that this be a far lower priority compared to the rest of the win you > have here. I agree. Mapping user-allocated buffers is extremely hard to get right when there are extra constraints. If it doesn't work already for some driver, I wouldn't put too much effort into making it work for more special cases. Arnd -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from moutng.kundenserver.de ([212.227.17.8]:55176 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757734Ab1FXPUq (ORCPT ); Fri, 24 Jun 2011 11:20:46 -0400 From: Arnd Bergmann Subject: Re: [Linaro-mm-sig] [PATCH/RFC 0/8] ARM: DMA-mapping =?iso-8859-1?q?framework=09redesign?= Date: Fri, 24 Jun 2011 17:20:15 +0200 References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <002701cc30be$ab296cc0$017c4640$%szyprowski@samsung.com> <4E02119F.4000901@codeaurora.org> In-Reply-To: <4E02119F.4000901@codeaurora.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-ID: <201106241720.15385.arnd@arndb.de> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Jordan Crouse Cc: Marek Szyprowski , 'Subash Patel' , linux-arch@vger.kernel.org, 'Russell King - ARM Linux' , 'Joerg Roedel' , linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, 'Kyungmin Park' , linux-arm-kernel@lists.infradead.org Message-ID: <20110624152015.3J_3mmDIiLMp_rQKRrJm78CAFg3ar3lqwA6_b-iQl-4@z> On Wednesday 22 June 2011, Jordan Crouse wrote: > >> I have a query in similar lines, but related to user virtual address > >> space. Is it feasible to extend these DMA interfaces(and IOMMU), to map > >> a user allocated buffer into the hardware? > > > > This can be done with the current API, although it may not look so > > straightforward. You just need to create a scatter list of user pages > > (these can be gathered with get_user_pages function) and use dma_map_sg() > > function. If the dma-mapping support iommu, it can map all these pages > > into a single contiguous buffer on device (DMA) address space. > > > > Some additional 'magic' might be required to get access to pages that are > > mapped with pure PFN (VM_PFNMAP flag), but imho it still can be done. > > > > I will try to implement this feature in videobuf2-dma-config allocator > > together with the next version of my patches for dma-mapping&iommu. > > With luck DMA_ATTRIB_NO_KERNEL_MAPPING should remove any lingering arguments > for trying to map user pages. Given that our ultimate goal here is buffer > sharing, user allocated pages have limited value and appeal. If anything, I > vote that this be a far lower priority compared to the rest of the win you > have here. I agree. Mapping user-allocated buffers is extremely hard to get right when there are extra constraints. If it doesn't work already for some driver, I wouldn't put too much effort into making it work for more special cases. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Fri, 24 Jun 2011 17:20:15 +0200 Subject: [Linaro-mm-sig] [PATCH/RFC 0/8] ARM: DMA-mapping =?iso-8859-1?q?framework=09redesign?= In-Reply-To: <4E02119F.4000901@codeaurora.org> References: <1308556213-24970-1-git-send-email-m.szyprowski@samsung.com> <002701cc30be$ab296cc0$017c4640$%szyprowski@samsung.com> <4E02119F.4000901@codeaurora.org> Message-ID: <201106241720.15385.arnd@arndb.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wednesday 22 June 2011, Jordan Crouse wrote: > >> I have a query in similar lines, but related to user virtual address > >> space. Is it feasible to extend these DMA interfaces(and IOMMU), to map > >> a user allocated buffer into the hardware? > > > > This can be done with the current API, although it may not look so > > straightforward. You just need to create a scatter list of user pages > > (these can be gathered with get_user_pages function) and use dma_map_sg() > > function. If the dma-mapping support iommu, it can map all these pages > > into a single contiguous buffer on device (DMA) address space. > > > > Some additional 'magic' might be required to get access to pages that are > > mapped with pure PFN (VM_PFNMAP flag), but imho it still can be done. > > > > I will try to implement this feature in videobuf2-dma-config allocator > > together with the next version of my patches for dma-mapping&iommu. > > With luck DMA_ATTRIB_NO_KERNEL_MAPPING should remove any lingering arguments > for trying to map user pages. Given that our ultimate goal here is buffer > sharing, user allocated pages have limited value and appeal. If anything, I > vote that this be a far lower priority compared to the rest of the win you > have here. I agree. Mapping user-allocated buffers is extremely hard to get right when there are extra constraints. If it doesn't work already for some driver, I wouldn't put too much effort into making it work for more special cases. Arnd