diff mbox

arm64: dma-mapping: Simplify pgprot handling

Message ID a82d2ce0db8d1511ea91bb37ef8432ce33b4719e.1438363644.git.robin.murphy@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robin Murphy July 31, 2015, 5:28 p.m. UTC
Since __get_dma_pgprot() does The Right Thing(TM) in the non-coherent
case, and the non-cacheable alias for DMA buffers is private to the
kernel anyway, we can simplify things slightly and make the code more
readable by just using PAGE_KERNEL as the base pgprot.

Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 arch/arm64/mm/dma-mapping.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Catalin Marinas Aug. 3, 2015, noon UTC | #1
On Fri, Jul 31, 2015 at 06:28:34PM +0100, Robin Murphy wrote:
> Since __get_dma_pgprot() does The Right Thing(TM) in the non-coherent
> case, and the non-cacheable alias for DMA buffers is private to the
> kernel anyway, we can simplify things slightly and make the code more
> readable by just using PAGE_KERNEL as the base pgprot.
> 
> Suggested-by: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>  arch/arm64/mm/dma-mapping.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
> index e5d74cd..0bcc4bc 100644
> --- a/arch/arm64/mm/dma-mapping.c
> +++ b/arch/arm64/mm/dma-mapping.c
> @@ -144,6 +144,7 @@ static void *__dma_alloc(struct device *dev, size_t size,
>  	struct page *page;
>  	void *ptr, *coherent_ptr;
>  	bool coherent = is_device_dma_coherent(dev);
> +	pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, false);
>  
>  	size = PAGE_ALIGN(size);
>  
> @@ -171,9 +172,7 @@ static void *__dma_alloc(struct device *dev, size_t size,
>  	/* create a coherent mapping */
>  	page = virt_to_page(ptr);
>  	coherent_ptr = dma_common_contiguous_remap(page, size, VM_USERMAP,
> -				__get_dma_pgprot(attrs,
> -					__pgprot(PROT_NORMAL_NC), false),
> -					NULL);
> +						   prot, NULL);
>  	if (!coherent_ptr)
>  		goto no_map;

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
diff mbox

Patch

diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index e5d74cd..0bcc4bc 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -144,6 +144,7 @@  static void *__dma_alloc(struct device *dev, size_t size,
 	struct page *page;
 	void *ptr, *coherent_ptr;
 	bool coherent = is_device_dma_coherent(dev);
+	pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, false);
 
 	size = PAGE_ALIGN(size);
 
@@ -171,9 +172,7 @@  static void *__dma_alloc(struct device *dev, size_t size,
 	/* create a coherent mapping */
 	page = virt_to_page(ptr);
 	coherent_ptr = dma_common_contiguous_remap(page, size, VM_USERMAP,
-				__get_dma_pgprot(attrs,
-					__pgprot(PROT_NORMAL_NC), false),
-					NULL);
+						   prot, NULL);
 	if (!coherent_ptr)
 		goto no_map;