aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@goop.org>2008-06-25 00:19:03 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 07:10:28 -0400
commit4583ed514ea9ac844a6eb02d33120beaedf6837f (patch)
tree9df2d1e1a5d1726303f761954593defc483e2d20
parentbb23e403e5162765dabe3dc78646724753d6359b (diff)
x86, 64-bit: unify early_ioremap
The 32-bit early_ioremap will work equally well for 64-bit, so just use it. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Cc: xen-devel <xen-devel@lists.xensource.com> Cc: Stephen Tweedie <sct@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Cc: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/mm/init_64.c52
-rw-r--r--arch/x86/mm/ioremap.c5
-rw-r--r--include/asm-x86/fixmap_64.h13
-rw-r--r--include/asm-x86/io.h13
-rw-r--r--include/asm-x86/io_32.h12
5 files changed, 27 insertions, 68 deletions
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index bfea7605eaab..9b6049133a82 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -257,58 +257,6 @@ static __meminit void unmap_low_page(void *adr)
257 early_iounmap(adr, PAGE_SIZE); 257 early_iounmap(adr, PAGE_SIZE);
258} 258}
259 259
260/* Must run before zap_low_mappings */
261__meminit void *early_ioremap(unsigned long addr, unsigned long size)
262{
263 pmd_t *pmd, *last_pmd;
264 unsigned long vaddr;
265 int i, pmds;
266
267 pmds = ((addr & ~PMD_MASK) + size + ~PMD_MASK) / PMD_SIZE;
268 vaddr = __START_KERNEL_map;
269 pmd = level2_kernel_pgt;
270 last_pmd = level2_kernel_pgt + PTRS_PER_PMD - 1;
271
272 for (; pmd <= last_pmd; pmd++, vaddr += PMD_SIZE) {
273 for (i = 0; i < pmds; i++) {
274 if (pmd_present(pmd[i]))
275 goto continue_outer_loop;
276 }
277 vaddr += addr & ~PMD_MASK;
278 addr &= PMD_MASK;
279
280 for (i = 0; i < pmds; i++, addr += PMD_SIZE)
281 set_pmd(pmd+i, __pmd(addr | __PAGE_KERNEL_LARGE_EXEC));
282 __flush_tlb_all();
283
284 return (void *)vaddr;
285continue_outer_loop:
286 ;
287 }
288 printk(KERN_ERR "early_ioremap(0x%lx, %lu) failed\n", addr, size);
289
290 return NULL;
291}
292
293/*
294 * To avoid virtual aliases later:
295 */
296__meminit void early_iounmap(void *addr, unsigned long size)
297{
298 unsigned long vaddr;
299 pmd_t *pmd;
300 int i, pmds;
301
302 vaddr = (unsigned long)addr;
303 pmds = ((vaddr & ~PMD_MASK) + size + ~PMD_MASK) / PMD_SIZE;
304 pmd = level2_kernel_pgt + pmd_index(vaddr);
305
306 for (i = 0; i < pmds; i++)
307 pmd_clear(pmd + i);
308
309 __flush_tlb_all();
310}
311
312static unsigned long __meminit 260static unsigned long __meminit
313phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end) 261phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
314{ 262{
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 0561fde56a51..092b3d72498c 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -381,8 +381,6 @@ void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
381 return; 381 return;
382} 382}
383 383
384#ifdef CONFIG_X86_32
385
386int __initdata early_ioremap_debug; 384int __initdata early_ioremap_debug;
387 385
388static int __init early_ioremap_debug_setup(char *str) 386static int __init early_ioremap_debug_setup(char *str)
@@ -483,6 +481,7 @@ static void __init __early_set_fixmap(enum fixed_addresses idx,
483 return; 481 return;
484 } 482 }
485 pte = early_ioremap_pte(addr); 483 pte = early_ioremap_pte(addr);
484
486 if (pgprot_val(flags)) 485 if (pgprot_val(flags))
487 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags)); 486 set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));
488 else 487 else
@@ -624,5 +623,3 @@ void __this_fixmap_does_not_exist(void)
624{ 623{
625 WARN_ON(1); 624 WARN_ON(1);
626} 625}
627
628#endif /* CONFIG_X86_32 */
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index 626098823a0c..c7dcc365f470 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -49,6 +49,19 @@ enum fixed_addresses {
49#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT 49#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
50 FIX_OHCI1394_BASE, 50 FIX_OHCI1394_BASE,
51#endif 51#endif
52 __end_of_permanent_fixed_addresses,
53 /*
54 * 256 temporary boot-time mappings, used by early_ioremap(),
55 * before ioremap() is functional.
56 *
57 * We round it up to the next 512 pages boundary so that we
58 * can have a single pgd entry and a single pte table:
59 */
60#define NR_FIX_BTMAPS 64
61#define FIX_BTMAPS_NESTING 4
62 FIX_BTMAP_END = __end_of_permanent_fixed_addresses + 512 -
63 (__end_of_permanent_fixed_addresses & 511),
64 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_NESTING - 1,
52 __end_of_fixed_addresses 65 __end_of_fixed_addresses
53}; 66};
54 67
diff --git a/include/asm-x86/io.h b/include/asm-x86/io.h
index 8e9eca93f9b9..c63563df4ac8 100644
--- a/include/asm-x86/io.h
+++ b/include/asm-x86/io.h
@@ -72,4 +72,17 @@ extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
72 unsigned long prot_val); 72 unsigned long prot_val);
73extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size); 73extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size);
74 74
75/*
76 * early_ioremap() and early_iounmap() are for temporary early boot-time
77 * mappings, before the real ioremap() is functional.
78 * A boot-time mapping is currently limited to at most 16 pages.
79 */
80extern void early_ioremap_init(void);
81extern void early_ioremap_clear(void);
82extern void early_ioremap_reset(void);
83extern void *early_ioremap(unsigned long offset, unsigned long size);
84extern void early_iounmap(void *addr, unsigned long size);
85extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
86
87
75#endif /* _ASM_X86_IO_H */ 88#endif /* _ASM_X86_IO_H */
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index d71be8df9797..4df44ed54077 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -122,18 +122,6 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
122extern void iounmap(volatile void __iomem *addr); 122extern void iounmap(volatile void __iomem *addr);
123 123
124/* 124/*
125 * early_ioremap() and early_iounmap() are for temporary early boot-time
126 * mappings, before the real ioremap() is functional.
127 * A boot-time mapping is currently limited to at most 16 pages.
128 */
129extern void early_ioremap_init(void);
130extern void early_ioremap_clear(void);
131extern void early_ioremap_reset(void);
132extern void *early_ioremap(unsigned long offset, unsigned long size);
133extern void early_iounmap(void *addr, unsigned long size);
134extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
135
136/*
137 * ISA I/O bus memory addresses are 1:1 with the physical address. 125 * ISA I/O bus memory addresses are 1:1 with the physical address.
138 */ 126 */
139#define isa_virt_to_bus virt_to_phys 127#define isa_virt_to_bus virt_to_phys