Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f6280dd authored by Linus Torvalds's avatar Linus Torvalds
Browse files
* 'iommu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (61 commits)
  amd-iommu: remove unnecessary "AMD IOMMU: " prefix
  amd-iommu: detach device explicitly before attaching it to a new domain
  amd-iommu: remove BUS_NOTIFY_BOUND_DRIVER handling
  dma-debug: simplify logic in driver_filter()
  dma-debug: disable/enable irqs only once in device_dma_allocations
  dma-debug: use pr_* instead of printk(KERN_* ...)
  dma-debug: code style fixes
  dma-debug: comment style fixes
  dma-debug: change hash_bucket_find from first-fit to best-fit
  x86: enable GART-IOMMU only after setting up protection methods
  amd_iommu: fix lock imbalance
  dma-debug: add documentation for the driver filter
  dma-debug: add dma_debug_driver kernel command line
  dma-debug: add debugfs file for driver filter
  dma-debug: add variables and checks for driver filter
  dma-debug: fix debug_dma_sync_sg_for_cpu and debug_dma_sync_sg_for_device
  dma-debug: use sg_dma_len accessor
  dma-debug: use sg_dma_address accessor instead of using dma_address directly
  amd-iommu: don't free dma adresses below 512MB with CONFIG_IOMMU_STRESS
  amd-iommu: don't preallocate page tables with CONFIG_IOMMU_STRESS
  ...
parents 75063600 92db1e6a
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -704,12 +704,24 @@ this directory the following files can currently be found:
				The current number of free dma_debug_entries
				The current number of free dma_debug_entries
				in the allocator.
				in the allocator.


	dma-api/driver-filter
				You can write a name of a driver into this file
				to limit the debug output to requests from that
				particular driver. Write an empty string to
				that file to disable the filter and see
				all errors again.

If you have this code compiled into your kernel it will be enabled by default.
If you have this code compiled into your kernel it will be enabled by default.
If you want to boot without the bookkeeping anyway you can provide
If you want to boot without the bookkeeping anyway you can provide
'dma_debug=off' as a boot parameter. This will disable DMA-API debugging.
'dma_debug=off' as a boot parameter. This will disable DMA-API debugging.
Notice that you can not enable it again at runtime. You have to reboot to do
Notice that you can not enable it again at runtime. You have to reboot to do
so.
so.


If you want to see debug messages only for a special device driver you can
specify the dma_debug_driver=<drivername> parameter. This will enable the
driver filter at boot time. The debug code will only print errors for that
driver afterwards. This filter can be disabled or changed later using debugfs.

When the code disables itself at runtime this is most likely because it ran
When the code disables itself at runtime this is most likely because it ran
out of dma_debug_entries. These entries are preallocated at boot. The number
out of dma_debug_entries. These entries are preallocated at boot. The number
of preallocated entries is defined per architecture. If it is too low for you
of preallocated entries is defined per architecture. If it is too low for you
+7 −5
Original line number Original line Diff line number Diff line
@@ -329,11 +329,6 @@ and is between 256 and 4096 characters. It is defined in the file
				    flushed before they will be reused, which
				    flushed before they will be reused, which
				    is a lot of faster
				    is a lot of faster


	amd_iommu_size= [HW,X86-64]
			Define the size of the aperture for the AMD IOMMU
			driver. Possible values are:
			'32M', '64M' (default), '128M', '256M', '512M', '1G'

	amijoy.map=	[HW,JOY] Amiga joystick support
	amijoy.map=	[HW,JOY] Amiga joystick support
			Map of devices attached to JOY0DAT and JOY1DAT
			Map of devices attached to JOY0DAT and JOY1DAT
			Format: <a>,<b>
			Format: <a>,<b>
@@ -646,6 +641,13 @@ and is between 256 and 4096 characters. It is defined in the file
			DMA-API debugging code disables itself because the
			DMA-API debugging code disables itself because the
			architectural default is too low.
			architectural default is too low.


	dma_debug_driver=<driver_name>
			With this option the DMA-API debugging driver
			filter feature can be enabled at boot time. Just
			pass the driver to filter for as the parameter.
			The filter can be disabled or changed to another
			driver later using sysfs.

	dscc4.setup=	[NET]
	dscc4.setup=	[NET]


	dtc3181e=	[HW,SCSI]
	dtc3181e=	[HW,SCSI]
+9 −2
Original line number Original line Diff line number Diff line
@@ -159,10 +159,17 @@ config IOMMU_DEBUG
	  options. See Documentation/x86_64/boot-options.txt for more
	  options. See Documentation/x86_64/boot-options.txt for more
	  details.
	  details.


config IOMMU_STRESS
	bool "Enable IOMMU stress-test mode"
	---help---
	  This option disables various optimizations in IOMMU related
	  code to do real stress testing of the IOMMU code. This option
	  will cause a performance drop and should only be enabled for
	  testing.

