rpms/kernel/devel kernel.spec, 1.1328, 1.1329 linux-2.6-debug-dma-api.patch, 1.2, 1.3

Kyle McMartin kyle at fedoraproject.org
Wed Feb 25 02:53:41 UTC 2009


Author: kyle

Update of /cvs/pkgs/rpms/kernel/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10687

Modified Files:
	kernel.spec linux-2.6-debug-dma-api.patch 
Log Message:
* Tue Feb 24 2009 Kyle McMartin <kyle at redhat.com>
- linux-2.6-debug-dma-api.patch: rebase to v3, had to hack it myself in
  places, so if it breaks, i get to keep all million pieces.



Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/kernel.spec,v
retrieving revision 1.1328
retrieving revision 1.1329
diff -u -r1.1328 -r1.1329
--- kernel.spec	24 Feb 2009 15:11:45 -0000	1.1328
+++ kernel.spec	25 Feb 2009 02:53:10 -0000	1.1329
@@ -1750,6 +1750,10 @@
 %kernel_variant_files -k vmlinux %{with_kdump} kdump
 
 %changelog
+* Tue Feb 24 2009 Kyle McMartin <kyle at redhat.com>
+- linux-2.6-debug-dma-api.patch: rebase to v3, had to hack it myself in
+  places, so if it breaks, i get to keep all million pieces.
+
 * Tue Feb 24 2009 Kristian Høgsberg <krh at redhat.com>
 - Pull in new round of intel KMS fixes.
 

linux-2.6-debug-dma-api.patch:

Index: linux-2.6-debug-dma-api.patch
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/devel/linux-2.6-debug-dma-api.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- linux-2.6-debug-dma-api.patch	5 Feb 2009 19:26:04 -0000	1.2
+++ linux-2.6-debug-dma-api.patch	25 Feb 2009 02:53:10 -0000	1.3
@@ -1,164 +1,5 @@
-commit 0df007e5142d29c3e2707acc23c8e9b5105288a5
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 16:28:07 2009 +0100
-
-    dma-debug: Documentation update
-    
-    Impact: add documentation about DMA-API debugging to DMA-API.txt
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 554b62839f2d9cf0b9aa13c9cd70bf58e7e4e0e3
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 15:13:15 2009 +0100
-
-    dma-debug: x86 architecture bindings
-    
-    Impact: make use of DMA-API debugging code in x86
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit bc33a312a4588585910dcfd194db0744cf9e3dab
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 15:01:12 2009 +0100
-
-    dma-debug: add checks for sync_single_sg_*
-    
-    Impact: add debug callbacks for dma_sync_sg_* functions
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 405797c50463944e7389b021d396f92aa1093053
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:55:38 2009 +0100
-
-    dma-debug: add checks for sync_single_range_*
-    
-    Impact: add debug callbacks for dma_sync_single_range_for_* functions
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 0cedfe07d54c682cf7f13dc9550c911dbbb9f50a
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:43:04 2009 +0100
-
-    dma-debug: add checks for sync_single_*
-    
-    Impact: add debug callbacks for dma_sync_single_for_* functions
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit fc10709e4202058e4d6b2db18a2ec8015a09e0fc
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:38:50 2009 +0100
-
-    dma-debug: add checking for [alloc|free]_coherent
-    
-    Impact: add debug callbacks for dma_[alloc|free]_coherent
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit d8f3a5e2fec916f325043d1f3a714739f9d44b08
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:19:54 2009 +0100
-
-    dma-debug: add add checking for map/unmap_sg
-    
-    Impact: add debug callbacks for dma_{un}map_sg
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 8c0dcad8c5316080c7158fb8f0bc10511721c303
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:14:49 2009 +0100
-
-    dma-debug: add checking for map/unmap_page/single
-    
-    Impact: add debug callbacks for dma_{un}map_[page|single]
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit f15c9695bfdb953b7e70e1911bbe14c30b11e939
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 14:10:26 2009 +0100
-
-    dma-debug: add core checking functions
-    
-    Impact: add functions to check on dma unmap and sync
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 6602032ed8aa974b4f6ac848ae343a83f9ab37dc
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 13:13:27 2009 +0100
-
-    dma-debug: add debugfs interface
-    
-    Impact: add debugfs interface for configuring DMA-API debugging
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit b954fbe7bc5bef620ff053b98b0ca58abf332f89
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 13:01:56 2009 +0100
-
-    dma-debug: add kernel command line parameters
-    
-    Impact: add dma_debug= and dma_debug_entries= kernel parameters
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 5ab513d8d2fa743bcd526c6fbacbc6ae7688d6d8
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 12:54:42 2009 +0100
-
-    dma-debug: add initialization code
-    
-    Impact: add code to initialize dma-debug core data structures
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 8520ee58bb81accffa2edc7134c7616613338c0b
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 12:42:46 2009 +0100
-
-    dma-debug: add allocator code
-    
-    Impact: add allocator code for struct dma_debug_entry
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit ce944795f6096ff8798ee9660da16565afd342e6
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 12:34:49 2009 +0100
-
-    dma-debug: add hash functions for dma_debug_entries
-    
-    Impact: implement necessary functions for the core hash
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit 92cf5ffc45d600f36338efa42cd24034a977422b
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 12:19:52 2009 +0100
-
-    dma-debug: add header file and core data structures
-    
-    Impact: add groundwork for DMA-API debugging
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
-
-commit b05343cc7b6993929b11f2e1ab376fcb4df177de
-Author: Joerg Roedel <joerg.roedel at amd.com>
-Date:   Fri Jan 9 12:14:24 2009 +0100
-
-    dma-debug: add Kconfig entry
-    
-    Impact: add a Kconfig entry for DMA-API debugging
-    
-    Signed-off-by: Joerg Roedel <joerg.roedel at amd.com>
 diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
