diff options
Diffstat (limited to 'kernel/resource.c')
| -rw-r--r-- | kernel/resource.c | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/kernel/resource.c b/kernel/resource.c index 414d6fc9131e..7797dae85b50 100644 --- a/kernel/resource.c +++ b/kernel/resource.c | |||
| @@ -38,10 +38,6 @@ EXPORT_SYMBOL(iomem_resource); | |||
| 38 | 38 | ||
| 39 | static DEFINE_RWLOCK(resource_lock); | 39 | static DEFINE_RWLOCK(resource_lock); |
| 40 | 40 | ||
| 41 | #ifdef CONFIG_PROC_FS | ||
| 42 | |||
| 43 | enum { MAX_IORES_LEVEL = 5 }; | ||
| 44 | |||
| 45 | static void *r_next(struct seq_file *m, void *v, loff_t *pos) | 41 | static void *r_next(struct seq_file *m, void *v, loff_t *pos) |
| 46 | { | 42 | { |
| 47 | struct resource *p = v; | 43 | struct resource *p = v; |
| @@ -53,6 +49,10 @@ static void *r_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 53 | return p->sibling; | 49 | return p->sibling; |
| 54 | } | 50 | } |
| 55 | 51 | ||
| 52 | #ifdef CONFIG_PROC_FS | ||
| 53 | |||
| 54 | enum { MAX_IORES_LEVEL = 5 }; | ||
| 55 | |||
| 56 | static void *r_start(struct seq_file *m, loff_t *pos) | 56 | static void *r_start(struct seq_file *m, loff_t *pos) |
| 57 | __acquires(resource_lock) | 57 | __acquires(resource_lock) |
| 58 | { | 58 | { |
| @@ -549,13 +549,9 @@ static void __init __reserve_region_with_split(struct resource *root, | |||
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | if (!res) { | 551 | if (!res) { |
| 552 | printk(KERN_DEBUG " __reserve_region_with_split: (%s) [%llx, %llx], res: (%s) [%llx, %llx]\n", | ||
| 553 | conflict->name, conflict->start, conflict->end, | ||
| 554 | name, start, end); | ||
| 555 | |||
| 556 | /* failed, split and try again */ | 552 | /* failed, split and try again */ |
| 557 | 553 | ||
| 558 | /* conflict coverred whole area */ | 554 | /* conflict covered whole area */ |
| 559 | if (conflict->start <= start && conflict->end >= end) | 555 | if (conflict->start <= start && conflict->end >= end) |
| 560 | return; | 556 | return; |
| 561 | 557 | ||
| @@ -831,3 +827,40 @@ static int __init reserve_setup(char *str) | |||
| 831 | } | 827 | } |
| 832 | 828 | ||
| 833 | __setup("reserve=", reserve_setup); | 829 | __setup("reserve=", reserve_setup); |
| 830 | |||
| 831 | /* | ||
| 832 | * Check if the requested addr and size spans more than any slot in the | ||
| 833 | * iomem resource tree. | ||
| 834 | */ | ||
| 835 | int iomem_map_sanity_check(resource_size_t addr, unsigned long size) | ||
| 836 | { | ||
| 837 | struct resource *p = &iomem_resource; | ||
| 838 | int err = 0; | ||
| 839 | loff_t l; | ||
| 840 | |||
| 841 | read_lock(&resource_lock); | ||
| 842 | for (p = p->child; p ; p = r_next(NULL, p, &l)) { | ||
| 843 | /* | ||
| 844 | * We can probably skip the resources without | ||
| 845 | * IORESOURCE_IO attribute? | ||
| 846 | */ | ||
| 847 | if (p->start >= addr + size) | ||
| 848 | continue; | ||
| 849 | if (p->end < addr) | ||
| 850 | continue; | ||
| 851 | if (p->start <= addr && (p->end >= addr + size - 1)) | ||
| 852 | continue; | ||
| 853 | printk(KERN_WARNING "resource map sanity check conflict: " | ||
| 854 | "0x%llx 0x%llx 0x%llx 0x%llx %s\n", | ||
| 855 | (unsigned long long)addr, | ||
| 856 | (unsigned long long)(addr + size - 1), | ||
| 857 | (unsigned long long)p->start, | ||
| 858 | (unsigned long long)p->end, | ||
| 859 | p->name); | ||
| 860 | err = -1; | ||
| 861 | break; | ||
| 862 | } | ||
| 863 | read_unlock(&resource_lock); | ||
| 864 | |||
| 865 | return err; | ||
| 866 | } | ||
