Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932345AbcLIFFi (ORCPT ); Fri, 9 Dec 2016 00:05:38 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:53220 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932170AbcLIFFh (ORCPT ); Fri, 9 Dec 2016 00:05:37 -0500 X-AuditID: cbfee61a-f79916d0000062de-30-584a3b9e07bf From: Jaewon Kim To: gregkh@linuxfoundation.org Cc: labbott@redhat.com, sumit.semwal@linaro.org, tixy@linaro.org, prime.zeng@huawei.com, tranmanphong@gmail.com, fabio.estevam@freescale.com, ccross@android.com, rebecca@android.com, benjamin.gaignard@linaro.org, arve@android.com, riandrews@android.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, Jaewon Kim Subject: [PATCH] [RFC] drivers: dma-coherent: pass struct dma_attrs to dma_alloc_from_coherent Date: Fri, 09 Dec 2016 14:05:29 +0900 Message-id: <1481259930-4620-1-git-send-email-jaewon31.kim@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsVy+t9jAd151l4RBm/7bCze/73PZtF06BSb xfaN31gtZnXpWjQvXs9m0b15JqNF7/tXTBYr9/xgsri8aw6bxb01/1ktJs9ez2xxY3KhxetN fxktTt39zG6xcP59dovevk4WBwGPbbu3sXr8O9zP5LFz1l12j5Yjb1k9Nn2axO5x59oeNo/9 c9ewe7zfd5XNo2/LKkaPz5vkArii3GwyUhNTUosUUvOS81My89JtlUJD3HQtlBTyEnNTbZUi dH1DgpQUyhJzSoE8IwM04OAc4B6spG+X4Jbxb21twWPJin8LpzI3MK4U7WLk5JAQMJHY828x E4QtJnHh3nq2LkYuDiGBpYwSp15sZ4Fwmpgk+pt+M4JUsQloS7xfMIkVxBYRkJN4cvsPM0gR s8B3Jom/t04xgySEBRIkNh6fA2azCKhKNK7YBWbzCrhLvPzxlg1inZzEyWOTWScwci9gZFjF KJFakFxQnJSea5iXWq5XnJhbXJqXrpecn7uJERwtz6R2MB7c5X6IUYCDUYmHt+K4Z4QQa2JZ cWXuIUYJDmYlEd7zll4RQrwpiZVVqUX58UWlOanFhxhNgQ6YyCwlmpwPjOS8knhDE3MTc2MD C3NLSxMjJXHextnPwoUE0hNLUrNTUwtSi2D6mDg4pRoYp5h1Zzte/7Wj8cjdkxf3HxXXmZ/6 gHdOW889jQtcx+XOKO6ZWbx/ddPaXt3vz5vTGVg/RtTYuHLfLLTX+y4XeWte7rFStZSoF8f/ JwaLTp5c0Kf8QO3kyqfHIgLMA46atOlLKRgdvx3xjTXNLfXIn/MvLvxe+mDW796vmbtkJno9 Zz7+RVKDQYmlOCPRUIu5qDgRANpQXqGsAgAA X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3222 Lines: 75 dma_alloc_from_coherent does not get struct dma_attrs information. If dma_attrs information is passed to dma_alloc_from_coherent, dma_alloc_from_coherent can do more jobs accodring to the information. As a example I added DMA_ATTR_SKIP_ZEROING to skip zeroing. Accoring to driver implementation ZEROING could be skipped or could be done later. Signed-off-by: Jaewon Kim --- drivers/base/dma-coherent.c | 6 +++++- include/linux/dma-mapping.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 640a7e6..428eced 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -151,6 +151,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev, * @dma_handle: This will be filled with the correct dma handle * @ret: This pointer will be filled with the virtual address * to allocated area. + * @attrs: dma_attrs to pass additional information * * This function should be only called from per-arch dma_alloc_coherent() * to support allocation from per-device coherent memory pools. @@ -159,7 +160,8 @@ void *dma_mark_declared_memory_occupied(struct device *dev, * generic memory areas, or !0 if dma_alloc_coherent should return @ret. */ int dma_alloc_from_coherent(struct device *dev, ssize_t size, - dma_addr_t *dma_handle, void **ret) + dma_addr_t *dma_handle, void **ret, + struct dma_attrs *attrs) { struct dma_coherent_mem *mem; int order = get_order(size); @@ -190,6 +192,8 @@ int dma_alloc_from_coherent(struct device *dev, ssize_t size, *ret = mem->virt_base + (pageno << PAGE_SHIFT); dma_memory_map = (mem->flags & DMA_MEMORY_MAP); spin_unlock_irqrestore(&mem->spinlock, flags); + if (dma_get_attr(DMA_ATTR_SKIP_ZEROING, attrs)) + return 1; if (dma_memory_map) memset(*ret, 0, size); else diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 08528af..737fd71 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -151,13 +151,14 @@ static inline int is_device_dma_capable(struct device *dev) * Don't use them in device drivers. */ int dma_alloc_from_coherent(struct device *dev, ssize_t size, - dma_addr_t *dma_handle, void **ret); + dma_addr_t *dma_handle, void **ret, + struct dma_attrs *attrs); int dma_release_from_coherent(struct device *dev, int order, void *vaddr); int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, size_t size, int *ret); #else -#define dma_alloc_from_coherent(dev, size, handle, ret) (0) +#define dma_alloc_from_coherent(dev, size, handle, ret, attrs) (0) #define dma_release_from_coherent(dev, order, vaddr) (0) #define dma_mmap_from_coherent(dev, vma, vaddr, order, ret) (0) #endif /* CONFIG_HAVE_GENERIC_DMA_COHERENT */ @@ -456,7 +457,7 @@ static inline void *dma_alloc_attrs(struct device *dev, size_t size, BUG_ON(!ops); - if (dma_alloc_from_coherent(dev, size, dma_handle, &cpu_addr)) + if (dma_alloc_from_coherent(dev, size, dma_handle, &cpu_addr, attrs)) return cpu_addr; if (!arch_dma_alloc_attrs(&dev, &flag)) -- 1.9.1