From: Brian Starkey <brian.starkey@arm.com> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Catalin Marinas <catalin.marinas@arm.com>, Dan Williams <dan.j.williams@intel.com>, Andrew Morton <akpm@linux-foundation.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Michal Nazarewicz <mina86@mina86.com> Subject: [RESEND2 PATCH 2/3] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP Date: Mon, 8 Feb 2016 17:30:51 +0000 [thread overview] Message-ID: <a85c534af867534e6693ce50a746fda096426586.1454950917.git.brian.starkey@arm.com> (raw) In-Reply-To: <cover.1454950917.git.brian.starkey@arm.com> In-Reply-To: <cover.1454950917.git.brian.starkey@arm.com> 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@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Michal Nazarewicz <mina86@mina86.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
WARNING: multiple messages have this Message-ID (diff)
From: brian.starkey@arm.com (Brian Starkey) To: linux-arm-kernel@lists.infradead.org Subject: [RESEND2 PATCH 2/3] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP Date: Mon, 8 Feb 2016 17:30:51 +0000 [thread overview] Message-ID: <a85c534af867534e6693ce50a746fda096426586.1454950917.git.brian.starkey@arm.com> (raw) In-Reply-To: <cover.1454950917.git.brian.starkey@arm.com> 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@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Michal Nazarewicz <mina86@mina86.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
next prev parent reply other threads:[~2016-02-08 17:31 UTC|newest] Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-02-08 17:30 [RESEND2 PATCH 0/3] Fix kernel panic in dma-coherent Brian Starkey 2016-02-08 17:30 ` Brian Starkey 2016-02-08 17:30 ` [RESEND2 PATCH 1/3] memremap: add MEMREMAP_WC flag Brian Starkey 2016-02-08 17:30 ` Brian Starkey 2016-02-08 18:30 ` Greg Kroah-Hartman 2016-02-08 18:30 ` Greg Kroah-Hartman 2016-02-09 9:15 ` Brian Starkey 2016-02-09 9:15 ` Brian Starkey 2016-02-16 11:14 ` Brian Starkey 2016-02-16 11:14 ` Brian Starkey 2016-02-17 0:43 ` Greg Kroah-Hartman 2016-02-17 0:43 ` Greg Kroah-Hartman 2016-02-17 10:07 ` Brian Starkey 2016-02-17 10:07 ` Brian Starkey 2016-02-08 20:03 ` Andrew Morton 2016-02-08 20:03 ` Andrew Morton 2016-02-09 10:23 ` Brian Starkey 2016-02-09 10:23 ` Brian Starkey 2016-02-17 11:53 ` Brian Starkey 2016-02-17 11:53 ` Brian Starkey 2016-02-17 19:02 ` Andrew Morton 2016-02-17 19:02 ` Andrew Morton 2016-02-08 17:30 ` Brian Starkey [this message] 2016-02-08 17:30 ` [RESEND2 PATCH 2/3] drivers: dma-coherent: use MEMREMAP_WC for DMA_MEMORY_MAP Brian Starkey 2016-02-08 17:30 ` [RESEND2 PATCH 3/3] drivers: dma-coherent: use memset_io for DMA_MEMORY_IO mappings Brian Starkey 2016-02-08 17:30 ` Brian Starkey 2016-02-08 17:50 ` [RESEND2 PATCH 0/3] Fix kernel panic in dma-coherent Mark Rutland 2016-02-08 17:50 ` Mark Rutland 2016-02-08 17:59 ` Robin Murphy 2016-02-08 17:59 ` Robin Murphy 2016-02-08 18:04 ` Mark Rutland 2016-02-08 18:04 ` Mark Rutland
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=a85c534af867534e6693ce50a746fda096426586.1454950917.git.brian.starkey@arm.com \ --to=brian.starkey@arm.com \ --cc=akpm@linux-foundation.org \ --cc=catalin.marinas@arm.com \ --cc=dan.j.williams@intel.com \ --cc=gregkh@linuxfoundation.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mina86@mina86.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.