-index 5244169..dca8be3 100644
+index 2a3fcc5..d9aa43d 100644
 --- a/Documentation/DMA-API.txt
 +++ b/Documentation/DMA-API.txt
 @@ -609,3 +609,109 @@ size is the size (and should be a page-sized multiple).
@@ -272,7 +113,7 @@
 +boot with 'dma_debug_entries=<your_desired_number>' to overwrite the
 +architectural default.
 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
-index 8511d35..fef67ed 100644
+index b182626..a0ba260 100644
 --- a/Documentation/kernel-parameters.txt
 +++ b/Documentation/kernel-parameters.txt
 @@ -491,6 +491,16 @@ and is between 256 and 4096 characters. It is defined in the file
@@ -303,19 +144,174 @@
 +config HAVE_DMA_API_DEBUG
 +	bool
 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
-index 73f7fe8..9e7aa97 100644
+index 9c39095..2200d1f 100644
 --- a/arch/x86/Kconfig
 +++ b/arch/x86/Kconfig
-@@ -40,6 +40,7 @@ config X86
+@@ -40,6 +40,8 @@ config X86
  	select HAVE_GENERIC_DMA_COHERENT if X86_32
  	select HAVE_EFFICIENT_UNALIGNED_ACCESS
  	select USER_STACKTRACE_SUPPORT
 +	select HAVE_DMA_API_DEBUG
++	select DMA_API_DEBUG
  
  config ARCH_DEFCONFIG
  	string
+diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
+index 132a134..23131fe 100644
+--- a/arch/x86/include/asm/dma-mapping.h
++++ b/arch/x86/include/asm/dma-mapping.h
+@@ -7,6 +7,7 @@
+  */
+ 
+ #include <linux/scatterlist.h>
++#include <linux/dma-debug.h>
+ #include <asm/io.h>
+ #include <asm/swiotlb.h>
+ #include <asm-generic/dma-coherent.h>
+@@ -93,9 +94,14 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size,
+ 	       int direction)
+ {
+ 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
++	dma_addr_t addr;
+ 
+ 	BUG_ON(!valid_dma_direction(direction));
+-	return ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
++	addr = ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
++	debug_dma_map_page(hwdev, virt_to_page(ptr),
++			   (unsigned long)ptr & PAGE_MASK, size, direction,
++			   addr, true);
++	return addr;
+ }
+ 
+ static inline void
+@@ -107,6 +113,7 @@ dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size,
+ 	BUG_ON(!valid_dma_direction(direction));
+ 	if (ops->unmap_single)
+ 		ops->unmap_single(dev, addr, size, direction);
++	debug_dma_unmap_page(dev, addr, size, direction, true);
+ }
+ 
+ static inline int
+@@ -114,9 +121,13 @@ dma_map_sg(struct device *hwdev, struct scatterlist *sg,
+ 	   int nents, int direction)
+ {
+ 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
++	int ents;
+ 
+ 	BUG_ON(!valid_dma_direction(direction));
+-	return ops->map_sg(hwdev, sg, nents, direction);
++	ents = ops->map_sg(hwdev, sg, nents, direction);
++	debug_dma_map_sg(hwdev, sg, ents, direction);
++
++	return ents;
+ }
+ 
+ static inline void
+@@ -126,6 +137,7 @@ dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+ 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
+ 
+ 	BUG_ON(!valid_dma_direction(direction));
++	debug_dma_unmap_sg(hwdev, sg, nents, direction);
+ 	if (ops->unmap_sg)
+ 		ops->unmap_sg(hwdev, sg, nents, direction);
+ }
+@@ -139,6 +151,7 @@ dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+ 	BUG_ON(!valid_dma_direction(direction));
+ 	if (ops->sync_single_for_cpu)
+ 		ops->sync_single_for_cpu(hwdev, dma_handle, size, direction);
++	debug_dma_sync_single_for_cpu(hwdev, dma_handle, size, direction);
+ 	flush_write_buffers();
+ }
+ 
+@@ -151,6 +164,7 @@ dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
+ 	BUG_ON(!valid_dma_direction(direction));
+ 	if (ops->sync_single_for_device)
+ 		ops->sync_single_for_device(hwdev, dma_handle, size, direction);
++	debug_dma_sync_single_for_device(hwdev, dma_handle, size, direction);
+ 	flush_write_buffers();
+ }
+ 
+@@ -164,6 +178,8 @@ dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+ 	if (ops->sync_single_range_for_cpu)
+ 		ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
+ 					       size, direction);
++	debug_dma_sync_single_range_for_cpu(hwdev, dma_handle,
++					    offset, size, direction);
+ 	flush_write_buffers();
+ }
+ 
+@@ -178,6 +194,8 @@ dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
+ 	if (ops->sync_single_range_for_device)
+ 		ops->sync_single_range_for_device(hwdev, dma_handle,
+ 						  offset, size, direction);
++	debug_dma_sync_single_range_for_device(hwdev, dma_handle,
++					       offset, size, direction);
+ 	flush_write_buffers();
+ }
+ 
+@@ -190,6 +208,7 @@ dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
+ 	BUG_ON(!valid_dma_direction(direction));
+ 	if (ops->sync_sg_for_cpu)
+ 		ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
++	debug_dma_sync_sg_for_cpu(hwdev, sg, nelems, direction);
+ 	flush_write_buffers();
+ }
+ 
+@@ -202,6 +221,7 @@ dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
+ 	BUG_ON(!valid_dma_direction(direction));
+ 	if (ops->sync_sg_for_device)
+ 		ops->sync_sg_for_device(hwdev, sg, nelems, direction);
++	debug_dma_sync_sg_for_device(hwdev, sg, nelems, direction);
+ 
+ 	flush_write_buffers();
+ }
+@@ -211,16 +231,21 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
+ 				      int direction)
+ {
+ 	struct dma_mapping_ops *ops = get_dma_ops(dev);
++	dma_addr_t addr;
+ 
+ 	BUG_ON(!valid_dma_direction(direction));
+-	return ops->map_single(dev, page_to_phys(page) + offset,
++	addr = ops->map_single(dev, page_to_phys(page) + offset,
+ 			       size, direction);
++	debug_dma_map_page(dev, page, offset, size, direction, addr, false);
++	return addr;
+ }
+ 
+ static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
+ 				  size_t size, int direction)
+ {
++	BUG_ON(!valid_dma_direction(direction));
+ 	dma_unmap_single(dev, addr, size, direction);
++	debug_dma_unmap_page(dev, addr, size, direction, false);
+ }
+ 
+ static inline void
+@@ -285,8 +310,11 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+ 	if (!ops->alloc_coherent)
+ 		return NULL;
+ 
+-	return ops->alloc_coherent(dev, size, dma_handle,
+-				   dma_alloc_coherent_gfp_flags(dev, gfp));
++	memory = ops->alloc_coherent(dev, size, dma_handle,
++				     dma_alloc_coherent_gfp_flags(dev, gfp));
++	debug_dma_alloc_coherent(dev, size, *dma_handle, memory);
++
++	return memory;
+ }
+ 
+ static inline void dma_free_coherent(struct device *dev, size_t size,
+@@ -299,6 +327,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
+ 	if (dma_release_from_coherent(dev, get_order(size), vaddr))
+ 		return;
+ 
++	debug_dma_free_coherent(dev, size, vaddr, bus);
+ 	if (ops->free_coherent)
+ 		ops->free_coherent(dev, size, vaddr, bus);
+ }
 diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
