diff options
author | Akinobu Mita <mita@miraclelinux.com> | 2006-03-24 06:15:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-24 10:33:15 -0500 |
commit | 3d1712c91df01d2573b934e972e231e8edb102c7 (patch) | |
tree | 71ed84ab8e8a59517ec1b7b1af082adc2beb1758 | |
parent | 9b04c997b1120feefa1e6ee8e2902270bc055cd2 (diff) |
[PATCH] x86_64: {set,clear,test}_bit() related cleanup and pci_mmcfg_init() fix
While working on these patch set, I found several possible cleanup on x86-64
and ia64.
akpm: I stole this from Andi's queue.
Not only does it clean up bitops. It also unrelatedly changes the prototype
of pci_mmcfg_init() and removes its arch_initcall(). It seems that the wrong
two patches got joined together, but this is the one which has been tested.
This patch fixes the current x86_64 build error (the pci_mmcfg_init()
declaration in arch/i386/pci/pci.h disagrees with the definition in
arch/x86_64/pci/mmconfig.c)
This also means that x86_64's pci_mmcfg_init() gets called in the same (new)
manner as x86's: from arch/i386/pci/init.c:pci_access_init(), rather than via
initcall.
The bitops cleanups came along for free.
All this worked OK in -mm testing (since 2.6.16-rc4-mm1) because x86_64 was
tested with both patches applied.
Signed-off-by: Akinobu Mita <mita@miraclelinux.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Con Kolivas <kernel@kolivas.org>
Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/x86_64/kernel/mce.c | 3 | ||||
-rw-r--r-- | arch/x86_64/kernel/setup.c | 3 | ||||
-rw-r--r-- | arch/x86_64/pci/mmconfig.c | 18 | ||||
-rw-r--r-- | include/asm-x86_64/mmu_context.h | 6 | ||||
-rw-r--r-- | include/asm-x86_64/pgtable.h | 6 |
5 files changed, 15 insertions, 21 deletions
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c index b8b9529fa89e..04282ef9fbd4 100644 --- a/arch/x86_64/kernel/mce.c +++ b/arch/x86_64/kernel/mce.c | |||
@@ -139,8 +139,7 @@ static void mce_panic(char *msg, struct mce *backup, unsigned long start) | |||
139 | 139 | ||
140 | static int mce_available(struct cpuinfo_x86 *c) | 140 | static int mce_available(struct cpuinfo_x86 *c) |
141 | { | 141 | { |
142 | return test_bit(X86_FEATURE_MCE, &c->x86_capability) && | 142 | return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA); |
143 | test_bit(X86_FEATURE_MCA, &c->x86_capability); | ||
144 | } | 143 | } |
145 | 144 | ||
146 | static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) | 145 | static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) |
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c index aa55e3cec665..f227d0c23dc6 100644 --- a/arch/x86_64/kernel/setup.c +++ b/arch/x86_64/kernel/setup.c | |||
@@ -1344,8 +1344,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
1344 | { | 1344 | { |
1345 | int i; | 1345 | int i; |
1346 | for ( i = 0 ; i < 32*NCAPINTS ; i++ ) | 1346 | for ( i = 0 ; i < 32*NCAPINTS ; i++ ) |
1347 | if ( test_bit(i, &c->x86_capability) && | 1347 | if (cpu_has(c, i) && x86_cap_flags[i] != NULL) |
1348 | x86_cap_flags[i] != NULL ) | ||
1349 | seq_printf(m, " %s", x86_cap_flags[i]); | 1348 | seq_printf(m, " %s", x86_cap_flags[i]); |
1350 | } | 1349 | } |
1351 | 1350 | ||
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c index 18f371fe37f8..e616500207e4 100644 --- a/arch/x86_64/pci/mmconfig.c +++ b/arch/x86_64/pci/mmconfig.c | |||
@@ -55,7 +55,7 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus) | |||
55 | static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) | 55 | static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) |
56 | { | 56 | { |
57 | char __iomem *addr; | 57 | char __iomem *addr; |
58 | if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), &fallback_slots)) | 58 | if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), fallback_slots)) |
59 | return NULL; | 59 | return NULL; |
60 | addr = get_virt(seg, bus); | 60 | addr = get_virt(seg, bus); |
61 | if (!addr) | 61 | if (!addr) |
@@ -143,29 +143,29 @@ static __init void unreachable_devices(void) | |||
143 | continue; | 143 | continue; |
144 | addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0)); | 144 | addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0)); |
145 | if (addr == NULL|| readl(addr) != val1) { | 145 | if (addr == NULL|| readl(addr) != val1) { |
146 | set_bit(i, &fallback_slots); | 146 | set_bit(i, fallback_slots); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | static int __init pci_mmcfg_init(void) | 151 | void __init pci_mmcfg_init(void) |
152 | { | 152 | { |
153 | int i; | 153 | int i; |
154 | 154 | ||
155 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) | 155 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) |
156 | return 0; | 156 | return; |
157 | 157 | ||
158 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); | 158 | acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg); |
159 | if ((pci_mmcfg_config_num == 0) || | 159 | if ((pci_mmcfg_config_num == 0) || |
160 | (pci_mmcfg_config == NULL) || | 160 | (pci_mmcfg_config == NULL) || |
161 | (pci_mmcfg_config[0].base_address == 0)) | 161 | (pci_mmcfg_config[0].base_address == 0)) |
162 | return 0; | 162 | return; |
163 | 163 | ||
164 | /* RED-PEN i386 doesn't do _nocache right now */ | 164 | /* RED-PEN i386 doesn't do _nocache right now */ |
165 | pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); | 165 | pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); |
166 | if (pci_mmcfg_virt == NULL) { | 166 | if (pci_mmcfg_virt == NULL) { |
167 | printk("PCI: Can not allocate memory for mmconfig structures\n"); | 167 | printk("PCI: Can not allocate memory for mmconfig structures\n"); |
168 | return 0; | 168 | return; |
169 | } | 169 | } |
170 | for (i = 0; i < pci_mmcfg_config_num; ++i) { | 170 | for (i = 0; i < pci_mmcfg_config_num; ++i) { |
171 | pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i]; | 171 | pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i]; |
@@ -173,7 +173,7 @@ static int __init pci_mmcfg_init(void) | |||
173 | if (!pci_mmcfg_virt[i].virt) { | 173 | if (!pci_mmcfg_virt[i].virt) { |
174 | printk("PCI: Cannot map mmconfig aperture for segment %d\n", | 174 | printk("PCI: Cannot map mmconfig aperture for segment %d\n", |
175 | pci_mmcfg_config[i].pci_segment_group_number); | 175 | pci_mmcfg_config[i].pci_segment_group_number); |
176 | return 0; | 176 | return; |
177 | } | 177 | } |
178 | printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address); | 178 | printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address); |
179 | } | 179 | } |
@@ -182,8 +182,4 @@ static int __init pci_mmcfg_init(void) | |||
182 | 182 | ||
183 | raw_pci_ops = &pci_mmcfg; | 183 | raw_pci_ops = &pci_mmcfg; |
184 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; | 184 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; |
185 | |||
186 | return 0; | ||
187 | } | 185 | } |
188 | |||
189 | arch_initcall(pci_mmcfg_init); | ||
diff --git a/include/asm-x86_64/mmu_context.h b/include/asm-x86_64/mmu_context.h index 16e4be4de0c5..19f0c83d0792 100644 --- a/include/asm-x86_64/mmu_context.h +++ b/include/asm-x86_64/mmu_context.h | |||
@@ -34,12 +34,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | |||
34 | unsigned cpu = smp_processor_id(); | 34 | unsigned cpu = smp_processor_id(); |
35 | if (likely(prev != next)) { | 35 | if (likely(prev != next)) { |
36 | /* stop flush ipis for the previous mm */ | 36 | /* stop flush ipis for the previous mm */ |
37 | clear_bit(cpu, &prev->cpu_vm_mask); | 37 | cpu_clear(cpu, prev->cpu_vm_mask); |
38 | #ifdef CONFIG_SMP | 38 | #ifdef CONFIG_SMP |
39 | write_pda(mmu_state, TLBSTATE_OK); | 39 | write_pda(mmu_state, TLBSTATE_OK); |
40 | write_pda(active_mm, next); | 40 | write_pda(active_mm, next); |
41 | #endif | 41 | #endif |
42 | set_bit(cpu, &next->cpu_vm_mask); | 42 | cpu_set(cpu, next->cpu_vm_mask); |
43 | load_cr3(next->pgd); | 43 | load_cr3(next->pgd); |
44 | 44 | ||
45 | if (unlikely(next->context.ldt != prev->context.ldt)) | 45 | if (unlikely(next->context.ldt != prev->context.ldt)) |
@@ -50,7 +50,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, | |||
50 | write_pda(mmu_state, TLBSTATE_OK); | 50 | write_pda(mmu_state, TLBSTATE_OK); |
51 | if (read_pda(active_mm) != next) | 51 | if (read_pda(active_mm) != next) |
52 | out_of_line_bug(); | 52 | out_of_line_bug(); |
53 | if(!test_and_set_bit(cpu, &next->cpu_vm_mask)) { | 53 | if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { |
54 | /* We were in lazy tlb mode and leave_mm disabled | 54 | /* We were in lazy tlb mode and leave_mm disabled |
55 | * tlb flush IPI delivery. We must reload CR3 | 55 | * tlb flush IPI delivery. We must reload CR3 |
56 | * to make sure to use no freed page tables. | 56 | * to make sure to use no freed page tables. |
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h index a617d364d08d..def903287193 100644 --- a/include/asm-x86_64/pgtable.h +++ b/include/asm-x86_64/pgtable.h | |||
@@ -293,19 +293,19 @@ static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned | |||
293 | { | 293 | { |
294 | if (!pte_dirty(*ptep)) | 294 | if (!pte_dirty(*ptep)) |
295 | return 0; | 295 | return 0; |
296 | return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep); | 296 | return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte); |
297 | } | 297 | } |
298 | 298 | ||
299 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) | 299 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) |
300 | { | 300 | { |
301 | if (!pte_young(*ptep)) | 301 | if (!pte_young(*ptep)) |
302 | return 0; | 302 | return 0; |
303 | return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep); | 303 | return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte); |
304 | } | 304 | } |
305 | 305 | ||
306 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) | 306 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep) |
307 | { | 307 | { |
308 | clear_bit(_PAGE_BIT_RW, ptep); | 308 | clear_bit(_PAGE_BIT_RW, &ptep->pte); |
309 | } | 309 | } |
310 | 310 | ||
311 | /* | 311 | /* |