linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-mapping: fix sync_single_range_* DMA debugging
       [not found]             ` <4E99E92B.6020408@ladisch.de>
@ 2011-10-15 21:09               ` Clemens Ladisch
  2011-10-19  8:59                 ` Stefan Richter
  2011-10-22  5:08                 ` FUJITA Tomonori
  0 siblings, 2 replies; 3+ messages in thread
From: Clemens Ladisch @ 2011-10-15 21:09 UTC (permalink / raw)
  To: Arnd Bergmann, Andrew Morton
  Cc: FUJITA Tomonori, Konrad Rzeszutek Wilk, Stefan Richter,
	linux-arch, linux-kernel

Commit 5fd75a7850b5 (dma-mapping: remove unnecessary sync_single_range_*
in dma_map_ops) unified not only the dma_map_ops but also the
corresponding debug_dma_sync_* calls.  This led to spurious WARN()ings
like the following because the DMA debug code was no longer able to
detect the DMA buffer base address without the separate offset parameter:

WARNING: at lib/dma-debug.c:911 check_sync+0xce/0x446()
firewire_ohci 0000:04:00.0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x00000000cedaa400] [size=1024 bytes]
Call Trace: ...
 [<ffffffff811326a5>] check_sync+0xce/0x446
 [<ffffffff81132ad9>] debug_dma_sync_single_for_device+0x39/0x3b
 [<ffffffffa01d6e6a>] ohci_queue_iso+0x4f3/0x77d [firewire_ohci]
 ...

To fix this, unshare the sync_single_* and sync_single_range_*
implementations so that we are able to call the correct debug_dma_sync_*
functions.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
 include/asm-generic/dma-mapping-common.h |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index 0c80bb3..9e31514 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -123,7 +123,12 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
 						 size_t size,
 						 enum dma_data_direction dir)
 {
-	dma_sync_single_for_cpu(dev, addr + offset, size, dir);
+	struct dma_map_ops *ops = get_dma_ops(dev);
+
+	BUG_ON(!valid_dma_direction(dir));
+	if (ops->sync_single_for_cpu)
+		ops->sync_single_for_cpu(dev, addr + offset, size, dir);
+	debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
 }

 static inline void dma_sync_single_range_for_device(struct device *dev,
@@ -132,7 +137,12 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
 						    size_t size,
 						    enum dma_data_direction dir)
 {
-	dma_sync_single_for_device(dev, addr + offset, size, dir);
+	struct dma_map_ops *ops = get_dma_ops(dev);
+
+	BUG_ON(!valid_dma_direction(dir));
+	if (ops->sync_single_for_device)
+		ops->sync_single_for_device(dev, addr + offset, size, dir);
+	debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
 }

 static inline void

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