-index f293a8d..50d28eb 100644
+index b254285..4f03337 100644
 --- a/arch/x86/kernel/pci-dma.c
 +++ b/arch/x86/kernel/pci-dma.c
 @@ -1,4 +1,5 @@
@@ -345,10 +341,10 @@
  	intel_iommu_init();
 diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h
 new file mode 100644
-index 0000000..8a8aae4
+index 0000000..d9f1069
 --- /dev/null
 +++ b/include/linux/dma-debug.h
-@@ -0,0 +1,160 @@
+@@ -0,0 +1,167 @@
 +/*
 + * Copyright (C) 2008 Advanced Micro Devices, Inc.
 + *
@@ -374,6 +370,7 @@
 +#include <linux/types.h>
 +
 +struct device;
++struct scatterlist;
 +
 +#ifdef CONFIG_DMA_API_DEBUG
 +
@@ -426,6 +423,8 @@
 +					 struct scatterlist *sg,
 +					 int nelems, int direction);
 +
++extern void debug_dma_dump_mappings(struct device *dev);
++
 +#else /* CONFIG_DMA_API_DEBUG */
 +
 +static inline void dma_debug_init(u32 num_entries)
@@ -506,14 +505,18 @@
 +{
 +}
 +
++static inline void debug_dma_dump_mappings(struct device *dev)
++{
++}
++
 +#endif /* CONFIG_DMA_API_DEBUG */
 +
 +#endif /* __DMA_DEBUG_H */
 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
-index 4c9ae60..92120f7 100644
+index 29044f5..a2edc9b 100644
 --- a/lib/Kconfig.debug
 +++ b/lib/Kconfig.debug
-@@ -906,6 +906,17 @@ config DYNAMIC_PRINTK_DEBUG
+@@ -902,6 +902,17 @@ config DYNAMIC_PRINTK_DEBUG
  	  debugging for all modules. This mode can be turned off via the above
  	  disable command.
  
@@ -546,10 +549,10 @@
  
 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
 new file mode 100644
-index 0000000..469e5b9
+index 0000000..9c1a498
 --- /dev/null
 +++ b/lib/dma-debug.c
