linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rmem: support for dma_addr different from phys_addr
@ 2017-07-04 10:34 Vladimir Kondratiev
  2017-07-04 10:43 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Kondratiev @ 2017-07-04 10:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Vladimir Kondratiev

On some systems, dma address differs from physical one due to
various reasons.

dma_init_coherent_memory is aware of it, it takes both
phys_addr_t and dma_addt_t arguments for memory block.
However, rmem_dma_device_init passes physical address for DMA one.

Fix this, using phys_to_dma(). This assumes the whole buffer has
same offset between physical and dma addresses.

Change-Id: Ic709312941ee4e1a37afb2ea25cbd759eabc009b
Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
---
 drivers/base/dma-coherent.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 640a7e63c453..5371cb19c918 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -292,7 +292,8 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 	struct dma_coherent_mem *mem = rmem->priv;
 
 	if (!mem &&
-	    !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
+	    !dma_init_coherent_memory(rmem->base, phys_to_dma(dev, rmem->base),
+				      rmem->size,
 				      DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE,
 				      &mem)) {
 		pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
-- 
2.11.0

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rmem: support for dma_addr different from phys_addr
  2017-07-04 10:34 [PATCH] rmem: support for dma_addr different from phys_addr Vladimir Kondratiev
@ 2017-07-04 10:43 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2017-07-04 10:43 UTC (permalink / raw)
  To: Vladimir Kondratiev; +Cc: linux-kernel

On Tue, Jul 04, 2017 at 01:34:38PM +0300, Vladimir Kondratiev wrote:
> On some systems, dma address differs from physical one due to
> various reasons.
> 
> dma_init_coherent_memory is aware of it, it takes both
> phys_addr_t and dma_addt_t arguments for memory block.
> However, rmem_dma_device_init passes physical address for DMA one.
> 
> Fix this, using phys_to_dma(). This assumes the whole buffer has
> same offset between physical and dma addresses.
> 
> Change-Id: Ic709312941ee4e1a37afb2ea25cbd759eabc009b

What is that line for?  You didn't use checkpatch.pl :(

> Intel Israel (74) Limited
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.

Ok, this is getting really annoying, according to my lawyers, I have to
never respond to emails with this in it, and should just delete it.  But
I'll be nice, and tell you all to go fix all of Intel's email system to
never send this stuff out again, it keeps happening over and over and
over and is preventing you from contributing to open source projects.

email is now deleted.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rmem: support for dma_addr different from phys_addr
  2017-07-04 12:50 Vladimir Kondratiev
@ 2017-07-05 19:25 ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2017-07-05 19:25 UTC (permalink / raw)
  To: Vladimir Kondratiev; +Cc: Greg Kroah-Hartman, linux-kernel, Vladimir Kondratiev

We've already got a different fix for this in the dma-mapping tree
for this merge window:

http://git.infradead.org/users/hch/dma-mapping.git/commitdiff/c41f9ea998f3ba61f38fa350eef28ec6caf0a07d

Also I think the subject line is rather confusing, I only read this mail
by accident..

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] rmem: support for dma_addr different from phys_addr
@ 2017-07-04 12:50 Vladimir Kondratiev
  2017-07-05 19:25 ` Christoph Hellwig
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Kondratiev @ 2017-07-04 12:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Vladimir Kondratiev

On some systems, dma address differs from physical one due to
various reasons.

dma_init_coherent_memory is aware of it, it takes both
phys_addr_t and dma_addt_t arguments for memory block.
However, rmem_dma_device_init passes physical address for DMA one.

Fix this, using phys_to_dma(). This assumes the whole buffer has
same offset between physical and dma addresses.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com>
---
 drivers/base/dma-coherent.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 640a7e63c453..5371cb19c918 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -292,7 +292,8 @@ static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 	struct dma_coherent_mem *mem = rmem->priv;
 
 	if (!mem &&
-	    !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
+	    !dma_init_coherent_memory(rmem->base, phys_to_dma(dev, rmem->base),
+				      rmem->size,
 				      DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE,
 				      &mem)) {
 		pr_err("Reserved memory: failed to init DMA memory pool at %pa, size %ld MiB\n",
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-05 19:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-04 10:34 [PATCH] rmem: support for dma_addr different from phys_addr Vladimir Kondratiev
2017-07-04 10:43 ` Greg Kroah-Hartman
2017-07-04 12:50 Vladimir Kondratiev
2017-07-05 19:25 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).