* Re: [PATCH] dma-mapping: fix sync_single_range_* DMA debugging
  2011-10-15 21:09               ` [PATCH] dma-mapping: fix sync_single_range_* DMA debugging Clemens Ladisch
@ 2011-10-19  8:59                 ` Stefan Richter
  2011-10-22  5:08                 ` FUJITA Tomonori
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Richter @ 2011-10-19  8:59 UTC (permalink / raw)
  To: Clemens Ladisch
  Cc: Arnd Bergmann, Andrew Morton, FUJITA Tomonori,
	Konrad Rzeszutek Wilk, linux-arch, linux-kernel

On Oct 15 Clemens Ladisch wrote:
> Commit 5fd75a7850b5 (dma-mapping: remove unnecessary sync_single_range_*
> in dma_map_ops) unified not only the dma_map_ops but also the
> corresponding debug_dma_sync_* calls.  This led to spurious WARN()ings
> like the following because the DMA debug code was no longer able to
> detect the DMA buffer base address without the separate offset parameter:
> 
> WARNING: at lib/dma-debug.c:911 check_sync+0xce/0x446()
> firewire_ohci 0000:04:00.0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x00000000cedaa400] [size=1024 bytes]
> Call Trace: ...
>  [<ffffffff811326a5>] check_sync+0xce/0x446
>  [<ffffffff81132ad9>] debug_dma_sync_single_for_device+0x39/0x3b
>  [<ffffffffa01d6e6a>] ohci_queue_iso+0x4f3/0x77d [firewire_ohci]
>  ...
> 
> To fix this, unshare the sync_single_* and sync_single_range_*
> implementations so that we are able to call the correct debug_dma_sync_*
> functions.
> 
> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>

Reviewed-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

> ---
>  include/asm-generic/dma-mapping-common.h |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
> index 0c80bb3..9e31514 100644
> --- a/include/asm-generic/dma-mapping-common.h
> +++ b/include/asm-generic/dma-mapping-common.h
> @@ -123,7 +123,12 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
>  						 size_t size,
>  						 enum dma_data_direction dir)
>  {
> -	dma_sync_single_for_cpu(dev, addr + offset, size, dir);
> +	struct dma_map_ops *ops = get_dma_ops(dev);
> +
> +	BUG_ON(!valid_dma_direction(dir));
> +	if (ops->sync_single_for_cpu)
> +		ops->sync_single_for_cpu(dev, addr + offset, size, dir);
> +	debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
>  }
> 
>  static inline void dma_sync_single_range_for_device(struct device *dev,
> @@ -132,7 +137,12 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
>  						    size_t size,
>  						    enum dma_data_direction dir)
>  {
> -	dma_sync_single_for_device(dev, addr + offset, size, dir);
> +	struct dma_map_ops *ops = get_dma_ops(dev);
> +
> +	BUG_ON(!valid_dma_direction(dir));
> +	if (ops->sync_single_for_device)
> +		ops->sync_single_for_device(dev, addr + offset, size, dir);
> +	debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
>  }
> 
>  static inline void



-- 
Stefan Richter
-=====-==-== =-=- =--==
http://arcgraph.de/sr/

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

* Re: [PATCH] dma-mapping: fix sync_single_range_* DMA debugging
  2011-10-15 21:09               ` [PATCH] dma-mapping: fix sync_single_range_* DMA debugging Clemens Ladisch
  2011-10-19  8:59                 ` Stefan Richter
@ 2011-10-22  5:08                 ` FUJITA Tomonori
  1 sibling, 0 replies; 3+ messages in thread
From: FUJITA Tomonori @ 2011-10-22  5:08 UTC (permalink / raw)
  To: clemens
  Cc: arnd, akpm, fujita.tomonori, konrad.wilk, stefanr, linux-arch,
	linux-kernel

On Sat, 15 Oct 2011 23:09:51 +0200
Clemens Ladisch <clemens@ladisch.de> wrote:

> Commit 5fd75a7850b5 (dma-mapping: remove unnecessary sync_single_range_*
> in dma_map_ops) unified not only the dma_map_ops but also the
> corresponding debug_dma_sync_* calls.  This led to spurious WARN()ings
> like the following because the DMA debug code was no longer able to
> detect the DMA buffer base address without the separate offset parameter:
> 
> WARNING: at lib/dma-debug.c:911 check_sync+0xce/0x446()
> firewire_ohci 0000:04:00.0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x00000000cedaa400] [size=1024 bytes]
> Call Trace: ...
>  [<ffffffff811326a5>] check_sync+0xce/0x446
>  [<ffffffff81132ad9>] debug_dma_sync_single_for_device+0x39/0x3b
>  [<ffffffffa01d6e6a>] ohci_queue_iso+0x4f3/0x77d [firewire_ohci]
>  ...
> 
> To fix this, unshare the sync_single_* and sync_single_range_*
> implementations so that we are able to call the correct debug_dma_sync_*
> functions.
> 
> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
> ---
>  include/asm-generic/dma-mapping-common.h |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)

Acked-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>


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

end of thread, other threads:[~2011-10-22  5:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4DC960B2.40406@ladisch.de>
     [not found] ` <20110510203826.17d1ad91@stein>
     [not found]   ` <4DCAAEFF.8060907@ladisch.de>
     [not found]     ` <20110517223618.43633eee@stein>
     [not found]       ` <4DD36B16.6040802@ladisch.de>
     [not found]         ` <4E920ABE.8070100@ladisch.de>
     [not found]           ` <20111015171523.434f47c8@stein>
     [not found]             ` <4E99E92B.6020408@ladisch.de>
2011-10-15 21:09               ` [PATCH] dma-mapping: fix sync_single_range_* DMA debugging Clemens Ladisch
2011-10-19  8:59                 ` Stefan Richter
2011-10-22  5:08                 ` FUJITA Tomonori

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).