-@@ -0,0 +1,753 @@
+@@ -0,0 +1,818 @@
 +/*
 + * Copyright (C) 2008 Advanced Micro Devices, Inc.
 + *
@@ -576,6 +579,7 @@
 +#include <linux/debugfs.h>
 +#include <linux/device.h>
 +#include <linux/types.h>
++#include <linux/sched.h>
 +#include <linux/list.h>
 +#include <linux/slab.h>
 +
@@ -603,7 +607,7 @@
 +struct hash_bucket {
 +	struct list_head list;
 +	spinlock_t lock;
-+} __cacheline_aligned_in_smp;
++} ____cacheline_aligned_in_smp;
 +
 +/* Hash list to save the allocated dma addresses */
 +static struct hash_bucket dma_entry_hash[HASH_SIZE];
@@ -743,6 +747,36 @@
 +}
 +
 +/*
++ * Dump mapping entries for debugging purposes
++ */
++void debug_dma_dump_mappings(struct device *dev)
++{
++	int idx;
++
++	for (idx = 0; idx < HASH_SIZE; idx++) {
++		struct hash_bucket *bucket = &dma_entry_hash[idx];
++		struct dma_debug_entry *entry;
++		unsigned long flags;
++
++		spin_lock_irqsave(&bucket->lock, flags);
++
++		list_for_each_entry(entry, &bucket->list, list) {
++			if (!dev || dev == entry->dev) {
++				dev_info(entry->dev,
++					 "%s idx %d P=%Lx D=%Lx L=%Lx %s\n",
++					 type2name[entry->type], idx,
++					 (unsigned long long)entry->paddr,
++					 entry->dev_addr, entry->size,
++					 dir2name[entry->direction]);
++			}
++		}
++
++			spin_unlock_irqrestore(&bucket->lock, flags);
++	}
++}
++EXPORT_SYMBOL(debug_dma_dump_mappings);
++
++/*
 + * Wrapper function for adding an entry to the hash.
 + * This function takes care of locking itself.
 + */
@@ -1005,7 +1039,7 @@
 +			   "[device address=0x%016llx] [size=%llu bytes] "
 +			   "[cpu alloc address=%p] [cpu free address=%p]",
 +			   ref->dev_addr, ref->size,
