1 #include <linux/dma-mapping.h>
2 #include <asm/iommu_table.h>
3 #include <linux/string.h>
4 #include <linux/kallsyms.h>
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
;
19 for (p
= start
; p
< finish
; p
++)
20 if (p
->detect
== q
->depend
)
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
++) {
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.
40 memmove(p
, q
, sizeof(*p
));
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
;
54 /* Simple cyclic dependency checker. */
55 for (p
= start
; p
< finish
; p
++) {
56 q
= find_dependents_of(start
, finish
, p
);
57 x
= find_dependents_of(start
, finish
, q
);
59 printk(KERN_ERR
"CYCLIC DEPENDENCY FOUND! %pS depends on %pS and vice-versa. BREAKING IT.\n",
60 p
->detect
, q
->detect
);
61 /* Heavy handed way..*/
66 for (p
= start
; p
< finish
; p
++) {
67 q
= find_dependents_of(p
, finish
, p
);
69 printk(KERN_ERR
"EXECUTION ORDER INVALID! %pS should be called before %pS!\n",
70 p
->detect
, q
->detect
);
75 inline void check_iommu_entries(struct iommu_table_entry
*start
,
76 struct iommu_table_entry
*finish
)