config IOMMU_LEAK
config IOMMU_LEAK
	bool "IOMMU leak tracing"
	bool "IOMMU leak tracing"
	depends on DEBUG_KERNEL
	depends on IOMMU_DEBUG && DMA_API_DEBUG
	depends on IOMMU_DEBUG
	---help---
	---help---
	  Add a simple leak tracer to the IOMMU code. This is useful when you
	  Add a simple leak tracer to the IOMMU code. This is useful when you
	  are debugging a buggy device driver that leaks IOMMU mappings.
	  are debugging a buggy device driver that leaks IOMMU mappings.
+2 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,8 @@ extern int amd_iommu_init(void);
extern int amd_iommu_init_dma_ops(void);
extern int amd_iommu_init_dma_ops(void);
extern void amd_iommu_detect(void);
extern void amd_iommu_detect(void);
extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
extern void amd_iommu_flush_all_domains(void);
extern void amd_iommu_flush_all_devices(void);
#else
#else
static inline int amd_iommu_init(void) { return -ENODEV; }
static inline int amd_iommu_init(void) { return -ENODEV; }
static inline void amd_iommu_detect(void) { }
static inline void amd_iommu_detect(void) { }
+44 −11
Original line number Original line Diff line number Diff line
@@ -194,6 +194,27 @@
#define PD_DMA_OPS_MASK		(1UL << 0) /* domain used for dma_ops */
#define PD_DMA_OPS_MASK		(1UL << 0) /* domain used for dma_ops */
#define PD_DEFAULT_MASK		(1UL << 1) /* domain is a default dma_ops
#define PD_DEFAULT_MASK		(1UL << 1) /* domain is a default dma_ops
					      domain for an IOMMU */
					      domain for an IOMMU */
extern bool amd_iommu_dump;
#define DUMP_printk(format, arg...)					\
	do {								\
		if (amd_iommu_dump)						\
			printk(KERN_INFO "AMD IOMMU: " format, ## arg);	\
	} while(0);

/*
 * Make iterating over all IOMMUs easier
 */
#define for_each_iommu(iommu) \
	list_for_each_entry((iommu), &amd_iommu_list, list)
#define for_each_iommu_safe(iommu, next) \
	list_for_each_entry_safe((iommu), (next), &amd_iommu_list, list)

#define APERTURE_RANGE_SHIFT	27	/* 128 MB */
#define APERTURE_RANGE_SIZE	(1ULL << APERTURE_RANGE_SHIFT)
#define APERTURE_RANGE_PAGES	(APERTURE_RANGE_SIZE >> PAGE_SHIFT)
#define APERTURE_MAX_RANGES	32	/* allows 4GB of DMA address space */
#define APERTURE_RANGE_INDEX(a)	((a) >> APERTURE_RANGE_SHIFT)
#define APERTURE_PAGE_INDEX(a)	(((a) >> 21) & 0x3fULL)


/*
/*
 * This structure contains generic data for  IOMMU protection domains
 * This structure contains generic data for  IOMMU protection domains
@@ -209,6 +230,26 @@ struct protection_domain {
	void *priv;		/* private data */
	void *priv;		/* private data */
};
};


/*
 * For dynamic growth the aperture size is split into ranges of 128MB of
 * DMA address space each. This struct represents one such range.
 */
struct aperture_range {

	/* address allocation bitmap */
	unsigned long *bitmap;

	/*
	 * Array of PTE pages for the aperture. In this array we save all the
	 * leaf pages of the domain page table used for the aperture. This way
	 * we don't need to walk the page table to find a specific PTE. We can
	 * just calculate its address in constant time.
	 */
	u64 *pte_pages[64];

	unsigned long offset;
};

/*
/*
 * Data container for a dma_ops specific protection domain
 * Data container for a dma_ops specific protection domain
 */
 */
@@ -222,18 +263,10 @@ struct dma_ops_domain {
	unsigned long aperture_size;
	unsigned long aperture_size;


	/* address we start to search for free addresses */
	/* address we start to search for free addresses */
	unsigned long next_bit;
	unsigned long next_address;

	/* address allocation bitmap */
	unsigned long *bitmap;


	/*
	/* address space relevant data */
	 * Array of PTE pages for the aperture. In this array we save all the
	struct aperture_range *aperture[APERTURE_MAX_RANGES];
	 * leaf pages of the domain page table used for the aperture. This way
	 * we don't need to walk the page table to find a specific PTE. We can
	 * just calculate its address in constant time.
	 */
	u64 **pte_pages;


	/* This will be set to true when TLB needs to be flushed */
	/* This will be set to true when TLB needs to be flushed */
	bool need_flush;
	bool need_flush;
Loading