x86, ioapic: Fix potential resume deadlock
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / kernel / pci-iommu_table.c
blob55d745ec11818d958bacebef0940d33b7e508e70
1 #include <linux/dma-mapping.h>
2 #include <asm/iommu_table.h>
3 #include <linux/string.h>
4 #include <linux/kallsyms.h>
7 #define DEBUG 1
9 static struct iommu_table_entry * __init
10 find_dependents_of(struct iommu_table_entry *start,
11 struct iommu_table_entry *finish,
12 struct iommu_table_entry *q)
14 struct iommu_table_entry *p;
16 if (!q)
17 return NULL;
19 for (p = start; p < finish; p++)
20 if (p->detect == q->depend)
21 return p;
23 return NULL;
27 void __init sort_iommu_table(struct iommu_table_entry *start,
28 struct iommu_table_entry *finish) {
30 struct iommu_table_entry *p, *q, tmp;
32 for (p = start; p < finish; p++) {
33 again:
34 q = find_dependents_of(start, finish, p);
35 /* We are bit sneaky here. We use the memory address to figure
36 * out if the node we depend on is past our point, if so, swap.
38 if (q > p) {
39 tmp = *p;
40 memmove(p, q, sizeof(*p));
41 *q = tmp;
42 goto again;
48 #ifdef DEBUG
49 void __init check_iommu_entries(struct iommu_table_entry *start,
50 struct iommu_table_entry *finish)
52 struct iommu_table_entry *p, *q, *x;
53 char sym_p[KSYM_SYMBOL_LEN];
54 char sym_q[KSYM_SYMBOL_LEN];
56 /* Simple cyclic dependency checker. */
57 for (p = start; p < finish; p++) {
58 q = find_dependents_of(start, finish, p);
59 x = find_dependents_of(start, finish, q);
60 if (p == x) {
61 sprint_symbol(sym_p, (unsigned long)p->detect);
62 sprint_symbol(sym_q, (unsigned long)q->detect);
64 printk(KERN_ERR "CYCLIC DEPENDENCY FOUND! %s depends" \
65 " on %s and vice-versa. BREAKING IT.\n",
66 sym_p, sym_q);
67 /* Heavy handed way..*/
68 x->depend = 0;
72 for (p = start; p < finish; p++) {
73 q = find_dependents_of(p, finish, p);
74 if (q && q > p) {
75 sprint_symbol(sym_p, (unsigned long)p->detect);
76 sprint_symbol(sym_q, (unsigned long)q->detect);
78 printk(KERN_ERR "EXECUTION ORDER INVALID! %s "\
79 "should be called before %s!\n",
80 sym_p, sym_q);
84 #else
85 inline void check_iommu_entries(struct iommu_table_entry *start,
86 struct iommu_table_entry *finish)
89 #endif