From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Szyprowski Date: Tue, 27 Dec 2011 08:25:25 +0000 Subject: RE: [PATCH 00/14] DMA-mapping framework redesign preparation Message-Id: <000901ccc471$15db8bc0$4192a340$%szyprowski@samsung.com> List-Id: References: <1324643253-3024-1-git-send-email-m.szyprowski@samsung.com> <20111223163516.GO20129@parisc-linux.org> In-Reply-To: <20111223163516.GO20129@parisc-linux.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: 'Matthew Wilcox' Cc: linux-kernel@vger.kernel.org, 'Benjamin Herrenschmidt' , 'Thomas Gleixner' , 'Andrew Morton' , 'Arnd Bergmann' , 'Stephen Rothwell' , microblaze-uclinux@itee.uq.edu.au, linux-arch@vger.kernel.org, x86@kernel.org, linux-sh@vger.kernel.org, linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, discuss@x86-64.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, 'Jonathan Corbet' , 'Kyungmin Park' , Andrzej Pietrasiewicz Hello, On Friday, December 23, 2011 5:35 PM Matthew Wilcox wrote: > On Fri, Dec 23, 2011 at 01:27:19PM +0100, Marek Szyprowski wrote: > > The first issue we identified is the fact that on some platform (again, > > mainly ARM) there are several functions for allocating DMA buffers: > > dma_alloc_coherent, dma_alloc_writecombine and dma_alloc_noncoherent > > Is this write-combining from the point of view of the device (ie iommu), > or from the point of view of the CPU, or both? It is about write-combining from the CPU point of view. Right now there are no devices with such advanced memory interface to do write combining on the DMA side, but I believe that they might appear at some point in the future as well. > > The next step in dma mapping framework update is the introduction of > > dma_mmap/dma_mmap_attrs() function. There are a number of drivers > > (mainly V4L2 and ALSA) that only exports the DMA buffers to user space. > > Creating a userspace mapping with correct page attributes is not an easy > > task for the driver. Also the DMA-mapping framework is the only place > > where the complete information about the allocated pages is available, > > especially if the implementation uses IOMMU controller to provide a > > contiguous buffer in DMA address space which is scattered in physical > > memory space. > > Surely we only need a helper which drivrs can call from their mmap routine > to solve this? On ARM architecture it is already implemented this way and a bunch of drivers use dma_mmap_coherent/dma_mmap_writecombine calls. We would like to standardize these calls across all architectures. > > Usually these drivers don't touch the buffer data at all, so the mapping > > in kernel virtual address space is not needed. We can introduce > > DMA_ATTRIB_NO_KERNEL_MAPPING attribute which lets kernel to skip/ignore > > creation of kernel virtual mapping. This way we can save previous > > vmalloc area and simply some mapping operation on a few architectures. > > I really think this wants to be a separate function. dma_alloc_coherent > is for allocating memory to be shared between the kernel and a driver; > we already have dma_map_sg for mapping userspace I/O as an alternative > interface. This feels like it's something different again rather than > an option to dma_alloc_coherent. That is just a starting point for the discussion. I thought about this API a bit and came to conclusion that there is no much difference between a dma_alloc_coherent which creates a mapping in kernel virtual space and the one that does not. It is just a hint from the driver that it will not use that mapping at all. Of course this attribute makes sense only together with adding a dma_mmap_attrs() call, because otherwise drivers won't be able to get access to the buffer data. On coherent architectures where dma_alloc_coherent is just a simple wrapper around alloc_pages_exact() such attribute can be simply ignored without any impact on the drivers (that's the main idea behind dma attributes!). However such hint will help a lot on non-coherent architectures where additional work need to be done to provide a cohenent mapping in kernel address space. It also saves some precious kernel resources like vmalloc address range. Best regards -- Marek Szyprowski Samsung Poland R&D Center From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752943Ab1L0IZs (ORCPT ); Tue, 27 Dec 2011 03:25:48 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:29386 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158Ab1L0IZl (ORCPT ); Tue, 27 Dec 2011 03:25:41 -0500 MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii Date: Tue, 27 Dec 2011 09:25:25 +0100 From: Marek Szyprowski Subject: RE: [PATCH 00/14] DMA-mapping framework redesign preparation In-reply-to: <20111223163516.GO20129@parisc-linux.org> To: "'Matthew Wilcox'" Cc: linux-kernel@vger.kernel.org, "'Benjamin Herrenschmidt'" , "'Thomas Gleixner'" , "'Andrew Morton'" , "'Arnd Bergmann'" , "'Stephen Rothwell'" , microblaze-uclinux@itee.uq.edu.au, linux-arch@vger.kernel.org, x86@kernel.org, linux-sh@vger.kernel.org, linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, discuss@x86-64.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, "'Jonathan Corbet'" , "'Kyungmin Park'" , Andrzej Pietrasiewicz Message-id: <000901ccc471$15db8bc0$4192a340$%szyprowski@samsung.com> Organization: SPRC X-Mailer: Microsoft Office Outlook 12.0 Content-language: pl Thread-index: AczBkN6KMgxtoNoIReeb7jeu/nBm0QC3D65A References: <1324643253-3024-1-git-send-email-m.szyprowski@samsung.com> <20111223163516.GO20129@parisc-linux.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Friday, December 23, 2011 5:35 PM Matthew Wilcox wrote: > On Fri, Dec 23, 2011 at 01:27:19PM +0100, Marek Szyprowski wrote: > > The first issue we identified is the fact that on some platform (again, > > mainly ARM) there are several functions for allocating DMA buffers: > > dma_alloc_coherent, dma_alloc_writecombine and dma_alloc_noncoherent > > Is this write-combining from the point of view of the device (ie iommu), > or from the point of view of the CPU, or both? It is about write-combining from the CPU point of view. Right now there are no devices with such advanced memory interface to do write combining on the DMA side, but I believe that they might appear at some point in the future as well. > > The next step in dma mapping framework update is the introduction of > > dma_mmap/dma_mmap_attrs() function. There are a number of drivers > > (mainly V4L2 and ALSA) that only exports the DMA buffers to user space. > > Creating a userspace mapping with correct page attributes is not an easy > > task for the driver. Also the DMA-mapping framework is the only place > > where the complete information about the allocated pages is available, > > especially if the implementation uses IOMMU controller to provide a > > contiguous buffer in DMA address space which is scattered in physical > > memory space. > > Surely we only need a helper which drivrs can call from their mmap routine > to solve this? On ARM architecture it is already implemented this way and a bunch of drivers use dma_mmap_coherent/dma_mmap_writecombine calls. We would like to standardize these calls across all architectures. > > Usually these drivers don't touch the buffer data at all, so the mapping > > in kernel virtual address space is not needed. We can introduce > > DMA_ATTRIB_NO_KERNEL_MAPPING attribute which lets kernel to skip/ignore > > creation of kernel virtual mapping. This way we can save previous > > vmalloc area and simply some mapping operation on a few architectures. > > I really think this wants to be a separate function. dma_alloc_coherent > is for allocating memory to be shared between the kernel and a driver; > we already have dma_map_sg for mapping userspace I/O as an alternative > interface. This feels like it's something different again rather than > an option to dma_alloc_coherent. That is just a starting point for the discussion. I thought about this API a bit and came to conclusion that there is no much difference between a dma_alloc_coherent which creates a mapping in kernel virtual space and the one that does not. It is just a hint from the driver that it will not use that mapping at all. Of course this attribute makes sense only together with adding a dma_mmap_attrs() call, because otherwise drivers won't be able to get access to the buffer data. On coherent architectures where dma_alloc_coherent is just a simple wrapper around alloc_pages_exact() such attribute can be simply ignored without any impact on the drivers (that's the main idea behind dma attributes!). However such hint will help a lot on non-coherent architectures where additional work need to be done to provide a cohenent mapping in kernel address space. It also saves some precious kernel resources like vmalloc address range. Best regards -- Marek Szyprowski Samsung Poland R&D Center From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx121.postini.com [74.125.245.121]) by kanga.kvack.org (Postfix) with SMTP id BC1736B004F for ; Tue, 27 Dec 2011 03:25:40 -0500 (EST) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=us-ascii Received: from euspt1 ([210.118.77.14]) by mailout4.w1.samsung.com (Sun Java(tm) System Messaging Server 6.3-8.04 (built Jul 29 2009; 32bit)) with ESMTP id <0LWU00326SQQ4Q20@mailout4.w1.samsung.com> for linux-mm@kvack.org; Tue, 27 Dec 2011 08:25:38 +0000 (GMT) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LWU00IWXSQQN9@spt1.w1.samsung.com> for linux-mm@kvack.org; Tue, 27 Dec 2011 08:25:38 +0000 (GMT) Date: Tue, 27 Dec 2011 09:25:25 +0100 From: Marek Szyprowski Subject: RE: [PATCH 00/14] DMA-mapping framework redesign preparation In-reply-to: <20111223163516.GO20129@parisc-linux.org> Message-id: <000901ccc471$15db8bc0$4192a340$%szyprowski@samsung.com> Content-language: pl References: <1324643253-3024-1-git-send-email-m.szyprowski@samsung.com> <20111223163516.GO20129@parisc-linux.org> Sender: owner-linux-mm@kvack.org List-ID: To: 'Matthew Wilcox' Cc: linux-kernel@vger.kernel.org, 'Benjamin Herrenschmidt' , 'Thomas Gleixner' , 'Andrew Morton' , 'Arnd Bergmann' , 'Stephen Rothwell' , microblaze-uclinux@itee.uq.edu.au, linux-arch@vger.kernel.org, x86@kernel.org, linux-sh@vger.kernel.org, linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, discuss@x86-64.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, 'Jonathan Corbet' , 'Kyungmin Park' , Andrzej Pietrasiewicz Hello, On Friday, December 23, 2011 5:35 PM Matthew Wilcox wrote: > On Fri, Dec 23, 2011 at 01:27:19PM +0100, Marek Szyprowski wrote: > > The first issue we identified is the fact that on some platform (again, > > mainly ARM) there are several functions for allocating DMA buffers: > > dma_alloc_coherent, dma_alloc_writecombine and dma_alloc_noncoherent > > Is this write-combining from the point of view of the device (ie iommu), > or from the point of view of the CPU, or both? It is about write-combining from the CPU point of view. Right now there are no devices with such advanced memory interface to do write combining on the DMA side, but I believe that they might appear at some point in the future as well. > > The next step in dma mapping framework update is the introduction of > > dma_mmap/dma_mmap_attrs() function. There are a number of drivers > > (mainly V4L2 and ALSA) that only exports the DMA buffers to user space. > > Creating a userspace mapping with correct page attributes is not an easy > > task for the driver. Also the DMA-mapping framework is the only place > > where the complete information about the allocated pages is available, > > especially if the implementation uses IOMMU controller to provide a > > contiguous buffer in DMA address space which is scattered in physical > > memory space. > > Surely we only need a helper which drivrs can call from their mmap routine > to solve this? On ARM architecture it is already implemented this way and a bunch of drivers use dma_mmap_coherent/dma_mmap_writecombine calls. We would like to standardize these calls across all architectures. > > Usually these drivers don't touch the buffer data at all, so the mapping > > in kernel virtual address space is not needed. We can introduce > > DMA_ATTRIB_NO_KERNEL_MAPPING attribute which lets kernel to skip/ignore > > creation of kernel virtual mapping. This way we can save previous > > vmalloc area and simply some mapping operation on a few architectures. > > I really think this wants to be a separate function. dma_alloc_coherent > is for allocating memory to be shared between the kernel and a driver; > we already have dma_map_sg for mapping userspace I/O as an alternative > interface. This feels like it's something different again rather than > an option to dma_alloc_coherent. That is just a starting point for the discussion. I thought about this API a bit and came to conclusion that there is no much difference between a dma_alloc_coherent which creates a mapping in kernel virtual space and the one that does not. It is just a hint from the driver that it will not use that mapping at all. Of course this attribute makes sense only together with adding a dma_mmap_attrs() call, because otherwise drivers won't be able to get access to the buffer data. On coherent architectures where dma_alloc_coherent is just a simple wrapper around alloc_pages_exact() such attribute can be simply ignored without any impact on the drivers (that's the main idea behind dma attributes!). However such hint will help a lot on non-coherent architectures where additional work need to be done to provide a cohenent mapping in kernel address space. It also saves some precious kernel resources like vmalloc address range. Best regards -- Marek Szyprowski Samsung Poland R&D Center -- 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 mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by ozlabs.org (Postfix) with ESMTP id D6323B6FAA for ; Tue, 27 Dec 2011 19:25:43 +1100 (EST) Received: from euspt1 (mailout2.w1.samsung.com [210.118.77.12]) by mailout2.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTP id <0LWU00KQHSQQRV@mailout2.w1.samsung.com> for linuxppc-dev@lists.ozlabs.org; Tue, 27 Dec 2011 08:25:38 +0000 (GMT) Received: from linux.samsung.com ([106.116.38.10]) by spt1.w1.samsung.com (iPlanet Messaging Server 5.2 Patch 2 (built Jul 14 2004)) with ESMTPA id <0LWU00IWXSQQN9@spt1.w1.samsung.com> for linuxppc-dev@lists.ozlabs.org; Tue, 27 Dec 2011 08:25:38 +0000 (GMT) Date: Tue, 27 Dec 2011 09:25:25 +0100 From: Marek Szyprowski Subject: RE: [PATCH 00/14] DMA-mapping framework redesign preparation In-reply-to: <20111223163516.GO20129@parisc-linux.org> To: 'Matthew Wilcox' Message-id: <000901ccc471$15db8bc0$4192a340$%szyprowski@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii References: <1324643253-3024-1-git-send-email-m.szyprowski@samsung.com> <20111223163516.GO20129@parisc-linux.org> Cc: linux-mips@linux-mips.org, linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, linux-mm@kvack.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, 'Stephen Rothwell' , 'Jonathan Corbet' , x86@kernel.org, 'Arnd Bergmann' , microblaze-uclinux@itee.uq.edu.au, linaro-mm-sig@lists.linaro.org, Andrzej Pietrasiewicz , 'Thomas Gleixner' , linux-arm-kernel@lists.infradead.org, discuss@x86-64.org, linux-kernel@vger.kernel.org, 'Kyungmin Park' , linux-alpha@vger.kernel.org, 'Andrew Morton' , linuxppc-dev@lists.ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hello, On Friday, December 23, 2011 5:35 PM Matthew Wilcox wrote: > On Fri, Dec 23, 2011 at 01:27:19PM +0100, Marek Szyprowski wrote: > > The first issue we identified is the fact that on some platform (again, > > mainly ARM) there are several functions for allocating DMA buffers: > > dma_alloc_coherent, dma_alloc_writecombine and dma_alloc_noncoherent > > Is this write-combining from the point of view of the device (ie iommu), > or from the point of view of the CPU, or both? It is about write-combining from the CPU point of view. Right now there are no devices with such advanced memory interface to do write combining on the DMA side, but I believe that they might appear at some point in the future as well. > > The next step in dma mapping framework update is the introduction of > > dma_mmap/dma_mmap_attrs() function. There are a number of drivers > > (mainly V4L2 and ALSA) that only exports the DMA buffers to user space. > > Creating a userspace mapping with correct page attributes is not an easy > > task for the driver. Also the DMA-mapping framework is the only place > > where the complete information about the allocated pages is available, > > especially if the implementation uses IOMMU controller to provide a > > contiguous buffer in DMA address space which is scattered in physical > > memory space. > > Surely we only need a helper which drivrs can call from their mmap routine > to solve this? On ARM architecture it is already implemented this way and a bunch of drivers use dma_mmap_coherent/dma_mmap_writecombine calls. We would like to standardize these calls across all architectures. > > Usually these drivers don't touch the buffer data at all, so the mapping > > in kernel virtual address space is not needed. We can introduce > > DMA_ATTRIB_NO_KERNEL_MAPPING attribute which lets kernel to skip/ignore > > creation of kernel virtual mapping. This way we can save previous > > vmalloc area and simply some mapping operation on a few architectures. > > I really think this wants to be a separate function. dma_alloc_coherent > is for allocating memory to be shared between the kernel and a driver; > we already have dma_map_sg for mapping userspace I/O as an alternative > interface. This feels like it's something different again rather than > an option to dma_alloc_coherent. That is just a starting point for the discussion. I thought about this API a bit and came to conclusion that there is no much difference between a dma_alloc_coherent which creates a mapping in kernel virtual space and the one that does not. It is just a hint from the driver that it will not use that mapping at all. Of course this attribute makes sense only together with adding a dma_mmap_attrs() call, because otherwise drivers won't be able to get access to the buffer data. On coherent architectures where dma_alloc_coherent is just a simple wrapper around alloc_pages_exact() such attribute can be simply ignored without any impact on the drivers (that's the main idea behind dma attributes!). However such hint will help a lot on non-coherent architectures where additional work need to be done to provide a cohenent mapping in kernel address space. It also saves some precious kernel resources like vmalloc address range. Best regards -- Marek Szyprowski Samsung Poland R&D Center From mboxrd@z Thu Jan 1 00:00:00 1970 From: m.szyprowski@samsung.com (Marek Szyprowski) Date: Tue, 27 Dec 2011 09:25:25 +0100 Subject: [PATCH 00/14] DMA-mapping framework redesign preparation In-Reply-To: <20111223163516.GO20129@parisc-linux.org> References: <1324643253-3024-1-git-send-email-m.szyprowski@samsung.com> <20111223163516.GO20129@parisc-linux.org> Message-ID: <000901ccc471$15db8bc0$4192a340$%szyprowski@samsung.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hello, On Friday, December 23, 2011 5:35 PM Matthew Wilcox wrote: > On Fri, Dec 23, 2011 at 01:27:19PM +0100, Marek Szyprowski wrote: > > The first issue we identified is the fact that on some platform (again, > > mainly ARM) there are several functions for allocating DMA buffers: > > dma_alloc_coherent, dma_alloc_writecombine and dma_alloc_noncoherent > > Is this write-combining from the point of view of the device (ie iommu), > or from the point of view of the CPU, or both? It is about write-combining from the CPU point of view. Right now there are no devices with such advanced memory interface to do write combining on the DMA side, but I believe that they might appear at some point in the future as well. > > The next step in dma mapping framework update is the introduction of > > dma_mmap/dma_mmap_attrs() function. There are a number of drivers > > (mainly V4L2 and ALSA) that only exports the DMA buffers to user space. > > Creating a userspace mapping with correct page attributes is not an easy > > task for the driver. Also the DMA-mapping framework is the only place > > where the complete information about the allocated pages is available, > > especially if the implementation uses IOMMU controller to provide a > > contiguous buffer in DMA address space which is scattered in physical > > memory space. > > Surely we only need a helper which drivrs can call from their mmap routine > to solve this? On ARM architecture it is already implemented this way and a bunch of drivers use dma_mmap_coherent/dma_mmap_writecombine calls. We would like to standardize these calls across all architectures. > > Usually these drivers don't touch the buffer data at all, so the mapping > > in kernel virtual address space is not needed. We can introduce > > DMA_ATTRIB_NO_KERNEL_MAPPING attribute which lets kernel to skip/ignore > > creation of kernel virtual mapping. This way we can save previous > > vmalloc area and simply some mapping operation on a few architectures. > > I really think this wants to be a separate function. dma_alloc_coherent > is for allocating memory to be shared between the kernel and a driver; > we already have dma_map_sg for mapping userspace I/O as an alternative > interface. This feels like it's something different again rather than > an option to dma_alloc_coherent. That is just a starting point for the discussion. I thought about this API a bit and came to conclusion that there is no much difference between a dma_alloc_coherent which creates a mapping in kernel virtual space and the one that does not. It is just a hint from the driver that it will not use that mapping at all. Of course this attribute makes sense only together with adding a dma_mmap_attrs() call, because otherwise drivers won't be able to get access to the buffer data. On coherent architectures where dma_alloc_coherent is just a simple wrapper around alloc_pages_exact() such attribute can be simply ignored without any impact on the drivers (that's the main idea behind dma attributes!). However such hint will help a lot on non-coherent architectures where additional work need to be done to provide a cohenent mapping in kernel address space. It also saves some precious kernel resources like vmalloc address range. Best regards -- Marek Szyprowski Samsung Poland R&D Center