-+			   entry->paddr, ref->paddr);
++			   (void *)entry->paddr, (void *)ref->paddr);
 +	}
 +
 +	/*
@@ -1029,6 +1063,13 @@
 +	put_hash_bucket(bucket, &flags);
 +}
 +
++static void check_for_stack(struct device *dev, void *addr)
++{
++	if (object_is_on_stack(addr))
++		err_printk(dev, "DMA-API: device driver maps memory from stack"
++				" [addr=%p]\n", addr);
++}
++
 +static void check_sync(struct device *dev, dma_addr_t addr,
 +		       u64 size, u64 offset, int direction, bool to_cpu)
 +{
@@ -1073,6 +1114,29 @@
 +				dir2name[direction]);
 +	}
 +
++	if (entry->direction == DMA_BIDIRECTIONAL)
++		goto out;
++
++	if (to_cpu && !(entry->direction == DMA_FROM_DEVICE) &&
++		      !(direction == DMA_TO_DEVICE))
++		err_printk(dev, "DMA-API: device driver syncs "
++				"device read-only DMA memory for cpu "
++				"[device address=0x%016llx] [size=%llu bytes] "
++				"[mapped with %s] [synced with %s]\n",
++				addr, entry->size,
++				dir2name[entry->direction],
++				dir2name[direction]);
++
++	if (!to_cpu && !(entry->direction == DMA_TO_DEVICE) &&
++		       !(direction == DMA_FROM_DEVICE))
++		err_printk(dev, "DMA-API: device driver syncs "
++				"device write-only DMA memory to device "
++				"[device address=0x%016llx] [size=%llu bytes] "
++				"[mapped with %s] [synced with %s]\n",
++				addr, entry->size,
++				dir2name[entry->direction],
++				dir2name[direction]);
++
 +out:
 +	put_hash_bucket(bucket, &flags);
 +
@@ -1101,8 +1165,10 @@
 +	entry->size      = size;
 +	entry->direction = direction;
 +
-+	if (map_single)
++	if (map_single) {
 +		entry->type = dma_debug_single;
++		check_for_stack(dev, page_address(page) + offset);
++	}
 +
 +	add_dma_entry(entry);
 +}
@@ -1151,6 +1217,8 @@
 +		entry->dev_addr  = s->dma_address;
 +		entry->direction = direction;
 +
++		check_for_stack(dev, sg_virt(s));
++
 +		add_dma_entry(entry);
 +	}
 +}
@@ -1303,161 +1371,3 @@
 +}
 +EXPORT_SYMBOL(debug_dma_sync_sg_for_device);
 +
-diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
-index 5a34780..6a5e070 100644
---- a/arch/x86/include/asm/dma-mapping.h
-+++ b/arch/x86/include/asm/dma-mapping.h
-@@ -7,6 +7,7 @@
-  */
- 
- #include <linux/scatterlist.h>
-+#include <linux/dma-debug.h>
- #include <asm/io.h>
- #include <asm/swiotlb.h>
- #include <asm-generic/dma-coherent.h>
-@@ -93,9 +94,14 @@ dma_map_single(struct device *hwdev, voi
- 	       int direction)
- {
- 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
-+	dma_addr_t addr;
- 
- 	BUG_ON(!valid_dma_direction(direction));
--	return ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
-+	addr = ops->map_single(hwdev, virt_to_phys(ptr), size, direction);
-+	debug_dma_map_page(hwdev, virt_to_page(ptr),
-+			  (unsigned long)ptr & ~PAGE_MASK, size,
-+			  direction, addr, true);
-+	return addr;
- }
- 
- static inline void
-@@ -107,6 +113,7 @@ dma_unmap_single(struct device *dev, dma
- 	BUG_ON(!valid_dma_direction(direction));
- 	if (ops->unmap_single)
- 		ops->unmap_single(dev, addr, size, direction);
-+	debug_dma_unmap_page(dev, addr, size, direction, true);
- }
- 
- static inline int
-@@ -114,9 +121,12 @@ dma_map_sg(struct device *hwdev, struct 
- 	   int nents, int direction)
- {
- 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
-+	int ents;
- 
- 	BUG_ON(!valid_dma_direction(direction));
--	return ops->map_sg(hwdev, sg, nents, direction);
-+	ents = ops->map_sg(hwdev, sg, nents, direction);
-+	debug_dma_map_sg(hwdev, sg, ents, direction);
-+	return ents;
- }
- 
- static inline void
-@@ -126,6 +136,7 @@ dma_unmap_sg(struct device *hwdev, struc
- 	struct dma_mapping_ops *ops = get_dma_ops(hwdev);
- 
- 	BUG_ON(!valid_dma_direction(direction));
-+	debug_dma_unmap_sg(hwdev, sg, nents, direction);
- 	if (ops->unmap_sg)
- 		ops->unmap_sg(hwdev, sg, nents, direction);
- }
-@@ -139,6 +150,7 @@ dma_sync_single_for_cpu(struct device *h
- 	BUG_ON(!valid_dma_direction(direction));
- 	if (ops->sync_single_for_cpu)
- 		ops->sync_single_for_cpu(hwdev, dma_handle, size, direction);
-+	debug_dma_sync_single_for_cpu(hwdev, dma_handle, size, direction);
- 	flush_write_buffers();
- }
- 
-@@ -151,6 +163,7 @@ dma_sync_single_for_device(struct device
- 	BUG_ON(!valid_dma_direction(direction));
- 	if (ops->sync_single_for_device)
- 		ops->sync_single_for_device(hwdev, dma_handle, size, direction);
-+	debug_dma_sync_single_for_device(hwdev, dma_handle, size, direction);
- 	flush_write_buffers();
- }
- 
-@@ -164,6 +177,8 @@ dma_sync_single_range_for_cpu(struct dev
- 	if (ops->sync_single_range_for_cpu)
- 		ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
- 					       size, direction);
-+	debug_dma_sync_single_range_for_cpu(hwdev, dma_handle,
-+					    offset, size, direction);
- 	flush_write_buffers();
- }
- 
-@@ -178,6 +193,8 @@ dma_sync_single_range_for_device(struct 
- 	if (ops->sync_single_range_for_device)
- 		ops->sync_single_range_for_device(hwdev, dma_handle,
- 						  offset, size, direction);
-+	debug_dma_sync_single_range_for_device(hwdev, dma_handle,
-+					       offset, size, direction);
- 	flush_write_buffers();
- }
- 
-@@ -190,6 +207,7 @@ dma_sync_sg_for_cpu(struct device *hwdev
- 	BUG_ON(!valid_dma_direction(direction));
- 	if (ops->sync_sg_for_cpu)
- 		ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
-+	debug_dma_sync_sg_for_cpu(hwdev, sg, nelems, direction);
- 	flush_write_buffers();
- }
- 
-@@ -202,6 +220,7 @@ dma_sync_sg_for_device(struct device *hw
- 	BUG_ON(!valid_dma_direction(direction));
- 	if (ops->sync_sg_for_device)
- 		ops->sync_sg_for_device(hwdev, sg, nelems, direction);
-+	debug_dma_sync_sg_for_device(hwdev, sg, nelems, direction);
- 
- 	flush_write_buffers();
- }
-@@ -211,16 +230,25 @@ static inline dma_addr_t dma_map_page(st
- 				      int direction)
- {
- 	struct dma_mapping_ops *ops = get_dma_ops(dev);
-+	dma_addr_t addr;
- 
- 	BUG_ON(!valid_dma_direction(direction));
--	return ops->map_single(dev, page_to_phys(page) + offset,
-+	addr = ops->map_single(dev, page_to_phys(page) + offset,
- 			       size, direction);
-+	debug_dma_map_page(dev, page, offset, size, direction, addr, false);
-+
-+	return addr;
- }
- 
- static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
- 				  size_t size, int direction)
- {
--	dma_unmap_single(dev, addr, size, direction);
-+	struct dma_mapping_ops *ops = get_dma_ops(dev);
-+
-+	BUG_ON(!valid_dma_direction(direction));
-+	if (ops->unmap_single)
-+		ops->unmap_single(dev, addr, size, direction);
-+	debug_dma_unmap_page(dev, addr, size, direction, true);
- }
- 
- static inline void
-@@ -285,8 +312,11 @@ dma_alloc_coherent(struct device *dev, s
- 	if (!ops->alloc_coherent)
- 		return NULL;
- 
--	return ops->alloc_coherent(dev, size, dma_handle,
--				   dma_alloc_coherent_gfp_flags(dev, gfp));
-+	memory = ops->alloc_coherent(dev, size, dma_handle,
-+				     dma_alloc_coherent_gfp_flags(dev, gfp));
-+	debug_dma_alloc_coherent(dev, size, *dma_handle, memory);
-+
-+	return memory;
- }
- 
- static inline void dma_free_coherent(struct device *dev, size_t size,
-@@ -299,6 +329,7 @@ static inline void dma_free_coherent(str
- 	if (dma_release_from_coherent(dev, get_order(size), vaddr))
- 		return;
- 
-+	debug_dma_free_coherent(dev, size, vaddr, bus);
- 	if (ops->free_coherent)
- 		ops->free_coherent(dev, size, vaddr, bus);
- }




More information about the scm-commits mailing list