diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-02-26 00:31:23 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-26 00:31:23 -0500 |
commit | 801c0be81454901e02c49abe12929c67e7d1cb55 (patch) | |
tree | 749cb64a2829b174e6d5df76da756285e7554002 /arch/x86 | |
parent | 13b2eda64d14d0a0c15c092664c7351ea58ea851 (diff) | |
parent | 13093cb0e59053bf97910de3a24f07cdff71c62c (diff) |
Merge branches 'x86/urgent' and 'x86/pat' into x86/core
Conflicts:
arch/x86/include/asm/pat.h
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/iomap.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/pat.h | 3 | ||||
-rw-r--r-- | arch/x86/mm/iomap_32.c | 44 | ||||
-rw-r--r-- | arch/x86/mm/pat.c | 46 |
4 files changed, 78 insertions, 20 deletions
diff --git a/arch/x86/include/asm/iomap.h b/arch/x86/include/asm/iomap.h index 86af26091d6c..bd46495ff7de 100644 --- a/arch/x86/include/asm/iomap.h +++ b/arch/x86/include/asm/iomap.h | |||
@@ -24,7 +24,10 @@ | |||
24 | #include <asm/tlbflush.h> | 24 | #include <asm/tlbflush.h> |
25 | 25 | ||
26 | int | 26 | int |
27 | is_io_mapping_possible(resource_size_t base, unsigned long size); | 27 | reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot); |
28 | |||
29 | void | ||
30 | free_io_memtype(u64 base, unsigned long size); | ||
28 | 31 | ||
29 | void * | 32 | void * |
30 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); | 33 | iomap_atomic_prot_pfn(unsigned long pfn, enum km_type type, pgprot_t prot); |
diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h index 9709fdff6615..b0e70056838e 100644 --- a/arch/x86/include/asm/pat.h +++ b/arch/x86/include/asm/pat.h | |||
@@ -15,4 +15,7 @@ extern int reserve_memtype(u64 start, u64 end, | |||
15 | unsigned long req_type, unsigned long *ret_type); | 15 | unsigned long req_type, unsigned long *ret_type); |
16 | extern int free_memtype(u64 start, u64 end); | 16 | extern int free_memtype(u64 start, u64 end); |
17 | 17 | ||
18 | extern int kernel_map_sync_memtype(u64 base, unsigned long size, | ||
19 | unsigned long flag); | ||
20 | |||
18 | #endif /* _ASM_X86_PAT_H */ | 21 | #endif /* _ASM_X86_PAT_H */ |
diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c index 6c2b1af16926..d5e28424622c 100644 --- a/arch/x86/mm/iomap_32.c +++ b/arch/x86/mm/iomap_32.c | |||
@@ -21,13 +21,13 @@ | |||
21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
22 | 22 | ||
23 | #ifdef CONFIG_X86_PAE | 23 | #ifdef CONFIG_X86_PAE |
24 | int | 24 | static int |
25 | is_io_mapping_possible(resource_size_t base, unsigned long size) | 25 | is_io_mapping_possible(resource_size_t base, unsigned long size) |
26 | { | 26 | { |
27 | return 1; | 27 | return 1; |
28 | } | 28 | } |
29 | #else | 29 | #else |
30 | int | 30 | static int |
31 | is_io_mapping_possible(resource_size_t base, unsigned long size) | 31 | is_io_mapping_possible(resource_size_t base, unsigned long size) |
32 | { | 32 | { |
33 | /* There is no way to map greater than 1 << 32 address without PAE */ | 33 | /* There is no way to map greater than 1 << 32 address without PAE */ |
@@ -38,6 +38,46 @@ is_io_mapping_possible(resource_size_t base, unsigned long size) | |||
38 | } | 38 | } |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | int | ||
42 | reserve_io_memtype_wc(u64 base, unsigned long size, pgprot_t *prot) | ||
43 | { | ||
44 | unsigned long ret_flag; | ||
45 | |||
46 | if (!is_io_mapping_possible(base, size)) | ||
47 | goto out_err; | ||
48 | |||
49 | if (!pat_enabled) { | ||
50 | *prot = pgprot_noncached(PAGE_KERNEL); | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | if (reserve_memtype(base, base + size, _PAGE_CACHE_WC, &ret_flag)) | ||
55 | goto out_err; | ||
56 | |||
57 | if (ret_flag == _PAGE_CACHE_WB) | ||
58 | goto out_free; | ||
59 | |||
60 | if (kernel_map_sync_memtype(base, size, ret_flag)) | ||
61 | goto out_free; | ||
62 | |||
63 | *prot = __pgprot(__PAGE_KERNEL | ret_flag); | ||
64 | return 0; | ||
65 | |||
66 | out_free: | ||
67 | free_memtype(base, base + size); | ||
68 | out_err: | ||
69 | return -EINVAL; | ||
70 | } | ||
71 | EXPORT_SYMBOL_GPL(reserve_io_memtype_wc); | ||
72 | |||
73 | void | ||
74 | free_io_memtype(u64 base, unsigned long size) | ||
75 | { | ||
76 | if (pat_enabled) | ||
77 | free_memtype(base, base + size); | ||
78 | } | ||
79 | EXPORT_SYMBOL_GPL(free_io_memtype); | ||
80 | |||
41 | /* Map 'pfn' using fixed map 'type' and protections 'prot' | 81 | /* Map 'pfn' using fixed map 'type' and protections 'prot' |
42 | */ | 82 | */ |
43 | void * | 83 | void * |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 05f9aef6818a..fdfedb65d45a 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -634,6 +634,33 @@ void unmap_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot) | |||
634 | } | 634 | } |
635 | 635 | ||
636 | /* | 636 | /* |
637 | * Change the memory type for the physial address range in kernel identity | ||
638 | * mapping space if that range is a part of identity map. | ||
639 | */ | ||
640 | int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags) | ||
641 | { | ||
642 | unsigned long id_sz; | ||
643 | |||
644 | if (!pat_enabled || base >= __pa(high_memory)) | ||
645 | return 0; | ||
646 | |||
647 | id_sz = (__pa(high_memory) < base + size) ? | ||
648 | __pa(high_memory) - base : | ||
649 | size; | ||
650 | |||
651 | if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) { | ||
652 | printk(KERN_INFO | ||
653 | "%s:%d ioremap_change_attr failed %s " | ||
654 | "for %Lx-%Lx\n", | ||
655 | current->comm, current->pid, | ||
656 | cattr_name(flags), | ||
657 | base, (unsigned long long)(base + size)); | ||
658 | return -EINVAL; | ||
659 | } | ||
660 | return 0; | ||
661 | } | ||
662 | |||
663 | /* | ||
637 | * Internal interface to reserve a range of physical memory with prot. | 664 | * Internal interface to reserve a range of physical memory with prot. |
638 | * Reserved non RAM regions only and after successful reserve_memtype, | 665 | * Reserved non RAM regions only and after successful reserve_memtype, |
639 | * this func also keeps identity mapping (if any) in sync with this new prot. | 666 | * this func also keeps identity mapping (if any) in sync with this new prot. |
@@ -642,7 +669,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, | |||
642 | int strict_prot) | 669 | int strict_prot) |
643 | { | 670 | { |
644 | int is_ram = 0; | 671 | int is_ram = 0; |
645 | int id_sz, ret; | 672 | int ret; |
646 | unsigned long flags; | 673 | unsigned long flags; |
647 | unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); | 674 | unsigned long want_flags = (pgprot_val(*vma_prot) & _PAGE_CACHE_MASK); |
648 | 675 | ||
@@ -679,23 +706,8 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot, | |||
679 | flags); | 706 | flags); |
680 | } | 707 | } |
681 | 708 | ||
682 | /* Need to keep identity mapping in sync */ | 709 | if (kernel_map_sync_memtype(paddr, size, flags) < 0) { |
683 | if (paddr >= __pa(high_memory)) | ||
684 | return 0; | ||
685 | |||
686 | id_sz = (__pa(high_memory) < paddr + size) ? | ||
687 | __pa(high_memory) - paddr : | ||
688 | size; | ||
689 | |||
690 | if (ioremap_change_attr((unsigned long)__va(paddr), id_sz, flags) < 0) { | ||
691 | free_memtype(paddr, paddr + size); | 710 | free_memtype(paddr, paddr + size); |
692 | printk(KERN_ERR | ||
693 | "%s:%d reserve_pfn_range ioremap_change_attr failed %s " | ||
694 | "for %Lx-%Lx\n", | ||
695 | current->comm, current->pid, | ||
696 | cattr_name(flags), | ||
697 | (unsigned long long)paddr, | ||
698 | (unsigned long long)(paddr + size)); | ||
699 | return -EINVAL; | 711 | return -EINVAL; |
700 | } | 712 | } |
701 | return 0; | 713 | return 0; |