lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 05 Jan 2016 20:02:41 +0100
From:	Michal Nazarewicz <mina86@...a86.com>
To:	Brian Starkey <brian.starkey@....com>, gregkh@...uxfoundation.org
Cc:	catalin.marinas@....com, dan.j.williams@...el.com,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [RESEND PATCH 2/3] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP

On Tue, Jan 05 2016, Brian Starkey wrote:
> When the DMA_MEMORY_MAP flag is used, memory which can be accessed
> directly should be returned, so use memremap(..., MEMREMAP_WC) to
> provide a writecombine mapping.
>
> Signed-off-by: Brian Starkey <brian.starkey@....com>
> Reviewed-by: Catalin Marinas <catalin.marinas@....com>

Acked-by: Michal Nazarewicz <mina86@...a86.com>

> ---
>  drivers/base/dma-coherent.c |   20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
> index 55b8398..f98359a 100644
> --- a/drivers/base/dma-coherent.c
> +++ b/drivers/base/dma-coherent.c
> @@ -2,6 +2,7 @@
>   * Coherent per-device memory handling.
>   * Borrowed from i386
>   */
> +#include <linux/io.h>
>  #include <linux/slab.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> @@ -31,7 +32,10 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_add
>  	if (!size)
>  		goto out;
>  
> -	mem_base = ioremap(phys_addr, size);
> +	if (flags & DMA_MEMORY_MAP)
> +		mem_base = memremap(phys_addr, size, MEMREMAP_WC);
> +	else
> +		mem_base = ioremap(phys_addr, size);
>  	if (!mem_base)
>  		goto out;
>  
> @@ -58,8 +62,12 @@ static int dma_init_coherent_memory(phys_addr_t phys_addr, dma_addr_t device_add
>  
>  out:
>  	kfree(dma_mem);
> -	if (mem_base)
> -		iounmap(mem_base);
> +	if (mem_base) {
> +		if (flags & DMA_MEMORY_MAP)
> +			memunmap(mem_base);
> +		else
> +			iounmap(mem_base);
> +	}
>  	return 0;
>  }
>  
> @@ -67,7 +75,11 @@ static void dma_release_coherent_memory(struct dma_coherent_mem *mem)
>  {
>  	if (!mem)
>  		return;
> -	iounmap(mem->virt_base);
> +
> +	if (mem->flags & DMA_MEMORY_MAP)
> +		memunmap(mem->virt_base);
> +	else
> +		iounmap(mem->virt_base);
>  	kfree(mem->bitmap);
>  	kfree(mem);
>  }
> -- 
> 1.7.9.5
>

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  ミハウ “mina86” ナザレヴイツ  (o o)
ooo +--<mpn@...gle.com>--<xmpp:mina86@...ber.org>--ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