Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1670787 > unrolled thread

Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree

Started byChristoph Hellwig <hch@infradead.org>
First post2017-06-20 15:50 +0200
Last post2017-06-22 15:00 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset  when used with device tree Christoph Hellwig <hch@infradead.org> - 2017-06-20 15:50 +0200
    Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when  used with device tree Robin Murphy <robin.murphy@arm.com> - 2017-06-20 16:00 +0200
      Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset  when used with device tree Christoph Hellwig <hch@infradead.org> - 2017-06-26 11:40 +0200
    Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when  used with device tree Vladimir Murzin <vladimir.murzin@arm.com> - 2017-06-22 15:00 +0200

#1670787 — Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree

FromChristoph Hellwig <hch@infradead.org>
Date2017-06-20 15:50 +0200
SubjectRe: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree
Message-ID<tUrHB-Q2-47@gated-at.bofh.it>
Wouldn't the smal patch below solve the same issue in a simple way?

diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 640a7e63c453..e8f8447d705b 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -290,9 +290,11 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
 static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
 {
 	struct dma_coherent_mem *mem = rmem->priv;
+	dma_addr_t dev_addr = ((rmem->base >> PAGE_SHIFT) -
+				dev->dma_pfn_offset) << PAGE_SHIFT;
 
 	if (!mem &&
-	    !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
+	    !dma_init_coherent_memory(rmem->base, dev_addr, 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",

[toc] | [next] | [standalone]


#1670791 — Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree

FromRobin Murphy <robin.murphy@arm.com>
Date2017-06-20 16:00 +0200
SubjectRe: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree
Message-ID<tUrRg-Tl-19@gated-at.bofh.it>
In reply to#1670787
On 20/06/17 14:42, Christoph Hellwig wrote:
> Wouldn't the smal patch below solve the same issue in a simple way?

That assumes that all devices accessing a shared pool will have the same
 dma_pfn_offset as the first one, which cannot strictly be relied upon
(even if it is highly likely in practice).

Robin.

> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
> index 640a7e63c453..e8f8447d705b 100644
> --- a/drivers/base/dma-coherent.c
> +++ b/drivers/base/dma-coherent.c
> @@ -290,9 +290,11 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
>  static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
>  {
>  	struct dma_coherent_mem *mem = rmem->priv;
> +	dma_addr_t dev_addr = ((rmem->base >> PAGE_SHIFT) -
> +				dev->dma_pfn_offset) << PAGE_SHIFT;
>  
>  	if (!mem &&
> -	    !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
> +	    !dma_init_coherent_memory(rmem->base, dev_addr, 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",
> 

[toc] | [prev] | [next] | [standalone]


#1674571

FromChristoph Hellwig <hch@infradead.org>
Date2017-06-26 11:40 +0200
Message-ID<tWyEX-Ba-35@gated-at.bofh.it>
In reply to#1670791
On Tue, Jun 20, 2017 at 02:50:34PM +0100, Robin Murphy wrote:
> On 20/06/17 14:42, Christoph Hellwig wrote:
> > Wouldn't the smal patch below solve the same issue in a simple way?
> 
> That assumes that all devices accessing a shared pool will have the same
>  dma_pfn_offset as the first one, which cannot strictly be relied upon
> (even if it is highly likely in practice).

Which seems like another argument why the global pool should be
a different implementation / interface than the per-device dma
mapping helpers..

[toc] | [prev] | [next] | [standalone]


#1672606 — Re: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree

FromVladimir Murzin <vladimir.murzin@arm.com>
Date2017-06-22 15:00 +0200
SubjectRe: [PATCH v5 3/7] drivers: dma-coherent: Account dma_pfn_offset when used with device tree
Message-ID<tV9Si-4Ry-15@gated-at.bofh.it>
In reply to#1670787
On 20/06/17 14:42, Christoph Hellwig wrote:
> Wouldn't the smal patch below solve the same issue in a simple way?
> 
> diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
> index 640a7e63c453..e8f8447d705b 100644
> --- a/drivers/base/dma-coherent.c
> +++ b/drivers/base/dma-coherent.c
> @@ -290,9 +290,11 @@ EXPORT_SYMBOL(dma_mmap_from_coherent);
>  static int rmem_dma_device_init(struct reserved_mem *rmem, struct device *dev)
>  {
>  	struct dma_coherent_mem *mem = rmem->priv;
> +	dma_addr_t dev_addr = ((rmem->base >> PAGE_SHIFT) -
> +				dev->dma_pfn_offset) << PAGE_SHIFT;
>  
>  	if (!mem &&
> -	    !dma_init_coherent_memory(rmem->base, rmem->base, rmem->size,
> +	    !dma_init_coherent_memory(rmem->base, dev_addr, 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",
> 

Robin has already commented on this - dma_pfn_offset may vary across devices
and reserved memory region may be shared between them.

Cheers
Vladimir

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web